:root {
  color-scheme: light;
  --paper: #f6f1e7;
  --paper-2: #fffdf8;
  --paper-3: #efe7d6;
  --ink: #1d2a3a;
  --ink-2: #3a4a5c;
  --muted: #6a7684;
  --line: #ddd2bf;
  --line-2: #c9bba3;
  --ocean: #d3e7ee;
  --ocean-2: #c3dde7;
  --land: #f4ecda;
  --land-hover: #ecdfc0;
  --land-picked: #f0d79c;
  --border: #9a8a70;
  --coast: #6f6352;
  --accent: #e2553b;
  --accent-2: #c8432b;
  --gold: #f4c14d;

  --t1: #7f8b85; --t1-bg: #e6eae7; --t1-map: #c8d0cb;
  --t2: #23885b; --t2-bg: #d6efe2; --t2-map: #8fd3b0;
  --t3: #2a63bd; --t3-bg: #dbe6f8; --t3-map: #9dbdf0;
  --t4: #7646c4; --t4-bg: #e9def9; --t4-map: #c4a8ef;
  --t5: #b27b00; --t5-bg: #fbecc4; --t5-map: #f4cf6a;
  --tm: #a83e3a; --tm-bg: #f5dcd9; --tm-map: #e5a8a2;

  --f-display: 'Fraunces', Georgia, serif;
  --f-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(29, 42, 58, .06), 0 8px 24px -12px rgba(29, 42, 58, .25);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 500 15px/1.45 var(--f-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
kbd {
  font: 600 11px var(--f-mono);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--paper-2);
}
.muted { color: var(--muted); }
.eyebrow {
  font: 700 11px/1.2 var(--f-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

/* ---------------------------------------------------------------- app grid */
#app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  position: relative;
  z-index: 5;
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.topbar-title strong { font: 700 18px/1.2 var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-status { display: flex; align-items: center; gap: 10px; }
.band-label { font: 700 11px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent-2); white-space: nowrap; }
.pips { display: flex; gap: 4px; }
.pip { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--line-2); background: var(--paper); }
.pip.current { border-color: var(--ink); }
.pip[data-tier] { border-color: transparent; }
.pip[data-tier="1"] { background: var(--t1); }
.pip[data-tier="2"] { background: var(--t2); }
.pip[data-tier="3"] { background: var(--t3); }
.pip[data-tier="4"] { background: var(--t4); }
.pip[data-tier="5"] { background: var(--t5); }
.pip[data-tier="miss"] { background: var(--ink-2); }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--paper-3); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#soundBtn .ic-off { display: none; }
#soundBtn.muted-state .ic-on { display: none; }
#soundBtn.muted-state .ic-off { display: block; }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "prompt sky" "map sky" "controls sky";
  gap: 12px;
  padding: 12px;
  min-height: 0;
}
.prompt-bar { grid-area: prompt; }
.map-wrap { grid-area: map; }
.sky { grid-area: sky; }
.control-bar { grid-area: controls; }
.results { grid-area: results; display: none; }

#app[data-screen="home"] .stage,
#app[data-screen="loading"] .stage {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "map";
}
#app[data-screen="home"] :is(.prompt-bar, .sky, .control-bar),
#app[data-screen="loading"] :is(.prompt-bar, .sky, .control-bar) { display: none; }
#app:not([data-screen="home"]) .home { display: none; }

#app[data-screen="results"] .stage {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "map results";
}
#app[data-screen="results"] :is(.prompt-bar, .sky, .control-bar) { display: none; }
#app[data-screen="results"] .results { display: block; }

/* ---------------------------------------------------------------- prompt */
.prompt-bar {
  padding: 4px 4px 0;
}
.prompt-bar .eyebrow { color: var(--accent-2); }
.prompt-bar h1 {
  margin: 4px 0 0;
  font: 800 clamp(20px, 2.6vw, 30px)/1.15 var(--f-display);
  letter-spacing: -.01em;
  text-wrap: balance;
}

