:root {
  color-scheme: dark;
  --bg: #100814;
  --bg2: #1a1028;
  --ink: #f3ffe8;
  --dim: #9bb8a0;
  --line: #2c6a38;
  --blade: #b4ff39;
  --gold: #ffd23f;
  --cyan: #7fd6ff;
  --bad: #ff6b9a;
  --glass: rgba(16, 8, 20, 0.92);
  --font: "Poppins", "Avenir Next", sans-serif;
  --mono: "JetBrains Mono", monospace;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f7f1;
  --bg2: #ffffff;
  --ink: #14241b;
  --dim: #3e5c49;
  --line: #1f7a3a;
  --blade: #1f7a3a;
  --gold: #8a6208;
  --cyan: #1c4fa8;
  --bad: #9a2348;
  --glass: rgba(255, 255, 255, 0.94);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink); font-family: var(--font);
}
button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; }
.loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  margin: 0; color: var(--dim);
}
.loading[hidden] { display: none; }
.app {
  height: 100dvh; display: flex; flex-direction: column;
  padding: 58px 8px 8px; gap: 6px; min-height: 0;
}
.brand {
  position: fixed; z-index: 4; top: 8px; right: 12px;
  display: flex; align-items: center; gap: 8px;
  max-width: min(280px, 46vw); pointer-events: none;
}
.logo { width: 36px; height: 36px; flex: none; }
html[data-theme="dark"] .logo, .logo { filter: drop-shadow(0 0 6px rgba(180, 255, 57, 0.45)); }
.brand h1 { margin: 0; font-size: 16px; letter-spacing: 0.04em; line-height: 1.1; }
.brand p { margin: 0; color: var(--dim); font-size: 11px; line-height: 1.2; }
.hud {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  padding: 0 300px 0 4px; min-height: 36px;
}
.who { margin: 0; font-size: 14px; flex: 1 1 220px; }
.hud b { color: var(--gold); font-weight: 600; font-family: var(--mono); }
.hud span { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.hint { margin: 0; color: var(--dim); font-size: 13px; }
.hint[hidden] { display: none; }
.stage {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr; gap: 8px;
}
.dock, .board {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  min-height: 0; position: relative;
}
.dock { overflow: auto; padding: 8px 8px 64px; display: flex; flex-direction: column; gap: 8px; }
.board { overflow: hidden; display: flex; flex-direction: column; }
.sight { display: none; flex: 1; min-height: 0; position: relative; }
.sight.on { display: flex; flex-direction: column; }
.sight-note { margin: 8px 10px 0; color: var(--dim); font-size: 13px; }
#gg-world, #gg-iso, #gg-svg { width: 100%; height: 100%; min-height: 0; display: block; flex: 1; }
#gg-iso { background: #10241a; }
html[data-theme="light"] #gg-iso { background: #e7efe4; }
#gg-svg { background: transparent; }
.map-tools {
  position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; z-index: 2;
}
.map-tools button, .act, .row, .mini, .tabs button, #gg-menu > button, .card-title button, .card-keys button {
  border: 1px solid var(--line); background: var(--glass); border-radius: 999px; padding: 6px 10px;
}
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button.on, .act.focus, .row.on { outline: 2px solid var(--gold); background: rgba(180, 255, 57, 0.12); }
.primary { border-color: var(--gold); }
.search { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.list { max-height: 112px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; justify-content: space-between; text-align: left; }
.iso { color: var(--dim); font-family: var(--mono); font-size: 12px; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; }
.act[disabled] { opacity: 0.4; }
.preview { min-height: 1.4em; margin: 0; color: var(--dim); font-size: 14px; }
.confirm { display: flex; gap: 8px; }
.confirm[hidden], .pick[hidden], .modal[hidden] { display: none; }
.more { color: var(--dim); }
.log { list-style: none; padding: 0; margin: 6px 0; font-size: 13px; }
.log li { border-top: 1px solid rgba(127, 214, 255, 0.15); padding: 6px 0; }
.dim { color: var(--dim); }
.db-layout { display: grid; grid-template-columns: 160px 1fr; gap: 8px; min-height: 0; height: 100%; padding: 8px; }
.db-side button { display: flex; justify-content: space-between; width: 100%; margin-bottom: 6px; }
.db-side button.on { outline: 2px solid var(--gold); }
.db-main { min-height: 0; display: flex; flex-direction: column; }
.db-wrap { overflow: auto; min-height: 0; flex: 1; }
.db-wrap table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
.db-wrap th, .db-wrap td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.db-wrap td.soft { white-space: normal; max-width: 280px; }
.db-bar { display: flex; gap: 6px; align-items: center; padding: 8px; flex: none; }
.globe-wrap { height: 100%; min-height: 0; position: relative; flex: 1; }
#gg-globe, #gg-globe-overlay, #gg-globe-hit,
#gg-3d, #gg-3d-overlay, #gg-3d-hit { position: absolute; inset: 0; width: 100%; height: 100%; }
#gg-globe-overlay, #gg-globe-hit { background: transparent; }
#gg-globe-hit, #gg-3d-hit { cursor: grab; touch-action: none; }
#gg-world { cursor: grab; touch-action: none; }
.policy { border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.menu-label { margin: 0 0 4px; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--gold); }
.pol-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0; }
.pol-row .dim { flex: 1 1 100%; }
.pol-row b { min-width: 1.2em; text-align: center; font-family: var(--mono); }
.layers { flex-wrap: wrap; }
.layers button[aria-pressed="false"] { opacity: 0.45; }
#gg-3d-cap { margin: 0 8px; }
.note { position: absolute; left: 8px; bottom: 8px; margin: 0; font-size: 12px; color: var(--dim); max-width: 70%; }
.pick { padding: 8px; border: 1px dashed var(--gold); border-radius: 12px; }
#gg-orb {
  position: fixed; z-index: 51; left: 70px; top: 12px; width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid var(--gold); background: radial-gradient(circle at 40% 35%, #fff6cc, #c9a227 45%, #3a2a08);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.25);
}
#gg-menu {
  position: fixed; z-index: 50; left: 70px; top: 66px; display: flex; flex-direction: column; gap: 8px;
  background: var(--glass); padding: 10px; border-radius: 12px; border: 1px solid var(--gold);
  width: min(320px, calc(100vw - 86px)); max-height: calc(100dvh - 80px); overflow: auto;
}
#gg-menu[hidden] { display: none; }
.menu-label { margin: 4px 0 0; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--gold); }
.menu-note { margin: 0; color: var(--dim); font-size: 13px; }
.modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.45); padding: 16px;
}
.modal > div {
  max-width: 420px; background: var(--bg2); border: 1px solid var(--gold);
  border-radius: 14px; padding: 14px;
}
#gg-cards { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.gg-card {
  position: fixed; pointer-events: auto; display: flex; flex-direction: column;
  background: var(--glass); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28); min-width: 0;
}
.card-title {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; cursor: grab;
  touch-action: none; border-bottom: 1px solid var(--line); flex: none;
}
.card-title strong { flex: 1; min-width: 0; }
.card-body { overflow: auto; padding: 8px 10px; font-size: 13px; min-height: 0; flex: 1; }
.card-body p, .card-body ul { margin: 0 0 6px; }
.card-resize {
  position: absolute; right: 2px; bottom: 2px; width: 22px; height: 22px;
  border: 0; background: transparent; color: var(--dim); cursor: nwse-resize; touch-action: none;
}
.card-keys { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 8px; }
.gg-card.min { height: auto !important; }
.gg-card.min .card-body, .gg-card.min .card-keys, .gg-card.min .card-resize { display: none; }
#gg-feier {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.55); text-align: center;
}
#gg-feier[hidden] { display: none; }
.cup { font-size: 72px; line-height: 1; animation: pop 0.6s ease; }
#gg-feier strong { display: block; font-size: 28px; color: var(--gold); }
.sr { position: fixed; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.dock, .card-body, .db-wrap, #gg-menu, .list {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.dock::-webkit-scrollbar, .card-body::-webkit-scrollbar, .db-wrap::-webkit-scrollbar,
#gg-menu::-webkit-scrollbar, .list::-webkit-scrollbar { width: 8px; height: 8px; }
.dock::-webkit-scrollbar-thumb, .card-body::-webkit-scrollbar-thumb, .db-wrap::-webkit-scrollbar-thumb,
#gg-menu::-webkit-scrollbar-thumb, .list::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 8px;
}
@media (prefers-reduced-motion: reduce) {
  .cup { animation: none; }
  .logo { filter: none; }
}
@keyframes pop { from { transform: scale(0.4); } to { transform: scale(1); } }
@media (max-width: 760px) {
  .app { padding: 96px 6px 6px; }
  .brand { top: 8px; right: 8px; }
  .hud, .hint { padding-left: 0; margin-left: 0; padding-right: 8px; }
  .stage { display: flex; flex-direction: column; }
  .board { order: 1; flex: 1 1 auto; min-height: 160px; }
  .dock { order: 2; flex: 0 1 36%; max-height: 40%; }
  .list { max-height: 72px; }
  .db-layout { grid-template-columns: 1fr; overflow: auto; }
  .gg-card.sheet {
    left: 8px !important; right: 8px !important; top: auto !important;
    width: auto !important; height: min(42dvh, 360px) !important;
    bottom: calc(34% + 10px);
  }
  .gg-card.chip {
    top: 100px !important; height: 36px !important; width: auto !important;
    left: auto !important;
  }
}

