@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; }
#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; }
.hero h1 .brand {
  background: linear-gradient(92deg, var(--teal) 10%, #3aa9e0 50%, var(--accent) 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero h1 .globe { 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; }
.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; }
.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 ---------- */
#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 */
#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; }
#map-world .landxx { fill: #e0dccd; }
#mapwrap .faded, #mapwrap .faded * { fill: #f2f0e9 !important; }
#mapwrap.focus .landxx { fill: #efede5; }
#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; }

.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; }
}