/* ---------------------------------------------------------------- map */
.map-wrap {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ocean);
  box-shadow: var(--shadow);
}
.map { position: absolute; inset: 0; }
.map-svg { display: block; width: 100%; height: 100%; touch-action: none; outline: none; cursor: grab; }
.map-svg:active { cursor: grabbing; }
.interactive .map-svg { cursor: crosshair; }
.map-svg :is(path, circle) { vector-effect: non-scaling-stroke; }
.ocean-bg { fill: var(--ocean); }
.sphere { fill: var(--ocean); stroke: var(--ocean-2); stroke-width: 1.5; }
.graticule { fill: none; stroke: rgba(29, 42, 58, .07); stroke-width: .8; }
.country { fill: var(--land); stroke: none; transition: fill .25s ease; }
.interactive .country:hover { fill: var(--land-hover); }
.country.picked, .interactive .country.picked:hover { fill: var(--land-picked); }
.country.dim { fill: #ebe5d8; }
.country[data-tier="1"] { fill: var(--t1-map); }
.country[data-tier="2"] { fill: var(--t2-map); }
.country[data-tier="3"] { fill: var(--t3-map); }
.country[data-tier="4"] { fill: var(--t4-map); }
.country[data-tier="5"] { fill: var(--t5-map); }
.country[data-tier="miss"] { fill: var(--tm-map); }
.borders { fill: none; stroke: var(--border); stroke-width: .7; stroke-linejoin: round; }
.no-borders .borders { display: none; }
/* With borders off, highlights would give the shapes away. */
.no-borders .country.picked, .no-borders.interactive .country:hover, .no-borders.interactive .country.picked:hover { fill: var(--land); }
.no-borders .marker.picked .marker-dot { fill: var(--land); stroke: var(--coast); }
.coast { fill: none; stroke: var(--coast); stroke-width: .9; stroke-linejoin: round; }
.focus-outline { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; pointer-events: none; }
.borders, .coast, .graticule { pointer-events: none; }
.markers { pointer-events: none; }
.marker-hit { fill: transparent; }
.marker-dot { fill: var(--land); stroke: var(--coast); stroke-width: 1; }
.interactive .marker:hover .marker-dot { fill: var(--land-hover); }
.marker.picked .marker-dot { fill: var(--land-picked); stroke: var(--ink); }
.marker[data-tier="1"] .marker-dot { fill: var(--t1); }
.marker[data-tier="2"] .marker-dot { fill: var(--t2); }
.marker[data-tier="3"] .marker-dot { fill: var(--t3); }
.marker[data-tier="4"] .marker-dot { fill: var(--t4); }
.marker[data-tier="5"] .marker-dot { fill: var(--t5); }
.marker[data-tier="miss"] .marker-dot { fill: var(--tm); }
.interactive .marker { cursor: crosshair; }

.pin { pointer-events: none; }
.pin-shadow { fill: rgba(29, 42, 58, .25); }
.pin-body { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.pin-eye { fill: #fff; }
.pin.tier-1 .pin-body { fill: var(--t1); }
.pin.tier-2 .pin-body { fill: var(--t2); }
.pin.tier-3 .pin-body { fill: var(--t3); }
.pin.tier-4 .pin-body { fill: var(--t4); }
.pin.tier-5 .pin-body { fill: var(--t5); }
.pin.tier-miss .pin-body { fill: var(--ink-2); }

.map-tools {
  position: absolute; inset-inline-start: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.tool-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--paper-2);
  font: 700 20px/1 var(--f-mono);
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow);
}
.tool-btn:hover { background: var(--paper-3); }
.tool-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 1.8; }
#app[data-screen="home"] .map-tools { display: none; }
.map-credit {
  position: absolute; inset-inline-end: 10px; bottom: 6px; margin: 0;
  font: 600 10px var(--f-mono); color: rgba(29, 42, 58, .5);
  pointer-events: none;
}

