:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  --ink: #182523;
  --page: #f5f6f4;
  --surface: #fff;
  --muted: #4c5c59;
  --line: #d2dcd8;
  --control-line: #acbab6;
  --hover: #edf3f0;
  --quiet: #335550;
  --focus: #076458;
  --accent: #076458;
  --accent-hover: #084f47;
  --accent-ink: #fff;
  --positive: #235b3d;
  --negative: #854138;
  --water: #eff5f8;
  --grid: #cbd8de;
  --land: #e0e5dd;
  --border: #7f928e;
  --lake-line: #99afb4;
  --leader: #53645f;
  --pin-line: #274e47;
  --pin-ink: #21443d;
  --pin-hover: #d7eeea;
  --pin-correct: #076458;
  --pin-wrong: #9c3c32;
  --hint-fill: #ffab55;
  --hint-line: #99510d;
  --hint-ink: #33200a;
  --hint-panel: #fff3e6;
  --hint-text: #713a09;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e9f0ee;
  --page: #121a19;
  --surface: #1c2826;
  --muted: #b1c4be;
  --line: #384b46;
  --control-line: #5f7771;
  --hover: #30423e;
  --quiet: #c4dcd5;
  --focus: #94dacf;
  --accent: #86d5c4;
  --accent-hover: #a6e7d8;
  --accent-ink: #102522;
  --positive: #9bddb9;
  --negative: #ffb5a9;
  --water: #172931;
  --grid: #32484e;
  --land: #3b4d44;
  --border: #8a9f95;
  --lake-line: #657e83;
  --leader: #bacfc7;
  --pin-line: #add2c7;
  --pin-ink: #e1f4ed;
  --pin-hover: #385b51;
  --pin-correct: #19715c;
  --pin-wrong: #a2473b;
  --hint-panel: #402b19;
  --hint-text: #ffd2a5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.wrap { width: min(1720px, calc(100% - 56px)); margin: 0 auto; }
