@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree-latin-wght.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

/* Light: lichen paper and spruce ink. Dark: the same forest at night, still green, never black. */
:root {
  color-scheme: light;
  --bg: #f1f6ec;
  --mint: #dfead2;
  --mint-2: #cadcb8;
  --line: rgba(16, 37, 26, 0.24);
  --ink: #10251a;
  --muted: #3a5445;
  --leaf: #1c6a38;
  --leaf-hover: #14552b;
  --on-action: #f4faee;
  --sprout: #2f7d46;
  --flight: #b3bcad;
  --sun: #e8a93a;
  /* Night trains: a pale dusk chip in light, a deep one in dark. Never a black block on a light page. */
  --night-bg: #dbe6e0;
  --night-fg: #10251a;
  --moon: #85590a;
  --danger: #b5442b;
  --danger-wash: #fbeee9;
  --paper: #fbfdf7;
  /* Departure board: in light mode a light board (cream tiles, ink letters); the dark board belongs to dark mode. */
  --board: #e2ecd5; --board-2: #f8fbf2; --board-fg: #10251a; --board-dim: #3a5445; --amber: #8a5300; --go: #17622f;
  --board-edge: rgba(16, 37, 26, 0.3); --board-lift: 0 18px 36px -26px rgba(10, 30, 18, 0.35);
  --board-rule: rgba(16, 37, 26, 0.16); --board-seam: rgba(16, 37, 26, 0.28); --board-shine: rgba(255, 255, 255, 0.5);
  --hill-1: #cfe2bb;
  --hill-2: #a9cf95;
  --hill-3: #6fae6c;
  --sky: #f6f9ee;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --leafcorner: 3px 18px 3px 18px;
}
/* Dark: a moonlit forest. Three clear steps (page < panel < board), warm amber for time, soft leaf for action. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #08110c; --mint: #13241a; --mint-2: #213a2b; --line: rgba(214, 236, 200, 0.22);
    --ink: #e9f3e1; --muted: #aec6b5; --leaf: #9ddc7b; --leaf-hover: #b8ea9b; --on-action: #0a1a10;
    --sprout: #5cc47f; --flight: #43584b; --sun: #f1d98a; --night-bg: #1b2a3a; --night-fg: #d6e4f2;
    --moon: #f1e4a2; --danger: #f19a84; --danger-wash: rgba(241, 154, 132, 0.14); --paper: #0f1d15;
    --board: #1b3326; --board-2: #2c4c3a; --board-fg: #f2f9ec; --board-dim: #b3cbba; --amber: #f5c15a; --go: #86e3a6;
    --board-edge: rgba(214, 236, 200, 0.26); --board-rule: rgba(255, 255, 255, 0.09); --board-seam: rgba(0, 0, 0, 0.5); --board-shine: rgba(255, 255, 255, 0.05); --board-lift: 0 24px 48px -24px rgba(0, 0, 0, 0.8);
    --hill-1: #111f17; --hill-2: #172f21; --hill-3: #204630; --sky: #0b1710;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08110c; --mint: #13241a; --mint-2: #213a2b; --line: rgba(214, 236, 200, 0.22);
  --ink: #e9f3e1; --muted: #aec6b5; --leaf: #9ddc7b; --leaf-hover: #b8ea9b; --on-action: #0a1a10;
  --sprout: #5cc47f; --flight: #43584b; --sun: #f1d98a; --night-bg: #1b2a3a; --night-fg: #d6e4f2;
  --moon: #f1e4a2; --danger: #f19a84; --danger-wash: rgba(241, 154, 132, 0.14); --paper: #0f1d15;
  --board: #1b3326; --board-2: #2c4c3a; --board-fg: #f2f9ec; --board-dim: #b3cbba; --amber: #f5c15a; --go: #86e3a6;
  --board-edge: rgba(214, 236, 200, 0.26); --board-rule: rgba(255, 255, 255, 0.09); --board-seam: rgba(0, 0, 0, 0.5); --board-shine: rgba(255, 255, 255, 0.05); --board-lift: 0 24px 48px -24px rgba(0, 0, 0, 0.8);
  --hill-1: #111f17; --hill-2: #172f21; --hill-3: #204630; --sky: #0b1710;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
::selection { background: var(--mint-2); color: var(--ink); }
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: var(--mint-2); border-radius: 9px; }
html { transition: background-color 0.4s; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Figtree", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
svg { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--sprout); outline-offset: 2px; border-radius: 8px; }
a { color: var(--leaf); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
::placeholder { color: var(--muted); opacity: 0.8; }
.mark { fill: var(--mint-2); stroke: var(--leaf); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; transform-origin: 20% 90%; transition: transform 0.5s var(--ease-out); }
.brand:hover .mark { transform: rotate(-12deg) scale(1.1); }

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
.primary {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px 18px;
  background: var(--leaf); color: var(--on-action); font-weight: 700; font-size: 15px; font-stretch: 90%;
  border-radius: var(--leafcorner); text-decoration: none;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18), 0 10px 18px -10px rgba(0, 0, 0, 0.35);
  transition: background-color 0.2s, transform 0.2s var(--ease-out), border-radius 0.4s var(--ease-out), box-shadow 0.2s;
}
.primary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.25s var(--ease-out); }
.primary:hover { background: var(--leaf-hover); border-radius: 18px 3px 18px 3px; }
.primary:hover svg { transform: translateX(3px); }
.primary:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.ghost { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-size: 13px; font-weight: 500; transition: background-color 0.2s, color 0.2s; }
.ghost:hover { background: var(--mint); color: var(--ink); }

.field {
  width: 100%; padding: 11px 14px; border: 1.5px solid color-mix(in srgb, var(--ink) 56%, transparent); border-radius: 12px 4px 12px 4px;
  font: 500 15px/1.3 "Figtree", system-ui, sans-serif; color: var(--ink); background: var(--paper);
  caret-color: var(--leaf); transition: border-color 0.2s, box-shadow 0.2s;
}
.field:focus { outline: none; border-color: var(--sprout); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sprout) 22%, transparent); }
.field[aria-invalid="true"] { border-color: var(--danger); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.knob { position: relative; width: 32px; height: 19px; border-radius: 999px; background: var(--flight); transition: background-color 0.3s; flex: none; }
.knob::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 14px; height: 14px; border-radius: 3px 12px 3px 12px;
  background: var(--bg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.35s var(--ease-out), border-radius 0.35s;
}
.switch input:checked + .knob { background: var(--leaf); }
.switch input:checked + .knob::after { transform: translateX(13px) rotate(90deg); }
.switch input:focus-visible + .knob { outline: 2px solid var(--sprout); outline-offset: 2px; }

/* Split-flap cells (ui/flaps.js) */
.flaps { display: inline-flex; gap: 2px; white-space: pre; perspective: 200px; }
.flap {
  display: inline-grid; place-items: center; width: 1.05em; height: 1.55em; border-radius: 3px; background-color: var(--mint-2); color: var(--ink);
  font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
  box-shadow: 0 1px 0 var(--line);
  background-image: linear-gradient(to bottom, transparent calc(50% - 0.5px), var(--line) calc(50% - 0.5px), var(--line) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}
.flap.space { width: 0.45em; background: none; box-shadow: none; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes arrive { from { transform: scale(0.4); } }
@keyframes grow { to { transform: scale(1); } }
@keyframes sway { 0%, 100% { transform: rotate(-1.6deg); } 50% { transform: rotate(1.6deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0ms !important; }
}

/* Reduce motion (Settings > Display, or the device setting): no animation or transition anywhere. */
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after {
  animation-duration: 0.001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important;
}

/* Real buttons: bordered, filled, a comfortable target. Used for every secondary action. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 16px; border: 1.5px solid color-mix(in srgb, var(--ink) 30%, transparent); border-radius: 12px; background: var(--mint); color: var(--ink); font: 600 14px/1.2 inherit; font-family: inherit; cursor: pointer; transition: background-color .15s, border-color .15s, transform .1s; }
.btn:hover { background: var(--mint-2); border-color: color-mix(in srgb, var(--leaf) 40%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Wordmark: "ride" in ink, "instead" in amber, set tight like one word. */
.wm { display: inline-flex; font-weight: 800; letter-spacing: -0.02em; text-transform: lowercase; }
.wm b { font-weight: 800; }
.wm i { font-style: normal; font-weight: 800; color: var(--amber); }
