/* ---- theme ------------------------------------------------------------------------------
   Light by default; dark follows the device (prefers-color-scheme) unless the header toggle
   picked one (html[data-theme]). Every colour is a token here. The loco, coach and wagon
   liveries never change (they are real), so the dark theme keeps trains readable: the ballast
   stays a light bed under every train, and vehicles get a light rim instead of a dark one. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --fg: #1d2433;
  --dim: #8b93a1;
  --border: #dde1e7;
  --hover: rgba(59, 130, 246, 0.18);

  --track-main: #e07a1f;
  --track-branch: #a39400;
  --track-loop: #4b5563;
  --platform-bg: #e7e5e4;   /* concrete */
  --platform-fg: #44403c;
  --platform-edge: #facc15; /* yellow safety line */
  --ballast: #d6cfc2;
  --sleeper: #a8a29e;
  --rail: #57534e;
  --building-bg: #efc7b6;
  --building-fg: #7c2d12;
  --river: #d6e8fb;
  --river-fg: #4a86c8;
  --bridge-bg: #c9bfae;
  --signal-red: #ef4444;
  --signal-yellow: #facc15;
  --signal-green: #22c55e;
  --housing: #1f2937;
  --housing-edge: #1f2937;
  --train-casing: #111827;
  --headlight: #fde68a;

  --vehicle-rim: #1c1917;
  --platform-stroke: #d6d3d1;
  --label-pill: rgba(255, 255, 255, 0.92);
  --reserved-ballast: #bbf7d0;
  --stop-board: #ffffff;
  --signal-post: #4b5563;
  --signal-housing: #0f172a;
  --signal-housing-edge: #475569;
  --marker-edge: #ffffff;
  --legend-edge: #0f172a;
  --notice-edge: rgba(15, 23, 42, 0.18);
  --notice-quiet: #f3f4f6;
  --notice-quiet-fg: #374151;
  --notice-station: #dbeafe;
  --notice-station-fg: #1e3a8a;
  --notice-signal: #dc2626;      /* a train waiting at a signal: the one that can cost a strike */
  --notice-signal-edge: #991b1b;
  --notice-signal-glow: #f87171;
  --notice-amber: #fde68a;
  --notice-amber-fg: #713f12;
  --backdrop: rgba(15, 23, 42, 0.45);
  --shadow: rgba(15, 23, 42, 0.28);
  --tile: #f8fafc;
  --on-good: #ffffff;  /* text on a --good background */

  --points: #0891b2;
  --reserved: #16a34a;
  --preview: #d49a00;
  --blocked: #e5484d;
  --good: #16a34a;
  --warn: #c58a00;
  --bad: #e5484d;

  color-scheme: light;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dark: by the device's setting unless the toggle chose light, or chosen with the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b;
    --surface: #171d26;
    --fg: #e6e9ef;
    --dim: #8b95a5;
    --border: #2a3340;
    --hover: rgba(96, 165, 250, 0.18);
    --track-main: #f59e42;
    --track-branch: #cbbd2a;
    --track-loop: #9ca3af;
    --platform-bg: #33373d;
    --platform-fg: #e7e5e4;
    --ballast: #6b6458;
    --sleeper: #8a8378;
    --rail: #d6d3d1;
    --building-bg: #5a3428;
    --building-fg: #f3c6b4;
    --river: #16324d;
    --river-fg: #7fb3e8;
    --bridge-bg: #57524a;
    --vehicle-rim: #e7e5e4;
    --platform-stroke: #464c55;
    --label-pill: rgba(31, 38, 48, 0.92);
    --reserved-ballast: #2f6b45;
    --stop-board: #e7e5e4;
    --signal-post: #94a3b8;
    --signal-housing-edge: #94a3b8;
    --legend-edge: #94a3b8;
    --notice-edge: rgba(0, 0, 0, 0.35);
    --notice-signal: #ef4444;
    --notice-signal-edge: #fecaca;
    --notice-signal-glow: #fca5a5;
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow: rgba(0, 0, 0, 0.55);
    --tile: #1f2630;
    --on-good: #0f141b;
    --points: #22d3ee;
    --reserved: #4ade80;
    --preview: #fbbf24;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --blocked: #f87171;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b;
  --surface: #171d26;
  --fg: #e6e9ef;
  --dim: #8b95a5;
  --border: #2a3340;
  --hover: rgba(96, 165, 250, 0.18);
  --track-main: #f59e42;
  --track-branch: #cbbd2a;
  --track-loop: #9ca3af;
  --platform-bg: #33373d;
  --platform-fg: #e7e5e4;
  --ballast: #6b6458;
  --sleeper: #8a8378;
  --rail: #d6d3d1;
  --building-bg: #5a3428;
  --building-fg: #f3c6b4;
  --river: #16324d;
  --river-fg: #7fb3e8;
  --bridge-bg: #57524a;
  --vehicle-rim: #e7e5e4;
  --platform-stroke: #464c55;
  --label-pill: rgba(31, 38, 48, 0.92);
  --reserved-ballast: #2f6b45;
  --stop-board: #e7e5e4;
  --signal-post: #94a3b8;
  --signal-housing-edge: #94a3b8;
  --legend-edge: #94a3b8;
  --notice-edge: rgba(0, 0, 0, 0.35);
  --notice-signal: #ef4444;
  --notice-signal-edge: #fecaca;
  --notice-signal-glow: #fca5a5;
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow: rgba(0, 0, 0, 0.55);
  --tile: #1f2630;
  --on-good: #0f141b;
  --points: #22d3ee;
  --reserved: #4ade80;
  --preview: #fbbf24;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --blocked: #f87171;
  color-scheme: dark;
}

