:root {
  --bg: #070b14;
  --panel: rgba(10, 16, 30, 0.78);
  --line: #1f2b44;
  --text: #e8edf7;
  --muted: #8796b3;
  --accent: #ffb648;
  --outbound: #4fd2ff;
  --inbound: #ff6fae;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  background: radial-gradient(ellipse at 50% 40%, #0d1528 0%, var(--bg) 70%);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
  overflow: hidden;
}

#stage { position: relative; min-height: 0; grid-row: 1; grid-column: 1; }
#stage canvas { position: absolute; inset: 0; }

.hud {
  grid-row: 1;
  grid-column: 1;
  z-index: 2;
  align-self: start;
  justify-self: start;
  margin: 20px 24px;
  pointer-events: none;
  max-width: 280px;
}
.hud h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.sub { margin: 2px 0 14px; color: var(--muted); }
.clock {
  margin: 0 0 10px;
  font-size: 40px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
}
.clock small { font-size: 14px; color: var(--muted); font-weight: 500; }

.stats { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0; }
.stats dt { color: var(--muted); font-size: 12px; }
.stats dd { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats.small dd { font-size: 15px; }
.stats.small div { min-width: 108px; }

.airport {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  pointer-events: auto;
  backdrop-filter: blur(6px);
}
.airport-head { display: flex; justify-content: space-between; align-items: baseline; }
.airport-head strong { font-size: 18px; }
.airport-name { margin: 2px 0 10px; color: var(--muted); font-size: 12px; }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.swatch.out { background: var(--outbound); }
.swatch.in { background: var(--inbound); }

button {
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.link { border: 0; color: var(--muted); font-size: 12px; padding: 2px 4px; }
button.link:hover { color: var(--text); }

.tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  padding: 6px 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}
.tooltip span { color: var(--muted); }

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
  background: rgba(7, 11, 20, 0.9);
}
.play {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border-color: var(--accent);
}
.play svg { width: 16px; height: 16px; fill: var(--accent); }
.play[aria-pressed='true'] .icon-play,
.play[aria-pressed='false'] .icon-pause { display: none; }

.speeds { display: flex; flex: none; }
.speeds button {
  padding: 5px 9px;
  font-size: 12px;
  color: var(--muted);
  border-radius: 0;
  margin-left: -1px;
}
.speeds button:first-child { border-radius: 6px 0 0 6px; }
.speeds button:last-child { border-radius: 0 6px 6px 0; }
.speeds button[aria-pressed='true'] { color: var(--bg); background: var(--accent); border-color: var(--accent); }

.timeline { flex: 1; min-width: 0; height: 64px; cursor: ew-resize; touch-action: none; }
.timeline .axis text { fill: var(--muted); font-size: 10px; }
.timeline .axis line { stroke: var(--line); }
.timeline .playhead { stroke: #fff; stroke-width: 1.5; }

@media (max-width: 720px) {
  body { grid-template-rows: auto 1fr auto; overflow: auto; }
  .hud { grid-row: 1; margin: 16px 16px 0; max-width: none; pointer-events: auto; }
  #stage { grid-row: 2; min-height: 300px; }
  .controls { flex-wrap: wrap; }
  .timeline { flex-basis: 100%; }
  .clock { font-size: 30px; }
}
