/* ============================================================
   Capital Quiz — "serika dark" theme (Monkeytype-inspired).
   Flat dark-gray surfaces, one signature yellow, monospace
   throughout, and the Monkeytype "flood with yellow" hover.
   ============================================================ */

:root {
  /* serika dark core */
  --bg: #323437;
  --surface: #2c2e31;   /* sub-alt — cards & controls */
  --surface-2: #393b3e; /* elevated / hover ground */
  --border: #45474a;
  --text: #d1d0c5;
  --text-dim: #898d93;  /* sub — lightened from MT's #646669 for readability */
  --main: #e2b714;      /* the accent — fills (buttons, hovers, caret, bars) */
  --main-ink: #2c2e31;  /* text that sits on top of --main */
  --accent-fg: var(--main); /* accent used AS text — darkened in the light theme */

  /* quiz semantics (kept disciplined, harmonised with the gray) */
  --good: #84c560;
  --bad: #ca4754;
  --blue: #6f9dc9;
  --amber: #d99a4e;
  --violet: #a98ee0;    /* the Locate dimension */
  --gold: var(--accent-fg);

  /* aliases so legacy class names keep working */
  --accent: var(--main);

  --radius: 9px;
  --radius-sm: 6px;
  --maxw: 480px;
  --mono: "JetBrains Mono", "Roboto Mono", ui-monospace, "SF Mono",
          "Cascadia Mono", Menlo, Consolas, monospace;
  --t: .12s ease;
}

/* `touch-action: manipulation` disables iOS double-tap "smart zoom" (which would
   shift the layout when tapping fast), while keeping scroll + pinch. Leaflet sets
   its own (higher-specificity) touch-action on the map, so map gestures are
   unaffected. The viewport meta's maximum-scale is ignored by iOS, so this is the
   real fix. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* App shell: a fixed-height column (header + content) that never scrolls the
   page. Individual views are sized to fit; only Settings (.app.scroll) grows. */
body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-fg);
  outline-offset: 2px;
}

/* ---------- header ---------- */
#hdr {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  /* Clear the notch / status bar in an installed iOS PWA (viewport-fit=cover
     lets content run under it). Falls back to the plain padding elsewhere. */
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.hdr-btn {
  background: none;
  border: none;
  color: var(--text);
  padding: 0;
}
.hdr-btn.brand {
  display: inline-flex;
  align-items: baseline;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text-dim);
  transition: color var(--t);
}
@media (hover: hover) { .hdr-btn.brand:hover { color: var(--text); } }
/* blinking caret — the typing-test tell */
.caret {
  width: 3px;
  height: 1.05em;
  margin-left: 4px;
  align-self: center;
  background: var(--main);
  border-radius: 1px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hdr-right { display: flex; align-items: center; gap: 8px; }
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--t), background var(--t), border-color var(--t);
}
@media (hover: hover) {
  .chip:hover {
    background: var(--main);
    border-color: var(--main);
    color: var(--main-ink);
  }
}

/* ---------- layout ---------- */
.app {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 22px;
  /* Respect the home-indicator (bottom) and landscape notch (sides). */
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app.scroll { overflow-y: auto; }
/* Children keep their natural size; the flashcard is the one element that
   grows to absorb the remaining space (so its photo + map share it). */
.app > * { animation: enter .18s ease both; flex: 0 0 auto; }
.app > .flash { flex: 1 1 auto; min-height: 0; }
/* Tiny / landscape viewports: let it scroll rather than clip the content. */
@media (max-height: 520px) { .app:not(.scroll) { overflow-y: auto; } }
@keyframes enter {
  from { opacity: 0; transform: translateY(5px); }
}
.loading { text-align: center; color: var(--text-dim); padding: 48px 0; }

h1, h2 { margin: 0 0 14px; letter-spacing: -.4px; }
h1 { font-size: 1.4rem; font-weight: 700; }
h2 { font-size: 1rem; color: var(--text-dim); font-weight: 600; }

.card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-dim);
  font-size: .95rem;
  font-weight: 700;
  transition: color var(--t), background var(--t), border-color var(--t),
              transform var(--t);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--main); color: var(--main-ink); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* the Monkeytype "flood with yellow" hover — pointer devices only, so a tap
   on touch never leaves a button stuck in the hovered state. */
