:root {
  color-scheme: dark;
  --bg: #06080c;
  --ink: #ece7dc;
  --muted: #9aa3ad;
  --line: rgba(236, 231, 220, 0.14);
  --glass: rgba(10, 13, 19, 0.72);
  --accent: #a9d6cc;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pad: max(16px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overflow: hidden; }
[hidden] { display: none !important; }

#field { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
#intro { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; pointer-events: none; }

/* ---------- The split: a full-height line dragged sideways; the map to its left, the field to its right ---------- */
.split {
  position: fixed; top: 0; bottom: 0; left: 0; width: 44px; margin-left: -22px;
  cursor: ew-resize; touch-action: none; outline: none;
}
.split::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 20px; width: 4px;
  background: var(--ink); box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}
.split .grip {
  position: absolute; top: 50%; left: 50%; width: 26px; height: 26px; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--glass); border: 1px solid var(--ink); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
.split:focus-visible .grip { border-color: var(--accent); }

/* ---------- Satellite or Topo, while the map shows ---------- */
.basemap {
  position: fixed; left: var(--pad); bottom: calc(max(8px, env(safe-area-inset-bottom)) + 22px);
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.basemap .pill { min-height: 30px; padding: 5px 12px; }
.basemap .pill.on { border-color: var(--ink); }
.basemap .credit { font-size: 9.5px; color: rgba(236, 231, 220, 0.75); background: var(--glass); border-radius: 999px; padding: 2px 8px; }

/* ---------- The seal and the corner ---------- */
.home {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: var(--pad);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--muted); text-decoration: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}
.home:hover { color: var(--ink); }
.corner {
  position: fixed; top: max(10px, env(safe-area-inset-top)); right: var(--pad);
  display: flex; gap: 8px; align-items: center;
}
.attribution {
  position: fixed; left: var(--pad); right: var(--pad); bottom: max(8px, env(safe-area-inset-bottom));
  margin: 0; font-size: 9.5px; line-height: 1.5; color: rgba(236, 231, 220, 0.45);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); pointer-events: none;
}

/* ---------- Pills ---------- */
.pill {
  font: inherit; font-size: 12.5px; color: var(--ink);
  background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; min-height: 34px; cursor: pointer;
}
.pill:hover { border-color: rgba(236, 231, 220, 0.35); }
.pill:focus-visible, .knob:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select.pill { max-width: 220px; }
select.pill option { background: #0d1117; color: var(--ink); }
.pill.round { width: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.pill.round svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.find { cursor: text; width: 170px; }
.find::placeholder { color: var(--muted); }

/* ---------- The deck (owner only) ---------- */
#toggle, .deck { display: none; }
body.owner #toggle { display: inline-flex; }
/* A sidebar on the right, under the corner buttons; slides in from the edge. */
body.owner .deck {
  display: block; position: fixed; right: var(--pad);
  top: calc(max(10px, env(safe-area-inset-top)) + 46px); bottom: max(16px, env(safe-area-inset-bottom));
  width: min(272px, calc(100vw - 2 * var(--pad))); overflow-y: auto;
  padding: 14px 14px 12px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transform: translateX(calc(100% + 2 * var(--pad))); transition: transform 0.28s ease;
}
body.owner.deck-open .deck { transform: translateX(0); }

.knobs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 6px; }
.knob { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: ns-resize; touch-action: none; user-select: none; border-radius: 10px; padding: 2px 0; }
.knob svg { width: 52px; height: 52px; }
.knob .rail { fill: none; stroke: var(--line); stroke-width: 3.5; stroke-linecap: round; }
.knob .value { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.knob .pointer { stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.knob span { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.knob.on span, .knob:hover span { color: var(--ink); }

.row { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.row .pill, .row select.pill, .row .find { width: 100%; max-width: none; }
.status { margin: 8px 2px 0; font-size: 11.5px; color: var(--muted); }
.status:empty { display: none; }

@media (max-width: 640px) {
  .knob svg { width: 46px; height: 46px; }
}
@media (prefers-reduced-motion: reduce) { .deck { transition: none; } }
