@font-face {
  font-family: 'Nunito';
  src: url('nunito.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; }

:root {
  --ink: #2d3142;
  --sub: #6b7085;
  --card: #ffffff;
  --accent: #ff6b35;
  --teal: #0aa596;
  --gold: #ffb703;
  --good: #2f8f2f;   /* text-safe green (WCAG AA on white) */
  --bad: #d6336c;    /* text-safe red/pink (WCAG AA on white) */
  --shadow: 0 4px 14px rgba(45,49,66,.10);
}

html, body { height: 100%; }
body {
  font-family: 'Nunito', "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #fdf6e3 0%, #e8f4fd 55%, #dff0ea 100%);
  background-attachment: fixed;
}

#app {
  max-width: 1000px; margin: 0 auto; padding: 12px; min-height: 100%; display: flex; flex-direction: column;
  /* it's a game, not a document: dragging should never leave text highlighted */
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#foot, #qcard .learn-sub { -webkit-user-select: text; user-select: text; }
#screen { flex: 1; display: flex; flex-direction: column; }
#mapstash { display: none; }
.loading { text-align: center; padding: 80px 0; font-size: 1.4rem; color: var(--sub); }

button { font: inherit; cursor: pointer; border: none; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 6px; }

#foot { text-align: center; color: var(--sub); font-size: .78rem; padding: 10px 6px 14px; }
#foot a { color: var(--sub); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- home ---------- */
.hero { text-align: center; padding: 14px 0 6px; }
.hero h1 { font-size: 2.4rem; font-weight: 900; letter-spacing: .5px; }
/* two-tone rather than a gradient: teal->orange interpolates through a muddy
   grey, which is obvious at large sizes (and on the social card) */
.hero h1 .brand { color: var(--teal); }
.hero h1 .brand .fu { color: var(--accent); }
.hero h1 .mark { display: inline-block; animation: floaty 3.5s ease-in-out infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-4px) rotate(5deg); } }
.hero, .tabs, .cards, .modes, .review-wrap, #qcard, .celebrate, .viewrow { animation: rise .22s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.hero .tagline { color: var(--sub); margin-top: 2px; font-size: 1rem; font-weight: 600; }
.totals { display: flex; gap: 10px; justify-content: center; margin: 14px 0 4px; flex-wrap: wrap; }
.total-pill { background: var(--card); border-radius: 999px; padding: 8px 18px; box-shadow: var(--shadow); font-weight: 600; }
.total-pill small { display: block; font-weight: 400; color: var(--sub); font-size: .75rem; text-align: center; }

.tabs { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
.tab { background: #ffffffaa; border-radius: 12px; padding: 10px 22px; font-weight: 700; font-size: 1.05rem; color: var(--sub); }
.tab { transition: transform .1s, background .15s; }
.tab:active { transform: scale(.96); }
.tab.active { background: var(--teal); color: #fff; box-shadow: var(--shadow); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding-bottom: 24px; }
.scard {
  background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow);
  text-align: left; display: flex; flex-direction: column; gap: 8px; position: relative;
  transition: transform .12s;
}
.scard { transition: transform .12s, box-shadow .12s; }
.scard:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(45,49,66,.14); }
.scard:active { transform: translateY(0); }
.scard .shead { display: flex; align-items: center; gap: 10px; }
.scard .semoji { font-size: 1.8rem; }
.scard .stitle { font-weight: 700; font-size: 1.08rem; }
.scard .scount { color: var(--sub); font-size: .85rem; }
.scard .sbar { height: 8px; border-radius: 4px; background: #eee9dd; overflow: hidden; }
.scard .sbar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--teal), #5fd0a5); transition: width .3s; }
.scard .sfoot { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; color: var(--sub); }
.stars { color: var(--gold); letter-spacing: 2px; }
.badge-next {
  position: absolute; top: -8px; right: 10px; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 3px 10px; font-size: .72rem; font-weight: 700; box-shadow: var(--shadow);
}
.badge-done { position: absolute; top: -8px; right: 10px; font-size: 1.2rem; }

.review-wrap { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; padding-bottom: 24px; width: 100%; }
.review-card { background: var(--card); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); text-align: left; }
.review-card h3 { margin-bottom: 4px; }
.review-card p { color: var(--sub); font-size: .92rem; margin-bottom: 10px; }
.review-card .btn-primary[disabled] { opacity: .45; cursor: default; }

