/* ---- Theme: colours live in custom properties; dark mode overrides them ---- */
:root {
  --bg: #f4f5f7;
  --fg: #111827;
  --muted: #6b7280;
  --card: #ffffff;
  --line: #d1d5db;
  --ocean: #cfe5f4;
  --land: #e7e1d0;
  --border: #b3ab94;
  --halo: rgba(255, 255, 255, .85);
  --a: #2563eb;
  --b: #ea580c;
  --good: #16a34a;
  --bad: #dc2626;
  --accent: #111827;
  --accent-fg: #ffffff;
  --focus: #2563eb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --card: #1a212b;
    --line: #2f3a48;
    --ocean: #14283a;
    --land: #3a4250;
    --border: #566175;
    --halo: rgba(20, 40, 58, .85);
    --a: #60a5fa;
    --b: #fb923c;
    --good: #22c55e;
    --bad: #ef4444;
    --accent: #e5e7eb;
    --accent-fg: #0f1419;
    --focus: #93c5fd;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
.wrap { max-width: 480px; margin: 0 auto; padding: 12px 16px 32px; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---- Header ---- */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.top h1 { font-size: 1.1rem; margin: 0; }
.unit { min-width: 56px; min-height: 40px; border: 1px solid var(--line); background: var(--card); border-radius: 20px; font-weight: 600; }

/* ---- Generic bits ---- */
.screen h2 { margin: .2em 0 .4em; }
.muted { color: var(--muted); }
.primary {
  display: block; width: 100%; min-height: 56px; margin-top: 16px;
  border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-fg);
  font-size: 1.1rem; font-weight: 700;
}
.secondary { min-height: 44px; padding: 0 16px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; }

/* ---- Question header + progress dots ---- */
.qhead { display: flex; justify-content: space-between; align-items: center; }
.dots { display: flex; gap: 6px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
.dot.current { border-color: var(--fg); }
.dot.good { background: var(--good); border-color: var(--good); }
.dot.bad { background: var(--bad); border-color: var(--bad); }
.prompt { font-size: 1.4rem; font-weight: 700; margin: 10px 0 12px; }
.debug { font: 12px/1.3 ui-monospace, monospace; color: var(--muted); margin-top: 8px; }

/* ---- Map stage: two square-ish panels side by side ---- */
.stage {
  position: relative; overflow: hidden; width: 100%;
  aspect-ratio: 2 / 1.05;
  background: var(--ocean); border-radius: 12px; border: 1px solid var(--line);
  margin-bottom: 14px;
}
.stage-hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem; text-align: center; padding: 8px; }
.panel { position: absolute; top: 0; width: 50%; height: 100%; overflow: hidden; }
.panel.a { left: 0; }
.panel.b { left: 50%; }
.panel svg { display: block; }
.divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--border); z-index: 3; }
.skip {
  position: absolute; right: 6px; bottom: 6px; z-index: 5; min-height: 32px; padding: 0 12px;
  border: 0; border-radius: 16px; background: rgba(0, 0, 0, .55); color: #fff; font-size: .8rem;
}
.len {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 4;
  font-weight: 700; font-size: .85rem; white-space: nowrap; opacity: 0;
  text-shadow: 0 0 3px var(--halo), 0 0 3px var(--halo);
}
.len.a { color: var(--a); top: calc(50% - 32px); }
.len.b { color: var(--b); top: calc(50% + 14px); }

/* SVG map styling (classes, so the theme variables apply) */
.land { fill: var(--land); }
.borders { fill: none; stroke: var(--border); stroke-width: .5; }
.route { fill: none; stroke-width: 3; stroke-linecap: round; }
.panel.a .route { stroke: var(--a); } .panel.a .city { fill: var(--a); }
.panel.b .route { stroke: var(--b); } .panel.b .city { fill: var(--b); }
.city { stroke: #fff; stroke-width: 1.5; }
.city-label { font: 600 10px system-ui, sans-serif; fill: var(--fg); stroke: var(--halo); stroke-width: 3; paint-order: stroke; }
.badge { font: 800 14px system-ui, sans-serif; }
.panel.a .badge { fill: var(--a); } .panel.b .badge { fill: var(--b); }

/* ---- Answer buttons ---- */
.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 14px;
  text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 14px;
  transition: background .2s, border-color .2s, color .2s;
}
.choice .letter {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: var(--bg); border: 1px solid var(--line);
}
.choice .txt { display: flex; flex-direction: column; min-width: 0; }
.choice .txt b { font-size: 1.05rem; overflow-wrap: anywhere; }
.choice .txt small { color: var(--muted); }
.choice:disabled { cursor: default; }
.choice.selected { border-color: var(--fg); background: var(--bg); }
.choice.correct { background: var(--good); border-color: var(--good); color: #fff; }
.choice.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }
.choice.correct small, .choice.wrong small { color: rgba(255, 255, 255, .85); }
.choice.correct .letter, .choice.wrong .letter { background: rgba(255, 255, 255, .25); border-color: transparent; color: #fff; }
.choice.reveal-correct { border-color: var(--good); box-shadow: 0 0 0 3px var(--good); }

.result-line { min-height: 1.5em; margin: 14px 0 0; font-weight: 700; text-align: center; }

/* ---- Results ---- */
.score { font-size: 3rem; font-weight: 800; text-align: center; margin: 4px 0; }
.share { text-align: center; font-size: 1.6rem; letter-spacing: 2px; margin: 4px 0 10px; }
.recap { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.recap li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: .9rem; }
.recap .ok { color: var(--good); } .recap .no { color: var(--bad); }

@media (prefers-reduced-motion: reduce) { .choice { transition: none; } }
