:root {
  --space: #03050a;
  --panel: rgba(8, 13, 22, 0.84);
  --panel-edge: rgba(255, 255, 255, 0.1);
  --tile: #1b1e24;
  --tile-hi: #23272f;
  --tile-ink: #f3f1ea;
  --signal: #ffc83d;
  --signal-ink: #1a1405;
  --truth: #ffffff;
  --muted: #8e9bb0;
  --ink: #e9edf3;

  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;

  --gutter: clamp(16px, 3vw, 28px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--space);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }

#globe { position: fixed; inset: 0; cursor: crosshair; }
#globe canvas { display: block; }
body.is-menu #globe { cursor: grab; }

/* ---------- split-flap board ---------- */
.flap {
  --tile-w: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--tile-w) * 0.14);
}
.flap-line { display: flex; gap: calc(var(--tile-w) * 0.08); }
.tile {
  position: relative;
  width: var(--tile-w);
  height: calc(var(--tile-w) * 1.36);
  display: grid;
  place-items: center;
  background: linear-gradient(var(--tile-hi) 0 50%, var(--tile) 50% 100%);
  border-radius: calc(var(--tile-w) * 0.1);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 2px 6px rgba(0, 0, 0, 0.55);
  color: var(--tile-ink);
  font: 600 calc(var(--tile-w) * 1.02) / 1 var(--display);
  text-transform: uppercase;
  overflow: hidden;
}
.tile::after { /* the hinge */
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: max(1px, calc(var(--tile-w) * 0.035));
  background: rgba(0, 0, 0, 0.75);
}
.tile.is-blank { background: transparent; box-shadow: none; }
.tile.is-blank::after { display: none; }
.tile.is-flipping span { animation: flip 70ms linear; }
@keyframes flip {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(0.15); }
  100% { transform: scaleY(1); }
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(var(--gutter) + env(safe-area-inset-top)) var(--gutter) 0;
  pointer-events: none;
  z-index: 3;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.6);
}
#hud > * { pointer-events: auto; }
.wordmark {
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  font: 700 22px/1 var(--display);
  letter-spacing: 0.02em;
  color: var(--signal);
}
.wordmark:hover { color: var(--truth); }
.hud-stats { display: flex; gap: 22px; text-align: right; }
.stat { display: flex; flex-direction: column; }
.stat-value { font: 600 30px/1 var(--display); font-variant-numeric: tabular-nums; color: var(--truth); }
.stat-label { font-size: 13px; color: #b9c3d2; }

#board {
  position: fixed;
  top: calc(var(--gutter) + env(safe-area-inset-top) + 44px);
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw - 2 * var(--gutter), 860px);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 2;
}
.country {
  margin: 12px 0 0;
  padding: 3px 12px 4px;
  border-radius: 6px;
  background: rgba(3, 5, 10, 0.6);
  font: 600 clamp(19px, 2.6vw, 26px)/1.2 var(--display);
  letter-spacing: 0.02em;
  color: var(--signal);
  text-align: center;
}

