/* Palette: a railway station clock and a printed timetable.
   Warm paper, near-black ink, one signal red (the second hand), one green for "correct". */
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url(../fonts/barlow-400.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url(../fonts/barlow-500.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url(../fonts/barlow-600.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url(../fonts/barlow-condensed-500.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url(../fonts/barlow-condensed-600.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url(../fonts/barlow-condensed-700.woff2) format("woff2"); }

:root {
  --paper: #eeebe3;
  --paper-2: #e4e0d5;
  --ink: #1e1e1c;
  --ink-2: #57554f;
  --rule: #c7c1b3;
  --red: #b5372b;
  --red-soft: #ecd3cc;
  --ok: #2f6b4a;
  --ok-soft: #d3e3d6;
  --key: #f6f4ee;
  --font: "Barlow", "Segoe UI", sans-serif;
  --font-num: "Barlow Condensed", "Arial Narrow", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #191917;
    --paper-2: #23231f;
    --ink: #e8e4da;
    --ink-2: #a39f94;
    --rule: #3b3a35;
    --red: #e0604f;
    --red-soft: #4a2622;
    --ok: #6fb58d;
    --ok-soft: #1f3a2b;
    --key: #262622;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.4 var(--font);
  overflow-x: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

.page { max-width: 520px; margin: 0 auto; padding: 12px 16px 40px; }
.bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-bottom: 6px; border-bottom: 2px solid var(--ink); font-size: 14px;
}
.bar a, .bar button.link { text-decoration: none; color: var(--ink-2); background: none; border: 0; padding: 0; cursor: pointer; font-size: 14px; }
.bar .mark { font: 700 18px/1 var(--font-num); letter-spacing: .02em; color: var(--ink); text-decoration: none; }
.bar .mark b { color: var(--red); font-weight: 700; }

h1, h2 { font-family: var(--font-num); font-weight: 600; line-height: 1; margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }

.btn {
  display: inline-block; border: 2px solid var(--ink); background: var(--ink); color: var(--paper);
  font: 600 18px/1 var(--font); padding: 15px 24px; border-radius: 2px; cursor: pointer; text-decoration: none;
  text-align: center;
}
.btn.red { background: var(--red); border-color: var(--red); color: #fbf7f2; }
.btn.quiet { background: none; color: var(--ink); }
.btn.wide { display: block; width: 100%; }
.btn:active { transform: translateY(1px); }
.links { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; font-size: 15px; }
.links button { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 15px; }

/* ---- home ---- */
.hero { padding: 26px 0 18px; }
.hero .clock { font: 700 112px/0.85 var(--font-num); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hero .clock span { color: var(--red); }
.hero h1 { font-size: 34px; margin: 14px 0 8px; max-width: 14ch; }
.hero p { margin: 0 0 18px; color: var(--ink-2); max-width: 36ch; }
.count { font-size: 14px; color: var(--ink-2); margin-top: 10px; }

.list { width: 100%; border-collapse: collapse; margin-top: 8px; }
.list th { text-align: right; font: 600 11px/1.2 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
  padding: 16px 0 6px 8px; border-bottom: 2px solid var(--ink); vertical-align: bottom; }
.list th:first-child { text-align: left; padding-left: 0; }
.list td { padding: 12px 0 12px 8px; border-bottom: 1px solid var(--rule); text-align: right; vertical-align: middle; }
.list td:first-child { text-align: left; padding-left: 0; }
.list .name { font: 600 21px/1.05 var(--font-num); text-decoration: none; display: block; }
.list .sub { font-size: 13px; color: var(--ink-2); }
.list .t { font: 500 20px/1 var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .t.none { color: var(--rule); }
.list .pct { font-size: 12px; color: var(--red); display: block; margin-top: 3px; }
.list tr.go { cursor: pointer; }

/* ---- intro ---- */
.intro h1 { font-size: 44px; margin: 22px 0 10px; }
.intro .how { font-size: 18px; margin: 0 0 8px; max-width: 34ch; }
.intro .note { font-size: 14px; color: var(--ink-2); margin: 0 0 18px; max-width: 40ch; }
.demo { height: 300px; margin: 8px 0 18px; position: relative; }
.intro .steps { margin: 0 0 20px; padding: 0; list-style: none; counter-reset: s; }
.intro .steps li { counter-increment: s; padding: 6px 0 6px 30px; position: relative; border-top: 1px solid var(--rule); font-size: 15px; }
.intro .steps li::before { content: counter(s); position: absolute; left: 0; top: 5px; font: 600 18px/1 var(--font-num); color: var(--red); }

/* ---- play: one screen, no scroll ---- */
.play {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  max-width: 520px; margin: 0 auto; padding: 8px 16px 12px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.play .bar { flex: none; }
.target { flex: none; display: flex; align-items: flex-end; justify-content: space-between; padding: 10px 0 4px; min-height: 104px; }
.target .lbl { font-size: 13px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.target .t { font: 700 88px/0.85 var(--font-num); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.target .you { text-align: right; }
.target .you .v { font: 600 34px/1 var(--font-num); color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 3.2em; display: inline-block; }
.status { flex: none; height: 30px; display: flex; align-items: center; gap: 10px; font-size: 15px; }
.status .clock { margin-left: auto; font: 600 20px/1 var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.status .bad { color: var(--red); font-weight: 600; }
.status .good { color: var(--ok); font-weight: 600; }
.status .go { color: var(--red); font: 700 22px/1 var(--font-num); letter-spacing: .02em; }
.stage { flex: 1; min-height: 0; position: relative; }
.stage .host { position: absolute; inset: 0; touch-action: none; }
.stage .cover {
  position: absolute; inset: -4px; display: flex; align-items: center; justify-content: center; z-index: 5;
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  font: 700 160px/1 var(--font-num); color: var(--red);
}
.stage .cover.msg { font: 600 22px/1.3 var(--font); color: var(--ink); text-align: center; padding: 20px; }
.pips { display: flex; gap: 5px; }
.pips i { width: 18px; height: 6px; background: var(--rule); display: block; }
.pips i.done { background: var(--ink); }
.pips i.now { background: var(--red); }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.okflash { animation: okf .5s ease-out; }
@keyframes okf { from { background: var(--ok-soft); } to { background: transparent; } }

/* ---- result ---- */
.res h1 { font-size: 22px; margin: 22px 0 4px; color: var(--ink-2); font-weight: 600; }
.res .score { font: 700 96px/0.9 var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.res .score small { font-size: 0.4em; font-weight: 600; margin-left: 4px; }
.res .per { font-size: 16px; color: var(--ink-2); margin: 6px 0 0; }
.res .rank { font: 600 30px/1.05 var(--font-num); margin: 22px 0 6px; max-width: 18ch; }
.res .rank em { font-style: normal; color: var(--red); }
.hist { display: block; width: 100%; height: 120px; margin: 0 0 2px; }
.histcap { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); position: relative; height: 18px; }
.histme { position: relative; height: 18px; font-size: 13px; color: var(--red); font-weight: 600; margin-top: 8px; }
.histme span { position: absolute; top: 0; transform: translateX(-50%); }
.picks { width: 100%; border-collapse: collapse; margin: 18px 0 6px; }
.picks td { padding: 6px 0; border-bottom: 1px solid var(--rule); font: 500 20px/1 var(--font-num); font-variant-numeric: tabular-nums; }
.picks td.r { text-align: right; }
.picks td.e { color: var(--red); font: 500 13px var(--font); text-align: right; }
.actions { display: grid; gap: 10px; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 16px; font-size: 15px; z-index: 50; border-radius: 2px; }

/* ---- world / about ---- */
.prose h1 { font-size: 40px; margin: 22px 0 12px; }
.prose h2 { font-size: 24px; margin: 26px 0 8px; }
.prose p, .prose li { max-width: 60ch; }
.prose ul { padding-left: 20px; }
.bars { margin: 12px 0; }
.bars .row { display: grid; grid-template-columns: 7.5em 1fr 4em; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.bars .row .n { font: 600 17px/1.1 var(--font-num); }
.bars .row .b { height: 14px; background: var(--ink); }
.bars .row.base .b { background: var(--red); }
.bars .row .v { font: 500 18px/1 var(--font-num); text-align: right; font-variant-numeric: tabular-nums; }

/* ---- desktop gate ---- */
.gate { padding-top: 40px; }
.gate h1 { font-size: 46px; max-width: 12ch; margin-bottom: 14px; }
.gate .qr { width: 196px; height: 196px; margin: 18px 0; background: var(--key); padding: 10px; border: 1px solid var(--rule); }
.gate .qr svg { width: 100%; height: 100%; display: block; }
.gate .url { font: 600 20px/1.2 var(--font-num); word-break: break-all; }

/* ---- keys (shared by the pickers) ---- */
.keys { display: grid; border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.key {
  appearance: none; border: 0; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); border-radius: 0;
  background: var(--key); min-height: 40px; padding: 0; cursor: pointer; position: relative;
  font: 600 26px/1 var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink);
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.key.down, .key.on { background: var(--ink); color: var(--paper); }
.key.quarter { font-weight: 700; }
.key.dim { color: var(--ink-2); font-weight: 500; }
@media (hover: hover) { .key:hover { outline: 2px solid var(--ink); outline-offset: -2px; z-index: 1; } }

.flick { grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(4, minmax(48px, 84px)); }
.stage .flick { position: absolute; left: 0; right: 0; bottom: 0; } /* keys near the thumb */
.flick-ov { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 20; }
.flick-ov .lab { position: absolute; transform: translate(-50%, -50%); font: 600 18px/1 var(--font-num);
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); padding: 5px 6px; border-radius: 2px; font-variant-numeric: tabular-nums; }
.flick-ov .lab.small { font-size: 15px; padding: 4px 5px; color: var(--ink-2); }
.flick-ov .lab.hit { background: var(--red); color: #fbf7f2; border-color: var(--red); }
.flick-ov .lab.mid { background: var(--ink); color: var(--paper); border-color: var(--ink); font-size: 24px; padding: 8px 9px; }
.flick-ov .disc { position: absolute; border-radius: 50%; background: var(--paper); opacity: .93; border: 1px solid var(--rule); transform: translate(-50%, -50%); }

.scrub { position: absolute; inset: 0; }
.scrub canvas { display: block; width: 100%; touch-action: none; }
.scrub .zones { position: absolute; left: 0; right: 0; top: 0; pointer-events: none; font: 500 12px var(--font); color: var(--ink-2); }
.scrub .zones div { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--rule); padding: 3px 0 0 2px; }
.scrub .zones div.on { color: var(--red); border-top-color: var(--red); }

.pa { position: absolute; inset: 0; display: flex; flex-direction: column; }
.pa .head { flex: none; height: 40px; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.pa .head .back { border: 1px solid var(--rule); background: var(--key); padding: 4px 10px; cursor: pointer; font: 600 22px/1 var(--font-num); color: var(--ink); text-transform: none; letter-spacing: 0; }
.pa .keys { flex: 1; min-height: 0; }
.pa .hours { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(6, 1fr); }
.pa .mins { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); }
.pa .mins .key { font-size: 30px; }

.pb { position: absolute; inset: 0; display: grid; grid-template-columns: 3fr 2fr; gap: 12px; }
.pb .col { display: flex; flex-direction: column; min-height: 0; }
.pb .lbl { flex: none; height: 22px; font: 600 12px/1 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.pb .keys { flex: 1; min-height: 0; }
.pb .hours { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(8, 1fr); }
.pb .mins { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(6, 1fr); }
.pb .key { font-size: 24px; }

.native { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: flex-start; padding-top: 24px; }
.native p { margin: 0 0 14px; color: var(--ink-2); max-width: 30ch; }
.native-in { font: 600 40px/1.1 var(--font-num); padding: 10px 14px; border: 2px solid var(--ink); background: var(--key); color: var(--ink); border-radius: 2px; min-width: 200px; }
