:root {
  --hud: #ffffff;
  --shadow: 0 0 0.6vh rgba(0, 0, 0, 0.28), 0 0.1vh 0.2vh rgba(0, 0, 0, 0.25);
  --font: 'Barlow Condensed', 'Arial Narrow', 'Helvetica Neue', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
body { font-family: var(--font); color: var(--hud); -webkit-font-smoothing: antialiased; user-select: none; }
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }

/* ---------- HUD (mirrors the burnt-in overlay of the reference footage) ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: var(--shadow); }
/* the map: right, between the clock and the column below (on a phone, on the left under the buttons) */
#map { position: absolute; right: 3vw; top: 23vh; width: 27vh; height: 27vh; }
/* bottom right, one column: energy, then power and cadence, then the speed (the biggest number on the HUD) */
.rcol { position: absolute; right: 3vw; bottom: 3.6vh; display: flex; flex-direction: column; align-items: flex-end; gap: 1.6vh; text-align: right; }
.rtop { display: flex; flex-direction: column; align-items: flex-end; gap: 1.6vh; }
.energy { display: flex; flex-direction: column; align-items: flex-end; }
.pc { display: flex; gap: 2.6vh; }
.lbl { font-weight: 600; font-size: 1.9vh; letter-spacing: 0.08em; line-height: 1; opacity: 0.96; }
.val { font-weight: 700; font-size: 4.8vh; line-height: 0.92; margin-top: 0.3vh; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
/* energy (W' balance): white fill = what's left, hatched end = capacity lost to fatigue for the rest of the ride */
.egauge { position: relative; width: 16vh; height: 1.3vh; margin: 0.9vh 0 0.7vh; border-radius: 0.65vh; overflow: hidden;
  background: rgba(255,255,255,0.2); box-shadow: 0 0 0.6vh rgba(0,0,0,0.25); }
.egauge i { position: absolute; top: 0; bottom: 0; }
.egauge .fill { left: 0; width: 100%; background: #fff; transition: background-color 0.3s; }
.egauge .lost { right: 0; width: 0; background: repeating-linear-gradient(135deg, rgba(0,0,0,0.42) 0 0.3vh, rgba(0,0,0,0.12) 0.3vh 0.6vh); }
.egauge.drain .fill { background: #ffc66e; }
.egauge.low .fill { background: #ff8a7a; }
.egauge.empty { animation: pulse 0.8s ease-in-out infinite; }
#eTag { font-weight: 700; margin-left: 0.4em; letter-spacing: 0.1em; }
#eTag.sprint { color: #ffc66e; } #eTag.empty { color: #ff8a7a; }
.esub { font-weight: 600; font-size: 1.7vh; letter-spacing: 0.06em; opacity: 0.9; font-variant-numeric: tabular-nums; }
#profile { position: absolute; left: 0; bottom: 0; width: 25vw; height: 11vh; }
.alt { position: absolute; left: 17.5vw; bottom: 3.2vh; font-weight: 700; font-size: 2.3vh; line-height: 1.05; text-align: right; font-variant-numeric: tabular-nums; }
.grade { position: absolute; left: 1.3vw; bottom: 1.2vh; }
.speed { display: flex; align-items: baseline; gap: 0.9vh; font-variant-numeric: tabular-nums; }
#spd { font-weight: 700; font-size: 10.5vh; line-height: 0.85; letter-spacing: 0.01em; min-width: 1.6em; text-align: right; }
#spdU { font-weight: 600; font-size: 2.6vh; letter-spacing: 0.08em; opacity: 0.96; }
.glbl { font-weight: 600; font-size: 1.45vh; letter-spacing: 0.08em; opacity: 0.95; }
#grade { font-weight: 700; font-size: 3.1vh; line-height: 1; font-variant-numeric: tabular-nums; }
.timer { position: absolute; right: 3vw; top: 4vh; text-align: right; }
#time { font-weight: 700; font-size: 5.4vh; line-height: 1; font-variant-numeric: tabular-nums; }
#togo { font-weight: 600; font-size: 1.9vh; letter-spacing: 0.08em; margin-top: 0.4vh; opacity: 0.9; }
#split { font-weight: 700; font-size: 2.6vh; margin-top: 1vh; transition: opacity 0.4s; opacity: 0; font-variant-numeric: tabular-nums; }
#split .good { color: #7cff9a; } #split .bad { color: #ff8a7a; }
#pace { position: absolute; left: 50%; top: 4.2vh; transform: translateX(-50%); font-weight: 600; font-size: 2.4vh; letter-spacing: 0.06em;
  transition: opacity 0.3s; opacity: 0; white-space: nowrap; }
#pace .arrow { font-size: 3vh; vertical-align: -0.6vh; margin-right: 0.3vw; filter: drop-shadow(0 0 0.4vh rgba(0,0,0,0.3)); }
#pace b { margin-left: 0.5vw; }
#pace .vs { margin-left: 0.8vw; opacity: 0.8; }
#draft { position: absolute; left: 50%; top: 8.6vh; transform: translateX(-50%); font-weight: 600; font-size: 2.1vh; letter-spacing: 0.12em;
  transition: opacity 0.3s; opacity: 0; white-space: nowrap; }
#draft b { color: #7cff9a; margin-left: 0.5vw; }
#hint { position: absolute; left: 50%; bottom: 13vh; transform: translateX(-50%); font-weight: 600; font-size: 2.3vh; letter-spacing: 0.12em;
  transition: opacity 0.35s; opacity: 0; white-space: nowrap; }
#hint b { display: inline-block; margin: 0 0.4em; padding: 0.15em 0.55em; border: 1px solid rgba(255,255,255,0.75); border-radius: 0.3em;
  font-weight: 700; letter-spacing: 0.08em; box-shadow: 0 0 0.6vh rgba(0,0,0,0.25); }
