/* ============================================================
   Atlas: monochrome editorial system.
   One typeface (Hanken Grotesk), ink-on-paper, hairline borders,
   colour reserved strictly for answer feedback.
   ============================================================ */

/* Self-hosted (the Google Fonts CDN sends visitor IPs to Google).
   One variable file per subset covers weights 400-900. */
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("assets/fonts/hanken-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("assets/fonts/hanken-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Light: warm paper & ink */
  --paper:     #f7f6f2;
  --surface:   #ffffff;
  --surface-2: #f1f0ea;
  --ink:       #1a1916;
  --ink-2:     #6e6c64;
  --ink-3:     #9b988e;
  --line:      #e7e4dc;
  --line-2:    #d8d4c8;
  --on-ink:    #f7f6f2;   /* text on an ink fill */

  --correct:    #2e7d52;
  --correct-bg: #eaf3ec;
  --correct-ln: #bfe0cb;
  --wrong:      #be3a2b;
  --wrong-bg:   #f8ebe8;
  --wrong-ln:   #f0cdc6;

  --shadow-1: 0 1px 2px rgba(26,25,22,.05);
  --shadow-2: 0 1px 2px rgba(26,25,22,.05), 0 12px 28px -10px rgba(26,25,22,.18);

  --r-lg: 20px;
  --r:    14px;
  --r-sm: 11px;
  --pill: 999px;
  --ease:    cubic-bezier(.2,.7,.2,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  color-scheme: light;
}

[data-theme="dark"] {
  --paper:     #0e0e10;
  --surface:   #161618;
  --surface-2: #1d1d20;
  --ink:       #f2f1ec;
  --ink-2:     #a3a19a;
  --ink-3:     #6f6e68;
  --line:      #262629;
  --line-2:    #33333a;
  --on-ink:    #131316;   /* text on the (light) ink fill */

  --correct:    #54c98c;
  --correct-bg: #142a20;
  --correct-ln: #265c41;
  --wrong:      #e2705f;
  --wrong-bg:   #2c1816;
  --wrong-ln:   #5a302a;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -14px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; } /* author display rules must not resurrect hidden elements */
html { height: 100%; }

body {
  font-family: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 0;
  height: 100%;
  overflow: hidden;                 /* the .app scroller handles all scrolling */
  transition: background-color .4s var(--ease), color .3s var(--ease);
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ── App shell ───────────────────────────────────────────── */
.app {
  position: relative; z-index: 1;
  max-width: 480px; margin: 0 auto;
  /* Scroll happens INSIDE this container (not the document) so iOS Safari's
     disappearing toolbar can't snap the page back to the top. An inner
     scroller keeps its scroll offset when the visual viewport resizes. */
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: clamp(18px, 5vw, 26px) clamp(18px, 5vw, 24px) clamp(20px, 5vw, 28px);
  display: flex; flex-direction: column;
}
.screen { display: none; flex-direction: column; flex: 1 0 auto; min-width: 0; }
.screen.is-active { display: flex; animation: screen-in .4s var(--ease-out); }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Top bar / brand ─────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 2px 0 6px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { color: var(--ink); }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: -.01em; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: var(--pill);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
  transition: transform .18s var(--ease), border-color .2s, color .2s, background-color .2s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.icon-btn:active { transform: scale(.93); }
.theme-toggle .ico-sun { color: var(--ink); }
.theme-toggle .ico-moon { color: var(--ink); display: none; }
[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
[data-theme="dark"] .theme-toggle .ico-moon { display: block; }

/* ── Hero ────────────────────────────────────────────────── */
.hero { margin: clamp(26px, 8vw, 52px) 0 24px; }
.hero-title {
  font-weight: 800; font-size: clamp(32px, 8.4vw, 44px);
  line-height: 1.02; letter-spacing: -.035em; max-width: 13ch;
}
.hero-sub {
  margin-top: 16px; max-width: 42ch; color: var(--ink-2);
  font-size: clamp(15px, 3.7vw, 16.5px); line-height: 1.55;
}

/* ── Daily challenge card ────────────────────────────────── */
.daily-card {
  display: flex; align-items: center; gap: 15px; width: 100%; text-align: left;
  padding: 15px 16px; margin-bottom: 14px; cursor: pointer; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-1);
  transition: transform .2s var(--ease), border-color .2s, box-shadow .25s var(--ease);
}
.daily-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.daily-card:active { transform: translateY(0) scale(.995); }

.daily-glyph {
  width: 48px; height: 50px; flex: 0 0 auto; display: flex; flex-direction: column;
  overflow: hidden; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface);
}
.cal-month { font-size: 9.5px; font-weight: 800; letter-spacing: .1em; text-align: center; padding: 3px 0; color: var(--on-ink); background: var(--ink); }
.cal-day { flex: 1; display: grid; place-items: center; font-weight: 800; font-size: 21px; font-variant-numeric: tabular-nums; }
.daily-card.is-done .daily-glyph { border-color: var(--correct-ln); }
.daily-card.is-done .cal-month { background: var(--correct); color: #fff; }

.daily-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.daily-kicker { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 800; }
.daily-date { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.daily-sub { font-size: 12.5px; color: var(--ink-2); }
.daily-end { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: 0 0 auto; }
.daily-streak { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 800; color: var(--ink); }
.daily-streak .ico-flame { width: 15px; height: 15px; }
.daily-cta {
  display: inline-flex; align-items: center; gap: 5px; padding: 8px 15px; border-radius: var(--pill);
  background: var(--ink); color: var(--on-ink); font-weight: 700; font-size: 13px; white-space: nowrap;
}
.daily-cta svg { fill: currentColor; }
.daily-card.is-done .daily-cta { background: transparent; color: var(--ink-2); border: 1px solid var(--line-2); }

/* ── Stat strip ──────────────────────────────────────────── */
.stat-strip {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  padding: 15px 6px; margin-bottom: 28px; box-shadow: var(--shadow-1);
}
.stat { text-align: center; display: flex; flex-direction: column; gap: 3px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-num { font-weight: 800; font-size: 23px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }

/* ── Setup ───────────────────────────────────────────────── */
.setup { display: flex; flex-direction: column; gap: 24px; margin-bottom: 30px; }
.setup-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 800; margin-bottom: 12px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.segmented.single { grid-template-columns: 1fr; }
.seg {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; transition: border-color .18s var(--ease), background-color .18s, color .18s, transform .15s var(--ease);
}
.seg-ico { width: 19px; height: 19px; flex: 0 0 auto; color: var(--ink-2); transition: color .18s; }
.seg-arrow { color: var(--ink-3); margin: 0 1px; font-weight: 500; }
.seg:hover { border-color: var(--line-2); }
.seg:active { transform: scale(.98); }
.seg.is-on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.seg.is-on .seg-ico, .seg.is-on .seg-arrow { color: var(--on-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 16px; border: 1px solid var(--line); border-radius: var(--pill);
  background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; transition: all .18s var(--ease);
}
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip.is-on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.label-new { font-size: 9px; font-weight: 800; letter-spacing: .12em; padding: 2px 7px; border-radius: var(--pill); background: var(--correct-bg); color: var(--correct); vertical-align: middle; margin-left: 4px; }
.btn-play.loading { opacity: .65; pointer-events: none; }

/* ── Primary / ghost buttons ─────────────────────────────── */
.btn-play {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 17px 24px; border: none; border-radius: var(--r);
  background: var(--ink); color: var(--on-ink); font: inherit; font-weight: 700; font-size: 16.5px; letter-spacing: -.01em;
  cursor: pointer; box-shadow: var(--shadow-2); margin-top: auto;
  transition: transform .16s var(--ease), opacity .2s;
}
.btn-play svg { fill: currentColor; }
.btn-play:hover { transform: translateY(-1px); }
.btn-play:active { transform: translateY(0) scale(.99); }
.play-hint { text-align: center; color: var(--ink-3); font-size: 12.5px; margin-top: 12px; }
.home-foot { text-align: center; font-size: 12px; margin-top: 28px; }
.home-foot a { color: var(--ink-3); text-decoration: none; }
.home-foot a:hover { color: var(--ink-2); text-decoration: underline; }
.g-danger.btn-ghost { color: var(--wrong); border-color: var(--wrong-ln); }
.g-danger.btn-ghost:hover { color: var(--wrong); background: var(--wrong-bg); }

.btn-ghost {
  width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 600; font-size: 14.5px; cursor: pointer;
  transition: all .18s var(--ease);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--line-2); }

/* ── Game top bar ────────────────────────────────────────── */
.game-top { padding-bottom: 16px; }
.game-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.game-headings { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.game-kind { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 800; }
.counter { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 16px; letter-spacing: -.01em; }
.counter-sep { color: var(--ink-3); margin: 0 1px; font-weight: 600; }
.game-meta { display: flex; align-items: center; gap: 8px; }

.streak, .score {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums;
  padding: 7px 13px; border-radius: var(--pill); border: 1px solid var(--line); background: var(--surface);
}
.streak { color: var(--ink); transition: transform .2s var(--ease); }
.streak-flame { width: 15px; height: 15px; color: var(--ink-3); transition: color .25s; }
.streak.hot .streak-flame { color: var(--ink); }
.streak.bump { animation: bump .4s var(--ease); }
@keyframes bump { 0%,100% { transform: scale(1); } 35% { transform: scale(1.16); } }
.score { color: var(--ink); }
.score-check { width: 15px; height: 15px; color: var(--correct); }

/* ── Progress ────────────────────────────────────────────── */
.progress { height: 4px; border-radius: var(--pill); background: var(--line); overflow: hidden; margin-bottom: clamp(18px, 5vw, 30px); }
.progress-fill { height: 100%; width: 0%; border-radius: inherit; background: var(--ink); transition: width .45s var(--ease-out); }

/* ── Quiz ────────────────────────────────────────────────── */
.quiz { display: flex; flex-direction: column; flex: 1; justify-content: center; min-height: 0; }
.prompt { text-align: center; color: var(--ink-2); font-size: clamp(15px, 4vw, 16.5px); font-weight: 600; margin-bottom: 22px; }
.stage { display: grid; place-items: center; margin-bottom: clamp(22px, 5vw, 32px); min-height: 150px; }

/* Flag */
.flag-frame {
  border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-2);
  width: min(76vw, 300px); max-height: 40vh; aspect-ratio: 3 / 2; display: grid; place-items: center;
  animation: pop-in .45s var(--ease-out);
}
.flag-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
@keyframes pop-in { from { opacity: 0; transform: scale(.94) translateY(6px); } to { opacity: 1; transform: none; } }

/* Big name (capital / nameToFlag) */
.name-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: pop-in .45s var(--ease-out); }
.name-card .nc-kicker { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); font-weight: 800; }
.name-card .nc-main { font-weight: 800; font-size: clamp(30px, 8vw, 44px); line-height: 1.05; letter-spacing: -.035em; max-width: 14ch; }

/* Outline / silhouette */
.shape-frame { color: var(--ink); width: min(60vw, 230px); max-height: 38vh; aspect-ratio: 1 / 1; display: grid; place-items: center; animation: pop-in .45s var(--ease-out); }
.shape-frame svg { width: 100%; height: 100%; display: block; }
.shape-frame svg, .shape-frame svg * { fill: currentColor !important; stroke: none !important; }
.shape-frame .shape-img { width: 100%; height: 100%; object-fit: contain; }
[data-theme="dark"] .shape-frame .shape-img { filter: invert(1) brightness(1.4); }
.shape-frame.loading { width: 170px; height: 170px; border-radius: 18px; background: linear-gradient(100deg, var(--surface-2) 30%, var(--line) 50%, var(--surface-2) 70%); background-size: 220% 100%; animation: shimmer 1.2s linear infinite; }
.shape-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.shape-frame.is-ctx { width: min(84vw, 340px); height: auto; aspect-ratio: 4 / 3; max-height: 42vh; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-1); }
.ctx-canvas { width: 100%; height: 100%; display: block; }
.hint-btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; box-shadow: var(--shadow-1); transition: color .18s var(--ease), border-color .18s, transform .15s var(--ease); }
.hint-btn:hover { color: var(--ink); border-color: var(--line-2); }
.hint-btn:active { transform: scale(.97); }
.hint-ico { width: 16px; height: 16px; flex: 0 0 auto; }
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }

/* Globe */
.globe-locate { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.globe-target { text-align: center; max-width: 16ch; }
.globe-wrap { position: relative; display: grid; place-items: center; width: 100%; touch-action: none; }
.globe-canvas { width: min(74vw, 320px); height: min(74vw, 320px); display: block; touch-action: none; cursor: grab; animation: pop-in .45s var(--ease-out); }
.globe-canvas:active { cursor: grabbing; }
.globe-hint { font-size: 12.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .01em; }
.globe-zoom { position: absolute; right: 4px; bottom: 4px; display: flex; flex-direction: column; gap: 6px; }
.zoom-btn {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-1); transition: transform .15s var(--ease), border-color .2s;
}
.zoom-btn svg { width: 18px; height: 18px; }
.zoom-btn:hover { border-color: var(--line-2); }
.zoom-btn:active { transform: scale(.92); }

/* ── Options ─────────────────────────────────────────────── */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; min-width: 0; }
.opt {
  position: relative; display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 15px 16px; min-height: 56px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 600; font-size: 14.5px; text-align: left; cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform .14s var(--ease), border-color .18s, background-color .18s, opacity .25s;
  animation: opt-in .38s var(--ease-out) backwards;
}
.opt:nth-child(2) { animation-delay: .04s; }
.opt:nth-child(3) { animation-delay: .08s; }
.opt:nth-child(4) { animation-delay: .12s; }
@keyframes opt-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.opt:hover:not(:disabled) { border-color: var(--ink); transform: translateY(-1px); }
.opt:active:not(:disabled) { transform: scale(.985); }
.opt:disabled { cursor: default; }
.opt-label { flex: 1; min-width: 0; overflow-wrap: break-word; }

