:root {
  color-scheme: light;
  --bg: #f5eedf;
  --surface: #fffdf8;
  --ink: #1d2128;
  --ink-2: #4a505c;
  --muted: #8b8f99;
  --line: rgba(29, 33, 40, 0.1);
  --sun: #ffa41b;
  --sun-deep: #d57a00;
  --scarab: #177a72;
  --scarab-2: #2aa79c;
  --sea: #dbe9ec;
  --land: #efe5cf;
  --land-edge: #d6c8a6;
  --best: #7a4bd1;
  --shadow: rgba(80, 55, 10, 0.12);
  --r: 18px;
  --round: Fredoka, Nunito, ui-rounded, system-ui, sans-serif;
  --sans: "Petrov Sans", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f131c;
    --surface: #181e2b;
    --ink: #eef1f8;
    --ink-2: #c3c9d8;
    --muted: #868ea5;
    --line: rgba(255, 255, 255, 0.09);
    --scarab: #39c2b5;
    --scarab-2: #5fd8cc;
    --sea: #121a2a;
    --land: #263149;
    --land-edge: #33405c;
    --best: #b592ff;
    --shadow: rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 760px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
h1 { margin: 0; font: 700 30px/1 var(--round); letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.logo { width: 34px; height: 34px; }
.logo-sun { fill: var(--sun); }
.logo-body { fill: var(--scarab); stroke: var(--ink); stroke-width: 4; }
.logo-head { fill: var(--ink); }
.logo-line { stroke: var(--ink); stroke-width: 3; }
.logo-legs { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; fill: none; }
.sub { margin: 6px 0 0; color: var(--ink-2); font-weight: 600; }
.sub.date { margin-top: 0; color: var(--muted); font-weight: 500; font-size: 13px; }
.loading { color: var(--muted); text-align: center; margin: 60px 0; }

button { font: inherit; cursor: pointer; color: inherit; }
button.icon {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 700 18px var(--round);
}
button.primary {
  border: 0; border-radius: 999px; padding: 11px 26px; background: var(--sun); color: #1d2128;
  font: 700 16px var(--round); box-shadow: 0 3px 0 var(--sun-deep);
}
button.primary:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
button.link { border: 0; background: none; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; padding: 6px; font-size: 14px; }
button[hidden], [hidden] { display: none !important; }

.kicker { margin: 0; font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.note { margin: 6px 0; color: var(--muted); font-size: 13px; }

.map-box { background: var(--surface); border-radius: var(--r); box-shadow: 0 6px 22px var(--shadow); overflow: hidden; }
.status { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px 8px; }
.status > div { display: flex; flex-direction: column; min-width: 0; }
.status .right { text-align: right; }
.status small { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.status b { font: 700 19px/1.2 var(--round); }
.status span { font-size: 13px; color: var(--ink-2); }
#map { display: block; width: 100%; aspect-ratio: 2 / 1; background: var(--sea); touch-action: manipulation; }
#map .land { fill: var(--land); stroke: var(--land-edge); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
#map .dot { fill: var(--muted); opacity: 0.75; cursor: pointer; }
#map .dot.reach { fill: var(--scarab); opacity: 1; }
#map .dot.goal { fill: none; stroke: var(--sun-deep); stroke-width: 2.5; vector-effect: non-scaling-stroke; opacity: 1; }
#map .label { fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 3; vector-effect: non-scaling-stroke; font-family: var(--sans); font-weight: 700; pointer-events: none; }
#map .label.goal { fill: var(--sun-deep); }
#map .leg { fill: none; stroke: var(--scarab); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linecap: round; }
#map .leg.preview { stroke: var(--sun-deep); stroke-dasharray: 5 5; }
#map .leg.best { stroke: var(--best); stroke-dasharray: 2 5; stroke-width: 3; }
#map .sun { fill: var(--sun); stroke: #fff6; stroke-width: 2; vector-effect: non-scaling-stroke; }
#map .glow { fill: var(--sun); opacity: 0.28; }
.goal-line { margin: 0; padding: 8px 14px 10px; font-size: 14px; color: var(--ink-2); }
.goal-line b { color: var(--sun-deep); }
@media (prefers-color-scheme: dark) { .goal-line b, #map .label.goal { color: var(--sun); fill: var(--sun); } }

.side { margin-top: 14px; }
.board-box, .result, .journey { background: var(--surface); border-radius: var(--r); box-shadow: 0 6px 22px var(--shadow); padding: 14px; margin-bottom: 14px; }
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.board-head .kicker { color: var(--ink-2); }
select { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); max-width: 100%; }
.board { list-style: none; margin: 8px 0 0; padding: 0; }
.board li + li { border-top: 1px solid var(--line); }
.board button {
  width: 100%; display: grid; grid-template-columns: 52px 1fr auto; gap: 2px 10px; align-items: baseline;
  text-align: left; border: 0; background: none; padding: 9px 6px; border-radius: 10px;
}
.board button:hover { background: color-mix(in srgb, var(--scarab) 8%, transparent); }
.board button.on { background: color-mix(in srgb, var(--sun) 22%, transparent); }
.board .t { font: 700 17px var(--round); font-variant-numeric: tabular-nums; }
.board .to { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .to small { color: var(--muted); font-weight: 500; }
.board .goal .to { color: var(--sun-deep); }
@media (prefers-color-scheme: dark) { .board .goal .to { color: var(--sun); } }
.board .land { font-size: 13px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board .al { grid-column: 2 / 4; font-size: 12px; color: var(--muted); }
sup { font-size: 10px; color: var(--sun-deep); font-weight: 700; }
.fly-bar { position: sticky; bottom: 8px; display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-top: 10px; padding: 10px 12px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.fly-bar p { margin: 0; font-size: 14px; }

.result .score { margin: 6px 0 2px; font: 700 30px var(--round); }
.result .score small { font: 500 14px var(--sans); color: var(--muted); }
.verdict { margin: 0 0 12px; font-weight: 600; }
.toast { min-height: 1em; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.routes { display: grid; gap: 12px; margin-top: 10px; }
.legs { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.legs li { margin: 3px 0; }
.legs small { color: var(--muted); }
#best-legs li::marker { color: var(--best); }

.footnote { text-align: center; margin: 0; }
.credit { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
.credit a { color: inherit; }

dialog { max-width: 460px; border: 0; border-radius: var(--r); padding: 18px 20px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 12, 20, 0.45); }
dialog h2 { margin: 0 0 8px; font: 700 22px var(--round); }
dialog li { margin: 6px 0; }
dialog form { text-align: center; margin-top: 12px; }

/* Wide screens: the map takes the window's width and height, with the
   departures, result and journey in a column beside it. Phones keep one column. */
@media (min-width: 900px) {
  main { max-width: none; padding-left: 24px; padding-right: 24px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
  .side { margin-top: 0; }
  .map-box { position: sticky; top: 16px; }
  #map { aspect-ratio: auto; height: max(400px, calc(100dvh - 240px)); }
  .routes { grid-template-columns: 1fr; }
}
@media (min-width: 1600px) {
  .layout { grid-template-columns: minmax(0, 1fr) 460px; }
}