#hint b[data-a] { background: rgba(0,0,0,0.38); transition: background 0.08s, color 0.08s, border-color 0.08s; }
#hint b[data-a].on { background: #fff; color: #111; border-color: #fff; }
/* start hint: W over A S D as on the board (the top row sits a quarter key left), the sprint key (Space) as a bar
   under them, labels on each key's outer side, and the camera key (C) off to the right, in line with A S D */
#hint .kc { --k: 4.4vh; --g: 0.55vh; display: grid; gap: var(--g); align-items: center;
  grid-template-columns: 1fr minmax(var(--k), auto) minmax(var(--k), auto) minmax(var(--k), auto) 1fr 1.8vh minmax(var(--k), auto) auto;
  grid-template-areas: ". . w wl wl . . ." "al a s d dl . c cl" ". . sl . . . . ." ". sp sp sp spl . . ."; }
#hint .kc .k-camera { grid-area: c; }
#hint .kt-camera { grid-area: cl; padding-left: 0.5vh; }
#hint .kc .k { margin: 0; padding: 0 0.6vh; min-width: var(--k); height: var(--k); line-height: var(--k); text-align: center;
  font-size: 2.2vh; letter-spacing: 0; box-sizing: border-box; justify-self: center; }
#hint .kc .k-pedal { grid-area: w; transform: translateX(calc(-0.25 * (var(--k) + var(--g)))); }
#hint .kc .k-left { grid-area: a; } #hint .kc .k-brake { grid-area: s; } #hint .kc .k-right { grid-area: d; }
#hint .kc .k-sprint { grid-area: sp; justify-self: stretch; font-size: 1.7vh; letter-spacing: 0.14em; }
#hint .kt { font-size: 1.7vh; letter-spacing: 0.14em; opacity: 0.9; }
#hint .kt-pedal { grid-area: wl; padding-left: 0.4vh; transform: translateX(calc(-0.25 * (var(--k) + var(--g)))); }
#hint .kt-left { grid-area: al; justify-self: end; padding-right: 0.5vh; }
#hint .kt-right { grid-area: dl; padding-left: 0.5vh; }
#hint .kt-brake { grid-area: sl; justify-self: center; }
#hint .kt-sprint { grid-area: spl; padding-left: 0.5vh; }
#center { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); text-align: center; transition: opacity 0.25s; }
#center .big { font-weight: 700; font-size: 9vh; letter-spacing: 0.04em; line-height: 1; }
#center .count { font-size: 16vh; }
#center .go { color: #fff; }
#center .small { font-weight: 600; font-size: 2.4vh; letter-spacing: 0.14em; margin-top: 1vh; }
#toast { position: fixed; left: 50%; bottom: 6vh; transform: translateX(-50%); font-weight: 600; font-size: 2.1vh; letter-spacing: 0.12em;
  text-shadow: var(--shadow); opacity: 0; transition: opacity 0.35s; pointer-events: none; }