.opt-badge { position: absolute; right: 11px; top: 50%; transform: translateY(-50%) scale(.4); opacity: 0; width: 19px; height: 19px; transition: all .28s var(--ease-out); }
.opt-badge svg { width: 100%; height: 100%; }
.opt.correct { background: var(--correct-bg); border-color: var(--correct); color: var(--correct); }
.opt.correct .opt-badge { opacity: 1; transform: translateY(-50%) scale(1); }
.opt.wrong { background: var(--wrong-bg); border-color: var(--wrong); color: var(--wrong); }
.opt.wrong .opt-badge { opacity: 1; transform: translateY(-50%) scale(1); }
.opt.dim { opacity: .4; }
.opt.shake { animation: shake .4s var(--ease); }
@keyframes shake { 10%,90% { transform: translateX(-2px); } 30%,70% { transform: translateX(3px); } 50% { transform: translateX(-5px); } }

/* flag-only options (nameToFlag) */
.options.is-flags { grid-template-columns: 1fr 1fr; }
.opt-flag-tile { justify-content: center; padding: 11px; min-height: 0; }
.opt-flag-lg { width: 100%; aspect-ratio: 3/2; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.opt-flag-lg img { width: 100%; height: 100%; object-fit: contain; display: block; }
.options.is-flags .opt-flag-tile .opt-badge { top: 8px; right: 8px; left: auto; transform: scale(.4); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.options.is-flags .opt-flag-tile .opt-badge svg { width: 14px; height: 14px; }
.options.is-flags .opt-flag-tile.correct .opt-badge { background: var(--correct); opacity: 1; transform: scale(1); }
.options.is-flags .opt-flag-tile.wrong .opt-badge { background: var(--wrong); opacity: 1; transform: scale(1); }

/* typed answers (hard mode) */
.options.is-typed { display: flex; flex-direction: column; gap: 9px; }
.type-wrap { display: flex; gap: 9px; }
.type-input {
  flex: 1; min-width: 0; padding: 14px 16px;
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 600; font-size: 16px;
  outline: none; box-shadow: var(--shadow-1);
  transition: border-color .18s, background-color .18s, color .18s;
}
.type-input:focus { border-color: var(--ink); }
.type-input::placeholder { color: var(--ink-3); font-weight: 500; }
.type-input.correct { border-color: var(--correct); background: var(--correct-bg); color: var(--correct); }
.type-input.wrong { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); }
.type-pass {
  padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; transition: all .18s var(--ease);
}
.type-pass:hover:not(:disabled) { color: var(--ink); border-color: var(--line-2); }
.type-pass:disabled { opacity: .5; cursor: default; }
.type-sugs { display: flex; flex-direction: column; gap: 8px; min-height: 56px; }
.type-sug { width: 100%; animation: none; }
.type-sug.is-hot:not(:disabled) { border-color: var(--ink); }

/* ── Feedback / learn card ───────────────────────────────── */
.feedback { padding-top: 18px; min-height: 92px; }
.learn {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 13px; box-shadow: var(--shadow-2); animation: learn-in .35s var(--ease-out);
}
@keyframes learn-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.learn-flag { width: 54px; aspect-ratio: 3/2; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); flex: 0 0 auto; }
.learn-flag img { width: 100%; height: 100%; object-fit: cover; }
.learn-text { flex: 1; min-width: 0; }
.learn-verdict { font-weight: 800; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 2px; }
.learn.ok .learn-verdict { color: var(--correct); }
.learn.no .learn-verdict { color: var(--wrong); }
.learn-name { font-weight: 800; font-size: 18px; line-height: 1.15; letter-spacing: -.02em; }
.learn-detail { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
.learn-guess { display: inline-flex; align-items: center; gap: 7px; margin-top: 7px; padding: 3px 9px 3px 3px; background: var(--wrong-bg); border: 1px solid var(--wrong-ln); border-radius: var(--pill); }
.learn-guess.is-ocean { padding: 3px 10px; }
.learn-guess .lg-flag { width: 22px; aspect-ratio: 3/2; border-radius: 3px; overflow: hidden; border: 1px solid var(--line); flex: 0 0 auto; }
.learn-guess .lg-flag img { width: 100%; height: 100%; object-fit: cover; display: block; }
.learn-guess .lg-text { font-size: 12px; font-weight: 600; color: var(--wrong); }
.learn-guess .lg-text b { color: var(--ink); font-weight: 800; }
.learn-next {
  flex: 0 0 auto; align-self: stretch; display: flex; align-items: center; gap: 6px;
  padding: 0 16px; border: none; border-radius: 10px; cursor: pointer;
  background: var(--ink); color: var(--on-ink); font: inherit; font-weight: 700; font-size: 14px;
  transition: transform .15s var(--ease);
}
.learn-next svg { fill: currentColor; }
.learn-next:hover { transform: translateX(2px); }
.learn-next:active { transform: scale(.96); }

/* ── Summary ─────────────────────────────────────────────── */
.summary { justify-content: center; }
.summary-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); padding: clamp(26px, 7vw, 38px) clamp(22px, 6vw, 32px); text-align: center;
  animation: pop-in .45s var(--ease-out);
}
.summary-emoji { display: grid; place-items: center; }
.summary-emoji svg { width: 42px; height: 42px; color: var(--ink); }
.summary-title { font-weight: 800; font-size: clamp(25px, 7vw, 32px); margin-top: 14px; letter-spacing: -.03em; }
.summary-score { margin-top: 8px; font-size: 16px; color: var(--ink-2); }
.summary-score #summary-correct { font-weight: 800; font-size: 24px; color: var(--ink); font-variant-numeric: tabular-nums; }
.summary-of { color: var(--ink-3); }

.summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 26px 0; }
.sstat { border: 1px solid var(--line); border-radius: var(--r); padding: 15px 6px; display: flex; flex-direction: column; gap: 4px; }
.sstat-num { font-weight: 800; font-size: 22px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sstat-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }

.review { text-align: left; margin: 6px 0 24px; }
.review-title { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 800; margin-bottom: 11px; }
.review-list { display: flex; flex-direction: column; gap: 7px; }
.review-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--line); }
.review-item .ri-flag { width: 38px; aspect-ratio: 3/2; border-radius: 5px; overflow: hidden; border: 1px solid var(--line); flex: 0 0 auto; }
.review-item .ri-flag img { width: 100%; height: 100%; object-fit: cover; }
.review-item .ri-name { font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; }
.review-item .ri-cap { font-size: 12px; color: var(--ink-3); }
.review-more { margin-top: 10px; text-align: center; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }

.summary-actions { display: flex; flex-direction: column; gap: 9px; }
.summary-actions .btn-play { margin-top: 0; }

/* ── Share popup ─────────────────────────────────────────── */
.sheet-backdrop { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(20, 18, 12, .45); }
.sheet-backdrop.is-open { display: grid; place-items: end center; animation: fade .2s var(--ease); }
[data-theme="dark"] .sheet-backdrop { background: rgba(0, 0, 0, .6); }
@media (min-width: 540px) { .sheet-backdrop.is-open { place-items: center; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-2);
  padding: 20px clamp(16px, 5vw, 22px) calc(22px + env(safe-area-inset-bottom));
  animation: sheet-up .28s var(--ease-out);
}
@media (min-width: 540px) { .sheet { border-radius: var(--r-lg); } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-title { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.sheet-sub { color: var(--ink-2); font-size: 13.5px; margin: 4px 0 16px; }
.share-link { display: flex; gap: 8px; }
.share-link input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px; font: inherit; font-size: 13px;
  color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
.share-copy {
  flex: 0 0 auto; height: 46px; padding: 0 20px; border: none; border-radius: 12px;
  background: var(--ink); color: var(--on-ink); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  transition: transform .15s var(--ease);
}
.share-copy:active { transform: scale(.96); }

/* ── Account / groups ────────────────────────────────────── */
.account-avatar {
  display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 50%; background: var(--ink); color: var(--on-ink);
  font-weight: 800; font-size: 13px;
}
.groups-glyph, .quick-glyph { display: grid; place-items: center; color: var(--ink-2); }
#variant-options .seg span:first-child:not(.seg-ico) { margin-left: 0; }

.g-body { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
.g-loading, .g-error { text-align: center; color: var(--ink-3); font-size: 14px; padding: 40px 0; }
.g-error { color: var(--wrong); }
.g-section { margin: 14px 0 0; }
.g-pad { padding: 14px; }

.g-empty { text-align: center; padding: 26px 8px 8px; display: flex; flex-direction: column; gap: 12px; }
.g-empty-title { font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.g-empty-sub { color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }

.g-list { display: flex; flex-direction: column; gap: 9px; }
.g-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
  box-shadow: var(--shadow-1); transition: border-color .18s var(--ease), transform .15s var(--ease);
}
.g-row:hover { border-color: var(--line-2); transform: translateY(-1px); }
.g-row svg { color: var(--ink-3); flex: 0 0 auto; }
.g-row-emoji { font-size: 22px; flex: 0 0 auto; }
.g-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.g-row-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.g-row-sub { font-size: 12px; color: var(--ink-3); }

.g-forms { display: flex; flex-direction: column; gap: 18px; margin-top: 10px; }
.g-form { display: flex; flex-direction: column; gap: 9px; }
.g-form-row { display: flex; gap: 8px; min-width: 0; }
.g-input {
  flex: 1; min-width: 0; height: 46px; padding: 0 13px; font: inherit; font-weight: 600; font-size: 14px;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  outline: none; transition: border-color .18s;
}
.g-input:focus { border-color: var(--ink); }
.g-input::placeholder { color: var(--ink-3); font-weight: 500; }
.g-input-emoji { flex: 0 0 58px; text-align: center; font-size: 19px; padding: 0; }
select.g-input { appearance: none; -webkit-appearance: none; }
.g-btn {
  flex: 0 0 auto; height: 46px; padding: 0 18px; border: none; border-radius: 12px;
  background: var(--ink); color: var(--on-ink); font: inherit; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: transform .15s var(--ease);
}
.g-btn:active { transform: scale(.96); }
.g-btn-ghost { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); }
.g-btn-ghost:hover { color: var(--ink); border-color: var(--line-2); }

.g-head { display: flex; align-items: center; gap: 12px; }
.g-head-emoji { font-size: 30px; }
.g-head-text { flex: 1; min-width: 0; }
.g-head-name { font-weight: 800; font-size: 21px; letter-spacing: -.02em; }
.g-head-sub { font-size: 12.5px; color: var(--ink-3); }

.g-streak-banner {
  padding: 11px 14px; border: 1px dashed var(--line-2); border-radius: var(--r);
  color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.g-streak-banner.is-lit { border-style: solid; border-color: var(--correct-ln); background: var(--correct-bg); color: var(--correct); }

.g-attempts { display: flex; flex-direction: column; gap: 6px; }
.g-attempt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 13px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13.5px;
}
.g-attempt.is-me { border-color: var(--ink); }
.g-attempt-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-attempt-score { color: var(--ink-2); font-weight: 600; flex: 0 0 auto; }

.g-board { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.g-lb-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.g-lb-row + .g-lb-row { border-top: 1px solid var(--line); }
.g-lb-row.is-me { background: var(--surface-2); }
.g-lb-rank { width: 20px; text-align: center; font-weight: 800; color: var(--ink-3); flex: 0 0 auto; }
.g-lb-row:first-child .g-lb-rank { color: var(--ink); }
.g-lb-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.g-lb-title { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 800; }
.g-lb-pts { font-weight: 800; color: var(--ink); flex: 0 0 auto; }
.g-badge {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .06em;
  padding: 2px 7px; border-radius: var(--pill); background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line); vertical-align: middle;
}
.g-badge.is-up { background: var(--correct-bg); color: var(--correct); border-color: var(--correct-ln); }

.g-coop { display: flex; flex-direction: column; gap: 8px; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.g-coop .progress { margin-bottom: 0; }
.g-coop-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

.g-challenge {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
}
.g-ch-text { flex: 1; min-width: 0; }
.g-ch-form { padding: 13px; border: 1px dashed var(--line-2); border-radius: var(--r); }
.g-leave { border: none; background: none; color: var(--ink-3); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 10px 0 2px; align-self: center; }
.g-leave:hover { color: var(--wrong); }
.g-regions { display: flex; flex-direction: column; gap: 12px; }
.g-region .progress { margin-bottom: 0; margin-top: 6px; }

.summary-group { display: flex; flex-direction: column; gap: 9px; }
.summary-group:not(:empty) { margin-bottom: 9px; }
.g-posted {
  padding: 11px 14px; border-radius: var(--r); font-size: 13.5px; font-weight: 700;
  background: var(--correct-bg); color: var(--correct); border: 1px solid var(--correct-ln);
}
.g-posted.is-muted { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }

/* ── Confetti (restrained, monochrome + accent) ──────────── */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ── Desktop (mobile-first base above) ───────────────────── */
@media (min-width: 760px) {
  /* The inner .app scroller exists for iOS toolbar behavior; on desktop it
     puts a scrollbar mid-page, so scroll the document instead. */
  body { overflow: auto; height: auto; }
  .app {
    max-width: 680px; padding-left: 32px; padding-right: 32px;
    height: auto; min-height: 100vh; min-height: 100dvh; overflow-y: visible;
  }

  /* Home: use the width instead of stretching vertically. */
  .hero { margin: 40px 0 28px; }
  .setup { display: grid; grid-template-columns: 1fr 1fr; gap: 24px 20px; }
  #answers-group .segmented, #variant-options { grid-template-columns: 1fr; }
  .btn-play { margin-top: 32px; }
  .home-foot { margin-top: 20px; }

  /* Game: questions with media go stage-left / answers-right;
     text-only questions stay stacked in a comfortable column. */
  .app:has(#screen-game.is-active) { max-width: 920px; }
  .quiz:not(.has-media) { width: 100%; max-width: 560px; margin: 0 auto; }
  .quiz.has-media {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
    grid-template-areas: "prompt prompt" "stage options";
    align-content: center; column-gap: 40px; row-gap: 10px;
  }
  .quiz.has-media .prompt { grid-area: prompt; }
  .quiz.has-media .stage { grid-area: stage; margin-bottom: 0; }
  .quiz.has-media .stage > * { max-width: 100%; }
  .quiz.has-media .options { grid-area: options; align-self: center; grid-template-columns: 1fr; }

  .flag-frame { width: min(38vw, 440px); }
  .shape-frame { width: min(30vw, 330px); }
  .shape-frame.is-ctx { width: min(38vw, 460px); }
  .globe-canvas { width: min(52vh, 460px); height: min(52vh, 460px); }
  .globe-wrap { width: fit-content; }

  .feedback { width: 100%; max-width: 560px; margin: 0 auto; }
  .summary-card { width: 100%; max-width: 560px; margin: 0 auto; }
  .g-body { width: 100%; max-width: 620px; margin: 0 auto; }
}

/* Fine pointers don't need thumb-sized targets. */
@media (pointer: fine) {
  .opt { min-height: 50px; padding: 12px 16px; }
  .type-input { font-size: 14.5px; } /* 16px is only there to stop iOS focus-zoom */
}

/* Surface the existing keyboard shortcuts where a keyboard is likely. */
@media (pointer: fine) and (min-width: 760px) {
  .options:not(.is-typed) { counter-reset: optkey; }
  .options:not(.is-typed) .opt { counter-increment: optkey; }
  .options:not(.is-typed) .opt::after {
    content: counter(optkey);
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    width: 20px; height: 20px; display: grid; place-items: center;
    font-size: 11px; font-weight: 700; color: var(--ink-3);
    border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2);
    transition: opacity .2s;
  }
  .opt.correct::after, .opt.wrong::after, .opt.dim::after { opacity: 0; }
  .opt-flag-tile::after { right: auto; left: 8px; top: 8px; transform: none; }
  .learn-next::after {
    content: "enter";
    font-size: 9.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    padding: 2px 6px; border-radius: 5px; opacity: .75;
    border: 1px solid color-mix(in srgb, var(--on-ink) 35%, transparent);
  }
}

/* ── Misc ────────────────────────────────────────────────── */
@media (max-width: 360px) { .options { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .08s !important; }
}
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
button:focus:not(:focus-visible) { outline: none; }