@media (hover: hover) {
  .btn:hover { background: var(--main); color: var(--main-ink); }
  .btn.primary:hover { filter: brightness(1.08); }
  .btn.ghost:hover { background: var(--bad); border-color: var(--bad); color: var(--main-ink); }
  .btn:disabled:hover { background: var(--surface); color: var(--text-dim); }
}

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }

.big-btn {
  font-size: 1.1rem;
  padding: 18px 16px;
  flex-direction: column;
  gap: 5px;
}
.big-btn .sub { font-size: .72rem; font-weight: 600; color: var(--text-dim); }
.big-btn.primary .sub { color: var(--main-ink); opacity: .75; }
@media (hover: hover) {
  .big-btn:hover .sub { color: var(--main-ink); opacity: .75; }
}

/* ---------- home ---------- */
.stat-row { display: flex; gap: 8px; margin-bottom: 14px; }
.stat {
  flex: 1; min-width: 0; /* four-up: let boxes shrink rather than overflow */
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 14px 6px;
  text-align: center;
  transition: border-color var(--t), transform var(--t);
}
.stat:active { transform: translateY(1px); }
@media (hover: hover) { .stat:hover { border-color: var(--main); } }
.stat .num { font-size: 1.4rem; font-weight: 700; color: var(--accent-fg); font-variant-numeric: tabular-nums; }
/* Wide fractions (Known x/y with a 3-digit total) shrink to fit the quarter-width box. */
.stat .num.fit { font-size: clamp(0.75rem, 4vw, 1.4rem); }
.stat .num.gold { color: var(--gold); }
.stat .num.bad { color: var(--bad); }
.stat .lbl { font-size: .72rem; color: var(--text-dim); margin-top: 2px; }
.daily {
  display: flex; align-items: center; gap: 10px;
  margin-top: 6px; padding: 16px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-weight: 600;
  transition: border-color var(--t), color var(--t);
}
@media (hover: hover) { .daily:hover { border-color: var(--main); color: var(--text); } }
.daily strong { color: var(--accent-fg); font-weight: 700; }

/* ---------- deck browser ---------- */
.deck-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.deck-head .link-btn { flex: 0 0 auto; }
.deck-search { flex: 1; }

.deck-scope { margin-bottom: 12px; }

.deck-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
/* second (speed) filter axis: a labelled chip row that AND-combines with status */
.deck-filters.speed { align-items: center; margin-top: -6px; }
.deck-axis {
  font-size: .7rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .5px; margin-right: 2px;
}
.deck-chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); padding: 6px 11px; border-radius: 999px;
  font-size: .76rem; font-weight: 700;
  transition: color var(--t), background var(--t), border-color var(--t);
}
.deck-chip .c { margin-left: 5px; font-variant-numeric: tabular-nums; opacity: .7; }
.deck-chip.on { background: var(--main); border-color: var(--main); color: var(--main-ink); }
.deck-chip.struggling { color: var(--bad); border-color: var(--bad); }
.deck-chip.struggling.on { background: var(--bad); border-color: var(--bad); color: var(--main-ink); }
@media (hover: hover) {
  .deck-chip:hover { border-color: var(--main); color: var(--text); }
  .deck-chip.on:hover { color: var(--main-ink); }
  .deck-chip.struggling:hover { border-color: var(--bad); color: var(--bad); }
  .deck-chip.struggling.on:hover { color: var(--main-ink); }
}

.deck-group { margin-bottom: 8px; }
.deck-group > summary {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 2px; border-bottom: 1px solid var(--border);
  font-size: .74rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .5px;
}
.deck-group > summary::-webkit-details-marker { display: none; }
.deck-group .g-count { font-weight: 600; }