/* ---------- dock ---------- */
#dock {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  padding: 0 var(--gutter) calc(var(--gutter) + 10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: none;
  z-index: 3;
}
#dock > * { pointer-events: auto; }
#result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 22px 10px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: rise 260ms ease-out;
}
.result-points { font: 700 54px/0.9 var(--display); color: var(--signal); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.result-detail { font-size: 15px; line-height: 1.35; color: var(--muted); }
.result-detail #resultPointsWord { color: var(--ink); font-weight: 600; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.dock-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn {
  border: 0;
  border-radius: 999px;
  padding: 13px 26px;
  font: 600 19px/1 var(--display);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, opacity 120ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary { background: var(--signal); color: var(--signal-ink); box-shadow: 0 6px 24px rgba(255, 200, 61, 0.25); }
.btn-primary:hover:not(:disabled) { background: #ffd666; }
.btn-primary:disabled {
  background: var(--panel);
  color: var(--muted);
  box-shadow: none;
  border: 1px solid var(--panel-edge);
  cursor: default;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.btn-quiet { background: var(--panel); color: var(--ink); border: 1px solid var(--panel-edge); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn-quiet:hover { background: rgba(30, 38, 52, 0.9); }

/* ---------- globe pins (html elements) ---------- */
.pin { width: 0; height: 0; position: relative; pointer-events: none; }
.pin svg { position: absolute; left: -13px; bottom: 0; width: 26px; height: 36px; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)); }
.pin.is-dropping svg { animation: drop 240ms cubic-bezier(.3, 1.6, .5, 1); transform-origin: 50% 100%; }
@keyframes drop { from { transform: translateY(-14px) scale(0.8); opacity: 0; } }
.pin-label {
  position: absolute;
  left: 0;
  bottom: 42px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 3px 9px 4px;
  border-radius: 6px;
  background: rgba(3, 5, 10, 0.78);
  color: var(--truth);
  font: 600 17px/1.1 var(--display);
  letter-spacing: 0.02em;
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  overflow-y: auto;
  z-index: 5;
  background: radial-gradient(ellipse at center, rgba(3, 5, 10, 0.2), rgba(3, 5, 10, 0.75));
}
.panel {
  width: min(100%, 640px);
  padding: clamp(22px, 4vw, 40px);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 22px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.panel-start { display: flex; flex-direction: column; align-items: center; text-align: center; }
.flap-title { --tile-w: clamp(28px, 7.4vw, 52px); }
.lede { margin: 22px 0 20px; max-width: 46ch; font-size: 17px; color: var(--ink); }

.kind {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-edge);
}
.kind label { position: relative; cursor: pointer; }
.kind input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kind span {
  display: block;
  padding: 8px 20px;
  border-radius: 999px;
  font: 600 18px/1 var(--display);
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: background-color 120ms ease, color 120ms ease;
}
.kind label:hover span { color: var(--ink); }
.kind input:checked + span { background: var(--signal); color: var(--signal-ink); }
.kind input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.mode {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 18px 16px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.mode:hover { border-color: var(--signal); background: rgba(255, 200, 61, 0.06); }
.mode-name { font: 700 26px/1.05 var(--display); color: var(--signal); }
.mode-desc { font-size: 15px; line-height: 1.4; color: var(--ink); }
.mode-best { font-size: 14px; color: var(--muted); margin-top: 4px; }
.mode-best:empty { display: none; }

.start-foot { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.hint { margin: 0; font-size: 14px; }


/* end screen: an arrivals board */
.panel-end { display: flex; flex-direction: column; align-items: center; text-align: center; max-height: calc(100dvh - 2 * var(--gutter)); }
.end-kicker { margin: 0; font: 600 20px/1 var(--display); color: var(--muted); }
.end-score { margin: 6px 0 0; font: 700 clamp(72px, 16vw, 112px)/0.9 var(--display); color: var(--signal); font-variant-numeric: tabular-nums; }
.end-max { font-size: 0.36em; color: var(--muted); margin-left: 0.25em; font-weight: 600; }
.end-summary { margin: 12px 0 18px; color: var(--ink); max-width: 44ch; }
.arrivals {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--tile);
  border-radius: 12px;
  overflow: hidden;
  text-align: left;
}
.arr-body { overflow-y: auto; max-height: 46vh; }
.arr-row {
  display: grid;
  grid-template-columns: 1fr 88px 64px;
  gap: 12px;
  align-items: baseline;
  padding: 9px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.55);
}
.arr-head { border-top: 0; background: var(--tile-hi); font-size: 13px; color: var(--muted); padding-block: 8px; }
.arr-city { font: 600 20px/1.15 var(--display); color: var(--tile-ink); letter-spacing: 0.02em; }
.arr-country { display: block; font: 400 13px/1.3 var(--body); color: var(--muted); letter-spacing: 0; }
.arr-dist { font: 500 18px/1 var(--display); color: var(--tile-ink); font-variant-numeric: tabular-nums; }
.arr-pts { font: 700 22px/1 var(--display); color: var(--signal); font-variant-numeric: tabular-nums; }
.arr-pts.is-zero { color: var(--muted); }
.num { text-align: right; }
.end-actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.credit {
  position: fixed;
  right: 10px;
  bottom: 6px;
  margin: 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  pointer-events: none;
  z-index: 1;
}

@media (max-width: 560px) {
  .modes { grid-template-columns: 1fr; }
  .stat-value { font-size: 24px; }
  .hud-stats { gap: 16px; }
  .wordmark { font-size: 19px; }
  .result-points { font-size: 44px; }
  #result { padding: 8px 18px 8px 14px; }
  .btn { padding: 12px 20px; font-size: 18px; }
  .arr-row { grid-template-columns: 1fr 74px 48px; padding-inline: 12px; }
}

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