.header { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: 13px; padding-top: 23px; }
.courses { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.courses a {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--quiet);
  font-size: 13px;
  text-decoration: none;
}
.courses a:hover { background: var(--hover); }
.courses [aria-current="page"] {
  border-color: var(--accent);
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
}
.preferences { display: flex; align-items: center; gap: 3px; }
.preferences button { white-space: nowrap; }
h1, h2, p { margin: 0; }
h1 { margin-top: 4px; font-size: clamp(25px, 4vw, 36px); line-height: 1.12; letter-spacing: -.035em; }
.subtitle { color: var(--muted); font-size: 13px; }
.settings { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.filter { display: flex; align-items: center; gap: 6px; min-width: 0; }
.filter select { color: var(--ink); }
.settings label { font-size: 13px; color: var(--muted); }
.instructions { margin: 13px 0 16px; color: var(--muted); font-size: 14px; }
.scoreboard { grid-area: history; font-size: 13px; }
.scoreboard summary { padding: 8px 10px; cursor: pointer; font-weight: 650; }
.scoreboard-body { padding: 0 10px 10px; }
.score-scope { font-weight: 650; }
.score-caption { margin: 3px 0 8px; color: var(--muted); }
.score-list { margin: 0; padding: 0; list-style: none; }
.score-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.score-list time { color: var(--muted); font-size: 12px; }
.score-list strong { font-variant-numeric: tabular-nums; }
.score-list .passed { color: var(--positive); }
.score-list .failed { color: var(--negative); }
select {
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
}
button {
  min-height: 40px;
  padding: 7px 11px;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  color: inherit;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
}
button:hover:not(:disabled) { background: var(--hover); }
button:disabled { opacity: .6; }
.primary { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.quiet { border-color: transparent; color: var(--quiet); background: transparent; }
.board {
  display: grid;
  grid-template: "map prompt" auto "map history" 1fr / minmax(0, 1fr) 295px;
  gap: 14px;
  align-items: start;
}
.panel { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.map-card { grid-area: map; overflow: hidden; }
.map-header, .map-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
}
.map-header h2 { font-size: 15px; font-weight: 650; }
.map-tools { flex-shrink: 0; }
.map-tools { display: flex; gap: 3px; }
.map-tools button { min-height: 34px; padding: 4px 7px; font-size: 12px; }
.map-stage {
  position: relative;
  height: clamp(470px, 68vh, 850px);
  background: var(--water);
  border-block: 1px solid var(--line);
  overflow: hidden;
}
#map { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
#map:active { cursor: grabbing; }
#map:focus-visible { outline-offset: -3px; }
#map .gridline { stroke: var(--grid); stroke-width: .65; }
#map .land { fill: var(--land); stroke: var(--border); stroke-width: .8; }
#map .lake { fill: var(--water); stroke: var(--lake-line); stroke-width: .65; }
.map-points { position: absolute; inset: 0; pointer-events: none; }
.map-point {
  position: absolute;
  top: 0;
  left: 0;
  width: 26px;
  height: 26px;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  pointer-events: auto;
  touch-action: none;
}
.map-point span {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1px solid var(--pin-line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--pin-ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.map-point:hover:not(:disabled) { background: transparent; }
.map-point:not([aria-disabled="true"]):hover span, .map-point:focus-visible span {
  background: var(--pin-hover);
  border-width: 2px;
}
.map-point[aria-disabled="true"] { cursor: default; }
.map-point.muted span { opacity: .35; }
.map-point.hint span { background: var(--hint-fill); color: var(--hint-ink); border-color: var(--hint-line); }
.map-point.correct span { background: var(--pin-correct); color: #fff; border-color: var(--pin-correct); }
.map-point.incorrect span { background: var(--pin-wrong); color: #fff; border-color: var(--pin-wrong); }
#map .leader-line { fill: none; stroke: var(--leader); stroke-width: 1; }
#map .leader-anchor { fill: var(--leader); }
#zoom-in, #zoom-out { min-width: 34px; padding-inline: 0; font-size: 18px; line-height: 1; }
.map-footer { min-height: 37px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.quiz-card { grid-area: prompt; padding: 15px; }
.round-header { display: flex; justify-content: space-between; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.round-score { margin-top: 8px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.question { margin: 13px 0 10px; }
.question h2 { margin-top: 4px; font-size: clamp(26px, 3vw, 32px); line-height: 1.12; letter-spacing: -.025em; overflow-wrap: anywhere; }
.prompt-label { color: var(--muted); font-size: 13px; }
.kind { margin-top: 3px; color: var(--muted); font-size: 13px; }
.feedback.good, .feedback.bad {
  margin-top: 12px;
  padding: 8px 10px;
  border-inline-start: 3px solid currentColor;
  border-radius: 0 5px 5px 0;
  background: var(--hover);
}
.feedback.good { color: var(--positive); }
.feedback.bad { color: var(--negative); }
.feedback-status { font-size: 13px; font-weight: 600; }
.feedback-name { color: var(--ink); font-size: 21px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.feedback-name:not(:empty) { margin-top: 2px; }
.hint-box { display: grid; gap: 7px; margin-top: 10px; padding: 8px 9px; border-radius: 5px; background: var(--hint-panel); color: var(--hint-text); font-size: 13px; }
.hint-box button { justify-self: start; min-height: 34px; padding: 5px 9px; font-size: 13px; }
#next { margin-top: 10px; }
.results {
  width: min(480px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: clamp(16px, 4vw, 24px);
  color: var(--ink);
  box-shadow: 0 20px 60px #0005;
}
.results[open] { animation: result-in .24s ease-out both; }
.results::backdrop { background: #0a181780; }
.result-heading { display: flex; align-items: center; gap: 10px; }
.result-gif {
  display: block;
  width: 100%;
  height: min(34dvh, 235px);
  margin-top: 12px;
  border-radius: 7px;
  background: var(--page);
  object-fit: contain;
}
@keyframes result-in {
  from { opacity: 0; transform: translateY(9px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.results h2 { font-size: clamp(26px, 4vw, 34px); }
.result-mark {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  height: 38px;
  border: 1px solid var(--positive);
  border-radius: 50%;
  color: var(--positive);
  background: var(--hover);
  animation: pass-in .45s ease-out both;
}
.result-score { margin-top: 8px; color: var(--muted); font-size: 14px; }
.result-score strong { color: var(--ink); font-size: 24px; font-variant-numeric: tabular-nums; }
@keyframes pass-in {
  from { opacity: 0; transform: translateY(4px) scale(.84); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .results[open], .result-mark { animation: none; }
}
.result-detail { margin: 8px 0 13px; color: var(--muted); }
.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 7px; padding: 12px 0 22px; color: var(--muted); font-size: 11px; }
@media (max-width: 1040px) {
  .header { grid-template-columns: minmax(0, 1fr) auto; }
  .settings { grid-column: 1 / -1; }
}
@media (max-width: 840px) {
  .wrap { width: calc(100% - 26px); }
  .header { gap: 10px; padding-top: 14px; }
  .settings { gap: 6px; }
  .settings button, .settings select { min-height: 34px; font-size: 13px; }
  .instructions { margin: 9px 0 12px; font-size: 13px; }
  .board { grid-template: "history" auto "prompt" auto "map" auto / minmax(0, 1fr); gap: 9px; }
  .map-stage { height: clamp(300px, 46svh, 570px); }
  .map-footer { padding-block: 5px; font-size: 10px; gap: 3px; }
  .quiz-card { position: sticky; top: 0; z-index: 1; padding: 10px 11px; }
  .question h2 { font-size: 25px; }
  .feedback-name { font-size: 19px; }
  .question { margin-top: 8px; }
}
@media (max-width: 550px) {
  .settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
  .filter { display: grid; gap: 4px; }
  .filter select { width: 100%; }
  .settings button { justify-self: start; }
}
@media (max-width: 450px) {
  .preferences { flex-direction: column; align-items: end; gap: 0; }
  .preferences button { min-height: 27px; padding: 3px 6px; font-size: 12px; }
  .map-footer span:nth-child(2) { flex-basis: 100%; }
}