/* ---------- section overview ---------- */
.abar { display: flex; align-items: center; gap: 10px; padding: 6px 0 10px; }
.btn-back {
  background: var(--card); border-radius: 12px; width: 42px; height: 42px; font-size: 1.2rem;
  box-shadow: var(--shadow); flex-shrink: 0;
}
.atitle { font-weight: 800; font-size: 1.25rem; flex: 1; margin: 0; }
.atitle small { display: block; font-weight: 400; font-size: .8rem; color: var(--sub); }
.astreak { font-weight: 800; color: var(--accent); font-size: 1.05rem; min-width: 52px; text-align: right; }

.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.mode-btn {
  background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow);
  text-align: center; transition: transform .12s; border-top: 4px solid transparent;
}
.modes .mode-btn:nth-child(1) { border-top-color: #a0c4ff; }
.modes .mode-btn:nth-child(2) { border-top-color: #7ed957; }
.modes .mode-btn:nth-child(3) { border-top-color: var(--gold); }
.modes .mode-btn:nth-child(4) { border-top-color: #ffadad; }
.mode-btn:hover { transform: translateY(-2px); }
.mode-btn:active { transform: translateY(1px); }
.mode-btn .mico { font-size: 1.6rem; }
.mode-btn .mname { font-weight: 700; margin-top: 2px; }
.mode-btn .mdesc { font-size: .78rem; color: var(--sub); margin-top: 2px; }

/* ---------- map ---------- */

/* ---------- map base styles, lifted out of the SVGs ----------
   The two source maps ship their own <style> blocks. Serving those means
   allowing 'unsafe-inline' in the style-src CSP directive, so app.js strips
   them at load time and they live here instead, verbatim.

   :where() keeps each rule at its original specificity (a single class), so
   the overrides further down this file win exactly as they did before. */

/* from us.svg */
:where(#map-us) .state { fill:#D0D0D0; }
:where(#map-us) .borders { stroke:#FFFFFF; stroke-width:1; }
:where(#map-us) .dccircle { display:yes; }   /* inert: "yes" is not a display value — kept as the source had it */
:where(#map-us) .separator1 { stroke:#B0B0B0; stroke-width:2; }

/* from world.svg */
:where(#map-world) .circlexx { opacity: 0; fill: #c0c0c0; stroke: #000000; stroke-width: 0.5; }
:where(#map-world) .subxx { opacity: 0; fill: #c0c0c0; stroke: #000000; stroke-width: 0.3; }
:where(#map-world) .landxx { fill: #c0c0c0; stroke: #ffffff; stroke-width: 0.5; fill-rule: evenodd; }
:where(#map-world) .coastxx { stroke-width: 0.2; }
:where(#map-world) .antxx { opacity: 1; fill: #c0c0c0; }
:where(#map-world) .noxx { opacity: 0; fill: #c0c0c0; stroke: #000000; stroke-width: 0.5; }
:where(#map-world) .limitxx { opacity: 0; fill: #c0c0c0; stroke: #ffffff; stroke-width: 0.2; fill-rule: evenodd; }
:where(#map-world) .unxx { opacity: 0; fill: #c0c0c0; stroke: #000000; stroke-width: 0.3; }
:where(#map-world) .oceanxx { opacity: 1; fill: #ffffff; stroke: #000000; stroke-width: 0.5; }

#mapwrap {
  flex: 1; min-height: 300px; background: #cfe8fb; border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow); position: relative; border: 4px solid #fff;
}
#mapwrap svg { width: 100%; height: 100%; display: block; }

/* home progress map: outline every state/country, or borders vanish inside a tint */
#mapwrap.home .geo-piece, #mapwrap.home .geo-piece * {
  stroke: #5f5340; stroke-opacity: .42; stroke-width: 1px; vector-effect: non-scaling-stroke;
}
#mapwrap.home .landxx { fill: #e8e4d8; }   /* land we don't quiz: clearly not a region, clearly not sea */

/* home progress map */
#mapwrap.home { flex: none; height: auto; aspect-ratio: var(--ar, 959 / 593); min-height: 0; margin-bottom: 24px; }
.viewrow { text-align: right; margin-bottom: 8px; }
#mapwrap .hovreg { filter: brightness(1.07) saturate(1.25); }
.pill-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.pill {
  position: absolute; transform: translate(-50%, -50%); pointer-events: auto;
  background: rgba(255, 255, 255, .94); border: 2px solid transparent; border-radius: 999px;
  padding: 4px 10px; box-shadow: var(--shadow); font-size: .8rem; font-weight: 700;
  display: flex; gap: 5px; align-items: center; white-space: nowrap; color: var(--ink);
}
.pill:hover { transform: translate(-50%, -50%) scale(1.1); z-index: 3; }
.pill .pstars { color: var(--gold); font-size: .72rem; letter-spacing: 1px; }
.pill.next { border-color: var(--accent); }
.pill.done { border-color: var(--gold); }
.pill { animation: pillin .3s ease-out both; }
@keyframes pillin { from { opacity: 0; } to { opacity: 1; } }
.btn-zoomout {
  position: absolute; top: 10px; left: 10px; pointer-events: auto; z-index: 3;
  background: rgba(255, 255, 255, .94); border-radius: 999px; padding: 7px 14px;
  font-weight: 700; font-size: .85rem; box-shadow: var(--shadow); color: var(--ink);
}
.btn-zoomout:hover { background: #fff; }
@media (max-width: 620px) {
  .pill { font-size: .62rem; padding: 2px 6px; gap: 3px; }
  .pill .pstars { display: none; }
}

#mapwrap .geo-piece, #mapwrap .geo-piece * { fill: #efe9da !important; }
#map-world .oceanxx { fill: #cfe8fb !important; }
/* the ocean path is outlined in the source map; zoomed in that edge reads as a stray line */
#mapwrap.focus .oceanxx { stroke: none; }
#map-world .landxx { fill: #e0dccd; }
/* borders: the source maps draw white hairlines, which vanish against pale fills */
#mapwrap.focus .geo-piece, #mapwrap.focus .geo-piece * {
  stroke: #bdb6a3; stroke-width: 1px; vector-effect: non-scaling-stroke;
}
#mapwrap.focus .faded-far, #mapwrap.focus .faded-far * { stroke: #ddd9cd; }
#mapwrap.focus .insec, #mapwrap.focus .insec * { stroke: #b3762a; stroke-width: 1.6px; }
#mapwrap.focus .hl, #mapwrap.focus .hl * { stroke: #7a4a12; stroke-width: 2px; }

#mapwrap .faded, #mapwrap .faded * { fill: #e6e1d0 !important; }        /* same continent: context */
#mapwrap .faded-far, #mapwrap .faded-far * { fill: #f4f3ee !important; } /* other continents: barely there */
#mapwrap.focus .landxx { fill: #f4f3ee; }
/* with a continent in focus, untracked land recedes with the far tier */
#mapwrap.focus svg:not(.has-context) .landxx { fill: #e6e1d0; }
#mapwrap .insec, #mapwrap .insec * { fill: #ffe08a !important; }
#mapwrap .hl, #mapwrap .hl * { fill: #ffb703 !important; }
#mapwrap .good, #mapwrap .good * { fill: #7ed957 !important; }
#mapwrap .bad, #mapwrap .bad * { fill: #f06a8a !important; }
#mapwrap .geo-clickable, #mapwrap .geo-clickable * { cursor: pointer; }
#mapwrap .hov, #mapwrap .hov * { fill: #8fd3f4 !important; }
#mapwrap.focus .hov, #mapwrap.focus .hov * { stroke: #1c3b52; stroke-width: 2px; }
.hover-ring { fill: none; stroke: #1c3b52; stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
#mapwrap .geo-hit { fill: transparent; cursor: pointer; }
#mapwrap .dot-shown { opacity: 1; stroke: #b3762a; stroke-width: 1.2px; vector-effect: non-scaling-stroke; }

.geo-label {
  font-family: 'Nunito', "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  font-weight: 800;
  fill: #2d3142;
  stroke: #ffffff;
  paint-order: stroke;
  stroke-linejoin: round;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.geo-marker {
  fill: none; stroke: var(--accent); stroke-width: 3; vector-effect: non-scaling-stroke;
  animation: pulse 1.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.map-toast {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 999px; padding: 7px 16px; font-size: .95rem;
  box-shadow: var(--shadow); white-space: nowrap; animation: fadein .15s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- question card ---------- */
#qcard {
  background: var(--card); border-radius: 18px; padding: 14px 16px; margin-top: 12px;
  box-shadow: var(--shadow); min-height: 108px; display: flex; flex-direction: column; justify-content: center; gap: 10px;
}
.prompt { font-size: 1.15rem; text-align: center; }
.prompt b { color: var(--accent); }
.feedback { text-align: center; font-weight: 700; min-height: 1.3em; }
.feedback.ok, .feedback.no { animation: pop .22s ease-out; }
.feedback.ok { color: var(--good); }
.feedback.no { color: var(--bad); }
@keyframes pop { from { transform: scale(.8); } }
.astreak.pop { animation: pop .3s ease-out; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice {
  background: #fff; border: 2px solid #e8e3d4; border-bottom-width: 4px; border-radius: 14px;
  padding: 12px 10px; font-weight: 700; font-size: 1rem; transition: border-color .1s, transform .08s;
}
.choice:hover:not([disabled]) { border-color: var(--teal); }
.choice:active:not([disabled]) { transform: translateY(2px); border-bottom-width: 2px; }
.choice.right { background: #dff5d0; border-color: var(--good); }
.choice.wrong { background: #fde3ea; border-color: var(--bad); animation: shake .3s; }
.choice[disabled] { cursor: default; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.alt-row { text-align: center; }
.btn-alt { background: none; color: var(--sub); font-size: .8rem; text-decoration: underline; padding: 2px 6px; }
.btn-alt:hover { color: var(--ink); }

.learn-card { text-align: center; }
.learn-name { font-size: 1.6rem; font-weight: 800; }
.learn-sub { color: var(--sub); margin-top: 2px; }
.learn-nav { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 10px; }
.learn-count { color: var(--sub); font-size: .9rem; min-width: 64px; }

.btn-primary {
  background: var(--teal); color: #fff; border-radius: 14px; padding: 11px 26px; font-weight: 800; font-size: 1rem;
  box-shadow: 0 4px 0 #067c6f; transition: transform .08s, box-shadow .08s;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #067c6f; }
.btn-ghost {
  background: #f0ede3; border-radius: 14px; padding: 11px 20px; font-weight: 700;
  box-shadow: 0 3px 0 #d9d4c4; transition: transform .08s, box-shadow .08s;
}
.btn-ghost:active { transform: translateY(2px); box-shadow: 0 1px 0 #d9d4c4; }

.aprog { height: 8px; border-radius: 4px; background: #ffffff99; overflow: hidden; margin-bottom: 10px; }
.aprog-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: 4px; transition: width .3s; width: 0; }

/* ---------- celebration ---------- */
.celebrate {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  text-align: center; padding: 30px 10px;
}
.celebrate .big { font-size: 4rem; animation: bigpop .5s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes bigpop { from { transform: scale(.3); opacity: 0; } }
.celebrate .stars-big { animation: pop .45s ease-out both .15s; }
.celebrate h2 { font-size: 1.7rem; }
.celebrate .sub { color: var(--sub); max-width: 420px; }
.celebrate .stars-big { font-size: 2.4rem; color: var(--gold); letter-spacing: 6px; }
.celebrate .actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.missed {
  background: var(--card); border-radius: 14px; padding: 12px 18px; box-shadow: var(--shadow);
  text-align: left; max-width: 420px; width: 100%;
}
.missed h3 { font-size: .95rem; margin-bottom: 6px; }
.missed ul { margin: 0; padding: 0; list-style: none; }
.missed li { margin: 4px 0; display: flex; align-items: center; gap: 10px; }
.missed .mtext span { color: var(--sub); font-size: .9rem; }
.missed .mini-slot { width: 52px; height: 42px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.mini-shape { width: 100%; height: 100%; }
.mini-shape * { fill: #ffd166; stroke: #2d3142; stroke-width: 1.2px; stroke-linejoin: round; }

.confetti-bit { position: fixed; top: -30px; font-size: 1.5rem; pointer-events: none; z-index: 99; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-width: 620px) {
  .hero h1 { font-size: 1.6rem; }
  .prompt { font-size: 1rem; }
  #mapwrap { min-height: 220px; }
  .choices { grid-template-columns: 1fr; }
  .choice { padding: 10px; }
}


/* ---------- pre-rendered page copy ----------
   Present in the HTML for crawlers and for anyone without JavaScript; the app
   replaces it with the interactive version of the same content once maps load. */
.prerender { max-width: 62ch; margin: 24px auto; padding: 0 4px; -webkit-user-select: text; user-select: text; }
.prerender h1 { font-size: 1.9rem; font-weight: 900; line-height: 1.2; }
.prerender h2 { font-size: 1.15rem; font-weight: 800; margin-top: 20px; color: var(--sub); }
.prerender p { margin: 10px 0; line-height: 1.55; }
.prerender ul { margin: 10px 0 10px 20px; line-height: 1.7; }
.prerender a { color: var(--teal); }
.prerender .pr-note { color: var(--sub); font-size: .85rem; margin-top: 18px; }

/* ---------- prose pages (privacy, terms, credits) ---------- */
.prose {
  max-width: 68ch; margin: 0 auto; padding: 8px 4px 32px; flex: 1;
  -webkit-user-select: text; user-select: text; line-height: 1.6;
}
.prose .backlink { margin: 10px 0 18px; }
.prose .backlink a { color: var(--teal); font-weight: 700; text-decoration: none; }
.prose h1 { font-size: 2rem; font-weight: 900; margin-bottom: 14px; }
.prose h2 { font-size: 1.2rem; font-weight: 800; margin: 26px 0 6px; }
.prose h3 { font-size: 1rem; font-weight: 800; margin: 18px 0 4px; color: var(--sub); }
.prose p { margin: 10px 0; }
.prose .lede { font-size: 1.1rem; color: var(--ink); background: var(--card);
  border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.prose ul { margin: 10px 0 10px 22px; }
.prose li { margin: 5px 0; }
.prose ul.credit { list-style: none; margin-left: 0; }
.prose ul.credit li { margin: 7px 0; padding-left: 14px; border-left: 3px solid #e3ded0; }
.prose a { color: #0a7f74; }
.prose code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em;
  background: #ffffffaa; border-radius: 5px; padding: 1px 5px; }
.prose .upd { color: var(--sub); }

@media (max-width: 560px) {
  .prose h1 { font-size: 1.6rem; }
  .prerender h1 { font-size: 1.5rem; }
}