.deck-row {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--border);
  padding: 11px 2px; text-align: left; color: var(--text);
  transition: background var(--t);
}
.deck-row .deck-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.deck-name { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-name .arrow { color: var(--text-dim); margin: 0 4px; }
.deck-meta { font-size: .72rem; color: var(--text-dim); }
.deck-star { flex: 0 0 auto; color: var(--gold); font-size: .95rem; }
.deck-leech { flex: 0 0 auto; color: var(--bad); font-size: .9rem; }
.deck-speed {
  flex: 0 0 auto; font-size: .74rem; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--text-dim);
}
.deck-speed.fluent { color: var(--good); }
.deck-speed.slow { color: var(--amber); }
.deck-speed.untimed { opacity: .45; }
/* right cluster: the Reflex schedule (speed pill + next resurface), stacked and
   kept apart from the SRS due in the left meta line */
.deck-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.deck-redue { font-size: .66rem; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.deck-row.open { background: var(--surface); }
.deck-row:active { background: var(--surface-2); }
@media (hover: hover) { .deck-row:hover { background: var(--surface); } }

.dot { flex: 0 0 auto; width: 11px; height: 11px; border-radius: 50%; box-sizing: border-box; }
.dot.s-new { border: 2px solid var(--text-dim); }
.dot.s-learning { background: var(--amber); }
.dot.s-known { background: var(--main); }
.dot.s-mastered { background: var(--gold); }

.deck-peek { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.deck-peek .photo {
  width: 100%; height: 150px; object-fit: cover;
  border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 10px;
}
.deck-peek .map-box { height: 150px; min-height: 0; max-height: none; flex: none; margin: 0 0 10px; }
.deck-peek .pop {
  display: inline-block; background: var(--surface-2);
  padding: 5px 13px; border-radius: 999px; font-size: .8rem; color: var(--text-dim); margin-bottom: 12px;
}
.deck-dirs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.dir {
  font-size: .72rem; font-weight: 700; color: var(--text-dim);
  background: var(--surface-2); padding: 5px 10px; border-radius: 999px;
}
.dir.on { color: var(--good); box-shadow: inset 0 0 0 1px var(--good); }

/* ---------- session top bar ---------- */
.sess-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; color: var(--text-dim); font-size: .85rem;
}
.progress-dots { letter-spacing: 3px; color: var(--accent-fg); }

/* ---------- flashcard ---------- */
.flash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 0;
}
.flash .prompt { font-size: 1rem; color: var(--text-dim); margin-bottom: 6px; }
.flash .subject { font-size: 1.8rem; font-weight: 700; margin-bottom: 4px; letter-spacing: -.5px; }

/* question-type badges (shared by Learn + Challenge) */
.qbadge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  padding: 5px 13px;
  border-radius: 999px;
  margin-bottom: 14px;
  color: var(--main-ink); /* dark ink reads on the (light) dark-theme fills */
}
.b-capital { background: var(--main); }
.b-country { background: var(--blue); }
.b-pop     { background: var(--amber); }
.b-locate  { background: var(--violet); }
.flash .answer { font-size: 2.1rem; font-weight: 800; color: var(--accent-fg); margin: 4px 0 14px; letter-spacing: -.5px; }
.flash .loc-capital { color: var(--text-dim); font-size: .85rem; margin: -10px 0 12px; }
.flash .subject + .loc-capital { margin-top: 0; } /* c2loc prompt: sits under the country name, not the big answer */
.flash .hint { color: var(--text-dim); font-size: .8rem; margin-top: 18px; }
.flash img.photo {
  width: 100%; align-self: stretch;
  flex: 1 1 0; min-height: 88px; max-height: 240px; object-fit: cover;
  border-radius: var(--radius-sm); margin: 10px 0; background: var(--surface-2);
}
.flash .pop {
  display: inline-block; margin: 6px 0;
  background: var(--surface-2);
  padding: 5px 13px; border-radius: 999px; font-size: .82rem; color: var(--text-dim);
}
.flash .pop.graded { color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }

