/* MOUNTAIN MILE. One type family, three sizes, one accent. */
:root {
  --font: "DIN Condensed", "Roboto Condensed", "Arial Narrow", sans-serif-condensed, "Helvetica Neue", Arial, sans-serif;
  --ink: #f3f1ea;
  --dim: #a9a79f;
  --gold: #d0a52a;
  --panel: rgba(11, 12, 14, 0.78);
  --line: rgba(243, 241, 234, 0.16);
  --s: clamp(15px, 1.9vmin + 7px, 21px);       /* body */
  --m: calc(var(--s) * 1.5);                    /* values and buttons */
  --l: calc(var(--s) * 3.6);                    /* the name */
  --tile: calc(var(--s) * 2.7);
  --pad: max(14px, env(safe-area-inset-left));
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #0b0c0e; color: var(--ink); font-family: var(--font); font-size: var(--s); line-height: 1.25; letter-spacing: 0.01em; -webkit-user-select: none; user-select: none; touch-action: none; }
[hidden] { display: none !important; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#touch { position: fixed; inset: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

/* ---- while riding */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { position: absolute; }
#clock { top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); font-size: calc(var(--m) * 1.5); font-variant-numeric: tabular-nums; font-weight: 700; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55); }
#who { top: max(12px, env(safe-area-inset-top)); left: var(--pad); font-size: var(--m); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
#who b { color: var(--gold); font-weight: 700; margin-right: 0.4em; }
#tools { top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; pointer-events: auto; }
.tool { height: var(--tile); padding: 0 0.8em; display: flex; align-items: center; gap: 0.45em; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: var(--s); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.tool svg { width: 1.3em; height: 1.3em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#split { top: calc(max(10px, env(safe-area-inset-top)) + var(--m) * 2.1); left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: var(--m); padding: 0.15em 0.7em; background: var(--panel); border-radius: 8px; opacity: 0; transition: opacity 0.25s; font-variant-numeric: tabular-nums; }
#split.on { opacity: 1; }
#split .up { color: #7fd48a; } #split .dn { color: #ff8a6b; }
#count { top: 34%; left: 50%; transform: translate(-50%, -50%); font-size: calc(var(--l) * 1.6); font-weight: 700; text-shadow: 0 2px 24px rgba(0, 0, 0, 0.6); }
#note { top: 46%; left: 50%; transform: translateX(-50%); font-size: var(--m); padding: 0.2em 0.8em; background: var(--panel); border-radius: 8px; opacity: 0; transition: opacity 0.3s; white-space: nowrap; }
#note.on { opacity: 1; }
#gauge { right: max(18px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: auto auto auto; align-items: baseline; column-gap: 0.4em; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6); }
#gauge b { font-size: calc(var(--l) * 0.9); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 1.6em; text-align: right; line-height: 1; }
#gauge b.warn { color: #ffb020; }
#gauge span { font-size: var(--s); color: var(--dim); }
#gauge i { font-style: normal; font-size: var(--m); color: var(--gold); font-weight: 700; margin-left: 0.6em; }
#revs { grid-column: 1 / -1; height: 5px; background: rgba(243, 241, 234, 0.18); border-radius: 3px; overflow: hidden; margin-top: 4px; }
#revs u { display: block; height: 100%; width: 0; background: var(--ink); }
#revs u.hot { background: #ff5a3c; }
body.inside #gauge { display: none; }
body.touch #gauge { bottom: auto; right: auto; left: var(--pad); top: calc(max(12px, env(safe-area-inset-top)) + var(--m) * 1.5); }

#stick { width: 150px; height: 64px; margin: -32px 0 0 -75px; border-radius: 32px; border: 2px solid rgba(243, 241, 234, 0.35); background: rgba(11, 12, 14, 0.28); opacity: 0; transition: opacity 0.15s; left: 22%; top: 72%; }
#stick.on { opacity: 1; }
#nub { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(243, 241, 234, 0.85); }
body.touch #stick { opacity: 0.45; }
body.touch #stick.on { opacity: 1; }
.pedal { display: none; pointer-events: auto; right: max(18px, env(safe-area-inset-right)); width: calc(var(--tile) * 2.1); border-radius: 16px; border: 2px solid rgba(243, 241, 234, 0.4); background: rgba(11, 12, 14, 0.4); font-size: var(--m); font-weight: 700; }
body.touch.pedals .pedal { display: block; }
#pedal-go { bottom: max(18px, env(safe-area-inset-bottom)); height: calc(var(--tile) * 2.4); }
#pedal-stop { bottom: calc(max(18px, env(safe-area-inset-bottom)) + var(--tile) * 2.4 + 12px); height: calc(var(--tile) * 1.5); }
.pedal.down { background: rgba(208, 165, 42, 0.75); color: #0b0c0e; }

/* ---- cards */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: flex-start; padding: max(12px, env(safe-area-inset-top)) var(--pad) max(12px, env(safe-area-inset-bottom)); overflow-y: auto; touch-action: pan-y; }
#finish, #pause, #loading { justify-content: center; }
#loading { background: #0b0c0e; }
.card { width: min(100%, calc(var(--s) * 24)); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: calc(var(--s) * 1.1); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: flex; flex-direction: column; gap: calc(var(--s) * 0.7); }
.card.narrow { width: min(100%, calc(var(--s) * 19)); }
.card.bare { background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; align-items: center; text-align: center; }
.mark { line-height: 0; }
.mark img { display: block; width: auto; height: auto; max-width: min(100%, calc(var(--s) * 15)); max-height: 26vh; }
.card.bare .mark img { max-width: min(70vw, calc(var(--s) * 20)); max-height: 40vh; }
h2 { font-size: calc(var(--m) * 1.5); font-weight: 700; text-transform: uppercase; line-height: 1; padding-top: 0.1em; }
.lede { color: var(--ink); max-width: 30em; }
.small { color: var(--dim); }
.small a { color: inherit; }
.credit { font-size: calc(var(--s) * 0.82); }
.riders { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rider { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 6px 8px; padding: 10px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; align-items: center; }
.rider[aria-checked="true"] { border-color: var(--gold); background: rgba(208, 165, 42, 0.1); }
.rider input { background: rgba(243, 241, 234, 0.08); border: 1px solid var(--line); border-radius: 8px; height: var(--tile); padding: 0.2em 0.5em 0; min-width: 0; -webkit-user-select: text; user-select: text; }
.rider .num { width: 3.1em; text-align: center; font-size: var(--m); font-weight: 700; color: var(--gold); font-style: italic; }
.rider .name { width: 100%; font-size: var(--m); }
.rider .best { font-weight: 400; color: var(--dim); font-variant-numeric: tabular-nums; }
.rider .help-toggle { justify-self: end; height: calc(var(--tile) * 0.8); padding: 0.15em 0.8em 0; border: 1px solid var(--line); border-radius: 8px; background: rgba(243, 241, 234, 0.08); }
.paint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#swatches { display: flex; gap: 8px; }
.sw { width: var(--tile); height: var(--tile); border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.sw[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px #0b0c0e inset; }
.pick { display: flex; align-items: center; gap: 6px; color: var(--dim); }
.pick input { width: var(--tile); height: var(--tile); border: 2px solid var(--line); border-radius: 10px; padding: 2px; background: none; }
.go { height: calc(var(--tile) * 1.25); border-radius: 12px; background: var(--gold); color: #0b0c0e; font-size: calc(var(--m) * 1.15); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 0.12em; }
.plain { height: var(--tile); border-radius: 12px; border: 1px solid var(--line); background: rgba(243, 241, 234, 0.06); font-size: var(--m); padding-top: 0.1em; }
.opts { display: flex; gap: 8px; }
.opt { flex: 1; height: var(--tile); border-radius: 10px; border: 1px solid var(--line); background: rgba(243, 241, 234, 0.06); padding-top: 0.1em; }
.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.results div { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.results span { display: block; color: var(--dim); }
.results b { font-size: var(--m); font-variant-numeric: tabular-nums; }
.board { display: grid; gap: 4px; }
.board div { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 8px; background: rgba(243, 241, 234, 0.06); font-variant-numeric: tabular-nums; }
.board div.me { outline: 1px solid var(--gold); }
.loadbar { width: min(60vw, 320px); height: 4px; background: rgba(243, 241, 234, 0.16); border-radius: 2px; overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 4%; background: var(--gold); transition: width 0.3s; }

/* phones held sideways: less height, so the card tightens up */
@media (max-height: 520px) {
  :root { --s: clamp(13px, 2.6vh + 4px, 17px); --l: calc(var(--s) * 2.5); }
  .card { padding: calc(var(--s) * 0.8); gap: calc(var(--s) * 0.45); }
  .mark img { max-height: 22vh; }
}
@media (max-width: 560px) and (orientation: portrait) { .screen { align-items: flex-start; } }