/* Train numbers are coloured by their train (inline style); lift the dark ones on a dark panel. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .entry .number { filter: brightness(1.8); }
}
:root[data-theme="dark"] .entry .number { filter: brightness(1.8); }

/* ---- page layout ------------------------------------------------------------------------ */
* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 12px 16px 24px;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 24px;
  margin-bottom: 10px;
}

h1 { margin: 0; font-size: 16px; letter-spacing: 0.08em; }
h1 .station { font-weight: 400; letter-spacing: 0; color: var(--dim); margin-left: 8px; }

.top-bar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; }
/* The one control in the header: railway saffron so it is easy to find. */
.menu-button {
  font: inherit;
  font-weight: 700;
  padding: 4px 16px;
  border: 0;
  border-radius: 999px;
  background: #ea580c;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(194, 65, 12, 0.35);
  cursor: pointer;
}
.menu-button:hover { background: #c2410c; }
/* Light / dark: a round icon button, a moon in light mode and a sun in dark mode. */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--fg); }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .sun, .theme-toggle.dark .moon { display: none; }
.theme-toggle.dark .sun { display: inline; }
/* Next to it, the tutorial in blue. */
.tutorial-button {
  font: inherit;
  font-weight: 700;
  padding: 4px 16px;
  border: 0;
  border-radius: 999px;
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(29, 78, 216, 0.35);
  cursor: pointer;
}
.tutorial-button:hover { background: #1d4ed8; }
.tutorial-button.confirm { background: #ffffff; color: #1d4ed8; box-shadow: inset 0 0 0 2px #2563eb; }
/* Plain pill buttons inside the Menu. */
.pill-button {
  font: inherit;
  padding: 3px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}
.pill-button:hover { border-color: var(--fg); }
.pill-button.confirm { border-color: var(--bad); color: var(--bad); font-weight: 600; }

/* Level picker (in the Menu): one row of pills, the chosen one filled. */
.levels { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.levels button {
  font: inherit;
  font-size: 13px;
  padding: 3px 12px;
  border: 0;
  background: var(--surface);
  color: var(--dim);
  cursor: pointer;
}
.levels button + button { border-left: 1px solid var(--border); }
.levels button:hover { color: var(--fg); }
.levels button[aria-pressed="true"] { background: var(--fg); color: var(--surface); }
.levels button:disabled { opacity: 0.45; cursor: not-allowed; }
.levels button:disabled:hover { color: var(--dim); }
.auto-toggle {
  font: inherit;
  font-size: 13px;
  padding: 3px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--dim);
  cursor: pointer;
}
.auto-toggle:hover:not(:disabled) { color: var(--fg); }
.auto-toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.auto-toggle[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: var(--on-good); }
.clock { font-size: 18px; font-weight: 700; letter-spacing: 0.04em; }
.stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; }
.stats button {
  font: inherit;
  padding: 2px 10px;
  border: 1px solid var(--good);
  border-radius: 6px;
  background: transparent;
  color: var(--good);
  cursor: pointer;
}

/* The map fills the full width; on a narrow screen it scrolls sideways inside this frame. */
.map-frame {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.map {
  display: block;
  width: 100%;
  min-width: 1000px; /* on phones the map scrolls sideways rather than shrinking to nothing */
  height: auto;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
@media (max-width: 900px) {
  .panels { grid-template-columns: minmax(0, 1fr); }
}

.panel {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
}
.panel h2 { margin: 0 0 6px; font-size: 13px; }
.panel h2 .dim { font-weight: 400; }
.panel p { margin: 4px 0; }

.entry {
  display: grid;
  grid-template-columns: 6ch minmax(0, 1.2fr) minmax(0, 1.4fr) 11ch 3ch 16ch;
  gap: 8px;
  padding: 1px 4px;
  border-radius: 4px;
  white-space: nowrap;
}
.entry > span { overflow: hidden; text-overflow: ellipsis; }
.entry .stars { color: var(--warn); }
.entry .status { text-align: right; }
.entry.upcoming { opacity: 0.72; }
.panel-sub { margin: 10px 0 4px; font-size: 13px; border-top: 1px solid var(--border); padding-top: 8px; }

.log { list-style: none; margin: 0; padding: 0; }
.log li { padding: 1px 0; }
.help { margin-top: 8px; font-size: 12px; }
.legend { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12px; color: var(--dim); }
.legend li { display: flex; gap: 8px; align-items: flex-start; margin: 3px 0; }
.legend svg { flex: none; width: 24px; height: 14px; transform: translateY(2px); }
.legend-points { fill: var(--surface); stroke: var(--points); stroke-width: 2; }
.legend-blade { fill: none; stroke: var(--points); stroke-width: 2.4; stroke-linecap: round; }
.legend-leg { fill: none; stroke: var(--dim); stroke-width: 1.5; stroke-linecap: round; }
.legend-leg.faded { opacity: 0.35; stroke-dasharray: 2 2; }
.legend-red { fill: var(--signal-red); stroke: var(--legend-edge); stroke-width: 2; }
.legend-green { fill: var(--signal-green); stroke: var(--legend-edge); stroke-width: 2; }
.legend-yellow { fill: var(--signal-yellow); stroke: var(--legend-edge); stroke-width: 2; }
.legend-chevron { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.legend-chevron.yellow { stroke: var(--signal-yellow); }
.legend-chevron.green { stroke: var(--signal-green); }
.legend-track { stroke: var(--track-loop); stroke-width: 2; }
.legend-preview { stroke: var(--preview); stroke-width: 6; stroke-linecap: round; opacity: 0.5; }

/* ---- text colours --------------------------------------------------------------------- */
.dim { color: var(--dim); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

[data-action] { cursor: pointer; }
.entry[data-action]:hover { background: var(--hover); }

/* ---- map: scenery ----------------------------------------------------------------------- */
.map text { font-size: 15px; text-anchor: middle; }
.river { fill: var(--river); }
.river-label { fill: var(--river-fg); font-style: italic; }
.bridge { fill: var(--bridge-bg); }
.platform { fill: var(--platform-bg); stroke: var(--platform-stroke); stroke-width: 0.8; }
.platform-edge { fill: var(--platform-edge); }
.platform-label { fill: var(--platform-fg); font-weight: 600; font-size: 14px; }
/* Names of the loops and the loco siding, on the track (no slab to put them on). */
.track-label rect { fill: var(--label-pill); stroke: var(--platform-stroke); stroke-width: 0.8; }
.track-label text { fill: var(--platform-fg); font-size: 11px; font-weight: 600; text-anchor: middle; }
.building { fill: var(--building-bg); }
.building-label { fill: var(--building-fg); font-weight: 600; }
.scenery-label { fill: var(--dim); }
.map .approach-label { fill: var(--fg); font-weight: 700; font-size: 18px; text-anchor: start; }
.map .approach-label.align-end { text-anchor: end; }
.approach-label:hover { fill: var(--points); }

/* ---- map: track -------------------------------------------------------------------------
   Real-looking pieces: ballast bed, concrete sleepers, two steel rails; main and branch lines
   keep a slim orange / olive centre line as the map key. */
.ballast { stroke: var(--ballast); stroke-width: 11; stroke-linecap: round; }
.sleepers { stroke: var(--sleeper); stroke-width: 8.5; stroke-dasharray: 1.6 2.6; }
.rail { stroke: var(--rail); stroke-width: 1.1; stroke-linecap: round; }
.key { stroke-width: 1.3; stroke-linecap: round; }
.key.main { stroke: var(--track-main); }
.key.branch { stroke: var(--track-branch); }
/* A locked route: rails glow green. */
.ballast.reserved { stroke: var(--reserved-ballast); }
.rail.reserved { stroke: var(--reserved); stroke-width: 1.7; }
/* The leg a set of points is not set for: still there, clearly not connected. */
.unset { opacity: 0.22; }

.preview { fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; opacity: 0.4; }
.preview.ok { stroke: var(--preview); }
.preview.blocked { stroke: var(--blocked); opacity: 0.22; }
.preview.focus { stroke-width: 13; opacity: 0.7; }

/* Shunt limit board: white with a dark edge. */
.stop-board { fill: var(--stop-board); stroke: var(--housing); stroke-width: 1.5; }

/* ---- map: points ------------------------------------------------------------------------ */
.hit { fill: transparent; stroke: none; pointer-events: all; }
/* A lever at the toe: its arm (blade) lies along the way the points are set. Hovering the lever,
   or the branch it isn't set for, shows that way as a dashed ghost: tap to switch. */
.points-lever, .hit-leg { cursor: pointer; }
.hit-leg { fill: none; stroke: transparent; stroke-width: 14; stroke-linecap: round; pointer-events: stroke; }
.blade { fill: none; stroke: var(--points); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.blade.idle { display: none; }
.blade.ghost { opacity: 0.6; stroke-dasharray: 3 3; }
.knob { fill: var(--surface); stroke: var(--points); stroke-width: 2; pointer-events: none; transition: r 0.1s; }
.knob.hover { r: 4.5; }
.points.locked .hit-leg, .points-lever.locked { cursor: not-allowed; }
.points.locked .blade.set { stroke: var(--dim); }
.points.locked .knob { stroke: var(--dim); fill: var(--dim); }

/* ---- map: signals -----------------------------------------------------------------------
   One big lamp in the current colour, drawn like a real lit head: dark housing, a lens that is
   white-hot in the middle (gradients in render.js), a glass highlight and a halo of light round
   it. A marker on the track has the same meaning: red stop bar, yellow chevron, green double
   chevron. Each head carries all three colours; only the current one shows. */
.signal-post { stroke: var(--signal-post); stroke-width: 1.4; }
.signal-housing { fill: var(--signal-housing); stroke: var(--signal-housing-edge); stroke-width: 0.8; }
.signal-halo, .signal-lens { opacity: 0; transition: opacity 0.25s ease-out; }
.signal-shine { fill: #ffffff; opacity: 0.55; pointer-events: none; }
.aspect-danger .lens-danger, .aspect-caution .lens-caution, .aspect-clear .lens-clear,
.aspect-danger .halo-danger, .aspect-caution .halo-caution, .aspect-clear .halo-clear { opacity: 1; }
.signal:hover .signal-housing { stroke: var(--points); stroke-width: 1.4; }
/* Junction route indicator: a white bar off the lamp when the route turns off through points. */
.feather, .feather-under { stroke-linecap: round; opacity: 0; }
.feather { stroke: #ffffff; stroke-width: 2.6; }
.feather-under { stroke: rgba(15, 23, 42, 0.6); stroke-width: 4.2; }
.feather-on .feather, .feather-on .feather-under { opacity: 1; }
/* Markers on the track: only the one for the current aspect shows. */
.mk { display: none; }
.mk-danger { fill: var(--signal-red); stroke: var(--marker-edge); stroke-width: 1; }
.mk-caution, .mk-clear { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.mk-caution { stroke: var(--signal-yellow); }
.mk-clear { stroke: var(--signal-green); }
.mk-under { stroke: var(--marker-edge); stroke-width: 4.6; }
.aspect-danger .mk-danger, .aspect-caution .mk-caution, .aspect-clear .mk-clear { display: inline; }
/* A train is standing at this signal: a soft pulsing ring round the lamp. */
.signal-call { fill: none; stroke: none; }
.signal.called .signal-call { stroke: var(--signal-red); stroke-width: 1.8; animation: breathe 2.4s ease-in-out infinite; }

/* ---- map: trains ------------------------------------------------------------------------
   Top-down vehicles from js/vehicles.js, coloured in their real liveries; each has a thin dark rim. */
.vehicle { stroke: var(--vehicle-rim); stroke-width: 0.6; }
.headlight { fill: var(--headlight); stroke: var(--vehicle-rim); stroke-width: 0.5; }
.train.clearing { opacity: 0.55; }
.train-label { font-size: 13px; font-weight: 700; fill: var(--fg); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.train.focus { filter: drop-shadow(0 0 2.5px var(--preview)); }
.lead.ready, .blink { animation: breathe 2.4s ease-in-out infinite; }

/* ---- map: notices (gentle reminders, never flashing) ------------------------------------- */
.notice-body {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: notice-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  transition: opacity 0.4s ease;
}
.notice.leaving .notice-body { opacity: 0; }
.notice-box {
  fill: var(--surface);
  stroke: var(--notice-edge);
  stroke-width: 1;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.18));
}
.notice:hover .notice-box { stroke: var(--points); stroke-width: 1.5; }
.map .notice-text { font-size: 12px; font-weight: 600; text-anchor: start; }
/* The background says what the train is doing; the text always contrasts with it. */
.notice-quiet .notice-box { fill: var(--notice-quiet); }       /* arriving, going to the yard */
.notice-quiet .notice-text { fill: var(--notice-quiet-fg); }
.notice-station .notice-box { fill: var(--notice-station); }     /* boarding, waiting for its time */
.notice-station .notice-text { fill: var(--notice-station-fg); }
.notice-runround .notice-box { fill: var(--notice-amber); }    /* loco to run round */
.notice-runround .notice-text { fill: var(--notice-amber-fg); }
/* Waiting at a signal: red, with a glowing edge and a small nudge that ask to be clicked;
   faster and stronger once the train is close to a strike. */
.notice-signal .notice-box { fill: var(--notice-signal); stroke: var(--notice-signal-edge); stroke-width: 1.5; animation: signal-glow 1.4s ease-in-out infinite; }
.notice-signal .notice-text { fill: #ffffff; font-weight: 700; }
.notice-signal .notice-body { animation: notice-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), signal-nudge 1.4s ease-in-out 0.6s infinite; }
.notice-signal.urgent .notice-box { animation-duration: 0.8s; }
.notice-signal.urgent .notice-body { animation-duration: 0.6s, 0.8s; }
.notice-ready .notice-box { fill: #15803d; stroke: #14532d; animation: ready-pulse 1.4s ease-in-out infinite; }
.notice-ready .notice-text { fill: #ffffff; }

/* ---- sound toggle ----------------------------------------------------------------------- */
.sound-toggle {
  font: inherit;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--dim);
  cursor: pointer;
}
.sound-toggle[aria-pressed="true"] { color: var(--fg); }

/* ---- overlays: the how-to-play slides and the end-of-shift card ------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--backdrop);
}
.overlay[hidden] { display: none; }
.card {
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 20px 22px 16px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 10px 40px var(--shadow);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
.card h2 { margin: 0 0 10px; font-size: 20px; }
.card h3 { margin: 16px 0 6px; font-size: 15px; }
.card p { margin: 0 0 10px; }
.card .small { font-size: 13px; }
.card-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.card-actions .dots { flex: 1; text-align: center; color: var(--dim); letter-spacing: 0.3em; }
.card-actions button {
  font: inherit;
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}
.card-actions .primary { background: var(--fg); border-color: var(--fg); color: var(--surface); }
.card-actions .link-button { border: none; padding: 6px 4px; color: var(--dim); text-decoration: underline; white-space: nowrap; }
.card-actions button:disabled { visibility: hidden; }
#game-over .card-actions, #menu .card-actions { justify-content: flex-end; }
/* The tutorial's coach card: at the bottom, over the panels, leaving the map free. */
.coach {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 9;
  width: min(580px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 14px 18px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--points);
  border-radius: 12px;
  box-shadow: 0 8px 30px var(--shadow);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
.coach[hidden] { display: none; }
.coach-step { margin: 0; font-size: 12px; }
.coach-title { margin: 2px 0 6px; font-size: 18px; }
.coach-text { margin: 0; }
.coach .card-actions { margin-top: 10px; }
.coach-wait { flex: 1; text-align: right; font-size: 13px; }
.coach .card-actions [hidden] { display: none; }
/* What the tutorial points at: bands along lines, pulsing rings on points and signals. */
.hl-band { opacity: 0.35; }
.hl-platform { fill: #3b82f6; }
.hl-loop { fill: #f59e0b; }
.hl-through { fill: #14b8a6; }
.hl-siding { fill: #a855f7; }
.hl-ring { fill: none; stroke: var(--points); stroke-width: 3; pointer-events: none; animation: hl-pulse 1.2s ease-in-out infinite; }
@keyframes hl-pulse { 50% { stroke-width: 6; opacity: 0.45; } }
.menu-section { padding: 10px 0; border-top: 1px solid var(--border); }
.menu-section h3 { margin: 0 0 8px; }
.menu-section p { margin: 6px 0 0; }
.menu-section button { font-family: inherit; }
/* The landing card: shown on every load. */
.landing-tagline { font-size: 14px; }
#landing .card-actions { justify-content: space-between; margin-bottom: 12px; }
.card .disclaimer { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; }
.score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 12px 0 0; }
.score-grid div { padding: 8px 10px; background: var(--tile); border: 1px solid var(--border); border-radius: 8px; }
.score-grid dt { color: var(--dim); font-size: 12px; }
.score-grid dd { margin: 0; font-size: 18px; font-weight: 700; }
.strike-list { margin: 0; padding-left: 20px; }
.strike-list li { margin-bottom: 8px; }
.strike-list .when { color: var(--dim); }
.strike-list .why { display: block; color: var(--fg); font-size: 14px; }

@keyframes breathe { 50% { opacity: 0.45; } }
/* Ready: a soft green halo pulses round the tag (never a hard flash). The background itself
   stays dark green so the white text keeps its contrast. */
@keyframes ready-pulse { 50% { stroke: #4ade80; stroke-width: 3.5; } }
@keyframes signal-glow { 50% { stroke: var(--notice-signal-glow); stroke-width: 4; } }
@keyframes signal-nudge { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-2.5px); } }
@keyframes notice-in {
  from { opacity: 0; transform: translateY(5px) scale(0.94); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .signal.called .signal-call, .lead.ready, .blink, .notice-body, .notice-ready .notice-box,
  .notice-signal .notice-box, .notice-signal .notice-body { animation: none; }
  .signal-halo, .signal-lens { transition: none; }
}