/* reflex: live recall timer (front) + the latency verdict (back) */
.reflex-timer {
  font-size: 2.6rem; font-weight: 800; letter-spacing: -1px;
  color: var(--accent-fg); font-variant-numeric: tabular-nums; margin: 6px 0 2px;
}
.reflex-verdict {
  display: inline-block; margin: 4px 0 10px;
  padding: 4px 12px; border-radius: 999px;
  font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.reflex-verdict.fast { color: var(--good); box-shadow: inset 0 0 0 1px var(--good); }
.reflex-verdict.slow { color: var(--text-dim); box-shadow: inset 0 0 0 1px var(--border); }

/* ---------- map (themed CARTO basemaps show borders; pin stays normal) ---------- */
.map-box {
  width: 100%; align-self: stretch;
  flex: 1 1 0; min-height: 88px; max-height: 240px;
  border-radius: var(--radius-sm); overflow: hidden; margin: 10px 0;
}
/* Locate session: the map IS the answer surface, so let it grow past the small
   flashcard cap and fill the card. The verdict reuses the .hint slot. */
.locate-map { max-height: none; }
/* Locate verdict (also used by the challenge location question, outside .flash). */
.hint.ok { color: var(--good); font-weight: 700; }
.hint.no { color: var(--bad); font-weight: 700; }
.leaflet-container { background: var(--surface-2); font-family: var(--mono); }
.leaflet-control-attribution {
  background: rgba(44,46,49,.7) !important;
  color: var(--text-dim) !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

/* ---------- world progress map (#/map) ---------- */
.app > .map-wrap { flex: 1 1 auto; min-height: 0; } /* the map fills leftover space */
/* Full-bleed to the bottom edge: drop the app's bottom padding for the map view
   (the legend below carries the safe-area inset instead), so no dead band remains. */
.app:has(.map-wrap) { padding-bottom: 0; }
.map-bar { margin-bottom: 10px; }
.map-dims { display: flex; width: 100%; } /* fill the bar; segments share width evenly */
.map-dims button { flex: 1; padding: 8px 4px; font-size: .82rem; text-align: center; }
.map-wrap { position: relative; border-radius: var(--radius-sm); overflow: hidden; isolation: isolate; }
/* z-index contains Leaflet's internal panes (z 200–700) within this stacking
   context, so the peek panel below can sit above the map rather than under it. */
#worldmap { position: absolute; inset: 0; z-index: 0; }
.map-legend {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 10px; font-size: .72rem; color: var(--text-dim);
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); /* clear the home indicator */
}
.map-legend .sw { width: 16px; height: 12px; border-radius: 3px; }
/* Tap-to-peek overlay — slides up from the bottom of the map (no second map). */
/* Flat bottom sheet — a clean top-border divider, no drop shadow (off-style for
   the serika theme); the wrap's overflow:hidden clips the bottom corners to match
   the map container, so the panel reads as part of the same flat surface. */
/* Floating rounded card with a gap on all four sides (not a flush sheet). */
.map-panel {
  position: absolute; left: 10px; right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
  transform: translateY(calc(100% + 16px)); transition: transform .22s ease;
  text-align: center; z-index: 1; /* above #worldmap's contained panes */
}
.map-panel.open { transform: translateY(0); }
/* Round chip behind the × so it stays legible over any country photo. */
.map-panel-close {
  position: absolute; top: 8px; right: 8px;
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: 50%;
  color: var(--text); font-size: 1.2rem; line-height: 1; cursor: pointer;
}
@media (hover: hover) { .map-panel-close:hover { border-color: var(--main); } }
.map-panel-img { width: 100%; height: 110px; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.map-panel-name { font-weight: 800; font-size: 1.3rem; margin-top: 8px; letter-spacing: -.5px; }
.map-panel-cap { color: var(--text-dim); font-size: .85rem; margin: 2px 0 6px; }
.map-chips { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.map-chip {
  font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--main-ink); background: var(--main);
}
.map-chip.b0 { background: transparent; border-color: var(--border); color: var(--text-dim); }
.map-chip.b1 { background: var(--main); opacity: .55; }
.map-chip.b2 { background: var(--main); opacity: .72; }
.map-chip.b3 { background: var(--main); opacity: .86; }
.map-chip.b4 { background: var(--main); opacity: 1; }

/* SM-2 grade buttons — flat, flood with their own colour on hover */
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
/* Drill self-test uses two buttons (Missed it / Got it). */
.grades.two { grid-template-columns: repeat(2, 1fr); }
.grade {
  display: flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1.1;
  padding: 9px 4px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: 1rem;
  transition: color var(--t), background var(--t), border-color var(--t), transform var(--t);
}
/* next-due preview under each grade label (inherits the grade colour, dimmed) */
.g-when { font-size: .6rem; font-weight: 600; opacity: .65; font-variant-numeric: tabular-nums; }
.grade:active { transform: translateY(1px); }
.grade.again, .grade.miss { color: var(--bad); }
.grade.hard  { color: var(--amber); }
.grade.good, .grade.pass { color: var(--good); }
.grade.easy  { color: var(--blue); }
@media (hover: hover) {
  .grade.again:hover, .grade.miss:hover { background: var(--bad);   border-color: var(--bad);   color: var(--main-ink); }
  .grade.hard:hover  { background: var(--amber); border-color: var(--amber); color: var(--main-ink); }
  .grade.good:hover, .grade.pass:hover  { background: var(--good);  border-color: var(--good);  color: var(--main-ink); }
  .grade.easy:hover  { background: var(--blue);  border-color: var(--blue);  color: var(--main-ink); }
}

/* ---------- challenge run ---------- */
.run-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.run-score { font-size: 1.25rem; font-weight: 700; color: var(--accent-fg); font-variant-numeric: tabular-nums; }
.run-streak { color: var(--amber); font-weight: 700; }
.timer-track { height: 5px; background: var(--surface); border-radius: 999px; overflow: hidden; margin-bottom: 22px; }
.timer-fill { height: 100%; width: 100%; background: var(--main); transform-origin: left; }
/* time-trial: a big global countdown replaces the per-question bar */
.tt-clock {
  text-align: center; font-size: 2.6rem; font-weight: 800;
  color: var(--accent-fg); font-variant-numeric: tabular-nums;
  letter-spacing: -1px; margin: 2px 0 18px;
  transition: color var(--t);
}
.tt-clock.low { color: var(--bad); animation: tt-pulse .7s ease-in-out infinite; }
@keyframes tt-pulse { 50% { opacity: .5; } }
.tt-delta {
  font-weight: 800; font-variant-numeric: tabular-nums; opacity: 0;
}
.tt-delta.show { animation: tt-delta .7s ease-out forwards; }
.tt-delta.gain { color: var(--good); }
.tt-delta.loss { color: var(--bad); }
@keyframes tt-delta {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-8px); }
}

