/* Atlas - learn the map. Self-contained: no external fonts, no CDN. */

:root {
  --bg: #0e1418;
  --panel: #151d23;
  --ink: #e8eef2;
  --dim: #8a9aa6;
  --line: #24313a;
  --land: #2b3b46;
  --land-hi: #3b5060;
  --border: #55707f;
  --sea: #0e1418;
  --accent: #58b0e8;
  --good: #3ecf8e;
  --bad: #f2585b;
  --gold: #e8b84b;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f7f9;
    --panel: #ffffff;
    --ink: #16232b;
    --dim: #5d707d;
    --line: #d9e2e8;
    --land: #cfdae2;
    --land-hi: #b3c5d1;
    --border: #8ba3b3;
    --sea: #eaf1f5;
    --accent: #1a7fc1;
    --good: #14996a;
    --bad: #cf3134;
    --gold: #a97a10;
  }
}

* { box-sizing: border-box; }

/* The overlays below set `display: flex`, which beats the `hidden` attribute's
   UA `display: none` -- leaving an invisible full-screen layer eating every
   click on the map. Not optional. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.bar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  flex: none;
}

.prompt {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.prompt-lead {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  flex: none;
}

.prompt-target {
  font-size: clamp(20px, 3.2vw, 30px);
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt.is-retry .prompt-target { color: var(--gold); }

.bar-right {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
}

.tally {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--dim);
  white-space: nowrap;
}
.tally b { color: var(--ink); font-weight: 650; }

button {
  font: inherit;
  color: var(--ink);
  background: var(--land);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 13px;
  cursor: pointer;
}
button:hover { background: var(--land-hi); }

.ghost { background: transparent; font-size: 13px; }
.danger { color: var(--bad); }

/* ---------- round progress ---------- */

.round-bar {
  height: 3px;
  background: var(--line);
  flex: none;
}
.round-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.35s ease;
}

/* ---------- map ---------- */

main { flex: 1; min-height: 0; display: flex; }

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--sea);
  overflow: hidden;
  touch-action: none;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#map.is-panning { cursor: grabbing; }

#map path {
  fill: var(--land);
  /* Borders are drawn against LAND, not sea: at zoom the neighbouring country
     is what you need to be told apart from. Using --sea here made Monaco
     invisible inside France even at 65px. */
  stroke: var(--border);
  stroke-width: 1;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

#map path:hover { fill: var(--land-hi); }

/* States set by the round controller. Transitions are short on purpose:
   feedback has to land before the next prompt, not decorate it. */
#map path.is-correct { fill: var(--good); }
#map path.is-wrong   { fill: var(--bad); }
#map path.is-reveal  { fill: var(--gold); }
#map path.is-known   { fill: color-mix(in srgb, var(--good) 26%, var(--land)); }
#map path.is-shaky   { fill: color-mix(in srgb, var(--bad) 22%, var(--land)); }

#map path.is-correct, #map path.is-wrong, #map path.is-reveal {
  stroke: var(--ink);
  stroke-width: 1.2;
}

#map.is-locked path { pointer-events: none; }

.zoom-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.zoom-controls button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  background: var(--panel);
  opacity: 0.9;
}

.verdict {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%) translateY(6px);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 15px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  max-width: min(90vw, 640px);
  text-align: center;
}
.verdict.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.verdict.good { color: var(--good); }
.verdict.bad  { color: var(--bad); }

.hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--dim);
  pointer-events: none;
  white-space: nowrap;
}

/* ---------- progress sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  justify-content: flex-end;
  z-index: 20;
}

.sheet-inner {
  width: min(460px, 100%);
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.sheet-head, .sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sheet-foot { border-bottom: 0; border-top: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 16px; }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 24px;
}

.stat-row {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
}
.stat .n { font-size: 25px; font-weight: 680; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }

.sheet-body h3 {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 22px 0 9px;
}
.sheet-body h3:first-child { margin-top: 0; }

.pairs { list-style: none; margin: 0; padding: 0; }
.pairs li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.pairs .who { min-width: 0; }
.pairs .who b { font-weight: 600; }
.pairs .who span { color: var(--dim); }
.pairs .n { color: var(--bad); font-variant-numeric: tabular-nums; font-size: 13px; flex: none; }

.mastery { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--dim);
}
.chip.known { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.chip.shaky { color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }

.empty { color: var(--dim); font-size: 13px; margin: 0; }

/* ---------- round-complete ---------- */

.done {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
.done-inner {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 26px 30px;
  max-width: 460px;
  text-align: center;
}
.done-inner h2 { margin: 0 0 10px; font-size: 21px; }
.done-inner p { margin: 0 0 20px; color: var(--dim); }
.done-inner b { color: var(--ink); }

@media (max-width: 620px) {
  .bar { flex-wrap: wrap; gap: 8px 14px; }
  .prompt { order: 3; width: 100%; flex-basis: 100%; }
  .hint { display: none; }
}
