@font-face {
  font-family: Inter;
  src: url("/static/assets/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("/static/assets/fonts/instrument-serif-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --page: #f4f2ea;
  --surface: #fdfbf6;
  --text: #192b28;
  --muted: #495c54;
  --line: #deded2;
  --control-line: #a8b6ab;
  --primary: #20584b;
  --primary-hover: #173e36;
  --on-primary: #fff;
  --tint: #e8ede3;
  --notice: #805221;
  --radius: 19px;
  --shadow: 0 9px 28px rgb(36 53 45 / .055);
  --display: "Instrument Serif", Georgia, serif;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background: var(--page);
  line-height: 1.6;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse 70% 400px at 63% 0%, #e9eee3, transparent 100%); }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2 { font-size: clamp(1.5rem, 2.75vw, 2.1rem); }
h3 { font-size: 1.12rem; }
p, li { overflow-wrap: anywhere; }
a { color: var(--primary); text-underline-offset: .22em; }
a:hover { color: var(--primary-hover); }
button, input, select { font: inherit; }
button, select, summary { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
button:disabled { cursor: default; opacity: .55; }
.container { width: min(1240px, calc(100% - 64px)); margin-inline: auto; }
.sr-only, .skip-link:not(:focus) {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip-link:focus { position: fixed; top: 8px; left: 8px; background: white; padding: 10px 16px; z-index: 9; }
section[id], #saved-scores { scroll-margin-top: 1rem; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 750; letter-spacing: -.035em; text-decoration: none; }
.brand img { border-radius: 8px; flex: none; filter: hue-rotate(287deg) saturate(.54) brightness(.73); }
.site-nav { display: flex; align-items: center; gap: clamp(7px, 2vw, 28px); }
.site-nav a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 650; white-space: nowrap;
}
.site-nav a:hover { color: var(--primary); }
.site-nav .nav-play { padding-inline: 16px; background: var(--tint); color: var(--primary); border-radius: 9px; }
.hero { padding-block: 34px 27px; }
.hero h1 { font-family: var(--display); font-size: clamp(3.35rem, 6.5vw, 6rem); line-height: .97; font-weight: 400; letter-spacing: -.033em; }
.hero h1 span { display: inline-block; max-width: 100%; color: var(--primary); }
.hero p { font-size: clamp(.98rem, 2vw, 1.09rem); margin-top: 12px; color: var(--muted); max-width: 94ch; text-wrap: pretty; }

.quiz-shell, .info-panel, .faq-list {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.quiz-shell {
  --page: #101d20;
  --surface: #142428;
  --text: #f0f4ea;
  --muted: #b3c7c2;
  --line: #314448;
  --control-line: #657c7d;
  --tint: #21363a;
  --primary: #e7c889;
  --primary-hover: #f4dca6;
  --on-primary: #272116;
  --notice: #f0cb91;
  --open: #c9dbb8;
  --found: #6ce0b8;
  --missed: #e3ac65;
  --map-found: #198c69;
  --map-missed: #efce88;
  --map-missed-stripe: #98602e;
  color-scheme: dark;
  color: var(--text);
  box-shadow: 0 18px 38px rgb(22 43 38 / .17), 0 3px 8px rgb(22 43 38 / .1);
}
.quiz-console {
  padding: 21px 24px 11px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
}
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.quiz-heading h2 { font-size: clamp(1.15rem, 2vw, 1.43rem); }
.quiz-heading p { margin-top: 4px; font-size: .88rem; color: var(--muted); }
.quiz-metrics { display: flex; flex-wrap: wrap; gap: 8px; flex: none; max-width: 100%; }
.metric { min-width: 114px; padding: 7px 12px; border: 1px solid var(--line); background: var(--page); border-radius: 10px; }
.metric > span { color: var(--muted); display: block; font-size: .7rem; line-height: 1.3; font-weight: 650; }
.metric strong { display: block; font-size: 1.27rem; font-variant-numeric: tabular-nums; line-height: 1.35; }
.metric strong span { color: var(--muted); font-size: .88rem; font-weight: 600; }
#score { color: var(--primary); }
#quiz-fullscreen { align-self: center; font-size: .84rem; white-space: nowrap; }
.quiz-actions { margin-top: 13px; }
.setup-controls, .round-controls, .round-buttons, .paused-controls, .result-actions, .dialog-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.round-controls { flex-wrap: nowrap; }
#answer-form { display: flex; gap: 8px; flex: 1; min-width: 0; }
.button, select, input, .map-tools button {
  min-height: 44px; border: 1px solid var(--control-line); border-radius: 9px; padding: 8px 14px;
  background: var(--surface); color: var(--text);
}
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-weight: 690; line-height: 1.25; text-decoration: none; text-align: center;
}
.primary { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.primary:hover:not(:disabled) { color: var(--on-primary); background: var(--primary-hover); border-color: var(--primary-hover); }
.secondary:hover:not(:disabled), .map-tools button:hover:not(:disabled) { background: var(--tint); border-color: var(--primary); }
.quiet { color: var(--muted); border-color: transparent; }
.quiet:hover { background: var(--page); color: var(--text); }
#answer { width: 100%; min-width: 0; }
#answer, #mode { background: var(--page); }
#answer::placeholder { color: var(--muted); opacity: 1; }
#answer[aria-invalid="true"] { border-color: var(--missed); }
.feedback { min-height: 1.5em; margin-top: 6px; color: var(--muted); font-size: .84rem; }
.feedback[data-kind="success"] { color: var(--found); }
.feedback[data-kind="note"] { color: var(--notice); }
.result { display: grid; gap: 10px; }
.result p { margin-top: 3px; color: var(--muted); }
#share-fallback { max-width: 620px; }
#share-text { width: 100%; }
dialog { width: min(410px, calc(100% - 30px)); border: 1px solid var(--control-line); border-radius: var(--radius); color: var(--text); background: var(--surface); padding: 24px; }
dialog::backdrop { background: rgb(15 23 42 / .55); }
dialog p { margin: 10px 0 18px; color: var(--muted); }
.dialog-actions { justify-content: flex-end; }

.quiz-board { display: grid; grid-template-columns: minmax(0, 3.12fr) minmax(0, 1fr); border-top: 1px solid var(--line); }
.map-column { padding: 12px 20px 14px; min-width: 0; }
.map-top, .regions-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
.map-top h3, .regions-top h3 { font-size: 1rem; }
.map-tools { display: flex; flex-wrap: wrap; gap: 5px; }
.map-tools button { min-width: 44px; padding: 4px 10px; color: var(--text); font-weight: 650; background: var(--page); }
.map-tools button[aria-pressed="true"] { color: var(--primary); border-color: var(--primary); background: var(--tint); }
.map-viewport {
  position: relative; display: grid; place-items: center; aspect-ratio: 880 / 455;
  width: 100%;
  background: radial-gradient(ellipse at 52% 26%, #f4f9f7, #dcece9 82%);
  border: 1px solid #bdd3d3; border-radius: 12px;
  overflow: hidden; color: #315963; isolation: isolate;
}
#map-art { width: 100%; height: 100%; display: grid; place-items: center; min-height: 0; min-width: 0; }
#map-art svg { display: block; width: 100%; height: 100%; }
#map-art.concealed { visibility: hidden; }
.globe-art { position: absolute; inset: 0; touch-action: none; cursor: grab; }
.globe-art:active { cursor: grabbing; }
.globe-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.globe-art canvas + canvas { pointer-events: none; }
.map-viewport:has(.globe-art:not([hidden])) { background: radial-gradient(ellipse at 50% 42%, #f4faf9, #d9eae9 83%); }
.map-notice { color: var(--muted); font-size: .79rem; margin-top: 8px; }
.land path, .map-markers circle { vector-effect: non-scaling-stroke; }
#map-art .outside { fill: #b6c5b6; }
#map-art .found { fill: var(--map-found); stroke: #155844; }
#map-art .missed { fill: url("#missed-hatch"); stroke: var(--map-missed-stripe); }
#missed-hatch rect { fill: var(--map-missed); }
#missed-hatch path { stroke: var(--map-missed-stripe); stroke-width: .8; }
.map-viewport.zoomed { touch-action: none; cursor: grab; }
.map-viewport.zoomed:active { cursor: grabbing; }
.atlas-relief { pointer-events: none; }
.map-overlay { position: absolute; inset: 0; display: grid; gap: 10px; justify-items: center; align-content: center; padding: 12px; text-align: center; }
.map-tooltip { position: absolute; pointer-events: none; padding: 5px 9px; background: var(--text); color: var(--page); border-radius: 6px; font-size: .81rem; font-weight: 650; max-width: calc(100% - 12px); }
.map-legend { margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px 18px; list-style: none; color: var(--muted); font-size: .79rem; }
.map-legend li { display: flex; align-items: center; gap: 5px; }
.map-legend i { display: inline-block; border-radius: 3px; height: 12px; width: 12px; border: 1px solid #8aabac; }
.map-legend .legend-found { background: var(--map-found); border-color: var(--found); }
.map-legend .legend-open { background: var(--open); }
.map-legend .legend-missed { background: repeating-linear-gradient(135deg, var(--map-missed) 0 3px, var(--map-missed-stripe) 3px 4px); border-color: var(--missed); }

.regions { min-width: 0; padding: 18px 16px 13px; background: var(--page); border-left: 1px solid var(--line); border-radius: 0 0 var(--radius) 0; }
.regions-top { min-height: 34px; margin-bottom: 14px; }
.regions-top > span { color: var(--found); font-size: .75rem; font-weight: 680; white-space: nowrap; background: var(--tint); padding: 3px 8px; border-radius: 5px; }
.region { border-top: 1px solid var(--line); }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
.region summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 9px; align-items: center;
  padding: 10px 2px; gap: 8px 10px; min-height: 54px; font-size: .85rem; font-weight: 650;
}
.region summary:hover { color: var(--found); }
.region summary::after {
  content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); grid-area: 1 / 3;
}
.region[open] summary::after { transform: rotate(225deg); }
.region-score { color: var(--muted); font-variant-numeric: tabular-nums; }
.region-track { grid-column: 1 / -1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.region-track span { display: block; width: 0; height: 100%; background: var(--found); }
.region-content, #regions-paused { padding: 4px 2px 9px; font-size: .82rem; color: var(--muted); }
.region-content ul { margin: 2px 0 8px; padding-inline-start: 1.1rem; }
.region-subtitle { font-weight: 710; color: var(--text); }

.content-section { margin: 52px 0; }
.section-heading { margin-bottom: 17px; }
.section-heading h2 { font: 400 clamp(2.2rem, 4vw, 3.3rem) / 1 var(--display); letter-spacing: -.025em; }
.section-heading p { color: var(--muted); margin-top: 5px; max-width: 70ch; }
.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: flex; gap: 12px; padding: 18px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; counter-increment: step; }
.steps li::before { content: counter(step); flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--tint); color: var(--primary); font-weight: 750; }
.steps h3 { margin-top: 4px; }
.steps p, .info-panel p, .faq-list p { margin-top: 7px; color: var(--muted); }
.text-link { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; font-weight: 700; }
kbd { font-size: .88em; background: var(--tint); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; color: var(--text); box-decoration-break: clone; }
.info-panel { padding: clamp(17px, 3vw, 29px); }
.info-panel h3:not(:first-child), .legal h2:not(:first-child) { margin-top: 21px; }
.practice-grid { display: grid; grid-template-columns: 1.75fr 1fr; gap: 12px; }
.example { background: var(--tint); align-self: start; }
.example .example-score { font-size: 2.25rem; font-weight: 770; color: var(--primary); font-variant-numeric: tabular-nums; line-height: 1.2; }
.example-score span { font-size: 1.02rem; color: var(--muted); }
.example dl { margin-block: 13px; }
.example dl div { display: flex; justify-content: space-between; border-top: 1px solid var(--control-line); padding: 6px 0; gap: 8px; }
.example dd { font-weight: 700; }
.region-totals { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.region-totals li { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; background: var(--page); color: var(--muted); }
#region-list, .rules-panel { overflow-wrap: anywhere; }
.rules-panel > p { max-width: 78ch; }
.sources { font-size: .9rem; }
.faq-list details + details { border-top: 1px solid var(--line); }
.faq-list summary { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 10px 18px; font-weight: 690; gap: 12px; }
.faq-list summary::after { content: "+"; font-size: 1.4rem; color: var(--primary); }
.faq-list details[open] summary::after { content: "−"; }
.faq-list p { padding: 0 18px 15px; max-width: 76ch; }
.saved-scores { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: 16px; background: var(--page); flex-wrap: wrap; }
#storage-feedback:empty { display: none; }
.legal { max-width: 790px; margin-bottom: 52px; }
.legal h2 { font-size: 1.3rem; }
.legal .button { margin-top: 20px; }
main { min-height: 45vh; margin-bottom: 40px; }
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 24px 0 15px; }
.footer-main { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.footer-main p, .footer-notes { font-size: .83rem; color: var(--muted); }
.footer-main nav { display: flex; flex-wrap: wrap; column-gap: 14px; }
.footer-main nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: .88rem; font-weight: 600; }
.footer-notes { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
@media (max-width: 790px) {
  .container { width: calc(100% - 32px); }
  .hero { padding-block: 21px 17px; }
  .quiz-board { grid-template-columns: 1fr; }
  .regions { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
  .quiz-console { padding: 14px 13px 8px; }
  .quiz-console:has([data-stage="running"], [data-stage="paused"]) { position: sticky; top: 0; z-index: 2; }
  .quiz-actions { margin-top: 10px; }
  .map-column { padding: 9px 12px 10px; }
  .content-section { margin: 36px 0; }
}
@media (max-width: 580px) {
  .header-inner { min-height: 57px; gap: 6px; flex-wrap: wrap; }
  .brand { gap: 5px; font-size: .88rem; }
  .brand img { width: 27px; height: 27px; border-radius: 6px; }
  .site-nav { gap: 9px; }
  .site-nav a { font-size: .74rem; }
  .site-nav .nav-play { padding-inline: 8px; }
  .hero h1 { font-size: clamp(2.65rem, 11vw, 3.65rem); }
  .quiz-top { flex-wrap: wrap; align-items: start; }
  .metric { min-width: 79px; padding: 4px 7px; }
  .metric strong { font-size: 1.02rem; }
  .quiz-metrics { gap: 4px; }
  .quiz-heading p { font-size: .79rem; }
  .setup-controls { align-items: stretch; }
  .setup-controls select { flex: 1 1 100%; min-width: 0; padding-inline: 10px; }
  .round-controls { flex-wrap: wrap; }
  #answer-form { flex-basis: 100%; }
  .quiz-console .button { padding-inline: 10px; }
  .atlas-labels { display: none; }
  .map-viewport:has(.globe-art:not([hidden])) { aspect-ratio: 1.22; }
  .practice-grid, .steps { grid-template-columns: 1fr; }
  .region-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 370px) {
  .site-nav { gap: 7px; }
  .quiz-top { gap: 8px; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (max-height: 500px) {
  .quiz-console:has([data-stage="running"], [data-stage="paused"]) { position: static; }
}

.quiz-window-open, .quiz-window-open body { overflow: hidden; }
.quiz-shell[data-expanded] {
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.quiz-shell[data-expanded="window"] { position: fixed; inset: 0; z-index: 10; }
.quiz-shell[data-expanded] .quiz-console {
  padding-top: max(14px, env(safe-area-inset-top));
  border-radius: 0;
}
.quiz-shell[data-expanded] .regions { border-radius: 0; }

@media (min-width: 791px) and (min-height: 560px) {
  .quiz-shell[data-expanded] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .quiz-shell[data-expanded] .quiz-board { min-height: 0; }
  .quiz-shell[data-expanded] .map-column {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
  }
  .quiz-shell[data-expanded] .map-viewport { aspect-ratio: auto; min-height: 0; }
  .quiz-shell[data-expanded] .regions { min-height: 0; overflow-y: auto; }
}

@media (max-width: 790px) and (min-height: 501px) {
  .quiz-shell[data-expanded] .quiz-console { position: sticky; top: 0; z-index: 2; }
}