/* ---------- overlay cards ---------- */
#overlay { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(0,0,0,0.18), rgba(0,0,0,0.55)); padding: 16px; }
.card { width: min(560px, 100%); padding: 34px 38px 30px; background: rgba(10, 12, 14, 0.62); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; text-shadow: none; }
.card.small { width: min(420px, 100%); text-align: center; }
.kicker { font-weight: 600; font-size: 14px; letter-spacing: 0.24em; opacity: 0.75; }
.velo { font-style: italic; padding-right: 0.06em; } /* the slant leans past the box; keep it off the next word */
.title { font-weight: 700; font-size: 64px; line-height: 1; letter-spacing: 0.03em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.sub { font-weight: 600; font-size: 16px; letter-spacing: 0.1em; opacity: 0.85; }
.best { font-weight: 600; font-size: 15px; letter-spacing: 0.12em; opacity: 0.85; margin-top: 20px; }
.cta { margin-top: 20px; font-weight: 600; font-size: 18px; letter-spacing: 0.18em; animation: pulse 1.6s ease-in-out infinite; }
.cta b { font-weight: 700; }
@keyframes pulse { 50% { opacity: 0.45; } }
.stats, .splits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 18px; font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }
.splits { grid-template-columns: repeat(3, 1fr); font-size: 17px; opacity: 0.9; }
.stats span, .splits span { display: block; font-weight: 600; font-size: 12px; letter-spacing: 0.18em; opacity: 0.65; }
.bar { height: 3px; background: rgba(255,255,255,0.15); margin-top: 18px; border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: #fff; transition: width 0.2s; }

@media (max-width: 560px) {
  .card { padding: 24px 20px; }
  .title { font-size: 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- leaderboard, posting a time, suggestions ---------- */
.card { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
.board { margin-top: 18px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.1); }
.bhead { display: flex; justify-content: space-between; font-weight: 700; font-size: 13px; letter-spacing: 0.2em; opacity: 0.8; margin-bottom: 6px; }
.bhead span { font-weight: 600; opacity: 0.75; }
.bnote { font-family: system-ui, sans-serif; font-size: 13.5px; opacity: 0.7; }
.blist { list-style: none; margin: 0; padding: 0; font-size: 17px; font-variant-numeric: tabular-nums; }
.blist li { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 8px; padding: 3px 6px; border-radius: 4px; }
.blist li.you { background: rgba(255,255,255,0.14); font-weight: 700; }
.blist li.gap { margin-top: 6px; }
.blist .br { opacity: 0.6; text-align: right; }
.blist .bn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.04em; }
.blist .bt { font-weight: 700; }
.post { margin-top: 18px; }
.flbl { display: block; font-weight: 600; font-size: 13px; letter-spacing: 0.16em; opacity: 0.85; margin: 14px 0 6px; text-align: left; }
.flbl span { font-weight: 500; opacity: 0.7; letter-spacing: 0.06em; }
.post .flbl { margin-top: 0; }
.prow { display: flex; gap: 8px; }
.card input, .card textarea { flex: 1; min-width: 0; width: 100%; min-height: 40px; padding: 8px 10px; font: inherit; font-size: 17px; color: #fff;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.22); border-radius: 5px; user-select: text; }
.card textarea { font-family: system-ui, sans-serif; font-size: 15px; line-height: 1.45; resize: vertical; }
.card input::placeholder { color: rgba(255,255,255,0.45); }
.card button:not(.tog) { min-height: 40px; padding: 8px 16px; font: inherit; font-weight: 700; font-size: 15px; letter-spacing: 0.14em; color: #0b0d0f;
  background: #fff; border: 1px solid #fff; border-radius: 5px; cursor: pointer; }
.card button:disabled { opacity: 0.55; cursor: default; }
.card button.start { display: block; width: 100%; margin-top: 22px; min-height: 54px; font-size: 22px; letter-spacing: 0.32em; padding-left: calc(16px + 0.32em); }
.card button.start:hover { background: #e8ecef; }
.card button.ghost { color: #fff; background: transparent; border-color: rgba(255,255,255,0.3); }
.card button.link { display: block; margin: 14px auto 0; min-height: 32px; padding: 4px 8px; color: #fff; background: none; border: 0;
  font-weight: 600; font-size: 13px; letter-spacing: 0.18em; opacity: 0.75; text-decoration: underline; text-underline-offset: 3px; }
.card button.link:hover { opacity: 1; }
.card input:focus-visible, .card textarea:focus-visible, .card button:focus-visible { outline: 2px solid #7cc4ff; outline-offset: 2px; }
.pmsg { font-family: system-ui, sans-serif; font-size: 13.5px; min-height: 1.2em; margin-top: 6px; opacity: 0.85; text-align: left; }
.post[hidden] { display: none; }
/* dialogs over the cards: SUGGEST AN IDEA (ui/online.js) and ABOUT (ui/about.js) */
.dlg { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,0.5); }
.dlg[hidden] { display: none; }
.dlg .card { text-align: left; }
.dlg .title { font-size: 40px; }
.dlg .sub { font-family: system-ui, sans-serif; font-weight: 400; font-size: 14px; letter-spacing: 0; line-height: 1.45; }
#about .sub { font-size: 15px; line-height: 1.55; opacity: 0.9; }
#about .sub p { margin: 0 0 0.8em; }
#about .sub p:last-child { margin-bottom: 0; }
#about .sub p.lead { font-size: 1.12em; font-weight: 600; opacity: 1; }
#about .card:focus { outline: none; }
/* the small links under a card, side by side */
.links { display: flex; justify-content: center; gap: 4px 18px; flex-wrap: wrap; margin-top: 14px; }
.card .links button.link { margin: 0; }
.factions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- settings (gear, top left) ---------- */
#settingsBtn { position: fixed; left: 16px; top: 16px; z-index: 36; width: 44px; height: 44px; display: grid; place-items: center;
  color: #fff; background: rgba(10, 12, 14, 0.5); border: 1px solid rgba(255,255,255,0.16); border-radius: 50%; cursor: pointer;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background 0.15s, transform 0.25s; }
#settingsBtn:hover { background: rgba(10, 12, 14, 0.72); }
#settingsBtn.on { transform: rotate(60deg); background: rgba(10, 12, 14, 0.8); }
#settingsBtn:focus-visible, #settings button:focus-visible, #settings input:focus-visible { outline: 2px solid #7cc4ff; outline-offset: 2px; }
#settings { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.55); font-size: 15px; }
#settings[hidden] { display: none; }
.mpanel { width: min(700px, 100%); height: min(640px, calc(100vh - 32px)); height: min(640px, calc(100dvh - 32px)); display: flex; flex-direction: column;
  background: rgba(10, 12, 14, 0.9); border: 1px solid rgba(255,255,255,0.14); border-radius: 8px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.mhead { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 6px; }
.mtitle { font-weight: 700; font-size: 26px; letter-spacing: 0.2em; }
/* the tabs scroll sideways on a narrow screen, with no scrollbar; the rule under them is an inset shadow (not a border
   the tabs overlap with a negative margin), so nothing overflows downwards to make a vertical scrollbar */
.mtabs { display: flex; gap: 4px; padding: 0 16px; box-shadow: inset 0 -1px rgba(255,255,255,0.12); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.mtabs::-webkit-scrollbar { display: none; }
.mtabs button { flex: 0 0 auto; min-height: 44px; padding: 10px 16px; font: inherit; font-weight: 700; font-size: 16px; letter-spacing: 0.16em; color: #fff;
  background: none; border: 0; border-bottom: 3px solid transparent; cursor: pointer; opacity: 0.6; }
.mtabs button:hover { opacity: 0.9; }
.mtabs button[aria-selected="true"] { opacity: 1; border-bottom-color: #fff; }
.mbody { flex: 1; overflow-y: auto; padding: 8px 20px 12px; }
.mbody section:focus { outline: none; }
.mfoot { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.12); }
.mhint { flex: 1; text-align: center; font-size: 12px; letter-spacing: 0.16em; opacity: 0.5; }
.mfoot button { min-height: 40px; padding: 8px 16px; font: inherit; font-weight: 700; font-size: 14px; letter-spacing: 0.14em; border-radius: 5px; cursor: pointer; }
.mreset { color: #fff; background: none; border: 1px solid rgba(255,255,255,0.3); }
.mreset:disabled { opacity: 0.35; cursor: default; }
.mdone { color: #0b0d0f; background: #fff; border: 1px solid #fff; }
.shelp { font-family: system-ui, sans-serif; font-size: 13px; opacity: 0.6; margin-top: 6px; }
.srow.inline { flex-wrap: wrap; }
.srow.inline .shelp { flex-basis: 100%; }
/* keys tab */
.khelp { font-family: system-ui, sans-serif; font-size: 13.5px; opacity: 0.7; margin: 8px 0 2px; }
.kmsg { font-family: system-ui, sans-serif; font-size: 13.5px; min-height: 1.3em; margin-bottom: 4px; color: #9fd3ff; }
.kgroup { font-weight: 700; font-size: 13px; letter-spacing: 0.2em; opacity: 0.6; margin: 14px 0 4px; }
.krow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid rgba(255,255,255,0.07); }
.klbl { font-family: system-ui, sans-serif; font-size: 14.5px; opacity: 0.9; }
.kslots { display: flex; gap: 6px; flex: 0 0 auto; }
.kslot { min-width: 74px; min-height: 36px; padding: 6px 10px; display: inline-grid; place-items: center; font: inherit; font-weight: 700; font-size: 15px;
  letter-spacing: 0.06em; color: #fff; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.2); border-radius: 5px; cursor: pointer; }
button.kslot:hover { background: rgba(255,255,255,0.14); }
.kslot.empty { color: rgba(255,255,255,0.5); border-style: dashed; }
.kslot.wait { color: #0b0d0f; background: #9fd3ff; border-color: #9fd3ff; animation: pulse 1s ease-in-out infinite; }
.kslot.fixed { cursor: default; opacity: 0.55; }
@media (max-width: 560px) {
  .krow { flex-direction: column; align-items: flex-start; }
  .kslot { min-width: 60px; }
  .mhint { display: none; }
  .mfoot { justify-content: space-between; }
}
.sclose { width: 32px; height: 32px; font: inherit; font-size: 24px; line-height: 1; color: #fff; background: none; border: 0; border-radius: 4px; cursor: pointer; opacity: 0.8; }
.sclose:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.mlinks { display: flex; align-items: center; gap: 6px; }
.mlink { min-height: 32px; padding: 4px 8px; font: inherit; font-weight: 600; font-size: 13px; letter-spacing: 0.18em; color: #fff; background: none;
  border: 0; border-radius: 4px; cursor: pointer; opacity: 0.7; text-decoration: underline; text-underline-offset: 3px; }
.mlink:hover { opacity: 1; }
.mlink:focus-visible { outline: 2px solid #7cc4ff; outline-offset: 2px; }
.srow { padding: 10px 0; border-top: 1px solid rgba(255,255,255,0.08); }
.srow.inline { display: flex; justify-content: space-between; align-items: center; }
.slbl { display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; letter-spacing: 0.14em; opacity: 0.85; margin-bottom: 8px; }
.srow.inline .slbl { margin: 0; }
.slbl output { font-variant-numeric: tabular-nums; opacity: 1; font-weight: 700; letter-spacing: 0.04em; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-height: 36px; padding: 6px 10px; font: inherit; font-weight: 600; font-size: 14px; letter-spacing: 0.04em; color: #fff;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); border-radius: 5px; cursor: pointer; }
.seg button:hover { background: rgba(255,255,255,0.12); }
.seg button[aria-checked="true"] { background: #fff; color: #0b0d0f; border-color: #fff; }
#settings input[type="range"] { width: 100%; accent-color: #fff; margin: 4px 0 2px; }
.tog { position: relative; width: 46px; height: 26px; border-radius: 13px; border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.1); cursor: pointer; padding: 0; }
.tog i { position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.tog[aria-checked="true"] { background: #4caf7a; border-color: #4caf7a; }
.tog[aria-checked="true"] i { transform: translateX(20px); }
.sfoot { font-size: 11px; letter-spacing: 0.18em; opacity: 0.5; text-align: right; padding-top: 6px; }

/* ---------- touch screens (src/ui/touch.js): on-screen controls, a bigger HUD, the turn-sideways card ---------- */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body.touch { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body.touch #c { touch-action: none; }
#touch { position: fixed; inset: 0; z-index: 30; pointer-events: none; touch-action: none; }
#touch[hidden] { display: none; }
#touch > * { pointer-events: auto; }
.tsteer, .tbtn { display: grid; place-items: center; color: #fff; background: rgba(10, 12, 14, 0.34); border: 1.5px solid rgba(255,255,255,0.3);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); text-shadow: 0 1px 2px rgba(0,0,0,0.4); transition: background 0.08s, color 0.08s; }
.tsteer { position: absolute; left: calc(18px + env(safe-area-inset-left)); bottom: calc(18px + env(safe-area-inset-bottom));
  width: clamp(170px, 30vw, 280px); height: clamp(88px, 27vh, 132px); grid-template-columns: 1fr 1fr; border-radius: 999px; overflow: hidden; }
.tsteer span { display: grid; place-items: center; width: 100%; height: 100%; font-size: clamp(26px, 8vh, 40px); }
.tsteer .tl { border-right: 1px solid rgba(255,255,255,0.18); }
.tsteer.l .tl, .tsteer.r .tr, .tbtn.on { background: rgba(255,255,255,0.88); color: #0b0d0f; text-shadow: none; }
.tpad { position: absolute; right: calc(18px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(2, clamp(78px, 13vw, 124px)); grid-template-rows: clamp(46px, 14vh, 66px) clamp(80px, 25vh, 122px); gap: 10px; }
.tbtn { border-radius: 16px; font-weight: 700; font-size: clamp(13px, 3.6vh, 17px); letter-spacing: 0.14em; }
.t-pedal { border-color: rgba(255,255,255,0.5); }
.tbtn.glow:not(.on) { animation: tglow 1.1s ease-in-out infinite; }
@keyframes tglow { 50% { background: rgba(255,255,255,0.32); border-color: #fff; } }
.tpause { position: absolute; left: calc(70px + env(safe-area-inset-left)); top: 16px; width: 44px; height: 44px; display: flex; gap: 5px;
  align-items: center; justify-content: center; padding: 0; background: rgba(10, 12, 14, 0.5); border: 1px solid rgba(255,255,255,0.16); border-radius: 50%; cursor: pointer; }
.tpause i { width: 4px; height: 14px; border-radius: 1px; background: #fff; }
body.touch #settingsBtn { left: calc(16px + env(safe-area-inset-left)); }
.cardacts { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }

/* the HUD is sized in vh for a desktop window; on a phone held sideways that is tiny, so it gets floors in px. The
   bike computer on the bars shows grade and altitude, so the profile corner (under the steering pad) goes. */
body.touch .x-touch, body.touch #profile, body.touch .alt, body.touch .grade { display: none; }
body.touch #map { right: auto; left: calc(18px + env(safe-area-inset-left)); top: 72px;
  width: clamp(84px, calc(100vh - 72px - clamp(88px, 27vh, 132px) - 32px - env(safe-area-inset-bottom)), 150px); height: auto; aspect-ratio: 1; }
body.touch .lbl { font-size: max(1.9vh, 10px); }
body.touch .val { font-size: max(4.8vh, 20px); }
body.touch .esub { font-size: max(1.7vh, 9px); }
body.touch .egauge { width: max(16vh, 64px); height: max(1.3vh, 6px); }
/* the column sits over the PEDAL / BRAKE pad (.tpad: two rows and a 10 px gap); energy and power side by side */
body.touch .rtop { flex-direction: row; align-items: flex-end; gap: 16px; }
body.touch .rcol { gap: 6px; right: calc(18px + env(safe-area-inset-right));
  bottom: calc(18px + clamp(46px, 14vh, 66px) + clamp(80px, 25vh, 122px) + 10px + 10px + env(safe-area-inset-bottom)); }
body.touch #spd { font-size: max(10.5vh, 36px); }
body.touch #spdU { font-size: max(2.6vh, 11px); }
body.touch .timer { right: calc(16px + env(safe-area-inset-right)); top: 14px; }
body.touch #time { font-size: max(5.4vh, 24px); }
body.touch #togo { font-size: max(1.9vh, 10px); }
body.touch #split { font-size: max(2.6vh, 13px); }
body.touch #pace { font-size: max(2.4vh, 12px); top: 16px; }
body.touch #pace .arrow { font-size: max(3vh, 15px); }
body.touch #draft { font-size: max(2.1vh, 11px); top: max(8.6vh, 40px); }
body.touch #hint { font-size: max(2.3vh, 12px); bottom: calc(22px + env(safe-area-inset-bottom)); }
body.touch #center .big { font-size: max(9vh, 40px); }
body.touch #center .count { font-size: max(16vh, 64px); }
body.touch #center .small { font-size: max(2.4vh, 12px); }
body.touch #toast { font-size: max(2.1vh, 12px); bottom: max(6vh, 28px); }

/* short screens (phones sideways): tighter cards so the call to action stays in view */
@media (max-height: 520px) {
  .card { padding: 18px 24px 16px; }
  .card.small { width: min(460px, 100%); }
  .title { font-size: 42px; }
  .kicker { font-size: 12px; }
  .sub { font-size: 14px; }
  .best { margin-top: 10px; font-size: 13px; }
  .board { margin-top: 10px; padding-top: 8px; }
  .blist { font-size: 15px; }
  .blist li { padding: 1px 6px; }
  .cta { margin-top: 12px; font-size: 16px; }
  .card button.link { margin-top: 8px; }
  .card button.start { margin-top: 12px; min-height: 44px; font-size: 18px; }
  .stats, .splits { margin-top: 10px; font-size: 17px; }
  .post { margin-top: 10px; }
  /* ABOUT wider and tighter, so it fits without scrolling */
  #about .card.small { width: min(640px, 100%); }
  #about .title { font-size: 32px; }
  #about .sub { font-size: 14px; line-height: 1.45; }
  #about .factions { margin-top: 10px; }
}

/* held upright: suggest turning the phone (PLAY UPRIGHT ANYWAY dismisses it) */
#rotate { display: none; }
@media (orientation: portrait) {
  body.touch:not(.upright-ok) #rotate { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px;
    background: rgba(5, 6, 8, 0.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
}
#rotate .card { text-align: center; }
#rotate .title { font-size: 40px; margin-top: 18px; }
#rotate .sub { line-height: 1.4; }
#rotate .phone { width: 46px; height: 78px; margin: 4px auto 0; border: 3px solid #fff; border-radius: 10px; position: relative;
  animation: turn 2.4s ease-in-out infinite; }
#rotate .phone i { position: absolute; left: 50%; bottom: 5px; width: 10px; height: 3px; margin-left: -5px; border-radius: 2px; background: #fff; }
@keyframes turn { 0%, 25% { transform: rotate(0deg); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0deg); } }
@media (prefers-reduced-motion: reduce) { #rotate .phone { animation: none; transform: rotate(-90deg); } .tbtn.glow:not(.on) { animation: none; border-color: #fff; } }
