/* Earthlap: airport signage over a full-screen globe.
   Departures board for route choice, boarding pass for each question, passport stamps for the record. */
:root {
  /* Core (HANDOFF.md §4) */
  --ink: #111418;
  --ink-2: #3A404A;
  --muted: #5F6672;
  --surface: #FFFFFF;
  --line: #E3E5E9;
  --line-soft: #EEF0F2;
  --flight-blue: #2F6BFF;
  --easy: #138A4B;
  --medium: #C77700;
  --hard: #C4302B;
  --paper: #F4F1E8;

  /* Airport signage */
  --sign: #FFC629;          /* wayfinding yellow: go / board */
  --sign-hover: #FFD459;
  --board: #15191F;         /* departures board */
  --board-row: #1D232B;
  --board-row-on: #262E38;
  --board-line: #2B323C;
  --board-text: #FFD34D;    /* flap-display yellow */
  --board-dim: #A3ACB8;
  --board-easy: #4FD08B;
  --board-medium: #FFB547;
  --board-hard: #FF7A6E;
  --pass-stripe: #1F3E8C;   /* boarding pass band */
  --sky-1: #D7E7F5;
  --sky-2: #EEF4FA;

  --glass: rgba(255, 255, 255, 0.9);
  --shadow-float: 0 1px 2px rgba(17, 20, 24, 0.08), 0 14px 34px rgba(17, 30, 60, 0.18), 0 0 0 1px rgba(17, 20, 24, 0.06);
  --key: #FFFFFF;
  --key-fn: #C4C9D1;
  --tray: #D3D7DE;

  --font-ui: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-stamp: "Roboto Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;

  --gut: 10px;
  --r-panel: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden; color: var(--ink);
  font-family: var(--font-ui); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
body { background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 70%); overscroll-behavior: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--flight-blue); outline-offset: 2px; }
.mono { font-family: var(--font-mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot--easy { background: var(--easy); }
.dot--medium { background: var(--medium); }
.dot--hard { background: var(--hard); }
.mode-icon { display: block; flex: none; }

/* ---------- Globe ---------- */
.stage { position: fixed; inset: 0; }
.globe { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
.globe.is-dragging { cursor: grabbing; }
.g-sphere { fill: url(#g-ocean); }
.g-edge { fill: none; stroke: rgba(20, 50, 90, 0.18); stroke-width: 1; }
.g-graticule { fill: none; stroke: #FFFFFF; stroke-width: 0.8; opacity: 0.45; }
.g-land { fill: #F6F0E3; stroke: #C9BB9C; stroke-width: 0.6; stroke-linejoin: round; }
.g-night { fill: rgba(16, 28, 64, 0.30); pointer-events: none; }
.g-twilight { fill: rgba(16, 28, 64, 0.12); pointer-events: none; }
.g-trail { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* Routes: line style by mode, colour by difficulty when selected */
.g-arc { fill: none; stroke: #6F7C8C; stroke-width: 1.5; stroke-linecap: round; opacity: 0.75; }
.g-arc--plane { stroke-dasharray: 2 6; }
.g-arc--train { stroke-dasharray: 9 4; }
.g-arc--bus { stroke-dasharray: 0.5 5; stroke-width: 2.5; }
.g-arc--boat { stroke-dasharray: 14 6 3 6; }
.g-route.is-selected .g-arc { stroke-width: 3.5; opacity: 1; }
.g-route.is-selected .g-arc--plane { stroke-dasharray: none; }
.g-route.is-selected .g-arc--bus { stroke-width: 4.5; }
.g-route.is-selected .g-arc[data-level="easy"] { stroke: var(--easy); }
.g-route.is-selected .g-arc[data-level="medium"] { stroke: var(--medium); }
.g-route.is-selected .g-arc[data-level="hard"] { stroke: var(--hard); }
body[data-screen="leg"] .g-route.is-selected .g-arc,
body[data-screen="flight"] .g-route.is-selected .g-arc { stroke-width: 2.5; }
.g-arc-hit { fill: none; stroke: transparent; stroke-width: 22; stroke-linecap: round; cursor: pointer; pointer-events: stroke; }
.g-flown--bus { stroke-dasharray: 0.5 5; stroke-width: 4; }
.g-flown--train { stroke-dasharray: 9 4; }
.g-flown--boat { stroke-dasharray: 14 6 3 6; }
.g-plane__halo { fill: #FFFFFF; stroke: #FFFFFF; stroke-width: 3.5; stroke-linejoin: round; }
.g-plane__body { fill: var(--ink); }
.g-badge__disc { fill: var(--sign); stroke: var(--ink); stroke-width: 2; }
.g-badge__icon { fill: var(--ink); }

.markers { position: absolute; inset: 0; pointer-events: none; }
.marker { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.marker__dot { position: absolute; left: 0; top: 0; width: var(--s); height: var(--s); border-radius: 50%; transform: translate(-50%, -50%); }
.marker__code {
  position: absolute; left: 0; top: calc(var(--s) / 2 + 5px); transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--ink);
  background: var(--surface); padding: 1px 5px; border-radius: 4px; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(17, 20, 24, 0.2);
}
.marker.no-label .marker__code { display: none; }
.marker--visited .marker__dot { background: var(--ink); box-shadow: 0 0 0 2px #FFFFFF; }
.marker--current .marker__dot { background: var(--flight-blue); box-shadow: 0 0 0 3px #FFFFFF, 0 0 0 8px rgba(47, 107, 255, 0.25); }
.marker--current .marker__dot::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(47, 107, 255, 0.55); animation: ping 2.4s ease-out infinite; }
.marker--current .marker__code { background: var(--flight-blue); color: #FFFFFF; }
.marker--hub .marker__dot { background: #FFFFFF; box-shadow: 0 0 0 3px var(--ink); }
.marker--next .marker__dot { background: var(--sign); box-shadow: 0 0 0 3px var(--ink); }
.marker--next .marker__code { background: var(--board); color: var(--board-text); }
.marker--stop .marker__dot { background: var(--muted); box-shadow: 0 0 0 2px #FFFFFF; }
@keyframes ping { 0% { transform: scale(1); opacity: 1; } 80%, 100% { transform: scale(2.6); opacity: 0; } }

.recentre {
  position: fixed; z-index: 3; min-height: 36px; padding: 0 12px; border: 0; border-radius: 999px;
  background: var(--glass); box-shadow: var(--shadow-float); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  font-size: 12px; font-weight: 700; cursor: pointer;
}

/* ---------- HUD: floating panels ---------- */
.hud { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.panel {
  position: absolute; left: calc(var(--gut) + var(--safe-l)); right: calc(var(--gut) + var(--safe-r));
  pointer-events: auto; background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
  border-radius: var(--r-panel); box-shadow: var(--shadow-float);
  animation: panel-in 0.36s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.panel--top { top: calc(var(--gut) + var(--safe-t)); --from: -12px; }
.panel--bottom { bottom: calc(var(--gut) + var(--safe-b)); --from: 16px; }
.panel--full { top: calc(var(--gut) + var(--safe-t)); bottom: calc(var(--gut) + var(--safe-b)); --from: 16px; }
@keyframes panel-in { from { opacity: 0; transform: translateY(var(--from)); } to { opacity: 1; transform: none; } }
@media (min-width: 900px) {
  :root { --gut: 16px; }
  .hud { right: auto; width: 440px; }
}
@media (min-width: 560px) and (max-width: 899px) {
  .panel { left: 50%; right: auto; width: 500px; margin-left: -250px; }
}

/* ---------- Floating top chips ---------- */
.topchips {
  position: absolute; left: calc(var(--gut) + var(--safe-l)); right: calc(var(--gut) + var(--safe-r)); top: calc(var(--gut) + var(--safe-t));
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none;
  animation: panel-in 0.36s cubic-bezier(0.2, 0.8, 0.2, 1) both; --from: -10px;
}
.topchips > * { pointer-events: auto; }
.chip-logo { width: 42px; height: 42px; padding: 0; border: 0; border-radius: 12px; background: none; cursor: pointer; box-shadow: 0 6px 16px rgba(17, 30, 60, 0.22); flex: none; }
.chip-logo svg { width: 42px; height: 42px; display: block; }
.chip-clock {
  margin-left: auto;
  position: relative; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 14px; overflow: hidden;
  background: var(--board); color: #FFFFFF; border-radius: 12px; box-shadow: 0 6px 16px rgba(17, 30, 60, 0.25);
}
.cc__trip { font-size: 11px; font-weight: 700; color: var(--board-dim); letter-spacing: 0.4px; }
.cc__time, .cc__par { display: flex; flex-direction: column; line-height: 1.1; }
.cc__label { font-size: 9px; font-weight: 700; color: var(--board-dim); text-transform: uppercase; letter-spacing: 0.8px; }
.cc__time b { font-size: 14px; color: var(--board-text); }
.cc__par b { font-size: 12px; color: #FFFFFF; }
.cc__progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--sign); transition: width 0.8s ease; }
.pips { display: inline-flex; gap: 4px; }
.pip { width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--board-hard); display: inline-block; }
.pip.is-on { background: #FFFFFF; box-shadow: none; }
@media (max-width: 400px) { .cc__trip { display: none; } .chip-clock { gap: 10px; padding: 0 12px; } }

/* Map overlays: local time at the current city and weather at affected cities */
.here__time { display: inline-flex; align-items: center; gap: 3px; margin-left: 5px; padding-left: 5px; border-left: 1px solid rgba(255, 255, 255, 0.35); }
.here__time.is-day svg { color: #FFD34D; }
.here__time.is-night svg { color: #C9D4FF; }
.weather-layer { position: absolute; inset: 0; pointer-events: none; }
.wx {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; border: 0;
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px 2px 4px; border-radius: 999px;
  margin: -30px 0 0 6px; font: 700 10px/1 var(--font-mono); white-space: nowrap;
  background: rgba(255, 255, 255, 0.82); color: var(--muted); box-shadow: 0 1px 3px rgba(17, 20, 24, 0.2); opacity: 0.8;
  will-change: transform;
}
.wx.is-active { background: var(--board); color: var(--board-text); opacity: 1; animation: wx-pulse 2.4s ease-in-out infinite; }
@keyframes wx-pulse { 50% { box-shadow: 0 0 0 4px rgba(255, 198, 41, 0.35), 0 1px 3px rgba(17, 20, 24, 0.2); } }

/* Station-board ticker */
.ticker { display: block; overflow: hidden; white-space: nowrap; min-width: 0; }
.ticker__track { display: inline-flex; }
.ticker__text { display: inline-flex; align-items: center; gap: 4px; padding-right: 3em; }
.ticker.is-scrolling { -webkit-mask-image: linear-gradient(90deg, transparent, #000 10px, #000 calc(100% - 16px), transparent); mask-image: linear-gradient(90deg, transparent, #000 10px, #000 calc(100% - 16px), transparent); }
.ticker.is-scrolling .ticker__track { animation: tick var(--dur) linear infinite; }
@keyframes tick { to { transform: translateX(var(--dist)); } }
.tk-sep { font-style: normal; opacity: 0.5; margin: 0 6px; }
.tk-alert { display: inline-flex; align-items: center; gap: 4px; color: var(--board-text); }

/* ---------- Departures board (hub) ---------- */
.board { background: var(--board); color: #FFFFFF; padding: 12px 10px 10px; display: flex; flex-direction: column; gap: 6px; -webkit-backdrop-filter: none; backdrop-filter: none; }
.board__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 4px 4px; }
.board__title { font-size: 13px; font-weight: 800; letter-spacing: 1.8px; text-transform: uppercase; color: var(--board-text); }
.board__where { font-size: 13px; color: var(--board-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board__where b { color: #FFFFFF; font-size: 15px; margin: 0 2px; }
.board__ctx { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; margin-right: 4px; }
.board__cols, .dep { display: grid; grid-template-columns: 26px minmax(0, 1fr) 84px 52px; gap: 8px; align-items: center; }
.board__cols { padding: 0 10px; font-size: 10px; font-weight: 700; color: var(--board-dim); text-transform: uppercase; letter-spacing: 0.8px; }
.board__cols span:first-child { grid-column: 2; }
.board__cols span:nth-child(3) { text-align: right; }
.board__rows { display: flex; flex-direction: column; gap: 4px; }
.dep {
  min-height: 52px; padding: 6px 10px; border: 0; border-radius: 10px; background: var(--board-row); color: #FFFFFF;
  text-align: left; cursor: pointer; transition: background 0.15s, box-shadow 0.15s;
}
.dep:hover { background: var(--board-row-on); }
.dep[aria-checked="true"] { background: var(--board-row-on); box-shadow: inset 0 0 0 2px var(--sign); }
.dep__modes { display: flex; gap: 2px; color: var(--board-text); }
.dep__via { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dep__codes { font-size: 14px; font-weight: 700; color: var(--board-text); letter-spacing: 0.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep__detail { font-size: 11px; color: var(--board-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visa-tag { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; align-self: flex-start; font: 700 10px/1 var(--font-mono); letter-spacing: 0.3px; text-transform: uppercase; color: var(--board); background: var(--sign); padding: 3px 6px 3px 5px; border-radius: 4px; }
.visa-tag.is-refused { background: var(--board-hard); color: #FFFFFF; }
.dep.is-blocked { opacity: 0.55; }
.dep.is-blocked .dep__codes { text-decoration: line-through; text-decoration-thickness: 2px; }
.btn--go:disabled { background: var(--board-row-on); color: var(--board-dim); cursor: not-allowed; }
.btn--go:disabled .go__time { color: var(--board-dim); }
.dep__time { font-size: 14px; font-weight: 700; text-align: right; white-space: nowrap; }
.dep__class { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: #FFFFFF; }
.dep__dep { display: flex; flex-direction: column; gap: 1px; line-height: 1.2; min-width: 0; }
.dep__dep .mono { font-size: 14px; font-weight: 700; color: var(--board-text); }
.board__ticker { margin: 4px -10px -10px; padding: 7px 10px 8px; border-top: 1px solid var(--board-line); font: 700 11px/1 var(--font-mono); color: var(--board-dim); letter-spacing: 0.4px; border-radius: 0 0 var(--r-panel) var(--r-panel); }
.board__ticker b { color: var(--board-text); font-weight: 700; }
.dep__status .ticker__text { padding-right: 2em; }
.dep__status { font-size: 10px; color: var(--board-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep__status.is-delayed { color: var(--board-hard); font-weight: 700; }
.dep__class .dot--easy { background: var(--board-easy); }
.dep__class .dot--medium { background: var(--board-medium); }
.dep__class .dot--hard { background: var(--board-hard); }

/* ---------- Buttons ---------- */
.btn {
  min-height: 46px; border: 0; border-radius: 12px; padding: 0 16px; font-size: 15px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background 0.15s, transform 0.08s;
}
.btn:active { transform: translateY(1px); }
.btn--go { background: var(--sign); color: var(--ink); justify-content: space-between; width: 100%; }
.btn--go:hover { background: var(--sign-hover); }
.btn--go > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.go__time { font-size: 13px; color: rgba(17, 20, 24, 0.7); white-space: nowrap; }
.btn--secondary { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); font-size: 14px; font-weight: 600; }
.board .btn--go { margin-top: 4px; }

/* ---------- Boarding pass (leg + travel) ---------- */
.pass { display: flex; flex-direction: column; overflow: hidden; background: rgba(255, 255, 255, 0.95); max-height: calc(100% - 2 * var(--gut) - var(--safe-t) - var(--safe-b) - 70px); }
.pass__head { background: var(--pass-stripe); color: #FFFFFF; padding: 8px 14px 9px; display: flex; flex-direction: column; gap: 5px; flex: none; }
.pass__top { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.pass__level { flex: none; }
.pass__svc { display: flex; align-items: center; gap: 5px; font-weight: 700; flex: none; color: var(--board-text); }
.pass__svc .mono { color: #FFFFFF; }
.pass__top > .pass__ticker, .pass__status { flex: 1 1 auto; min-width: 0; color: rgba(255, 255, 255, 0.78); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pass__head { position: relative; }
.pass__count { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; padding-left: 8px; border-left: 1px solid rgba(255, 255, 255, 0.25); min-width: 58px; }
.pass__count small { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: rgba(255, 255, 255, 0.7); }
.pass__count b { font-size: 17px; color: var(--sign); }
.pass__count.is-urgent b { color: #FF8A7E; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.pass__fuse { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--sign); transform-origin: left; }
.pass__legno { font-weight: 500; opacity: 0.8; }
@media (max-width: 380px) { .pass__legno { display: none; } }
.pass__level { display: flex; align-items: center; gap: 5px; font-weight: 600; white-space: nowrap; }
.pass__level .dot { box-shadow: 0 0 0 1.5px #FFFFFF; }
.pass__route { display: grid; grid-template-columns: auto minmax(40px, 1fr) auto auto; gap: 10px; align-items: center; }
.pass__end { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.pass__end b { font-size: 22px; letter-spacing: -0.3px; }
.pass__end small { font-size: 11px; color: rgba(255, 255, 255, 0.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
.pass__end--to { text-align: right; }
.pass__end--to small { margin-left: auto; }
.pass__line { position: relative; height: 18px; }
.pass__line::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; border-top: 2px dashed rgba(255, 255, 255, 0.35); }
.pass__done { position: absolute; left: 0; top: 8px; height: 2px; background: var(--sign); width: 0; }
.pass__vehicle { position: absolute; top: 0; transform: translateX(-50%); color: var(--sign); left: 0; }
.pass__line:not(.is-moving) .pass__vehicle { left: 50% !important; }
.pass__time { font-size: 13px; font-weight: 700; padding-left: 8px; border-left: 1px solid rgba(255, 255, 255, 0.25); white-space: nowrap; }
.pass__tear { flex: none; height: 12px; position: relative; background: radial-gradient(circle at 0 50%, transparent 6px, transparent 6px) left / 50% 100% no-repeat; }
.pass__tear::before { content: ""; position: absolute; left: 14px; right: 14px; top: 5px; border-top: 2px dashed #D5D9DF; }
.pass__tear::after { content: ""; position: absolute; inset: 0 -7px; background: radial-gradient(circle 7px at 0 50%, rgba(17, 30, 60, 0.18) 98%, transparent) left / 7px 100% no-repeat, radial-gradient(circle 7px at 100% 50%, rgba(17, 30, 60, 0.18) 98%, transparent) right / 7px 100% no-repeat; }
.pass__body { padding: 10px 12px 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; }
.pass--travel .pass__head { padding-bottom: 11px; }
.pass__delay { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--board-text); background: rgba(0, 0, 0, 0.22); border-radius: 6px; padding: 4px 8px; margin-top: 2px; }

.q-prompt { margin: 0; font-weight: 700; font-size: 19px; line-height: 1.25; letter-spacing: -0.3px; text-wrap: pretty; }
.q-note { display: block; margin-top: 2px; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--muted); }

/* Country answer: one line, chips scroll sideways */
.answer { display: flex; flex-direction: column; gap: 6px; }
.answer-input {
  height: 44px; width: 100%; border-radius: 12px; border: 0; box-shadow: inset 0 0 0 2px var(--line);
  background: var(--surface); color: var(--ink); font-family: var(--font-ui); font-size: 18px; font-weight: 700;
  padding: 0 14px; caret-color: transparent; outline: none;
}
.answer-input::placeholder { color: #9AA1AC; font-weight: 500; }
.answer-input.is-ok { box-shadow: inset 0 0 0 2px var(--easy); }
.answer-input.is-miss { box-shadow: inset 0 0 0 2px var(--hard); }
.kb__suggest {
  display: flex; align-items: center; gap: 6px; height: 36px; margin: -2px -4px 0; padding: 0 8px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none;
  border-bottom: 1px solid rgba(17, 20, 24, 0.08);
}
.kb__suggest::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 30px; padding: 0 12px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, 0.9);
  font-size: 14px; font-weight: 600; cursor: pointer; scroll-snap-align: start; white-space: nowrap; box-shadow: 0 1px 0 #9AA1AB;
}
.chip:first-child { background: #FFFFFF; box-shadow: 0 1px 0 #9AA1AB, inset 0 0 0 1.5px var(--ink); }
.kb__hint { font-size: 12px; color: var(--muted); padding-left: 4px; }

/* Number answer: compact readout + slim line */
.numrow { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px 6px; border-radius: 12px; box-shadow: inset 0 0 0 2px var(--line); background: var(--surface); }
.numrow.is-ok { box-shadow: inset 0 0 0 2px var(--easy); }
.numrow.is-miss { box-shadow: inset 0 0 0 2px var(--hard); }
.numrow__top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.num-input {
  width: 1em; max-width: 50%; border: 0; background: transparent; padding: 0; outline: none; caret-color: transparent;
  font-family: var(--font-ui); font-weight: 800; font-size: 28px; letter-spacing: -0.8px; color: var(--ink);
}
.num-input::placeholder { color: #C3C8CF; }
.num-unit { font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; }
.num-covers { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.num-covers b { color: var(--ink); }
.numline { position: relative; height: 12px; }
.numline::before { content: ""; position: absolute; left: 0; right: 0; top: 5px; height: 2px; background: var(--line); }
.numline__band { position: absolute; top: 2px; height: 8px; border-radius: 4px; background: var(--ink); transition: left 0.15s, width 0.15s; }
.numline__answer { position: absolute; top: -2px; width: 3px; height: 16px; margin-left: -1px; border-radius: 2px; background: var(--hard); }
.numrow.is-ok .numline__answer { background: var(--easy); }
.numline__ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.numrow.is-empty .numline, .numrow.is-empty .numline__ticks { visibility: hidden; }

/* Spot the fake */
.choices { display: flex; flex-direction: column; gap: 6px; }
.choice {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line);
  font-size: 16px; font-weight: 600; text-align: left; cursor: pointer;
}
.choice:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--ink); }
.choice__n { width: 20px; height: 20px; flex: none; border-radius: 5px; background: var(--line-soft); color: var(--muted); font: 700 11px/20px var(--font-mono); text-align: center; }
.choice:disabled { cursor: default; color: var(--muted); }
.choice.is-real { box-shadow: inset 0 0 0 2px var(--easy); color: var(--ink); background: #EDF7F1; }
.choice.is-wrong { box-shadow: inset 0 0 0 2px var(--hard); color: var(--ink); background: #FCEFEE; }

.hint { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.result { display: flex; align-items: flex-start; gap: 10px; }
.result.is-fresh { animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
.result__mark { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #FFFFFF; font-weight: 700; font-size: 14px; margin-top: 1px; }
.result--ok .result__mark { background: var(--easy); }
.result--miss .result__mark { background: var(--hard); }
.result__text { margin: 0; font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.result__text strong { color: var(--ink); font-size: 14px; }
.result__text small { display: block; font-size: 11px; color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
.shake { animation: shake 0.32s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

.controls { flex: none; padding: 0 12px 12px; }
.controls--empty { display: none; }
.controls:has(.kb), .controls:has(.numpad) { padding: 0; }

/* Keyboards */
.kb { background: var(--tray); padding: 7px 4px 8px; display: flex; flex-direction: column; gap: 7px; }
.kb__row { display: flex; gap: 5px; justify-content: center; padding: 0 2px; }
.kb__row--mid { padding: 0 5%; }
.key {
  flex: 1 1 0; height: 42px; padding: 0; border: 0; border-radius: 7px; background: var(--key); color: var(--ink);
  box-shadow: 0 1px 0 #9AA1AB; font-family: var(--font-ui); font-size: 18px; font-weight: 500; cursor: pointer;
  display: grid; place-items: center; touch-action: manipulation; user-select: none;
}
.kb .key { max-width: 40px; }
.key:active { background: #E2E5EA; transform: translateY(1px); box-shadow: none; }
.key--fn { background: var(--key-fn); }
.kb .key--del { flex: 1.5 1 0; max-width: 58px; margin-left: 4px; }
.kb .key--space { flex: 1 1 auto; max-width: none; color: var(--muted); font-size: 14px; }
.key--go { background: var(--sign); font-size: 15px; font-weight: 700; box-shadow: 0 1px 0 #B88C00; }
.key--go:active { background: var(--sign-hover); }
.kb .key--go { flex: 0 0 96px; max-width: none; }

.numpad { background: var(--tray); padding: 7px 6px 8px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.numpad .key { height: 40px; font-size: 19px; font-weight: 600; border-radius: 8px; }
.numpad .key--tall { grid-row: span 3; height: auto; }
.numpad .key--wide { grid-column: span 2; }

/* ---------- Stamps ---------- */
.stamp {
  --ink: #24346B;
  color: var(--ink); font-family: var(--font-stamp); font-weight: 700; line-height: 1.1;
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px;
  transform: rotate(var(--rot, -4deg)); opacity: 0.88; white-space: nowrap; mix-blend-mode: multiply;
}
.stamp__top { font-size: 9px; letter-spacing: 1px; display: inline-flex; align-items: center; gap: 4px; }
.stamp__icon { display: inline-block; }
.stamp__big { font-size: 18px; letter-spacing: 0.5px; }
.stamp__bottom { font-size: 9px; letter-spacing: 1px; }
.stamp--double { border: 3px double var(--ink); border-radius: 8px; padding: 5px 11px 6px; }
.stamp--rule { border: 2px solid var(--ink); border-radius: 3px; padding: 4px 8px; }
.stamp--rule .stamp__top { border-bottom: 1px solid var(--ink); padding-bottom: 2px; align-self: stretch; }
.stamp--circle, .stamp--oval {
  border: 2px solid var(--ink); border-radius: 50%; align-items: center; justify-content: center; text-align: center;
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--ink);
}
.stamp--circle { width: 78px; height: 78px; }
.stamp--circle .stamp__top, .stamp--oval .stamp__top { font-size: 8px; }
.stamp--circle .stamp__bottom, .stamp--oval .stamp__bottom { font-size: 8px; letter-spacing: 0.6px; }
.stamp--oval { width: 112px; height: 76px; }
.stamp--oval .stamp__big { font-size: 16px; }
.stamp--missed { border: 2px solid var(--ink); padding: 3px 10px; opacity: 0.72; align-items: center; }
.stamp--missed .stamp__big { font-size: 14px; letter-spacing: 2px; }
.stamp--missed .stamp__bottom { font-size: 8px; }

.overlay { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.overlay > * { pointer-events: auto; }
.stamp-drop {
  position: fixed; transform: translate(-50%, -50%); pointer-events: none; padding: 18px 22px; border-radius: 16px;
  background: rgba(244, 241, 232, 0.95); box-shadow: 0 0 0 1px #DDD7C8, 0 18px 40px rgba(17, 20, 24, 0.22);
  animation: paper-in 0.25s ease-out both;
}
.stamp-drop .stamp { --paper: rgba(244, 241, 232, 1); animation: thump 0.42s cubic-bezier(0.3, 1.4, 0.5, 1) 0.12s both; }
.stamp-drop .stamp__big { font-size: 24px; }
.stamp-drop .stamp--circle { width: 104px; height: 104px; }
.stamp-drop .stamp--oval { width: 150px; height: 100px; }
.stamp-drop.is-leaving { animation: paper-out 0.26s ease-in both; }
@keyframes thump {
  0% { opacity: 0; transform: rotate(var(--rot, 0deg)) scale(1.8); }
  70% { opacity: 0.95; transform: rotate(var(--rot, 0deg)) scale(0.96); }
  100% { opacity: 0.9; transform: rotate(var(--rot, 0deg)) scale(1); }
}
@keyframes paper-in { from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes paper-out { to { opacity: 0; transform: translate(-50%, -54%) scale(0.98); } }

/* ---------- Passport ---------- */
.passport { display: flex; flex-direction: column; overflow: hidden; background: rgba(238, 243, 249, 0.9); }
.passport__scroll { overflow-y: auto; padding: 16px 14px 18px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.pp-head { display: flex; flex-direction: column; gap: 3px; padding: 0 4px; }
.pp-head .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.pp-head h1 { margin: 0; font-weight: 800; font-size: 26px; line-height: 1.1; letter-spacing: -0.6px; text-wrap: balance; }
.pp-score { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--sign); }
.pp-points { display: flex; flex-direction: column; line-height: 1; }
.pp-points b { font-size: 34px; letter-spacing: -1px; }
.pp-points span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; margin-top: 3px; }
.pp-break { margin: 0 0 0 auto; display: grid; gap: 2px; font-size: 12px; }
.pp-break div { display: flex; justify-content: space-between; gap: 12px; }
.pp-break dt { color: rgba(17, 20, 24, 0.7); }
.pp-break dd { margin: 0; font-weight: 700; }
.pp-stats { margin: 0; display: grid; grid-template-columns: 1.3fr repeat(3, minmax(0, 1fr)); background: var(--board); color: #FFFFFF; border-radius: 14px; padding: 10px 4px; }
.pp-stats div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pp-stats div + div { border-left: 1px solid var(--board-line); }
.pp-stats dd { margin: 0; font-size: 16px; font-weight: 800; order: 1; font-family: var(--font-mono); color: var(--board-text); }
.pp-stats dt { font-size: 10px; color: var(--board-dim); order: 2; text-transform: uppercase; letter-spacing: 0.5px; }
.visa {
  --paper: #F4F1E8;
  position: relative; flex: none; background: var(--paper); border-radius: 4px 14px 14px 4px;
  box-shadow: 0 0 0 1px #DDD7C8, 0 12px 28px rgba(17, 20, 24, 0.14); overflow: hidden;
}
.visa__bg { position: absolute; inset: 0; }
.visa__head { position: absolute; left: 22px; right: 14px; top: 12px; display: flex; justify-content: space-between; align-items: baseline; font-family: var(--font-stamp); color: #6E6758; letter-spacing: 1.6px; font-size: 11px; font-weight: 700; }
.visa__page { font-size: 14px; }
.visa .stamp { animation: stamp-settle 0.4s ease-out both; }
.visa__mrz { position: absolute; left: 10px; right: 0; bottom: 0; background: rgba(255, 255, 255, 0.55); border-top: 1px solid #DDD7C8; padding: 10px 14px 12px; font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5; letter-spacing: 1.2px; color: #2E2A22; white-space: nowrap; overflow: hidden; }
@keyframes stamp-settle { from { opacity: 0; } to { opacity: 0.88; } }
.pp-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.pp-actions .btn--go { justify-content: center; }
.pp-share { margin: 0; font-size: 12px; color: var(--ink-2); background: rgba(255, 255, 255, 0.75); border-radius: 10px; padding: 8px 10px; user-select: all; overflow-wrap: anywhere; white-space: pre-line; }
.pp-next { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- Intro ---------- */
.intro { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(17, 25, 40, 0.48); animation: fade 0.2s ease both; }
/* While a card is open, freeze everything underneath: animating content under the overlay made desktop browsers flicker */
body.is-overlaid .stage *, body.is-overlaid .stage *::before, body.is-overlaid .stage *::after, body.is-overlaid .hud *, body.is-overlaid .hud *::before, body.is-overlaid .hud *::after { animation-play-state: paused !important; }
.intro.is-leaving { animation: fade 0.2s ease reverse both; }
.intro__card { width: min(420px, 100%); background: var(--surface); border-radius: 22px; padding: 22px 20px 18px; box-shadow: 0 24px 60px rgba(17, 20, 24, 0.25); display: flex; flex-direction: column; gap: 12px; animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.intro__card h2 { margin: 0; font-size: 23px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.15; text-wrap: balance; }
.intro__list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 9px; }
.intro__list li { font-size: 14px; line-height: 1.45; color: var(--ink-2); padding-left: 16px; position: relative; }
.intro__list li::before { content: ""; position: absolute; left: 0; top: 7px; width: 7px; height: 7px; border-radius: 2px; background: var(--sign); box-shadow: 0 0 0 1px #B88C00; }
.intro__list strong { color: var(--ink); }
.intro__list .mode-icon { display: inline-block; vertical-align: -2px; }
.intro__list .dot { vertical-align: 1px; margin: 0 1px; }
.intro .btn--go { justify-content: center; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; top: calc(62px + var(--safe-t)); z-index: 6; transform: translate(-50%, -8px); max-width: calc(100% - 32px); padding: 9px 13px; border-radius: 10px; background: var(--board); color: var(--board-text); font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.fatal { position: fixed; inset: 0; margin: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--sky-2); z-index: 10; }

/* ---------- Small screens ---------- */
@media (max-height: 720px) and (max-width: 899px) {
  .q-prompt { font-size: 18px; }
  .key { height: 38px; }
  .numpad .key { height: 36px; }
  .dep { min-height: 46px; }
  .pass__end b { font-size: 19px; }
  .kb { gap: 6px; }
}
@media (max-width: 370px) {
  .board__cols, .dep { grid-template-columns: 24px minmax(0, 1fr) 70px 50px; gap: 6px; }
  .kb .key--go { flex-basis: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- Visa interview ---------- */
.consulate { overflow: hidden; display: flex; flex-direction: column; background: var(--paper); }
.consulate__head {
  position: relative; padding: 14px 16px 12px; color: #24346B; border-bottom: 2px dashed #CFC6B0;
  background: repeating-linear-gradient(-45deg, rgba(36, 52, 107, 0.05) 0 2px, transparent 2px 8px), var(--paper);
}
.consulate__kicker { display: inline-flex; align-items: center; gap: 6px; font: 700 11px/1 var(--font-stamp); letter-spacing: 1.6px; text-transform: uppercase; }
.consulate__country { margin: 4px 0 2px; font: 700 28px/1.05 var(--font-stamp); letter-spacing: 0.6px; text-transform: uppercase; }
.consulate__terms { margin: 0; font-size: 12px; color: #5C5A52; }
.consulate__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.consulate .choice { background: rgba(255, 255, 255, 0.85); }
.consulate__outcome { display: flex; align-items: center; gap: 14px; }
.consulate__outcome p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.consulate__actions { display: grid; }
.consulate__actions .btn--secondary { background: transparent; box-shadow: inset 0 0 0 1px #CFC6B0; }
.stamp--visa { border: 2px solid var(--ink); border-radius: 6px; padding: 5px 10px 6px; background: repeating-linear-gradient(90deg, transparent 0 6px, rgba(29, 107, 71, 0.07) 6px 7px); }
.stamp--visa .stamp__top { border-bottom: 1px dashed var(--ink); padding-bottom: 2px; align-self: stretch; }

/* ---------- Rival ---------- */
.cc__rival { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.cc__rival b { font-size: 12px; color: #FFFFFF; white-space: nowrap; }
.cc__rival b.is-ahead { color: var(--board-easy); }
.cc__rival b.is-behind { color: var(--board-hard); }
.g-rival-trail { fill: none; stroke: #D3382F; stroke-width: 2; stroke-dasharray: 1 5; stroke-linecap: round; opacity: 0.85; }
.rival-marker { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 12; pointer-events: none; will-change: transform; }
.rival-marker__dot { position: absolute; left: 0; top: 0; width: 13px; height: 13px; transform: translate(-50%, -50%) rotate(45deg); background: #D3382F; border-radius: 2px; box-shadow: 0 0 0 2.5px #FFFFFF, 0 2px 6px rgba(17, 20, 24, 0.35); }
.rival-marker.is-moving .rival-marker__dot { animation: rival-pulse 1.2s ease-in-out infinite; }
.rival-marker__label { position: absolute; left: 0; bottom: 12px; transform: translateX(-50%); font: 700 10px/1 var(--font-mono); letter-spacing: 0.6px; color: #FFFFFF; background: #D3382F; padding: 3px 5px; border-radius: 4px; white-space: nowrap; }
@keyframes rival-pulse { 50% { box-shadow: 0 0 0 2.5px #FFFFFF, 0 0 0 7px rgba(211, 56, 47, 0.25); } }

/* ---------- Passport ending ---------- */
.passport__scroll > * { flex-shrink: 0; }
.pp-head { position: relative; padding: 14px 16px 14px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.pp-head--win { background: linear-gradient(135deg, #FFF4CC, #FFE08A); box-shadow: inset 0 0 0 1px #E8C04D; }
.pp-head--draw { background: linear-gradient(135deg, #F3F5F8, #DDE3EA); }
.pp-head--lose { background: #EEF0F3; }
.pp-head--out { background: #FCEFEE; box-shadow: inset 0 0 0 1px #F1C9C6; }
.pp-sub { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); max-width: 30ch; }
.pp-result {
  position: absolute; right: 10px; top: 12px; transform: rotate(8deg); padding: 4px 8px; border: 2px solid currentColor; border-radius: 6px;
  font: 700 11px/1 var(--font-stamp); letter-spacing: 1.4px; color: #8E1F2E; opacity: 0.8; mix-blend-mode: multiply;
}
.pp-head--win .pp-result { color: #8A5A00; }
.pp-head--draw .pp-result { color: #24346B; }
.pp-head--lose .pp-result { color: #6F6A60; }
.pp-race { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--board); color: #FFFFFF; border-radius: 14px; padding: 10px 4px; }
.pp-race div { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.pp-race div + div { border-left: 1px solid var(--board-line); }
.pp-race dt { font-size: 10px; color: var(--board-dim); text-transform: uppercase; letter-spacing: 0.5px; order: 2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-race dd { margin: 0; font-size: 16px; font-weight: 800; color: var(--board-text); order: 1; }
.pp-challenge { background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 8px; }
.pp-challenge h2 { margin: 0; font-size: 16px; }
.pp-challenge > p { margin: -4px 0 0; font-size: 13px; color: var(--muted); }
.pp-challenge__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.pp-challenge .btn--go { justify-content: center; width: auto; }
.pp-name { display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); }
.pp-name input { height: 46px; border-radius: 12px; border: 0; box-shadow: inset 0 0 0 2px var(--line); padding: 0 12px; font: 600 15px var(--font-ui); color: var(--ink); background: #FFFFFF; min-width: 0; }
.pp-name input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--flight-blue); }
.pp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pp-actions .btn { flex: 1 1 auto; }

/* ---------- Intro: challenge code ---------- */
.intro__challenge { border-top: 1px solid var(--line); padding-top: 10px; }
.intro__challenge summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.intro__form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 10px; }
.intro__form input { height: 44px; border-radius: 12px; border: 0; box-shadow: inset 0 0 0 2px var(--line); padding: 0 12px; font: 500 14px var(--font-mono); min-width: 0; }
.intro__form input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--flight-blue); }
.intro__error { margin: 8px 0 0; font-size: 13px; color: var(--hard); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Hints ---------- */
.q-top { display: flex; align-items: flex-start; gap: 10px; }
.q-top .q-prompt { flex: 1 1 auto; min-width: 0; }
.hint-btn {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px 0 9px; margin-top: 1px;
  border: 0; border-radius: 999px; background: #FFF4CC; color: var(--ink); box-shadow: inset 0 0 0 1.5px #E8C04D;
  font: 700 12px/1 var(--font-ui); cursor: pointer;
}
.hint-btn b { display: inline-grid; place-items: center; min-width: 18px; height: 18px; border-radius: 9px; background: var(--ink); color: var(--sign); font: 700 11px/1 var(--font-mono); }
.hint-btn:hover:not(:disabled) { background: #FFE9A3; }
.hint-btn:disabled { opacity: 0.45; cursor: default; }
.hint-line {
  margin: -2px 0 0; display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 10px;
  background: #FFF4CC; font-size: 13px; font-weight: 600; color: var(--ink); animation: pop 0.25s ease both;
}
.choice.is-removed { opacity: 0.35; text-decoration: line-through; box-shadow: inset 0 0 0 2px var(--line-soft); }

/* ---------- Restart ---------- */
.intro__restart {
  align-self: center; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: none; cursor: pointer;
  font: 600 13px var(--font-ui); color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
}
.intro__restart:hover { color: var(--ink); }
.intro__restart.is-armed { background: #FCEFEE; color: var(--hard); text-decoration: none; box-shadow: inset 0 0 0 1.5px #F1C9C6; }

/* The How to play card can be taller than a phone screen: let it scroll. */
.intro { overflow-y: auto; align-items: start; padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px)); }
.intro__card { margin: auto 0; }

/* ---------- Pause menu ---------- */
.chip-menu {
  flex: none; width: 42px; height: 42px; border: 0; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; background: var(--board); color: #FFFFFF; box-shadow: 0 6px 16px rgba(17, 30, 60, 0.25);
}
.chip-menu:hover { color: var(--sign); }
.menu__head { display: flex; align-items: center; gap: 12px; }
.menu__head svg { flex: none; }
.menu__head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.4px; }
.menu__head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.menu__note { margin: 0; font-size: 13px; color: var(--ink-2); }
.menu__list { display: flex; flex-direction: column; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.menu__item { min-height: 46px; padding: 0 14px; border: 0; background: #FFFFFF; text-align: left; font: 600 15px var(--font-ui); cursor: pointer; }
.menu__item + .menu__item { border-top: 1px solid var(--line); }
.menu__item:hover { background: #F6F7F9; }
.menu__item--danger { color: var(--hard); }
.menu__item.is-armed { background: #FCEFEE; color: var(--hard); font-size: 13px; }

/* ---------- Incoming challenge ---------- */
.challenge-card .intro__card { gap: 8px; text-align: center; align-items: stretch; }
.challenge-card__kicker { align-self: center; font: 700 11px/1 var(--font-mono); letter-spacing: 1.2px; text-transform: uppercase; color: var(--board-text); background: var(--board); padding: 6px 10px; border-radius: 999px; }
.challenge-card__name { margin: 6px 0 0; font-size: 34px; font-weight: 800; letter-spacing: -1px; line-height: 1.05; overflow-wrap: anywhere; }
.challenge-card__lead { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink-2); }
.challenge-card__result { margin: 6px 0 0; font-size: 15px; }
.challenge-card__route { margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.challenge-card__terms { margin: 4px 0 6px; font-size: 13px; color: var(--muted); }
.pp-name i { font-style: normal; font-weight: 600; color: var(--muted); margin-left: 4px; }
.btn--go:disabled { background: #F0F1F4; color: var(--muted); cursor: default; }

/* Challenge: name gets its own full-width row, send button underneath. */
.pp-challenge__row { grid-template-columns: 1fr; }
.pp-challenge .btn--go { width: 100%; }
.num-input { max-width: 62%; }

/* ---------- Post-game (tidied) ---------- */
.passport__scroll { gap: 14px; }
.pp-card { position: relative; padding: 16px; border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 4px; }
.pp-card--win { background: linear-gradient(160deg, #FFF6D6, #FFE9A6); box-shadow: inset 0 0 0 1px #EDCB5E; }
.pp-card--draw { background: linear-gradient(160deg, #F4F6F9, #E3E8EF); }
.pp-card--out { background: #FDF2F1; box-shadow: inset 0 0 0 1px #F3D0CD; }
.pp-card__trip { font-size: 12px; font-weight: 600; color: var(--muted); }
.pp-card h1 { margin: 0; padding-right: 92px; font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: -0.6px; text-wrap: balance; overflow-wrap: anywhere; }
.pp-card__sub { margin: 2px 0 10px; font-size: 14px; color: var(--ink-2); }
.pp-card__stamp {
  position: absolute; right: 12px; top: 14px; transform: rotate(8deg); padding: 4px 7px; border: 2px solid currentColor; border-radius: 6px;
  font: 700 10px/1 var(--font-stamp); letter-spacing: 1.3px; color: #8E1F2E; opacity: 0.8; mix-blend-mode: multiply;
}
.pp-card--win .pp-card__stamp { color: #8A5A00; }
.pp-card--draw .pp-card__stamp { color: #24346B; }
.pp-card--lose .pp-card__stamp { color: #6F6A60; }
.pp-card .pp-race { background: rgba(17, 20, 24, 0.06); color: var(--ink); padding: 8px 4px; border-radius: 12px; }
.pp-card .pp-race div + div { border-left-color: rgba(17, 20, 24, 0.1); }
.pp-card .pp-race dd { color: var(--ink); font-size: 15px; }
.pp-card .pp-race dt { color: var(--muted); }
.pp-tally { margin-top: 8px; }
.pp-tally summary { display: flex; align-items: baseline; gap: 6px; cursor: pointer; list-style: none; font-size: 14px; font-weight: 600; }
.pp-tally summary::-webkit-details-marker { display: none; }
.pp-tally summary b { font-size: 22px; letter-spacing: -0.5px; }
.pp-tally summary span { margin-left: auto; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.pp-tally[open] summary span { text-decoration: none; }
.pp-tally .pp-break { margin: 8px 0 0; font-size: 13px; }
.pp-facts { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.pp-challenge { gap: 8px; }
.pp-challenge > p { margin: -4px 0 2px; }
.pp-name { position: relative; }
.pp-name input { width: 100%; }
.pp-name i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 11px; color: var(--muted); }
.pp-passport { display: flex; flex-direction: column; gap: 8px; }
.pp-passport h2, .pp-challenge h2 { margin: 0; font-size: 15px; font-weight: 700; }
.pp-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 16px; }
.pp-links button { border: 0; background: none; padding: 8px 4px; min-height: 40px; font: 600 14px var(--font-ui); color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.pp-links button:hover { color: var(--ink); }
.pp-next { margin-top: -8px; }

/* No sticky hover outlines on touch screens (they looked like a highlighted answer). */
.chip:first-child { box-shadow: 0 1px 0 #9AA1AB; }
@media (hover: none) {
  .choice:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--line); background: var(--surface); }
  .chip:hover { background: rgba(255, 255, 255, 0.9); box-shadow: 0 1px 0 #9AA1AB; }
  .dep:hover { background: var(--board-row); }
  .dep[aria-checked="true"]:hover { background: var(--board-row-on); box-shadow: inset 0 0 0 2px var(--sign); }
  .btn--go:hover { background: var(--sign); }
  .hint-btn:hover:not(:disabled) { background: #FFF4CC; box-shadow: inset 0 0 0 1.5px #E8C04D; }
  .menu__item:hover { background: #FFFFFF; }
}

/* ---------- Answer boost ---------- */
.boost {
  display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 7px 10px; border-radius: 10px;
  background: var(--board); color: #FFFFFF; font-size: 13px; font-weight: 600;
}
.boost.is-fresh { animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }
.boost__tier { color: var(--board-text); font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; font-size: 12px; }
.boost__what { color: #FFFFFF; }
.boost__pts { margin-left: auto; color: var(--board-easy); font-weight: 700; }

/* ---------- Clock pill: one line at any phone width ---------- */
.topchips { align-items: stretch; }
.chip-clock { flex: 0 1 auto; min-width: 0; gap: 0; padding: 0 4px 0 14px; }
.chip-clock > * { white-space: nowrap; flex: none; }
.cc__time, .cc__rival { padding-right: 12px; }
.cc__rival { min-width: 0; flex: 0 1 auto; }
.cc__rival b { white-space: nowrap; }
.cc__rival .cc__label { overflow: hidden; text-overflow: ellipsis; max-width: 96px; white-space: nowrap; }
.cc__time b { font-size: 14px; letter-spacing: -0.2px; }
.cc__rival b { font-size: 13px; }
.chip-clock .pips { padding: 0 10px; margin-left: 2px; border-left: 1px solid var(--board-line); align-self: stretch; align-items: center; }
.cc__trip { display: none; }
@media (max-width: 340px) {
  .chip-logo { display: none; } /* How to play is in the pause menu too */
}
@media (max-width: 360px) {
  .chip-clock { padding-left: 10px; }
  .cc__time, .cc__rival { padding-right: 8px; }
  .cc__time b { font-size: 13px; }
}

/* No double-tap zoom anywhere; the globe handles its own pinch. */
html, body { touch-action: manipulation; }

/* ---------- Higher or lower ---------- */
.choices--two { flex-direction: row; }
.choices--two .choice { flex: 1 1 0; min-width: 0; justify-content: center; text-align: center; min-height: 52px; padding: 6px 10px; }
.choices--two .choice__n { display: none; }

/* ---------- Pin it ---------- */
.globe.is-pinning { cursor: crosshair; }
.pinread {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 12px;
  background: var(--surface); box-shadow: inset 0 0 0 2px var(--ink); font-size: 14px; font-weight: 600; color: var(--ink);
}
.pinread svg { flex: none; color: var(--hard); }
.pinread.is-empty { box-shadow: inset 0 0 0 2px var(--line); color: var(--muted); font-weight: 500; }
.pinread.is-empty svg { color: var(--muted); }
.pinread.is-ok { box-shadow: inset 0 0 0 2px var(--easy); }
.pinread.is-miss { box-shadow: inset 0 0 0 2px var(--hard); }
.pinbar { display: flex; }
.pinbar .key--pin { flex: 1 1 auto; height: 46px; border-radius: 12px; font-size: 16px; }

.pin-layer { position: absolute; inset: 0; pointer-events: none; z-index: 13; }
.pin { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.pin__head {
  position: absolute; left: -9px; top: -24px; width: 18px; height: 18px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--hard); box-shadow: 0 0 0 2.5px #FFFFFF, 0 3px 8px rgba(17, 20, 24, 0.35);
  animation: pin-drop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.pin__head::after { content: ""; position: absolute; left: 6px; top: 6px; width: 6px; height: 6px; border-radius: 50%; background: #FFFFFF; }
.pin--answer .pin__head { background: var(--easy); }
.pin__label {
  position: absolute; left: 0; top: 6px; transform: translateX(-50%); white-space: nowrap;
  font: 700 11px/1 var(--font-ui); color: #FFFFFF; background: var(--easy); padding: 4px 6px; border-radius: 5px;
  box-shadow: 0 2px 6px rgba(17, 20, 24, 0.25);
}
@keyframes pin-drop { from { transform: translateY(-14px) rotate(-45deg); opacity: 0; } to { transform: rotate(-45deg); opacity: 1; } }
.g-pin-line { fill: none; stroke: var(--hard); stroke-width: 2; stroke-dasharray: 5 4; }
.g-pin-ring { fill: rgba(255, 198, 41, 0.22); stroke: var(--sign); stroke-width: 2; stroke-dasharray: 6 4; }
@media (prefers-reduced-motion: reduce) { .pin__head { animation: none; } }

/* ---------- Daily theme ---------- */
.theme-tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 4px; border-radius: 6px;
  background: var(--board); color: var(--board-text); font: 700 11px/1.2 var(--font-mono); letter-spacing: 0.4px; text-transform: uppercase;
}
.theme-tag b { background: var(--sign); color: var(--ink); border-radius: 4px; padding: 2px 4px; }
.theme-card { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--line-soft); margin: 0 0 10px; }
.theme-card p { margin: 0; font-size: 13px; color: var(--ink-2); }
.theme-card .theme-twist { font-weight: 600; color: var(--ink); }