.q-prompt { font-size: 1.35rem; font-weight: 700; text-align: center; margin: 12px 0 20px; letter-spacing: -.4px; }
.bonus-tag { display: inline-block; background: var(--amber); color: var(--main-ink); font-size: .62rem; font-weight: 700; letter-spacing: 1px; padding: 3px 9px; border-radius: 999px; margin-bottom: 8px; vertical-align: middle; }
.options { display: grid; gap: 10px; }
.opt {
  padding: 16px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--surface);
  color: var(--text); font-size: .95rem; font-weight: 600; text-align: left;
  transition: color var(--t), background var(--t), border-color var(--t);
}
.opt.correct { background: rgba(132,197,96,.16); color: var(--good); box-shadow: inset 0 0 0 1px var(--good); }
.opt.wrong   { background: rgba(202,71,84,.16); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.opt:disabled { cursor: default; }
@media (hover: hover) {
  .opt:hover { background: var(--main); color: var(--main-ink); }
  .opt:disabled:hover { background: var(--surface); color: var(--text); }
  .opt.correct:disabled:hover { background: rgba(132,197,96,.16); color: var(--good); }
  .opt.wrong:disabled:hover   { background: rgba(202,71,84,.16); color: var(--bad); }
}

/* ---------- results ---------- */
.result-score { text-align: center; font-size: 3.4rem; font-weight: 800; color: var(--accent-fg); font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.result-sub { text-align: center; color: var(--text-dim); margin-bottom: 20px; font-size: .85rem; }
.seed-line { display: flex; align-items: center; gap: 8px; font-size: .85rem; background: var(--surface-2); padding: 11px 13px; border-radius: var(--radius-sm); }
.seed-line .seed { flex: 1; overflow: hidden; text-overflow: ellipsis; color: var(--accent-fg); }

/* ---------- settings / forms ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-weight: 700; margin-bottom: 9px; font-size: .9rem; }
.field .desc, .desc { font-size: .76rem; color: var(--text-dim); margin-top: 6px; line-height: 1.45; }
select, input[type=text], textarea {
  width: 100%; padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-size: .95rem; font-family: inherit;
  transition: border-color var(--t);
}
textarea { resize: vertical; min-height: 64px; }
@media (hover: hover) { select:hover, input[type=text]:hover, textarea:hover { border-color: var(--text-dim); } }
select:focus, input[type=text]:focus, textarea:focus { outline: none; border-color: var(--accent-fg); }

/* backup card: paste-fallback disclosure + import error message */
.backup-paste summary {
  cursor: pointer; list-style: none; display: inline-block; margin-bottom: 8px;
  color: var(--accent-fg); font-size: .85rem; font-weight: 600;
}
.backup-paste summary::-webkit-details-marker { display: none; }
.desc.err { color: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.seg button { padding: 8px 20px; border: none; background: var(--surface-2); color: var(--text-dim); font-weight: 700; transition: color var(--t), background var(--t); }
@media (hover: hover) { .seg button:hover { color: var(--text); } }
.seg button.on { background: var(--main); color: var(--main-ink); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.radio-row { display: flex; flex-direction: column; gap: 12px; }
.radio-row label { display: flex; align-items: center; gap: 10px; font-weight: 500; }

/* checkbox + radio accent */
input[type=checkbox], input[type=radio] { accent-color: var(--main); width: 17px; height: 17px; cursor: pointer; }

.muted { color: var(--text-dim); }
.center { text-align: center; }
.spacer { height: 8px; }
.empty { text-align: center; color: var(--text-dim); padding: 36px 12px; }
.empty h1 { color: var(--text); }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: .85em; color: var(--accent-fg); }
.link-btn { background: none; border: none; color: var(--accent-fg); padding: 0; font-size: .85rem; font-weight: 600; transition: opacity var(--t); }
@media (hover: hover) { .link-btn:hover { opacity: .75; } }

/* ---------- light theme (Monkeytype "serika") ---------- */
/* Only the tokens change; every component reads them. Accent yellow stays a
   FILL colour (buttons/hovers/bars); --accent-fg darkens to stay readable as
   text on a light ground; the map swaps to CARTO's light basemap. */
:root[data-theme="light"] {
  --bg: #e6e6e8;
  --surface: #d9d9db;
  --surface-2: #cdced1;
  --border: #bcbdc1;
  --text: #323437;
  --text-dim: #74767c;
  --main: #e2b714;
  --main-ink: #2c2e31;
  --accent-fg: #8a6500;  /* darkened gold — readable as text on light */
  --good: #4f9a35;
  --bad: #c5384a;
  --blue: #37719f;
  --amber: #aa6a23;
  --violet: #6b4fb0;  /* darkened so light badge ink reads on it */
}
/* Light theme's blue/amber/violet fills are dark — flip the badge ink to light.
   The capital badge stays dark-on-yellow (yellow is light in both themes). */
:root[data-theme="light"] .b-country,
:root[data-theme="light"] .b-pop,
:root[data-theme="light"] .b-locate { color: #f3f3f4; }

:root[data-theme="light"] .leaflet-control-attribution {
  background: rgba(255,255,255,.7) !important;
}

/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, .app > * { animation: none !important; transition: none !important; }
  .caret { animation: none; }
}
