/* Overbooked. Layout: a flight-deck panel (instruments over a route map, controls under it),
   with the week's routes as a departures strip above. Light "daytime chart" and dark "night flight". */
@font-face { font-family: "Big Shoulders Display"; font-weight: 600; font-display: swap; src: url("../fonts/big-shoulders-display-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Big Shoulders Display"; font-weight: 800; font-display: swap; src: url("../fonts/big-shoulders-display-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 400; font-display: swap; src: url("../fonts/public-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 600; font-display: swap; src: url("../fonts/public-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 700; font-display: swap; src: url("../fonts/public-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); }

:root {
  --bg: #e9eef0; --panel: #f8fafa; --sea: #cfdde3; --space: #e1e8eb; --land: #f4f6f2; --land-edge: #a9bcc4;
  --ink: #13222a; --muted: #56676f; --line: #c5d2d7; --accent: #b5600c; --accent-soft: #f1d3ac; --on-accent: #ffffff;
  --good: #1f7a4d; --warn: #a8780a; --bad: #b3261e;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #081219; --panel: #0e1d27; --sea: #0d2230; --space: #050c12; --land: #1a3242; --land-edge: #2c4a5d;
    --ink: #e6eef2; --muted: #8ea3ae; --line: #22394a; --accent: #f2a23a; --accent-soft: #4a3214; --on-accent: #1a1003;
    --good: #4cc38a; --warn: #e2b23c; --bad: #ff6b5e; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(40px, env(safe-area-inset-bottom, 0px));
}
.wrap { max-width: 1100px; margin: 0 auto; display: grid; gap: 18px; }
h1, h2 { font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .03em; margin: 0; text-wrap: balance; }
h1 { font-size: 2.4rem; line-height: 1; }
h1 span { color: var(--accent); }
h2 { font-size: 1.5rem; margin-bottom: 6px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
.label { font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; }
.brand { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; }
.brand p { margin: 0; color: var(--muted); font-size: .9rem; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }

/* ---------- the week's routes ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week div { border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; background: var(--panel); min-width: 0; }
.week b { display: block; font: 700 .68rem var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.week span { display: block; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week .today { border-color: var(--accent); background: var(--accent-soft); }
.week .done span::after { content: " ✓"; color: var(--good); }

.route { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.route .name { font-family: var(--display); font-weight: 800; font-size: 1.5rem; text-transform: uppercase; line-height: 1.1; }
.route .about { color: var(--muted); font-size: .9rem; flex-basis: 100%; }
.practice { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }

/* ---------- game panel ---------- */
.deck { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.hud { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px 24px; padding: 14px 18px 10px; align-items: end; }
.readout .big { font-family: var(--mono); font-weight: 600; font-size: clamp(1.25rem, 3.4vw, 2rem); line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.readout.total .big { color: var(--accent); }
.sub { font-size: .8rem; color: var(--muted); }
.sub.cond { margin-top: 4px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.chip { display: inline-block; font: 700 .62rem var(--body); letter-spacing: .12em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--ink); color: var(--panel); vertical-align: 2px; margin-left: 6px; }
/* the hops plane: windows fill with passengers, the last hop is the door */
.hops { display: flex; margin-top: -6px; }
.fuselage { display: block; overflow: visible; max-width: 100%; height: auto; }
.fus-body, .fus-tail { fill: var(--bg); stroke: var(--muted); stroke-width: 1.2; stroke-linejoin: round; }
.fus-cockpit { fill: var(--sea); stroke: var(--muted); stroke-width: 1; }
.fus-stripe { stroke: var(--accent); stroke-width: 1.4; opacity: .55; }
.win rect { fill: var(--sea); stroke: var(--land-edge); stroke-width: 1; transition: fill .3s, stroke .3s; }
.win.used rect { fill: var(--accent-soft); stroke: var(--accent); }
.win.used circle, .win.used path { fill: var(--accent); }
.door-frame { fill: var(--sea); stroke: var(--muted); stroke-width: 1.2; }
.door.used .door-frame { stroke: var(--accent); stroke-width: 1.6; }
.door-panel { fill: var(--bg); stroke: var(--land-edge); stroke-width: 1; transform-box: fill-box; transition: transform .5s ease-in-out, opacity .5s; }
.door.used .door-panel { fill: var(--accent-soft); stroke: var(--accent); }
.pax { opacity: 0; transition: opacity .3s .45s; transform-box: fill-box; transform-origin: 50% 100%; }
.pax circle { fill: var(--ink); }
.pax .limb { fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pax .spark { fill: none; stroke: var(--accent); stroke-width: 1.2; stroke-linecap: round; display: none; }
.stairs { fill: var(--bg); stroke: var(--muted); stroke-width: 1; stroke-linejoin: round; opacity: 0; transition: opacity .3s .3s; }
.pax .arms-up, .door-x { display: none; }
.open .door-panel { transform: translateX(11px); opacity: 0; }
.open .pax { opacity: 1; }
.open .door-frame { fill: var(--accent-soft); }
.open .stairs { opacity: 1; }
.cheer .pax .arms-up { display: inline; }
.cheer .pax .arms-down { display: none; }
.cheer .pax .spark { display: inline; animation: spark .42s ease-in-out .8s 5 alternate; }
.cheer .pax { animation: cheer .42s ease-in-out .8s 5; }
@keyframes cheer { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes spark { from { opacity: .3; } to { opacity: 1; } }
.bust .win.used rect { fill: var(--bg); stroke: var(--bad); }
.bust .win.used circle, .bust .win.used path { fill: var(--bad); }
.bust .door-frame { stroke: var(--bad); }
.bust .door-x { display: inline; fill: none; stroke: var(--bad); stroke-width: 1.8; stroke-linecap: round; }
.gauge { grid-column: 1 / -1; position: relative; height: 30px; }
.gauge .track { position: absolute; inset: 8px 0; background: var(--sea); border-radius: 3px; overflow: hidden; }
.gauge .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); }
.gauge .fill.bust { background: var(--bad); }
.gauge .fill.hidden-total { width: 100% !important; background: repeating-linear-gradient(135deg, var(--line) 0 6px, transparent 6px 12px); }
.gauge .tick { position: absolute; top: 4px; bottom: 4px; width: 1px; background: var(--muted); opacity: .5; }
.gauge .tick b { position: absolute; top: -3px; left: 3px; font: 600 .6rem var(--mono); color: var(--muted); }
.gauge .target { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); left: calc(100% / 1.1); }

.mapbox { position: relative; border-block: 1px solid var(--line); }
.mapbox svg { display: block; width: 100%; height: auto; aspect-ratio: 1000 / 520; max-width: 100%; }
.mapbox svg:not([hidden]) { animation: mapfade .35s ease-out; }
@keyframes mapfade { from { opacity: 0; } }
svg.flat { background: var(--sea); }
svg.globe { background: var(--space); }
.globe-sea { fill: var(--sea); stroke: var(--land-edge); stroke-width: .8; }
.grat { fill: none; stroke: var(--land-edge); stroke-width: .5; opacity: .35; }
.land path { fill: var(--land); stroke: var(--land-edge); stroke-width: .5; vector-effect: non-scaling-stroke; transition: fill .4s; }
.land path.visited { fill: var(--accent-soft); stroke: var(--accent); }
.land path.na { opacity: .55; }
.dots circle { fill: var(--land); stroke: var(--land-edge); vector-effect: non-scaling-stroke; }
.dots circle.visited { fill: var(--accent); stroke: var(--accent); }
.routes path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.routes path.done { stroke-dasharray: 2 5 !important; stroke-dashoffset: 0 !important; }
.labels text { font-family: var(--body); font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round; text-anchor: middle; }
.labels text tspan.p { font-family: var(--mono); font-weight: 500; fill: var(--accent); }
.plane path { fill: var(--ink); stroke: var(--panel); stroke-width: .8; vector-effect: non-scaling-stroke; }
.viewswitch { position: absolute; top: 10px; right: 10px; display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--panel); }
.viewswitch button { border: 0; border-radius: 0; padding: 6px 12px; font-size: .8rem; background: transparent; }
.viewswitch button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.toast { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: var(--ink); color: var(--panel); font: 600 .95rem var(--mono); padding: 6px 12px; border-radius: 6px; opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; }

.controls { padding: 14px 18px 18px; display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.field { display: grid; gap: 4px; flex: 1 1 220px; min-width: 0; }
.field.select { flex: 0 1 280px; }
input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; width: 100%; }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); flex: none; }
.check { display: flex; gap: 8px; align-items: center; padding-block: 9px; font-size: .9rem; }
.check small { color: var(--muted); }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: 700 .9rem var(--body); border-radius: 6px; padding: 10px 16px; cursor: pointer; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
.msg { min-height: 1.5em; font-size: .9rem; color: var(--muted); margin: 0; }
.msg.err { color: var(--bad); }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; background: var(--bg); }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choices button { text-align: left; font-weight: 600; }
.choices button kbd { font: 600 .75rem var(--mono); color: var(--muted); margin-right: 8px; }
.choices button.right { border-color: var(--good); color: var(--good); }
.choices button.wrong { border-color: var(--bad); color: var(--bad); }
.result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.result-head .band { font-family: var(--display); font-weight: 800; font-size: 2rem; text-transform: uppercase; line-height: 1; }
.band.good { color: var(--good); } .band.warn { color: var(--warn); } .band.bad { color: var(--bad); }
.result-head .score { font: 600 1.4rem var(--mono); color: var(--accent); }
.breakdown { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; font-size: .9rem; max-width: 460px; }
.breakdown .num { text-align: right; }
.breakdown s { color: var(--bad); }
pre.share { margin: 0; font: .9rem/1.5 var(--mono); background: var(--panel); border: 1px solid var(--line); padding: 10px; border-radius: 6px; white-space: pre-wrap; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.bust { color: var(--bad); }

.stats { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: .85rem; color: var(--muted); }
.stats b { color: var(--ink); font-family: var(--mono); }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); max-width: min(560px, calc(100vw - 32px)); padding: 18px 20px; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog ol, dialog ul { padding-left: 1.2em; display: grid; gap: 5px; margin: 0 0 10px; }
footer { color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); padding-top: 12px; }
footer p { margin: 0 0 4px; }

@media (max-width: 700px) {
  .week { grid-template-columns: repeat(7, minmax(92px, 1fr)); overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; }
  .week div { scroll-snap-align: start; }
}
@media (max-width: 640px) {
  .hud { grid-template-columns: 1fr 1fr; }
  .hops-box { grid-column: 1 / -1; }
  .choices { grid-template-columns: 1fr; }
  h1 { font-size: 2rem; }
  .viewswitch button { padding: 4px 9px; }
}
@media (prefers-reduced-motion: reduce) { .mapbox svg:not([hidden]), .cheer .pax, .cheer .pax .spark { animation: none; } .door-panel, .pax, .stairs { transition: none; } }