/* reveal stamp */
.stamp {
  position: absolute; left: 50%; top: 18px;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 18px 6px;
  border: 3px solid currentColor;
  border-radius: 10px;
  background: rgba(255, 253, 248, .92);
  color: var(--t1);
  transform: translateX(-50%) rotate(-5deg) scale(.6);
  opacity: 0;
  pointer-events: none;
}
.stamp.show { animation: stamp 2.4s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.stamp-name { font: 800 24px/1 var(--f-display); text-transform: uppercase; letter-spacing: .06em; }
.stamp-m { font: 700 13px var(--f-mono); margin-top: 3px; }
.stamp[data-tier="1"] { color: var(--t1); }
.stamp[data-tier="2"] { color: var(--t2); }
.stamp[data-tier="3"] { color: var(--t3); }
.stamp[data-tier="4"] { color: var(--t4); }
.stamp[data-tier="5"] { color: var(--t5); }
.stamp[data-tier="miss"] { color: var(--tm); }
@keyframes stamp {
  0% { opacity: 0; transform: translateX(-50%) rotate(-12deg) scale(1.8); }
  14% { opacity: 1; transform: translateX(-50%) rotate(-5deg) scale(1); }
  80% { opacity: 1; transform: translateX(-50%) rotate(-5deg) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) rotate(-5deg) scale(.96); }
}

/* fact card (results) */
.fact-card {
  position: absolute; inset-inline-start: 12px; top: 12px;
  width: min(340px, calc(100% - 24px));
  padding: 12px 14px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.fact-card p { margin: 8px 0 0; }
.fact-head { display: flex; align-items: center; gap: 8px; }
.fact-head strong { font: 800 17px/1.2 var(--f-display); flex: 1; }
.fact-close { width: 30px; height: 30px; }
.fact-close svg { width: 16px; height: 16px; }
.fact-yours { font: 700 11px var(--f-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--accent-2); }

/* ---------------------------------------------------------------- controls */
.control-bar {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--paper-2);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.play-controls { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.readout-row { min-width: 0; }
.readout { margin: 0; font: 600 16px/1.3 var(--f-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout strong { font-weight: 800; }
.readout-k { font: 700 11px var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-inline-end: 6px; }
.key-hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.drop-row { display: flex; align-items: center; gap: 14px; }
.clock { font: 600 12px var(--f-mono); color: var(--muted); display: flex; align-items: center; gap: 8px; }
.clock-num { font-size: 18px; font-weight: 700; color: var(--ink); min-width: 3ch; text-align: end; }
.clock-bar { width: 90px; height: 6px; border-radius: 6px; background: var(--paper-3); overflow: hidden; }
.clock-bar span { display: block; height: 100%; background: var(--ink-2); transform-origin: left; transition: transform .2s linear; }
.clock.urgent .clock-num { color: var(--accent-2); }
.clock.urgent .clock-bar span { background: var(--accent); }

.reveal-controls { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center; }
.reveal-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.reveal-country { font: 800 22px/1.15 var(--f-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reveal-m { font: 700 15px var(--f-mono); color: var(--ink-2); margin-inline-start: auto; white-space: nowrap; }
.reveal-fact { grid-column: 1; margin: 0; color: var(--ink-2); min-height: 1.45em; }
.reveal-controls .btn { grid-column: 2; grid-row: 1 / span 2; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: var(--paper-2);
  font: 800 14px/1 var(--f-ui);
  letter-spacing: .02em;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
  box-shadow: 0 2px 0 var(--ink);
}
.btn:hover { background: var(--paper-3); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 2px 0 var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { background: #d9a598; }
.btn-drop { min-width: 180px; min-height: 52px; font-size: 16px; letter-spacing: .06em; text-transform: uppercase; }
.btn-big { min-height: 56px; font-size: 17px; width: 100%; }
.btn-quiet { border-color: var(--line-2); box-shadow: 0 2px 0 var(--line-2); font-weight: 700; }
.btn-block { width: 100%; margin-top: 8px; }
.link-btn { border: 0; background: none; padding: 4px 0; font: 700 12px var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--accent-2); cursor: pointer; }
.link-btn::after { content: ' ▸'; }
.link-btn[aria-expanded="true"]::after { content: ' ▾'; }

.tier-chip {
  display: inline-flex; align-items: center;
  padding: 3px 8px 2px;
  border: 1.5px solid currentColor;
  border-radius: 6px;
  font: 700 11px/1.2 var(--f-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--t1); background: var(--t1-bg);
}
.tier-chip.pending { color: var(--muted); background: var(--paper); border-style: dashed; }
.tier-chip[data-tier="2"] { color: var(--t2); background: var(--t2-bg); }
.tier-chip[data-tier="3"] { color: var(--t3); background: var(--t3-bg); }
.tier-chip[data-tier="4"] { color: var(--t4); background: var(--t4-bg); }
.tier-chip[data-tier="5"] { color: var(--t5); background: var(--t5-bg); }
.tier-chip[data-tier="miss"] { color: var(--tm); background: var(--tm-bg); }

/* ---------------------------------------------------------------- sky column */
.sky {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
}
.sky-art { min-height: 0; display: grid; place-items: center; }
.sky-svg { height: 100%; width: 100%; display: block; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--line-2); }
.sky-art { width: 100%; height: 100%; }
.band-line { stroke: rgba(255, 255, 255, .55); stroke-dasharray: 3 4; }
.band-name { font: 800 12px var(--f-display); fill: var(--ink); letter-spacing: .02em; }
.band-name.light { fill: #fff; }
.band-alt { font: 600 8.5px var(--f-mono); fill: rgba(29, 42, 58, .6); }
.band-alt.light { fill: rgba(255, 255, 255, .7); }
.stars circle { fill: #fff; opacity: .8; }
.clouds path { fill: rgba(255, 255, 255, .85); }
.hill { fill: #a9d29a; }
.hill-2 { fill: #8cc07f; }
.balloon-pos { transition: transform 1.2s cubic-bezier(.3, 1.25, .5, 1); }
.balloon { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.b-env { fill: var(--accent); stroke: #8f2e1d; stroke-width: 1.2; }
.b-stripe { fill: var(--gold); }
.b-shine { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: 2.4; stroke-linecap: round; }
.b-rope { stroke: #6b5a45; stroke-width: 1; fill: none; }
.b-basket { fill: #a87b4f; stroke: #6b4f31; stroke-width: 1; }

.flight-log {
  list-style: none; margin: 0; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--paper-2);
  display: grid; gap: 8px;
  box-shadow: var(--shadow);
}
.flight-log li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; opacity: .55; }
.flight-log li.current, .flight-log li:has(.tier-chip) { opacity: 1; }
.log-n { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; font: 700 11px var(--f-mono); }
.flight-log li.current .log-n { border-color: var(--ink); background: var(--ink); color: #fff; }
.log-q { margin: 0; font-size: 12px; line-height: 1.3; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.log-a { margin: 3px 0 0; display: flex; align-items: center; gap: 6px; font-size: 12px; flex-wrap: wrap; }
.log-res { font-weight: 800; }
.log-a .tier-chip { font-size: 9px; padding: 1px 5px; }
.log-m { font: 700 11px var(--f-mono); color: var(--muted); }

/* ---------------------------------------------------------------- results */
.results {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--paper-2);
  padding: 16px;
  box-shadow: var(--shadow);
}
.res-head { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.sky-mini { width: 64px; height: 96px; border-radius: 12px; background: linear-gradient(to top, #cfe6d0 0%, #cfe8f2 18%, #9fcbe6 50%, #4e7fbf 75%, #22325f 92%, #121a33 100%); position: relative; overflow: hidden; }
.mini-track { position: absolute; inset: 6px; }
.mini-balloon { position: absolute; left: 50%; width: 22px; height: 26px; margin-left: -11px; border-radius: 50% 50% 45% 45%; background: var(--accent); box-shadow: inset 6px 0 0 rgba(255, 255, 255, .25), inset -7px 0 0 var(--gold); }
.mini-balloon::after { content: ''; position: absolute; left: 7px; top: 29px; width: 8px; height: 6px; background: #a87b4f; border-radius: 2px; }
.res-alt { margin: 4px 0 0; font: 600 16px var(--f-mono); }
.res-alt strong { font: 800 38px/1 var(--f-display); }
.stars { color: var(--accent-2); font-size: 14px; letter-spacing: .1em; }
.res-band { margin: 2px 0 0; font: 700 12px var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent-2); }
.res-grid { margin: 6px 0 0; font-size: 18px; letter-spacing: 2px; }
.res-title { margin: 16px 0 8px; font: 700 11px var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.res-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.res-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--paper); }
.res-row.open { border-color: var(--ink); background: var(--paper-2); }
.res-q { display: grid; grid-template-columns: 22px 1fr; gap: 8px; }
.res-q p { margin: 0; font-weight: 700; line-height: 1.3; }
.res-n { width: 22px; height: 22px; border-radius: 6px; background: var(--ink); color: #fff; display: grid; place-items: center; font: 700 11px var(--f-mono); }
.res-a { display: flex; align-items: center; gap: 8px; margin-block: 8px 0; margin-inline: 30px 0; flex-wrap: wrap; }
.res-country { font-weight: 800; }
.res-m { font: 700 12px var(--f-mono); color: var(--muted); }
.res-toggle { margin-inline-start: auto; }
.res-answers { margin-block: 10px 2px; margin-inline: 30px 0; display: grid; gap: 10px; }
.ans-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ans-m { font: 700 11px var(--f-mono); color: var(--muted); }
.ans-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.country-chip {
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--paper-2);
  padding: 5px 10px; font: 700 13px var(--f-ui); cursor: pointer;
}
.country-chip:hover { border-color: var(--ink); }
.country-chip.yours { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.country-chip.yours::before { content: '📍 '; }
.country-chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.ans-note { margin: 0; font-size: 12px; color: var(--muted); border-inline-start: 2px solid var(--line-2); padding-inline-start: 8px; }
.res-tip { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.res-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.res-actions .btn { flex: 1 1 140px; }
.res-next { margin: 12px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------------- home */
.home {
  position: fixed; inset: 0; top: 61px;
  display: grid; place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(246, 241, 231, .55), rgba(246, 241, 231, .88));
  backdrop-filter: blur(1.5px);
  z-index: 3;
  overflow: auto;
}
.home-card {
  width: min(440px, 100%);
  text-align: center;
  padding: 26px 26px 22px;
  border: 1.5px solid var(--ink);
  border-radius: 20px;
  background: var(--paper-2);
  box-shadow: 0 4px 0 var(--ink), 0 30px 60px -30px rgba(29, 42, 58, .5);
}
.home-balloon svg { width: 74px; height: 84px; }
.home-balloon .balloon { animation: bob 3.2s ease-in-out infinite; }
.wordmark { margin: 0; font: 800 54px/1 var(--f-display); letter-spacing: -.02em; }
.tagline { margin: 6px 0 0; font: 700 12px var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--accent-2); }
.home-rules { margin: 14px 0 18px; font-size: 16px; color: var(--ink-2); }
.home-actions { display: grid; gap: 10px; }
.home-sub { margin: 0 0 4px; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.home-row { display: flex; gap: 10px; }
.home-row .btn { flex: 1; }

/* ---------------------------------------------------------------- drawer */
.scrim { position: fixed; inset: 0; background: rgba(29, 42, 58, .35); opacity: 0; transition: opacity .2s; z-index: 8; }
.scrim.show { opacity: 1; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0;
  width: min(420px, 92vw);
  background: var(--paper-2);
  border-inline-end: 1.5px solid var(--ink);
  transform: translateX(-102%);
  transition: transform .25s cubic-bezier(.3, .9, .3, 1);
  z-index: 9;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
}
.drawer.open { transform: none; }
[dir="rtl"] .drawer { transform: translateX(102%); }
[dir="rtl"] .drawer.open { transform: none; }
[dir="rtl"] .clock-bar span { transform-origin: right; }
[dir="rtl"] .link-btn::after { content: ' ◂'; }
[dir="rtl"] .link-btn[aria-expanded="true"]::after { content: ' ▾'; }
[dir="rtl"] #drawerBack svg { transform: scaleX(-1); }
/* The map and the altimeter are pictures, not text: keep them left-to-right. */
.map-wrap, .sky-art { direction: ltr; }
.map-wrap :is(.fact-card, .stamp) { direction: inherit; }
[dir="rtl"] .map-wrap .fact-card, [dir="rtl"] .map-wrap .stamp { direction: rtl; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.drawer-head strong { flex: 1; text-align: center; font: 800 20px var(--f-display); }
.drawer-body { overflow: auto; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.drawer-intro { margin: 0 0 14px; color: var(--ink-2); }
.drawer-h { margin: 20px 0 8px; font: 700 11px var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.drawer-h small { font-weight: 600; letter-spacing: .04em; text-transform: none; }
.drawer-foot { margin-top: 18px; font-size: 12px; color: var(--muted); }
/* Affiliation notice: quiet footer-style text under a hairline rule. */
.affiliation { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.6; color: var(--muted); }
.affiliation p { margin: 0 0 8px; }
.affiliation a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.affiliation a:hover { color: var(--ink); }
.notice { background: var(--t5-bg); border: 1px solid var(--t5-map); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.menu-list { display: grid; gap: 8px; }
.menu-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 14px; text-align: start;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--paper);
  font: 800 15px var(--f-ui); cursor: pointer;
}
.menu-row:hover { border-color: var(--ink); }
.menu-row em { font: 600 12px var(--f-mono); font-style: normal; color: var(--muted); text-align: end; }
.menu-row small { display: block; font: 700 10px var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.archive-row.done em { color: var(--t2); }

.prose p { margin: 0 0 12px; }
.prose h4 { margin: 18px 0 6px; font: 800 16px var(--f-display); }
.steps { margin: 0 0 14px; padding-inline-start: 20px; display: grid; gap: 8px; }
.tier-scale { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.tier-scale li { display: flex; align-items: center; justify-content: space-between; font: 700 13px var(--f-mono); border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.example { border: 1px solid var(--line-2); border-radius: 12px; padding: 12px; background: var(--paper); }
.example-q { font: 800 17px/1.25 var(--f-display); margin: 4px 0 8px !important; }
.example ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.example li { display: flex; gap: 8px; align-items: baseline; }

.setting { display: grid; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.segs { display: flex; gap: 6px; }
.seg { flex: 1; padding: 10px; border: 1.5px solid var(--line-2); border-radius: 10px; background: var(--paper); font: 800 14px var(--f-ui); cursor: pointer; }
.seg.on { border-color: var(--ink); background: var(--ink); color: #fff; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats-grid div { border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 6px; text-align: center; background: var(--paper); }
.stats-grid strong { display: block; font: 800 24px/1.1 var(--f-display); }
.stats-grid span { font: 700 10px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.band-bars, .tier-counts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.band-bars li { display: grid; grid-template-columns: 110px 1fr 28px; gap: 8px; align-items: center; font-size: 13px; font-weight: 700; }
.band-bars .bar { height: 12px; background: var(--paper-3); border-radius: 6px; overflow: hidden; }
.band-bars .bar span { display: block; height: 100%; background: var(--accent); border-radius: 6px; min-width: 2px; }
.band-bars em, .tier-counts em { font: 700 12px var(--f-mono); font-style: normal; text-align: end; }
.tier-counts { grid-template-columns: 1fr 1fr; }
.tier-counts li { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.stamps { display: flex; flex-wrap: wrap; gap: 6px; }
.stamp-chip { font: 700 12px var(--f-ui); padding: 4px 9px; border-radius: 999px; border: 1.5px solid var(--t1); background: var(--t1-bg); }
.stamp-chip[data-tier="2"] { border-color: var(--t2); background: var(--t2-bg); }
.stamp-chip[data-tier="3"] { border-color: var(--t3); background: var(--t3-bg); }
.stamp-chip[data-tier="4"] { border-color: var(--t4); background: var(--t4-bg); }
.stamp-chip[data-tier="5"] { border-color: var(--t5); background: var(--t5-bg); }

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { position: fixed; inset: 40% 16px auto; text-align: center; font-weight: 800; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 899px) {
  body { font-size: 14px; }
  .topbar { gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .topbar-title strong { font-size: 16px; }
  .band-label { display: none; }
  .pip { width: 12px; height: 12px; }
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "prompt" "map" "controls";
    gap: 8px;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .sky { display: none; }
  .prompt-bar { padding: 2px 4px 0; }
  .prompt-bar h1 { font-size: 21px; }
  .control-bar { padding: 10px 12px; }
  .play-controls { grid-template-columns: 1fr; gap: 8px; }
  .key-hint { display: none; }
  .drop-row { justify-content: space-between; }
  .btn-drop { flex: 1; min-width: 0; }
  .reveal-controls { grid-template-columns: 1fr; }
  .reveal-controls .btn { grid-column: 1; grid-row: auto; width: 100%; }
  .reveal-country { font-size: 19px; }
  .map-tools { inset-inline-start: 8px; bottom: 8px; }
  .tool-btn { width: 36px; height: 36px; }
  #app[data-screen="results"] .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 38dvh minmax(0, 1fr);
    grid-template-areas: "map" "results";
  }
  .results { padding: 12px; }
  .res-alt strong { font-size: 32px; }
  .home { top: 57px; }
  .home-card { padding: 20px 18px 18px; }
  .wordmark { font-size: 44px; }
  .stamp { top: 10px; }
  .stamp-name { font-size: 19px; }
  .fact-card { inset-inline-start: 8px; top: 8px; width: calc(100% - 16px); }
}

@media (max-height: 640px) and (min-width: 900px) {
  .flight-log { display: none; }
}

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

/* ---------------------------------------------------------------- languages */
.en-name { font: 600 .78em var(--f-mono); color: var(--muted); letter-spacing: .02em; margin-inline-start: 4px; white-space: nowrap; }
.reveal-country .en-name { font-size: .55em; }
.flight-log li.upcoming .log-q { font-weight: 700; color: var(--muted); }
.flight-log li.upcoming .log-a { font-size: 11px; }
.lang-row { text-decoration: none; color: inherit; }
.lang-row.current { border-color: var(--ink); background: var(--paper-2); }
.lang-row em { color: var(--t2); }

/* Scripts the Latin fonts do not cover fall back to matching Noto faces. */
:root:lang(el), :root:lang(ru) { --f-display: 'Fraunces', 'Noto Serif', Georgia, serif; }
:root:lang(ar) {
  --f-display: 'Noto Kufi Arabic', 'Fraunces', serif;
  --f-ui: 'Noto Sans Arabic', 'Manrope', system-ui, sans-serif;
  --f-mono: 'Noto Sans Arabic', 'JetBrains Mono', monospace;
}
:root:lang(he) {
  --f-display: 'Noto Serif Hebrew', 'Fraunces', serif;
  --f-ui: 'Noto Sans Hebrew', 'Manrope', system-ui, sans-serif;
  --f-mono: 'Noto Sans Hebrew', 'JetBrains Mono', monospace;
}
:root:lang(ja) { --f-display: 'Fraunces', 'Noto Serif JP', serif; --f-ui: 'Manrope', 'Noto Sans JP', sans-serif; --f-mono: 'Noto Sans JP', 'JetBrains Mono', monospace; }
:root:lang(ko) { --f-display: 'Fraunces', 'Noto Serif KR', serif; --f-ui: 'Manrope', 'Noto Sans KR', sans-serif; --f-mono: 'Noto Sans KR', 'JetBrains Mono', monospace; }
:root:lang(zh-Hant) { --f-display: 'Fraunces', 'Noto Serif TC', serif; --f-ui: 'Manrope', 'Noto Sans TC', sans-serif; --f-mono: 'Noto Sans TC', 'JetBrains Mono', monospace; }
/* Letter-spacing breaks Arabic joining and looks loose in CJK and Hebrew. */
:root:is(:lang(ar), :lang(he), :lang(ja), :lang(ko), :lang(zh-Hant)) :is(.eyebrow, .tagline, .band-label, .tier-chip, .stamp-name, .readout-k, .res-band, .res-title, .drawer-h, .link-btn, .stats-grid span, .btn-drop, .fact-yours, .menu-row small, .wordmark) { letter-spacing: 0; }
:root:lang(ar) .en-name, :root:lang(he) .en-name { font-family: 'JetBrains Mono', monospace; }
.wordmark { font-family: 'Fraunces', Georgia, serif; }
