/* Slideways Rally — © 2026 Redwork Studio. Wszelkie prawa zastrzeżone. All rights reserved. */
/* =========================================================================
 * Slideways Rally — the page's styles (#537), one section per component:
 *   tokens · page · backdrop and screens · buttons · panels, cards, chips · settings and controls · tables and
 *   results · loading, toasts · HUD · touch pads · rotate hint · short screens · start screen · road book · tabs ·
 *   goal card · menu odds and ends · guide · motion
 * Two menu faces (#313): html[data-ui="led"] (dot-matrix board on asphalt) and html[data-ui="blocks"] (stone and
 * grass); their rules sit with the component they dress. Text is drawn by RALLY.MenuText / the HUD as pixel-font
 * canvases sized from the CSS font-size and coloured from the CSS colour. Hard edges: no blur, no rounded menu boxes.
 * rem follows the window (HUD.resize); --u is 1 % of a 16:9 box on the screens laid out in it.
 * ========================================================================= */

/* ------------------------------------------------------------------ tokens */
:root {
  --ink: #ffffff; --dim: #c4c4c4; --yellow: #ffd23c; --yellow-d: #c99a00; --blue: #3d6fe0; --red: #ff5555; --green: #55ff55;
  /* good and bad beside the plain ones (U19): soft for small text on dark panels, hi for a bevel's light edge; bars fill green */
  --green-soft: #7fe08a; --green-hi: #9dffb0; --red-soft: #ff7a6a; --red-warm: #ff8a6a; --bar-fill: #3ddc5c; --bar-track: rgba(128, 128, 128, .35);
  --font: "Courier New", Menlo, Consolas, "Liberation Mono", monospace; --display: var(--font);
  --px: 4px;   /* bevel */
  /* the rally plates (#55) */
  --asphalt: #15181e; --asphalt-2: #1c2027; --plate: #262b35; --plate-hi: #343b48; --rally-red: #c41a22; --rally-red-hi: #e2343b;
  /* the two menu faces (#313) */
  --ui-asph: #1b1715; --ui-list: #2d2622; --ui-lava: #ff5a1f; --ui-lava-d: #b8300e; --ui-lava-l: #ff8a4a; --ui-ember: #ff9a2e; --ui-spark: var(--yellow);
  --ui-stone: #6f6f6f; --ui-stone-hi: #a8a8a8; --ui-stone-d: #4a4a4a; --ui-grass: #5fa23a; --ui-grass-hi: #8fd060; --ui-dirt: #8a6238; --ui-plank: #a8824e;
  --ui-noise: repeating-conic-gradient(rgba(0,0,0,.16) 0 25%, rgba(255,255,255,.07) 0 50%);
  /* touch pads: size step, steering pad, safe areas */
  --ts: 1; --pad: clamp(68px, 24vh, 118px); --steer: calc(clamp(84px, 30vh, 150px) * var(--ts)); --steer-x: calc(var(--tsafe-l) + 30px);
  --tsafe-l: env(safe-area-inset-left, 0px); --tsafe-r: env(safe-area-inset-right, 0px); --tsafe-t: env(safe-area-inset-top, 0px); --tsafe-b: env(safe-area-inset-bottom, 0px);
  /* menu screens (U14, U15): --u is 1 % of a 16:9 box inside the safe area; a phone's box is a little taller */
  --safe-w: calc(100vw - var(--tsafe-l) - var(--tsafe-r)); --safe-h: calc(100vh - var(--tsafe-t) - var(--tsafe-b));
  --u-desk: min(calc(var(--safe-w) / 100), calc(var(--safe-h) * .017778)); --u-phone: min(calc(var(--safe-w) / 100), calc(var(--safe-h) * .0205));
  /* the asphalt the full-screen menus stand on, per face */
  --asph-bg: repeating-linear-gradient(135deg, var(--asphalt) 0 18px, var(--asphalt-2) 18px 36px);
  /* own shorthands */
  --edge: #05070d; --ring: 0 0 0 3px #000; --drop: 0 4px 0 rgba(0,0,0,.45);
  --lava-press: inset 4px 4px 0 var(--ui-lava-l), inset -4px -4px 0 #5a1203;
  --grass-press: inset 4px 4px 0 var(--ui-grass-hi), inset -4px -4px 0 #2f5a1c;
  --stone-dots: var(--ui-noise) 0 0 / 8px 8px;
  --row-pick: #2353e0;
}

/* -------------------------------------------------------------------- page */
* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
html { background: #000; font-size: 16px; }
html, body {
  height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
  color: var(--ink); font-family: var(--font); font-weight: 700; text-transform: uppercase;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%;
}
body { background: #000; --steer: calc(clamp(84px, 30vh, 150px) * var(--ts)); }   /* on body, where the size class sets --ts */
button { color: inherit; font-family: inherit; font-weight: inherit; text-transform: inherit; }
:is(canvas, img).px { image-rendering: pixelated; }
img.shot { object-fit: cover; image-rendering: auto !important; }   /* the stages' real pictures (#524): photos, not pixel art */
.pxt { vertical-align: top; display: inline-block; }
.hidden { display: none !important; }   /* above every layout rule */
#app { overflow: hidden; position: fixed; inset: 0; }
#viewport, #viewport canvas { display: block; width: 100%; height: 100%; position: absolute; inset: 0; }
#viewport { touch-action: none; }

/* ------------------------------------------------------ backdrop and screens */
.menu-bg { overflow: hidden; position: absolute; inset: 0; background: #4a86d0; transition: opacity .6s ease; }
.menu-bg .menu-bg-cv { display: block; width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
body.has-scene .menu-bg { pointer-events: none; opacity: 0; }   /* the live scene takes over (#159) */
.ui { z-index: 20; position: absolute; inset: 0; }
.screen {
  display: flex; flex-direction: column; overflow-y: auto; position: absolute; inset: 0; padding: 4.5vh 6vw 3.5vh;
  touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; animation: fadein .3s steps(3, end);
}
/* scroll bars: chunky and square, in the face's colours, on every list that scrolls (#724, CrazyGames QA: the lists had
   the system's white bar). Phones and tablets draw their own (scroll-bar.js, #644), the screen keeps its old one. */
:root { --sb-track: #111111; --sb-thumb: var(--plate-hi); }
html[data-ui="led"] { --sb-track: #0f0c0b; --sb-thumb: var(--ui-ember); }
html[data-ui="blocks"] { --sb-track: #1e1c1a; --sb-thumb: var(--ui-plank); }
.screen::-webkit-scrollbar, body:is(:not(.is-mobile), .is-compact) *::-webkit-scrollbar { width: 12px; height: 12px; }
.screen::-webkit-scrollbar { width: 1rem; }
.screen::-webkit-scrollbar-track, body:is(:not(.is-mobile), .is-compact) *::-webkit-scrollbar-track { background: var(--sb-track); }
.screen::-webkit-scrollbar-thumb, body:is(:not(.is-mobile), .is-compact) *::-webkit-scrollbar-thumb { border: 3px solid var(--edge); background: var(--sb-thumb); }
body:is(:not(.is-mobile), .is-compact) *::-webkit-scrollbar-corner { background: var(--sb-track); }
/* Firefox has no ::-webkit-scrollbar; in Chrome scrollbar-color would switch the rules above off, so only there */
@supports not selector(::-webkit-scrollbar) { * { scrollbar-color: var(--sb-thumb) var(--sb-track); } }
/* full-screen menus and the loading / rotate screens stand on asphalt: the list once, the face in --asph-bg (U15) */
html[data-ui="led"] { --asph-bg: repeating-linear-gradient(135deg, var(--ui-asph) 0 18px, #221d1a 18px 36px); }
html[data-ui="blocks"] { --asph-bg: var(--ui-noise) 0 0 / 16px 16px, #33302c; }
.screen-stages, .screen-settings, .screen-help, .screen-privacy, .screen-controls, .screen-champIntro, .screen-daily, .screen-gymkhana, .screen-cars, .screen-history, .screen-historyRun, .screen-mp, .screen-mpLobby, .screen-mpResults, .screen-mpRoom, .screen-mpReports, .screen-mpReport, .screen-raceChoice, .screen-todayChoice, .loading, .rotate {
  background: var(--asph-bg); box-shadow: none; image-rendering: pixelated;
}
/* the screens laid out in --u keep out of a notch (U14): a transparent border as wide as the safe area, the background
   runs under it; their absolute rows measure from inside it */
.screen-main, .screen-stages, .screen-settings, .screen-help, .screen-privacy, .screen-controls, .screen-champIntro, .screen-daily, .screen-gymkhana, .screen-cars, .screen-history, .screen-historyRun, .screen-mp, .screen-mpLobby, .screen-mpResults, .screen-mpRoom, .screen-mpReports, .screen-mpReport, .screen-raceChoice, .screen-todayChoice {
  --u: var(--u-desk); border: 0 solid transparent; border-width: var(--tsafe-t) var(--tsafe-r) var(--tsafe-b) var(--tsafe-l); background-origin: border-box;
}
body.is-mobile :is(.screen-main, .screen-stages, .screen-settings, .screen-cars, .screen-history, .screen-historyRun, .screen-help, .screen-privacy) { --u: var(--u-phone); }
/* the screen header (BACK + title, #1209) in one unit on every screen, whichever --u the screen below it has */
:root { --u-top: var(--u-desk); }
body.is-mobile { --u-top: var(--u-phone); }
/* overlays over the race */
.screen-pause { justify-content: center; align-items: center; background: rgba(0, 0, 0, .62); }
.screen-results, .screen-champion { background: rgb(0 0 0 / .74); }
.screen-driver { justify-content: center; align-items: center; background: rgba(0, 0, 0, .6); }

/* headings, tips, footers */
.head h2 { margin: 0; color: #fff; font: 900 2.6rem/1 var(--font); }
.head h2::after { content: ""; display: block; width: 8rem; height: .5rem; margin-top: .8rem; background: var(--yellow); box-shadow: var(--ring); }
html[data-ui="led"] .head h2::after { background: repeating-linear-gradient(135deg, var(--ui-spark) 0 .7rem, var(--ui-asph) .7rem 1.4rem); }
html[data-ui="blocks"] .head h2::after { background: linear-gradient(var(--ui-grass) 0 40%, var(--ui-dirt) 40%); }
.head p { max-width: 52rem; margin: 1rem 0 0; color: var(--dim); font-size: 1.2rem; }
.head.center { text-align: center; }
.head.center h2::after { margin-right: auto; margin-left: auto; }
.screen-pause .head { margin: 0 0 2rem; }
.tip { max-width: 60rem; margin: 1.4rem 0 0; color: var(--dim); font-size: 1.1rem; }
.top-sub { max-width: 60rem; margin: 0 0 .4rem; color: var(--dim); font-size: 1.1rem; }
/* primary button first in the DOM, drawn on the far right (#383) */
.row-foot { display: flex; flex-flow: row-reverse wrap; gap: 1.2rem; margin-top: auto; padding-top: 1.8rem; }
/* the screen's main action and the buttons beside it (#1210): one height, letter size and padding on every menu screen
   (CHOOSE, DRIVE, PLAY, QUICK RACE, START, CONTINUE, NEXT), in the header's unit; A2's PLAY is its own, bigger thing */
body { --cta-h: max(40px, calc(4.69 * var(--u-top))); --cta-fs: max(13px, calc(2.2 * var(--u-top))); --cta-pad: calc(1.6 * var(--u-top)); }
:is(.btn.stage-play, .row-foot > .btn, .champ-round > .btn) { display: flex; justify-content: center; align-items: center; min-width: max-content; height: var(--cta-h); padding: 0 var(--cta-pad); font-size: var(--cta-fs); }
.champ-round > .btn { flex-direction: column; align-items: stretch; min-width: 0; height: auto; min-height: var(--cta-h); }   /* the label the card's width: a long PLAY: ROOKIE CUP wraps inside it */

/* ----------------------------------------------------------------- buttons */
.menu-col { width: 30rem; max-width: 90vw; display: flex; flex-direction: column; gap: 1rem; }
.btn {
  position: relative; padding: .85rem 1.4rem; appearance: none; cursor: pointer;
  border: 3px solid var(--edge); background: var(--plate); color: #fff; image-rendering: pixelated;
  font: 800 1.3rem var(--font); text-align: center; text-shadow: none;
  box-shadow: inset .45rem 0 0 var(--rally-red), 0 0 0 2px var(--edge), var(--drop);
}
.btn > span { display: block; }   /* the label's box: a long label wraps inside the button */
.btn .pxt { display: flex; justify-content: center; }   /* no line box under the drawn text (#666): the label sat high, the font's line height below it */
.btn.big { padding: 1rem 1.4rem; font-size: 1.45rem; }
.btn.primary { border-color: #b9f08c #1f5a16 #1f5a16 #b9f08c; background: var(--rally-red); background-blend-mode: multiply; box-shadow: inset 0 3px 0 var(--rally-red-hi), 0 0 0 2px var(--edge), var(--drop); }
.btn.ghost { background: #1d2129; background-blend-mode: multiply; }
.btn.focus { border-color: #fff; background: #1f4fd8; background-blend-mode: multiply; box-shadow: inset .45rem 0 0 var(--yellow), var(--ring), 0 0 0 6px var(--yellow); }
.btn.primary.focus { background: var(--rally-red-hi); }
.btn.disabled { pointer-events: none; opacity: .45; }
html[data-ui="led"] .btn, html[data-ui="led"] .select .arr {
  border: 3px solid #000; background: var(--ui-asph); color: #fff3dc; box-shadow: inset 4px 4px 0 #5a504a, inset -4px -4px 0 #000;
  clip-path: polygon(0 .6rem, .6rem 0, 100% 0, 100% calc(100% - .6rem), calc(100% - .6rem) 100%, 0 100%);
}
html[data-ui="led"] .btn.primary { background: linear-gradient(var(--ui-spark) 0 50%, var(--ui-ember) 50%); color: #2b1200; box-shadow: inset 4px 4px 0 #fff0a8, inset -4px -4px 0 #8a3a00; }
html[data-ui="led"] .btn.ghost { background: #241e1b; }
html[data-ui="led"] .btn.focus, html[data-ui="led"] .select .arr:hover { border-color: #000; background: var(--ui-lava-d); color: #fff; box-shadow: var(--lava-press); }
html[data-ui="led"] .btn.primary.focus { background: linear-gradient(#ffe27a 0 50%, #ffae4a 50%); color: #2b1200; box-shadow: inset 4px 4px 0 #fff, inset -4px -4px 0 var(--ui-lava-d); }
html[data-ui="blocks"] .btn, html[data-ui="blocks"] .select .arr { border: 3px solid #000; background: var(--stone-dots), var(--ui-stone); color: #fff; box-shadow: inset 5px 5px 0 var(--ui-stone-hi), inset -5px -5px 0 rgba(0,0,0,.5); }
html[data-ui="blocks"] .btn.primary { background: var(--stone-dots), linear-gradient(var(--ui-grass) 0 32%, var(--ui-dirt) 32%); box-shadow: inset 5px 5px 0 var(--ui-grass-hi), inset -5px -5px 0 rgba(0,0,0,.45); }
html[data-ui="blocks"] .btn.ghost { background: var(--stone-dots), #5a5a5a; }
html[data-ui="blocks"] .btn.focus, html[data-ui="blocks"] .select .arr:hover { border-color: var(--ui-spark); background: var(--stone-dots), #8a8a8a; box-shadow: inset 5px 5px 0 #d0d0d0, inset -5px -5px 0 rgba(0,0,0,.5), var(--ring); }
html[data-ui="blocks"] .btn.primary.focus { background: var(--stone-dots), linear-gradient(#7cc44c 0 32%, #a07446 32%); }
/* fingers need room */
body:is(.is-touch, .is-mobile) .btn { display: flex; justify-content: center; align-items: center; min-height: 52px; }
body.is-touch .menu-col { gap: 1.1rem; }   /* a little more room between fingers */
.var-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.2rem; }
.var-row .var-btn { padding: .55rem 1rem; font-size: 1rem; }
.setup-btn { margin-left: auto; }   /* the car button keeps to the right */

/* --------------------------------------------------- panels, cards, chips */
.panel {
  margin-top: 1.8rem; padding: 1.2rem 1.5rem; border: 3px solid var(--edge); background: rgba(28, 32, 39, .94); background-blend-mode: multiply; image-rendering: pixelated;
  box-shadow: inset 0 4px 0 var(--rally-red), 0 0 0 2px var(--edge);
}
.panel h3 { margin: .5rem 0 .6rem; color: var(--yellow); font: 800 1.15rem var(--font); }
html[data-ui="led"] .panel { border: 3px solid #000; background: rgba(27, 23, 21, .95); box-shadow: inset 4px 4px 0 var(--ui-lava-l), inset -4px -4px 0 #000; }
html[data-ui="blocks"] .panel { border: 3px solid #000; background: var(--ui-noise) 0 0 / 12px 12px, rgba(74, 74, 74, .96); box-shadow: inset 5px 5px 0 #7a7a7a, inset -5px -5px 0 rgba(0,0,0,.55); }
html[data-ui="blocks"] .panel h3 { color: #fff; }

.thumb { overflow: hidden; position: relative; aspect-ratio: 2 / 1; border-bottom: 3px solid #000; background: #000; }
.thumb img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.thumb .lock {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: .3rem; position: absolute; inset: 0; padding: 0 .6rem;
  background: rgba(0, 0, 0, .45); color: #fff; font: 800 1rem var(--font); text-align: center;
}
.thumb .lock span { max-width: 100%; }   /* GOLD MEDALS 0/3 wraps inside a narrow card (#441) */
.thumb .padlock { position: relative; width: 2.2rem; height: 1.7rem; margin-top: 1.1rem; border: 3px solid #000; background: #f2c94c; }
.thumb .padlock::before { content: ''; position: absolute; right: .3rem; bottom: 100%; left: .3rem; height: 1.1rem; border: 4px solid #000; border-bottom: 0; }
.thumb .padlock::after { content: ''; position: absolute; top: .35rem; left: 50%; width: 4px; height: .6rem; margin-left: -2px; background: #000; }
.cbody { position: relative; padding: 1.1rem 1rem 1rem; background: none; }
.cbody::before {   /* a chequered strip over the name */
  content: ""; position: absolute; top: 0; right: 0; left: 0; height: 8px; border-bottom: 3px solid #000;
  background: repeating-linear-gradient(90deg, #f2f2f2 0 12px, var(--edge) 12px 24px);
}
.cname { margin-top: .5rem; color: #fff; font: 900 1.35rem var(--font); }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .8rem 0; }
.chip { display: inline-block; padding: .25rem .6rem; border: 3px solid #000; background: #444; color: #fff; font-size: 1rem; font-weight: 800; }
.chip.s0 { background: #4a4d55; }
.chip.s1 { background: #8d7756; }
.chip.s2 { background: #7d98b3; }
.chip.s3 { background: #5b4632; }
.chip.s4 { background: #5f9dc4; }
.chip.s5 { background: #55702f; }
.cstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; padding-top: .7rem; border-top: 3px solid #000; }
.cstats small { display: block; color: #aeb7c4; font-size: .85rem; }
.cstats b { display: block; margin-top: .2rem; font: 800 1.05rem var(--font); }
.gold { color: var(--yellow); }   /* a record, a win */
.good { color: var(--green) !important; }
.bad { color: var(--red) !important; }
.badge {
  display: inline-block; margin-top: .5rem; padding: .25rem .7rem; border: 3px solid #000; background: var(--yellow); color: #3a2a00;
  font: 800 1.1rem var(--font); animation: mcr-pop .36s steps(4, end) both;   /* one pop in, no white flash (U8) */
}
.badge.unlock { margin-left: .5rem; background: var(--green-soft); color: #0e3a12; }
/* the gold medal (#464: the only one) */
.medal {
  display: inline-block; width: 1em; height: 1em; margin-right: .3em; vertical-align: -.05em; border: 2px solid #000; background: #666;
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.35), inset 2px 2px 0 rgba(255,255,255,.35);
}
.medal.gold { background: var(--yellow); }
.medal.silver { background: #d9dde6; }
.medal.bronze { background: #c97a3a; }
/* a gold on Junior (#1059): a star, not the gold square */
.medal.star { border: 0; background: var(--yellow); box-shadow: none; filter: drop-shadow(1px 1px 0 #000);
  clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 61%, 80% 100%, 50% 77%, 20% 100%, 30% 61%, 0 38%, 38% 36%); }

/* ----------------------------------------------------- settings and controls */
.settings { max-width: 56rem; }   /* settings, the car's handling, the guide */
.set-group { --acc: #b8791a; margin-top: 1.3rem; padding: 0 1.5rem .8rem; }
.set-group:first-child { margin-top: 1.8rem; }   /* as far from the title as any panel */
.set-group.g-audio { --acc: #2f5fd0; }
.set-group.g-drive { --acc: #2f8f3a; }
.set-group.g-gfx { --acc: #8a4fc4; }
.set-group h3 {   /* the section's colour band, a shine runs over it */
  display: flex; align-items: center; gap: .8rem; overflow: hidden; position: relative; margin: 0 -1.5rem .7rem; padding: .55rem 1.5rem;
  border-bottom: 3px solid #000; background: var(--acc); color: #fff; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35), inset 0 -3px 0 rgba(0, 0, 0, .35);
}
.set-group h3::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -5rem; width: 2.6rem; pointer-events: none; background: rgba(255, 255, 255, .28);
  transform: skewX(-20deg); animation: mcr-shine 3.4s steps(18, end) infinite;
}
.set-group h3 i { padding: .2rem .45rem; border: 3px solid; border-color: #000 #6a6a6a #6a6a6a #000; background: #141414; color: #fff; font-style: normal; }
.set-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 22rem; align-items: center; gap: 1rem; position: relative;
  margin: .15rem -.9rem; padding: .4rem .9rem; cursor: pointer; border: 3px solid transparent;
}
.set-row:nth-child(even) { background: rgba(0, 0, 0, .22); }
.set-row.focus { border-color: #fff; background: var(--row-pick); box-shadow: inset .55rem 0 0 var(--yellow), var(--ring); }
.set-row.focus::before {   /* a nudging arrow at the focused row */
  content: ""; position: absolute; top: 50%; left: -1.6rem; width: 0; height: 0; transform: translateY(-50%);
  border-top: .55rem solid transparent; border-bottom: .55rem solid transparent; border-left: .7rem solid var(--yellow);
  filter: drop-shadow(2px 0 0 #000) drop-shadow(-1px 0 0 #000); animation: mcr-nudge .6s steps(2, end) infinite;
}
html[data-ui="led"] .set-row.focus { border-color: #000; background: var(--ui-lava-d); box-shadow: inset .55rem 0 0 var(--ui-spark), var(--ring); }
html[data-ui="blocks"] .set-row.focus { border-color: #000; background: var(--ui-grass); box-shadow: var(--grass-press), var(--ring); }
body:is(.is-touch, .is-mobile) .set-row { min-height: 56px; }
.set-label { min-width: 0; color: #fff; font-size: 1.2rem; font-weight: 800; }
.set-label small { display: block; margin-top: max(.3rem, 6px); color: #ffe08a; font-size: 1rem; font-weight: 700; }   /* clear of the name's letters (#1206) */
.set-label small.diff-blurb { max-width: 30rem; margin-top: .2rem; color: var(--yellow); }
/* value controls: a dark well; a slider fills green, a choice has arrows, a notch row has five blocks */
.slider {
  overflow: hidden; position: relative; height: 2.3rem; cursor: ew-resize; touch-action: none;
  border: 3px solid; border-color: #000 #6a6a6a #6a6a6a #000; background: #08090b;
}
.slider .fill { position: absolute; top: 0; bottom: 0; left: 0; background: var(--bar-fill); box-shadow: inset 0 3px 0 var(--green-hi), inset 0 -3px 0 #1f8f38; }
.slider .val { display: flex; justify-content: center; align-items: center; position: absolute; inset: 0; color: #fff; font-size: 1rem; font-weight: 800; }
.select { display: flex; justify-content: space-between; align-items: center; height: 2.3rem; border: 3px solid; border-color: #000 #6a6a6a #6a6a6a #000; background: #08090b; }
.select .val { flex: 1; cursor: pointer; color: var(--yellow); font-size: 1.05rem; font-weight: 800; text-align: center; }
.select .arr {
  width: 2.6rem; height: 100%; padding: 0; appearance: none; cursor: pointer; border: 3px solid var(--edge); background: var(--plate); color: #fff;
  font-size: 1.6rem; font-weight: 900; box-shadow: inset .45rem 0 0 var(--rally-red), 0 0 0 2px var(--edge), var(--drop);
}
.select .arr:hover { border-color: #fff; background: #1f4fd8; background-blend-mode: multiply; box-shadow: inset .45rem 0 0 var(--yellow), var(--ring), 0 0 0 6px var(--yellow); }
body:is(.is-touch, .is-mobile) :is(.select, .slider) { height: max(2.3rem, 46px); }
body:is(.is-touch, .is-mobile) .select .arr { width: 48px; min-width: 48px; }
.notch .blocks { display: flex; flex: 1; justify-content: center; align-items: center; gap: .35rem; padding: 0 .5rem; }
.notch .blk { flex: 1; height: 1.2rem; cursor: pointer; border: 3px solid; border-color: #000 #4a4e56 #4a4e56 #000; background: #1a1c20; }
.notch .blk.mid { background: #2c2f36; }
.notch .blk.on { border-color: var(--green-hi) #1f8f38 #1f8f38 var(--green-hi); background: #45f06a; }
.notch .blk.cur {   /* the value pops in, then blinks */
  border-color: #fff #a08000 #a08000 #fff; background: #ffdd33; box-shadow: 0 0 0 2px #000, 0 0 .6rem var(--yellow);
  animation: mcr-pop .3s steps(3, end), mcr-cur 1.2s steps(2, end) .3s infinite;
}
/* the name field: the browser keeps the typing, the letters are the game's (#1206): the input's own text and caret are
   see-through, .name-px over it draws the name (or the placeholder) in the pixel font with a block cursor */
.name-wrap { position: relative; }
.name-wrap input.name {
  width: 100%; height: 100%; padding: 0 .7rem; outline: none; border: 0; background: #14171d; color: transparent; caret-color: transparent;
  font: 800 1.1rem var(--font); text-transform: none; box-shadow: inset 0 0 0 2px #3a3f4a;
}
.name-wrap input.name:focus { box-shadow: inset 0 0 0 2px var(--yellow); }
.name-wrap input.name::placeholder { color: transparent; }
.name-px { display: flex; align-items: center; position: absolute; inset: 0 .7rem; overflow: hidden; pointer-events: none; color: #fff; font-size: 1.1rem; white-space: nowrap; }
.name-px.empty { color: #7f8794; }
.name-px :is(.name-t, .pxt) { display: flex; }   /* no line box under the drawn letters (as on buttons, #666) */
.name-px i { display: none; width: .6em; height: 1em; margin-left: 2px; background: var(--yellow); animation: name-caret 1s steps(2, end) infinite; }
.name-wrap input.name:focus + .name-px i { display: block; }
@keyframes name-caret { 50% { opacity: 0; } }
/* the car's handling panel (#465) */
/* key rows: the key on the right lights up */
.ctl-wrap { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.ctl { flex: 1; min-width: 24rem; }
.ctl-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .2rem 1rem; padding: .5rem 0; border-bottom: 3px solid rgba(0, 0, 0, .5); font-size: 1.15rem; }
.ctl-row span { flex: 1 1 9em; min-width: 0; }   /* 9em: room for its longest word (HANDBRAKE) before the key moves under it */
.ctl-row kbd { margin-left: auto; }   /* a narrow column: the key under its name, never over it (STEER under PADS OR SLIDER, #1224) */
/* the screen stays still, a short window scrolls a panel's list; RESET KEYS stays under it in view (#1207) */
.screen-controls { overflow: hidden; }
.screen-controls .ctl-wrap { flex: 1 1 0; align-items: flex-start; min-height: 0; margin-top: 1.2rem; padding-bottom: 6px; overflow-y: auto; }   /* columns wrapped in a narrow window: they scroll here */
.screen-controls .ctl { display: flex; flex-direction: column; max-height: 100%; min-height: 0; margin: 0; box-sizing: border-box; }
.ctl-list { flex: 0 1 auto; min-height: 5rem; overflow-y: auto; padding-right: .3rem; }
@media (max-height: 420px) { .screen-controls :is(.top-sub, .tip) { display: none; } }   /* a low window: the lists get the room */
.ctl > .btn { flex: none; align-self: flex-start; margin-top: .8rem; }
.ctl-side { display: flex; flex: 1; flex-direction: column; min-width: 24rem; max-height: 100%; min-height: 0; }
.screen-controls .ctl-side > .ctl { flex: 0 1 auto; min-width: 0; }
.ctl-side > .tip { flex: none; margin: 1rem 0 0; }
.screen-controls .ctl-row { padding: .35rem 0; }   /* nine keys and RESET KEYS in a 1280x720 window */
.screen-controls kbd { padding: .2rem .6rem; }
kbd { padding: .3rem .7rem; border: 3px solid var(--edge); background: var(--plate-hi); color: #fff; font: 800 1rem var(--font); box-shadow: 0 3px 0 var(--edge); }
.keyrow { width: 100%; cursor: pointer; border-top: 0; border-right: 0; border-left: 0; background: none; color: inherit; font: inherit; text-align: left; }
.keyrow.focus kbd, .keyrow[data-focus] kbd { background: var(--yellow); color: #3a2a00; }
html[data-ui="led"] .keyrow.focus kbd { background: var(--ui-ember); color: #2b1200; }
html[data-ui="blocks"] .keyrow.focus kbd { background: var(--ui-grass); color: #fff; }
.keyrow kbd { max-width: 62%; font-size: .95em; text-align: right; white-space: normal; }

/* -------------------------------------------------------- tables, results */
.res-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; gap: 1.8rem; }
.res-main { gap: 1rem 1.5rem; display: grid; grid-template-columns: 1fr 1fr; }
.res-pos small, .res-time small { color: var(--dim); font-size: 1rem; display: block; }
.res-pos b { display: flex; align-items: flex-start; color: var(--ink); font: 900 4rem/1.1 var(--font); }
.res-pos.podium b { color: var(--yellow); }
.res-pos sup { vertical-align: top; font-size: 1.6rem; }
.res-pos em { color: var(--dim); font-size: 1.1rem; font-style: normal; }
.res-time b { font: 900 3.2rem/1.1 var(--font); display: block; }
.res-lines { grid-column: 1 / -1; }   /* across the whole run panel */
.res-lines > div { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 3px solid rgba(0, 0, 0, .5); font-size: 1.15rem; }
.res-lines span { min-width: 0; color: var(--dim); }
/* label and value never overlap (#717); a value's extra (the reason, NEW, the leader) drops under it, right-aligned,
   rather than being cut, and a value too long beside its label takes the next line (#720) */
.res-lines > div { flex-wrap: wrap; }
.res-lines > div > span { overflow: hidden; flex: 0 1 auto; }
.res-lines > div > b { display: flex; overflow: hidden; flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 3px .4rem; white-space: nowrap; }
.res-lines > div > b > i { margin-left: 0; }
.res-lines i { margin-left: .5rem; font-style: normal; font-weight: 800; }
/* #717/#720: the pixel text never drops below 2 px a dot, so a time is wider than a column in rem on a smaller screen
   and ran onto the gap. Every table's columns are the text's own width, shared by its rows (a row without subgrid
   sizes its own); only the name gives way */
.board { display: grid; grid-template-columns: auto minmax(0, 1fr) max-content max-content; column-gap: max(.6rem, 8px); align-content: start; }
.board > :not(.brow) { grid-column: 1 / -1; }
.board .brow { display: grid; grid-column: 1 / -1; grid-template-columns: auto minmax(0, 1fr) max-content max-content; grid-template-columns: subgrid; gap: max(.6rem, 8px); padding: .28rem .5rem; border-bottom: 3px solid rgba(0, 0, 0, .45); font-size: 1.1rem; }
.board .brow > span:only-child { grid-column: 1 / -1; }   /* "No records yet" */
.brow span { overflow: hidden; white-space: nowrap; }
.board.wide .brow { font-size: 1.2rem; }
.brow i { color: var(--dim); font: 900 1.1rem var(--font); font-style: normal; }
.brow em { color: var(--dim); font-style: normal; text-align: right; }
.brow.me { border: 3px solid #fff; background: #1f3f9f; font-weight: 800; }   /* the player's row */
html[data-ui="led"] .brow.me { border-color: var(--ui-lava-l); background: var(--ui-lava-d); }
html[data-ui="blocks"] .brow.me { border-color: var(--ui-grass-hi); background: var(--ui-grass); }
.head h2.res-verdict { color: #fff; }   /* the race's verdict (#327) */
.head h2.res-verdict.win { color: var(--yellow); }
.head h2.res-verdict.podium { color: #d9dde6; }
.screen-results .res-grid .res-main { display: block; margin-top: 0; padding: .8rem 1rem; }
/* championship cups (#121): a locked one greys all but the button that opens it (#358) */
.champ-rounds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: .6rem; }
.champ-round { display: flex; flex-direction: column; gap: .2rem; }
.champ-round h3 { display: flex; align-items: center; gap: .5rem; }
.champ-round h3 small { color: var(--dim); }
.champ-round .tip { margin: .3rem 0; font-size: .85rem; }
.champ-round .btn { margin-top: auto; }
.champ-round.locked > :not(.btn) { filter: grayscale(1) brightness(.6); }
.champ-round .btn.champ-prev { font-size: .8em; }
.champ-round .btn > span { max-width: 100%; }   /* PLAY: ROOKIE CUP wraps in a narrow column, not past the button (#1204) */
.champ-row {
  display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) 11rem 8rem 6rem; align-items: center; gap: .8rem; padding: .6rem 0;
  border-bottom: 3px solid rgba(0, 0, 0, .55); font-size: 1.2rem;
}
.champ-row b { color: var(--yellow); font: 900 1.2rem var(--font); }
/* #355: the name takes the line; the surface chip drops below when it does not fit (ŚRÓDZIEMNOMORSKIE: 17 letters) */
.champ-round .champ-row { display: flex; flex-wrap: wrap; align-items: center; column-gap: .8rem; row-gap: .15rem; padding: .2rem 0; font-size: 1rem; }
.champ-round .champ-row > b { flex: 0 0 2.6rem; }
.champ-round .champ-row > .chip { margin-left: auto; }
.champ-round .champ-row > span:nth-child(2) {   /* room for Ó / Ą marks; long names wrap, not clip */
  flex: 1 1 auto; min-width: 0; max-width: calc(100% - 3.4rem); overflow: hidden; margin: -5px 0; padding: 5px 0;
}
@media (max-height: 520px) {   /* a phone on its side: names and buttons only */
  .screen-champIntro .head p, .champ-round .tip, .champ-round .chip { display: none; }
  .champ-rounds { gap: .5rem; margin-top: .3rem; }
  .champ-round { padding: 4px 5px 6px; }
  .screen.screen-champIntro { padding-inline: calc(2vw + var(--tsafe-l)) calc(2vw + var(--tsafe-r)); }
  .champ-round h3 { margin: 2px 0; font-size: .9rem; }
  .champ-round .champ-row { grid-template-columns: 34px minmax(0, 1fr); column-gap: 6px; padding: .05rem 0; font-size: .64rem; flex-wrap: nowrap; }
  .champ-round .champ-row > b { flex-basis: 1.9rem; }
  .champ-round .champ-row > span:nth-child(2) { white-space: nowrap; }   /* one line per stage: the cup's button stays on screen (#650) */
  .screen-champIntro .row-foot { padding-top: .4rem; }
}
@media (max-height: 520px) and (max-width: 720px) {   /* a small phone: the stage's name without its number (#720) */
  .champ-round .champ-row > b { display: none; }
  .champ-round .champ-row > span:nth-child(2) { max-width: 100%; }
}

/* --------------------------------------------------------- loading, toasts */
.loading { display: flex; justify-content: center; align-items: center; z-index: 40; position: absolute; inset: 0; }
.load-inner { text-align: center; width: min(40rem, 88vw); }
.load-thumb { overflow: hidden; aspect-ratio: 2 / 1; border: var(--px) solid; border-color: #d8d8d8 #3a3a3a #3a3a3a #d8d8d8; background: #000; box-shadow: var(--ring); }
.load-thumb img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.load-title { margin-top: 1.6rem; font: 900 2.6rem var(--font); }
.load-sub { margin-top: .5rem; color: var(--yellow); font-size: 1.1rem; }
.load-bar { overflow: hidden; height: 1.6rem; margin: 1.8rem 0 .8rem; border: 3px solid; border-color: #000 #6a6a6a #6a6a6a #000; background: #141414; box-shadow: var(--ring); }
.load-bar i { display: block; width: 5%; height: 100%; background: repeating-linear-gradient(90deg, var(--bar-fill) 0 16px, #1c1c1c 16px 20px); transition: width .4s steps(8, end); }
.load-text { min-height: 1.6rem; color: #fff; font-size: 1.1rem; }
.load-tip { margin-top: 1.4rem; color: var(--dim); font-size: 1.1rem; }
.load-badge { display: block; width: min(30rem, 86vw); height: auto; margin: 0 auto 1.2vh; filter: drop-shadow(0 4px 0 rgba(0,0,0,.6)); animation: mcr-float 3s steps(4, end) infinite; }
/* the poster loading screen (#980): the stage's picture, its goal, the route as the bar */
.load-inner.load-poster-on { position: absolute; inset: 0; width: auto; text-align: left; }
.load-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: auto; }
.load-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.35) 0%, transparent 22%, transparent 42%, rgba(0,0,0,.86) 92%), linear-gradient(90deg, rgba(0,0,0,.55) 0%, transparent 50%); }
.load-poster-on .load-badge { position: absolute; left: 4vw; top: 3vh; width: min(16rem, 26vw); margin: 0; animation: none; }
.load-goal { position: absolute; right: 3.5vw; top: 3vh; width: max-content; max-width: 46vw; white-space: nowrap; padding: 1rem 1.2rem; display: grid; gap: .5rem; background: rgba(15,14,12,.88); box-shadow: inset 0 0 0 3px var(--orange, #ff7a2e); }
.load-goal small { color: var(--dim); font-size: .8rem; }
.load-goal b { color: var(--yellow); font-size: 1.7rem; line-height: 1.05; }
.load-goal span { font-size: 1rem; }
.load-goal .dim { color: var(--dim); }
.load-head { position: absolute; left: 4vw; top: calc(3vh + 3.6rem); }   /* under the logo, not over the car (#980) */
.load-poster-on .load-sub { margin: 0 0 .4rem; }
.load-poster-on .load-title { margin: 0; font-size: clamp(1.8rem, 4.2vw, 3.4rem); line-height: .95; }
.load-chips { margin-top: .9rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.load-chips > span { padding: .35rem .7rem; background: rgba(0,0,0,.6); border: 2px solid rgba(255,255,255,.2); font-size: .95rem; }
.load-poster-on .load-text { position: absolute; left: 4vw; bottom: 4.3rem; min-height: 0; color: var(--dim); font-size: .95rem; }
.load-poster-on .load-tip { position: absolute; right: 4vw; bottom: 4.3rem; width: min(24rem, 36vw); margin: 0; text-align: right; }
.load-poster-on .load-tip.lesson { color: var(--yellow); }
.load-route { position: absolute; left: 4vw; right: 4vw; bottom: 1.6rem; height: 2.2rem; }
.load-route svg { display: block; width: 100%; height: 100%; overflow: visible; }
.load-route .fill { transition: stroke-dasharray .4s steps(8, end); }
/* the live loading scene (#980): the game's canvas shows through, the poster steps aside */
body.load-live .menu-bg { opacity: 0; transition: none; }   /* at once: its 0.6 s fade would show the menu's old frame over the scene */
body.load-live .loading { background: none; }
body.load-live .load-poster { display: none; }
/* what plays over the live picture: it comes up from the dark and has a vignette until the world is built (body.load-ready),
   then the vignette fades (the picture sharpens itself, in the canvas); the text stands over all of it */
.load-poster-on > * { z-index: 2; }
.load-inner.load-poster-on::before, .load-inner.load-poster-on::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; }
body.load-live .load-inner.load-poster-on::before { background: #000; animation: load-bright 1.6s ease-out both; }
@keyframes load-bright { from { opacity: .82; } to { opacity: 0; } }
.load-inner.load-poster-on::after { background: radial-gradient(ellipse at center, transparent 52%, rgba(0,0,0,.6) 100%); transition: opacity .9s ease; }
body.load-live .load-inner.load-poster-on::after { opacity: 1; }
body.load-live.load-ready .load-inner.load-poster-on::after { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  body.load-live .load-inner.load-poster-on::before { animation: none; }
}
@media (max-height: 520px) {   /* a phone on its side: the name, the goal, two features and the route, no tip */
  .load-poster-on .load-badge { width: min(22rem, 30vw); top: 2vh; }   /* the logo 24 px high at 640 wide, not 8 (#1208) */
  .load-goal { right: 2.5vw; padding: .4rem .6rem; gap: .2rem; }
  .load-goal small, .load-goal .dim { display: none; }
  .load-goal b { font-size: .85rem; }
  .load-goal span { font-size: .7rem; }
  .load-head { top: calc(2vh + min(22rem, 30vw) / 8 + .5rem); }
  .load-poster-on .load-title { font-size: clamp(1.2rem, 4vw, 2rem); }
  .load-chips { margin-top: .4rem; }
  .load-chips > span { padding: .2rem .5rem; font-size: .75rem; }
  .load-chips > span:nth-child(3) { display: none; }
  .load-poster-on .load-text { bottom: 2.9rem; }   /* the status and the tip stay, over the route (#1208) */
  .load-poster-on .load-tip { bottom: 2.9rem; width: min(24rem, 46vw); }
  .load-route { bottom: .8rem; height: 1.5rem; }
}
@media (max-height: 520px) {   /* a phone on its side (#443): a smaller picture keeps the bar, the status and the tip on screen */
  .load-thumb { width: min(100%, 76vh); margin: 0 auto; }
  .load-title { margin-top: .6rem; }
  .load-sub { margin-top: .2rem; }
  .load-bar { margin: .7rem 0 .4rem; }
  .load-tip { margin-top: .4rem; }
}
.toasts {
  display: flex; flex-direction: column; align-items: center; gap: .5rem; z-index: 100; position: absolute; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%); pointer-events: none;
}
/* a menu screen keeps its buttons at the bottom (the results: MAIN MENU / SELECT / RETRY / NEXT): its notes go to the top */
body[data-screen]:not([data-screen='']) .toasts { top: var(--toast-top, 1.2rem); bottom: auto; }   /* --toast-top: under the screen's header (#1224) */
.toast {
  max-width: 80vw; padding: .6rem 1rem; border: 3px solid #000; border-left: .6rem solid var(--blue); background: #202020; font-size: 1rem;
  animation: fadein .25s steps(3, end); transition: opacity .4s steps(4, end);
}
.toast.error { border-left-color: var(--red); color: #ffb4ae; }
.toast.out { opacity: 0; }

/* --------------------------------------------------------------------- HUD */
.hud { z-index: 10; position: absolute; inset: 0; pointer-events: none; touch-action: none; font-family: var(--font); }
.hud > div { position: absolute; }   /* every panel places itself */
.hud canvas.px { display: inline-block; }   /* pixel text sits on the line */
.hud canvas.lens-splash { display: none; position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }   /* mud on the lens (#815) */
/* the corners are drawn smaller than the menus (#443: never below the phone layout) */
.hud-tl { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; top: 1.3rem; left: 1.6rem; transform: scale(.72); transform-origin: top left; }
.hud-tr { top: 1.3rem; left: 50%; width: auto; transform: translateX(-50%); transform-origin: top center; }   /* no scale: pixel text and icon stay crisp (#728) */
.hud-br { right: 1.2rem; bottom: 1rem; transform: scale(.72); transform-origin: bottom right; }
/* time, position and the next rival (#482): the speed panel's twin — figures left, a white tile right */
.hud-time-val { display: block; }   /* the stage clock */
.hud-run, .hud-speed { width: 19rem; }
.hud-run { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; border: 3px solid #000; background: rgba(0, 0, 0, .62); }
/* the stage's progress (U9): a thin bar along the panel's foot, a tick at each split */
.hud-prog { position: absolute; left: 0; right: 0; bottom: 0; height: .4rem; background: rgba(0, 0, 0, .7); pointer-events: none; }
.hud-prog b { display: block; width: 100%; height: 100%; background: var(--yellow); transform: scaleX(0); transform-origin: left; }
.hud-prog s { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: #000; }
.hr-l { display: grid; gap: .45rem; min-width: 0; padding: .55rem .9rem .6rem; }
.hr-rival { overflow: hidden; white-space: nowrap; }
.hr-pos { display: flex; justify-content: center; align-items: flex-end; gap: .1rem; width: 4.2rem; padding-bottom: .55rem; border-left: 3px solid #000; background: #f2efe6; }
.hr-pos.lead { background: var(--yellow); }
.hud-run.flash-up { border-color: var(--green); animation: mcr-glow 1.5s steps(3, end) 1; }
.hud-run.flash-down { border-color: var(--red); animation: mcr-glow 1.5s steps(3, end) 1; }
/* side notes under the time, each with a coloured edge */
.hud-pen { padding: .25rem .7rem; border: 3px solid #000; background: rgba(0, 0, 0, .55); }
.hud-bonus { padding: .25rem .7rem; border: 3px solid #000; border-left: .5rem solid var(--green); background: rgba(0, 0, 0, .55); }
.hud-delta { padding: .3rem .9rem; border: 3px solid #000; border-left: .5rem solid #fff; background: rgba(0, 0, 0, .78); animation: fadein .3s steps(3, end); }
.hud-ghost { padding: .2rem .7rem; border: 3px solid #000; border-left: .5rem solid #7fc4ff; background: rgba(0, 0, 0, .55); }
.hud-ghost.good, .hud-delta.good { border-left-color: var(--green); }
.hud-ghost.bad, .hud-delta.bad { border-left-color: var(--red); }
/* the next pace note (#728): the speed panel's look, a tile in the corner's colour with the black icon, the words on dark
   glass, the distance as a bar along the bottom (as the boost line); the note being driven gets a yellow edge */
.hud-notes { display: flex; flex-direction: column; gap: .5rem; }
.note { display: flex; align-items: stretch; border: 3px solid #000; background: rgba(0, 0, 0, .62); white-space: nowrap; }
.note-tile { display: grid; flex: none; place-items: center; padding: .4rem; border-right: 3px solid #000; background: var(--c, #f2efe6); }
.note-txt { display: flex; position: relative; flex-direction: column; justify-content: center; gap: .4rem; padding: .45rem 1rem .7rem .75rem; }
.note-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.note-bar { position: absolute; bottom: 0; left: 0; width: 0; height: .25rem; background: var(--c, #fff); }
.note.active { border-color: var(--yellow); background: rgb(40 30 0 / .78); }
/* the speed panel (#461, #676): speed and unit, the gear tile right, boost along the bottom */
.hud-speed { display: grid; grid-template-columns: minmax(0, 1fr) 4.2rem; min-width: 15rem; border: 3px solid #000; background: rgba(0, 0, 0, .62); }
.hd-l { position: relative; padding: .55rem 1.3rem .65rem .9rem; }
.hd-spd { display: flex; align-items: flex-end; gap: .6rem; }
.hs-val, .hs-unit, .hs-gear { line-height: 0; }
.hd-boost { position: absolute; bottom: 0; left: 0; width: 0; height: .22rem; background: #3d8bff; }
.hd-gear { display: grid; place-items: center; border-left: 3px solid #000; background: #f2efe6; }
.hd-gear.hot { background: #ff3a30; }
/* nitro: two upright cells left of the speed panel */
.hud-nitro { display: none; flex-direction: column; gap: .4rem; position: absolute; bottom: 1.2rem; left: -2.6rem; }
.hud-nitro.on { display: flex; }
.hud-nitro i { display: block; position: relative; width: 1.4rem; height: 3.2rem; border: 3px solid #000; background: #1c2430; }
.hud-nitro i b { position: absolute; right: 0; bottom: 0; left: 0; height: 0; background: #2f8bff; }
.hud-nitro i.burn b { background: #9fd0ff; }
.hud-nitro i.charge b { background: var(--ui-ember); }   /* filling from drift points (#111) */
/* the middle: countdown, wrong way, messages, drift points (#89), first-play tips (#115) */
.hud-center { display: flex; flex-direction: column; justify-content: center; align-items: center; top: 0; right: 0; bottom: 0; left: 0; }
.hud-countdown { margin-top: -12vh; opacity: 0; }
.hud-countdown.show { animation: cd 1s steps(10, end) forwards; }
.hud-countdown.go { animation-duration: 1.2s; }
.hud-wrong { position: absolute; top: 22vh; padding: .5rem 2.4rem; border: 4px solid #000; background: #c82020; animation: blink .6s steps(2) infinite; }
/* no keyboard focus (#1276): the start waits for a click (under the goal card), online a banner low in the middle */
.hud-focus { left: 50%; top: 58%; padding: 1.2rem 2.8rem; border: 4px solid #000; border-bottom: .5rem solid var(--yellow); background: rgba(0, 0, 0, .82); line-height: 0; transform: translate(-50%, -50%); animation: fadein .3s steps(3, end); }
.hud-focus.control { top: auto; bottom: 16vh; padding: .5rem 1.6rem; transform: translateX(-50%); border-bottom-color: #fff; animation: blink 1.2s steps(2) infinite; }
.hud-fade { position: fixed; inset: 0; pointer-events: none; background: #000; opacity: 0; }
.hud-msgs { display: flex; flex-direction: column; align-items: center; gap: .5rem; position: absolute; top: 12vh; }
.hud-msg { padding: .35rem 1.6rem; border: 3px solid #000; border-bottom: .4rem solid #fff; background: rgba(0, 0, 0, .78); animation: msg 2.4s steps(12, end) forwards; }
.hud-msg.good { border-bottom-color: var(--green); }
.hud-msg.bad { border-bottom-color: var(--red); }
.hud-msg.warn { border-bottom-color: var(--yellow); }
/* the message log (#676): short lines by the left edge, above the steering pads on a touch screen; the newest at the bottom */
.hud-log { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; left: 1.6rem; bottom: 1rem; }
.hud-line { padding: .2rem .6rem; border-left: .35rem solid #fff; background: rgba(0, 0, 0, .55); animation: log-line 3s steps(12, end) forwards; }
.hud-line.good { border-left-color: var(--green); }
.hud-line.warn { border-left-color: var(--yellow); }
.hud-line.bad { border-left-color: var(--red); animation: log-line 3s steps(12, end) forwards, log-flash .24s steps(2, end) 4; }
body.touch-on .hud-log { left: calc(var(--tsafe-l) + 24px); bottom: calc(var(--tsafe-b) + 26px + var(--steer) * 1.128); }
body.touch-on.portrait .hud-log { bottom: calc(var(--tsafe-b) + 26px + var(--steer) * 1.3); }
body.touch-swap.touch-on:not(.portrait) .hud-log { right: calc(var(--tsafe-r) + 24px); left: auto; align-items: flex-end; }
.hud-tip {
  position: absolute; top: 27vh; left: 50%; max-width: 90vw; padding: .45rem 1rem; transform: translateX(-50%);
  border: 3px solid #000; border-left: .5rem solid var(--yellow); background: rgba(0, 0, 0, .78); text-align: center;
}
.hud-drift { position: absolute; top: 66vh; padding: .3rem .9rem; border: 3px solid #000; border-left: .5rem solid #ffe14a; background: rgba(0, 0, 0, .55); }
.hud-combo { position: absolute; top: 34vh; padding: .3rem .9rem .5rem; border: 3px solid #000; border-left: .5rem solid #ff9a3c; background: rgba(0, 0, 0, .55); }
.hud-combo i { position: absolute; left: 0; bottom: 0; height: .25rem; background: #ffe14a; }
.hud-drift.end { border-left-color: var(--green); }
.hud-drift.lost { border-left-color: var(--red); }
/* corners: the minimap (#113), fps, the controls hint */
.hud-minimap { position: absolute; top: 1.2rem; right: 1.2rem; width: 10.5rem; height: 10.5rem; border-radius: 50%; image-rendering: pixelated; }
.hud-fps { right: 1.5rem; bottom: 21.5rem; padding: .2rem .5rem; border: 3px solid #000; background: rgba(0, 0, 0, .7); }
.hud-hint { bottom: 1.2rem; left: 50%; padding: .3rem .8rem; transform: translateX(-50%); border: 3px solid #000; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .4s steps(4, end); }
.hud-hint.show { opacity: 1; }   /* fades in and out in four steps */
body.hud-small .hud-tip { top: 30vh; }
body.portrait .hud-tip { top: 36vh; }
body.hud-small .hud-drift { top: 62vh; }
body.hud-small .hud-combo { top: 30vh; }
body.portrait .hud-drift { top: 52vh; }
body.portrait .hud-combo { top: 26vh; }
body.no-minimap .hud-minimap { display: none; }
body.hud-small .hud-minimap { top: calc(var(--tsafe-t) + .5rem); right: calc(var(--tsafe-r) + .6rem); width: 92px; height: 92px; }
body.portrait .hud-minimap { width: 84px; height: 84px; }
body.touch-on .hud-minimap { width: 80px; height: 80px; }   /* room for the nitro button below (#125) */
/* #356: the pause menu sits in the middle; the goal card, centre messages and the pace note step aside */
body[data-screen="pause"] :is(.hud-center, .hud-notes, .hud-tip) { visibility: hidden; }
@media (max-width: 900px) {   /* narrow windows */
  .res-grid { grid-template-columns: 1fr; }
  .set-row { grid-template-columns: minmax(0, 1fr) 14rem; }
  .hud-tr { top: 1rem; }
}

/* -------------------------------------------------------------- touch pads */
/* calm, see-through, rounded (#133); size follows use: gas biggest in the corner, nitro above it, brake beside, handbrake
   above the brake; colour only on gas (green), brake (red), handbrake (amber) and nitro (blue, glows with a shot ready) */
.touch { --gas: calc(var(--steer) * .92); --pad-a: .32; z-index: 12; position: absolute; inset: 0; pointer-events: none; touch-action: none; -webkit-user-select: none; user-select: none; }
.tpad {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; position: absolute; pointer-events: auto; touch-action: none;
  border: 2px solid rgba(255, 255, 255, .5); border-radius: 14px; background: rgba(14, 18, 26, var(--pad-a)); opacity: .85;
  transition: background .06s, border-color .06s;
}
.tpad::before { content: ""; position: absolute; inset: -10px; }   /* a generous hit area */
.tpad .ti, .tpad .tt { display: block; line-height: 0; pointer-events: none; opacity: .9; }
.tpad canvas { image-rendering: pixelated; display: block; }
.tp-throttle.auto { opacity: .6; }   /* auto throttle: the gas pad only shows */
.tpad.on { border-color: #fff; background: rgba(255, 255, 255, .24); opacity: 1; }
.tp-throttle { border-color: rgba(120, 255, 140, .7); }
.tp-throttle.on { background: rgba(85, 255, 85, .38); }
.tp-brake { border-color: rgba(255, 130, 130, .7); }
.tp-brake.on { background: rgba(255, 85, 85, .4); }
.tp-handbrake { border-color: rgba(255, 190, 90, .7); }
.tp-handbrake.on { background: rgba(255, 176, 60, .42); }
/* left thumb steers: the touch zone is the whole lower-left corner, the pads only show where (#125, #133) */
.tp-left, .tp-right { bottom: calc(var(--tsafe-b) + 20px); width: calc(var(--steer) * 1.1); height: calc(var(--steer) * 1.2); }
.tp-left { left: var(--steer-x); }
.tp-right { left: calc(var(--steer-x) + var(--steer) * 1.1 + 16px); }
.tp-left::before, .tp-right::before { content: ""; position: absolute; top: calc(var(--steer) * -.8); bottom: calc(-20px - var(--tsafe-b)); }
.tp-left::before { right: -8px; left: calc(-1 * var(--steer-x)); }
.tp-right::before { right: -40px; left: -8px; }
/* right thumb: an arc around the corner */
.tp-throttle { right: calc(var(--tsafe-r) + 18px); bottom: calc(var(--tsafe-b) + 18px); width: var(--gas); height: calc(var(--gas) * 1.55); }
.tp-nitro { right: calc(var(--tsafe-r) + 18px); bottom: calc(var(--tsafe-b) + 28px + var(--gas) * 1.55); width: var(--gas); height: calc(var(--gas) * .72); border-color: rgba(140, 190, 255, .55); border-radius: 50%; }
body.has-nitro .tp-nitro { border-color: #bfe0ff; background: rgba(47, 139, 255, .5); opacity: 1; box-shadow: 0 0 16px rgba(80, 160, 255, .85); }
.tp-brake { right: calc(var(--tsafe-r) + 32px + var(--gas)); bottom: calc(var(--tsafe-b) + 18px); width: calc(var(--gas) * .85); height: calc(var(--gas) * 1.05); }
.tp-handbrake { flex-direction: row; right: calc(var(--tsafe-r) + 32px + var(--gas)); bottom: calc(var(--tsafe-b) + 30px + var(--gas) * 1.05); width: calc(var(--gas) * .85); height: calc(var(--gas) * .5); }
.touch.steer-slider :is(.tp-left, .tp-right) { display: none; }
/* the steering slider in place of the steer pads (#773), one pad in their look and place (#796): arrows at its ends, a
   smaller pad with arrows for the knob that lights like a pressed pad */
.tslider { display: none; position: absolute; left: var(--steer-x); bottom: calc(var(--tsafe-b) + 20px); width: calc(var(--steer) * 2.2 + 16px); height: calc(var(--steer) * 1.2); pointer-events: auto; touch-action: none; opacity: .85; }
.touch.steer-slider .tslider { display: block; }
.tslider::before { content: ""; position: absolute; top: calc(var(--steer) * -.8); bottom: calc(-20px - var(--tsafe-b)); left: calc(-1 * var(--steer-x)); right: -40px; }
.tsl-track { position: absolute; inset: 0; border: 2px solid rgba(255, 255, 255, .5); border-radius: 14px; background: rgba(14, 18, 26, var(--pad-a)); pointer-events: none; }
.tsl-end { position: absolute; top: 50%; transform: translateY(-50%); line-height: 0; opacity: .55; }
.tsl-end.l { left: 8%; }
.tsl-end.r { right: 8%; }
.tsl-knob { display: flex; justify-content: center; align-items: center; gap: 2px; position: absolute; left: 50%; top: 6px; bottom: 6px; width: calc(var(--steer) * .6); transform: translateX(-50%); border: 2px solid rgba(255, 255, 255, .75); border-radius: 10px; background: rgba(255, 255, 255, .16); line-height: 0; }
.tsl-end canvas, .tsl-knob canvas { display: block; image-rendering: pixelated; }
.tslider.on { opacity: 1; }
.tslider.on .tsl-track { border-color: rgba(255, 255, 255, .75); }
.tslider.on .tsl-knob { border-color: #fff; background: rgba(255, 255, 255, .34); }
/* pause and reset in the top-left corner (#133; no camera button since #467) */
.ttop { position: absolute; inset: 0; pointer-events: none; }
.tbtn {
  display: flex; justify-content: center; align-items: center; position: absolute; width: 44px; height: 40px; pointer-events: auto; touch-action: none;
  border: 2px solid rgba(255, 255, 255, .5); border-radius: 10px; background: rgba(14, 18, 26, .55);
}
.tbtn::before { content: ""; inset: -6px; position: absolute; }   /* a bigger hit area */
/* pause over reset (the user's layout, #385): their hit areas stop short of each other, a stray reset costs seconds (U11) */
.tb-pause::before { bottom: -2px; }
.tb-reset::before { top: -2px; }
.tbtn .ti { line-height: 0; pointer-events: none; }
.tbtn canvas { display: block; image-rendering: pixelated; }
.tbtn.on { background: rgb(255 210 60 / .6); }
.tb-pause { top: calc(var(--tsafe-t) + 8px); left: calc(var(--tsafe-l) + 8px); }
.tb-reset { top: calc(var(--tsafe-t) + 60px); left: calc(var(--tsafe-l) + 8px); }   /* as the phone layout (#493) everywhere (U11) */
/* settings (#137): button size and opacity, left-handed (pedals left, steering right) */
body.touch-size-s { --ts: .85; }
body.touch-size-l { --ts: 1.15; }
body.touch-op-low .tpad { opacity: .5; }
body.touch-op-high .tpad { opacity: 1; }
body.touch-op-low .tpad.on { opacity: .8; }
body.touch-op-low .tslider { opacity: .5; }
body.touch-op-high .tslider { opacity: 1; }
body.touch-swap .tslider { right: var(--steer-x); left: auto; }
body.touch-swap .tslider::before { right: calc(-1 * var(--steer-x)); left: -40px; }
body.touch-swap { --steer-x: calc(var(--tsafe-r) + 30px); }
body.touch-swap.portrait { --steer-x: calc(var(--tsafe-r) + 24px); }
body.touch-swap .tp-right { right: var(--steer-x); left: auto; }
body.touch-swap .tp-left { right: calc(var(--steer-x) + var(--steer) * 1.1 + 16px); left: auto; }
body.touch-swap .tp-left::before { right: -8px; left: -40px; }
body.touch-swap .tp-right::before { right: calc(-1 * var(--steer-x)); left: -8px; }
body.touch-swap :is(.tp-throttle, .tp-nitro) { right: auto; left: calc(var(--tsafe-l) + 18px); }
body.touch-swap :is(.tp-brake, .tp-handbrake) { right: auto; left: calc(var(--tsafe-l) + 32px + var(--gas)); }
body.touch-swap.portrait :is(.tp-throttle, .tp-nitro) { left: calc(var(--tsafe-l) + 14px); }
body.touch-swap.portrait :is(.tp-brake, .tp-handbrake) { left: calc(var(--tsafe-l) + 24px + var(--gas)); }

/* ------------------------------------------------------------- rotate hint */
/* before a stage on a phone held upright (#428): the phone turns sideways, then a car crosses its screen */
.rotate { display: none; justify-content: center; align-items: center; z-index: 300; position: fixed; inset: 0; touch-action: none; text-align: center; }
.rotate.on { display: flex; }
.rot-box { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px; }
.rot-anim { display: grid; place-items: center; position: relative; width: 150px; height: 150px; }
.rot-phone {
  overflow: hidden; position: relative; width: 64px; height: 112px; box-sizing: border-box; border: 6px solid var(--yellow); border-bottom-width: 14px; background: #1c1916;
  box-shadow: var(--ring), inset 0 0 0 2px #000; animation: rot-turn 3.2s infinite;
}
/* drawn along the upright phone: lying sideways, the road runs across and the car drives left to right */
.rot-road { position: absolute; top: 0; bottom: 0; left: 50%; width: 16px; margin-left: -8px; background: #5a554e; opacity: 0; animation: rot-show 3.2s infinite; }
.rot-road::after { content: ''; position: absolute; top: 0; bottom: 0; left: 7px; width: 2px; background: repeating-linear-gradient(180deg, var(--yellow) 0 5px, transparent 5px 10px); }
.rot-car { position: absolute; top: 0; left: 50%; width: 8px; height: 13px; margin-left: -6px; background: #ff8a3d; opacity: 0; box-shadow: 0 0 0 1px #000; animation: rot-drive 3.2s infinite; }
.rot-arrow { position: absolute; top: 6px; right: 2px; image-rendering: pixelated; animation: rot-arrow 3.2s infinite; }
@media (prefers-reduced-motion: reduce) {
  .rot-phone { transform: rotate(-90deg); animation: none; }
  .rot-road { opacity: 1; animation: none; }
  .rot-car { top: 40px; opacity: 1; animation: none; }
  .rot-arrow { animation: none; }
}
.rot-t, .rot-s { line-height: 0; }
.rot-t canvas, .rot-s canvas { display: inline-block; }

/* ------------------------------------------------- HUD on phones and tablets */
/* compact (phones / short windows) */
body.hud-small .hud-tl { top: calc(var(--tsafe-t) + .5rem); left: calc(var(--tsafe-l) + .8rem); transform: scale(.83); }
body.hud-small .hud-tr { top: calc(var(--tsafe-t) + .5rem); }
body.touch-on .hud-tl { left: calc(var(--tsafe-l) + 60px); }   /* right of the pause / reset buttons (#133) */
body.hud-small .hud-br { right: calc(var(--tsafe-r) + .8rem); bottom: calc(var(--tsafe-b) + .6rem); transform: scale(.83); }
body.hud-small .hud-notes { gap: .3rem; }   /* tighter stack of notes */
body.hud-small .hud-msgs { top: 16vh; }
body.hud-small .hud-wrong { top: 28vh; }
/* touch overlay on: the speed panel at the bottom centre */
body.touch-on .hud-br { right: auto; bottom: calc(var(--tsafe-b) + .5rem); left: 50%; transform: translateX(-50%) scale(.72); transform-origin: bottom center; }
body.touch-on .hud-fps { top: auto; right: auto; bottom: calc(var(--tsafe-b) + var(--steer) * 1.2 + 78px); left: calc(var(--tsafe-l) + 1rem); }
body.touch-on .hud-hint { display: none; }   /* the pads say it */
/* portrait: pads in both bottom corners, the speed panel above them, notes across the top */
body.portrait { --pad: 68px; --steer: calc(91px * min(1, var(--ts))); --steer-x: calc(var(--tsafe-l) + 24px); }
body.portrait :is(.tp-left, .tp-right) { height: calc(var(--steer) * 1.3); }
body.portrait .touch { --gas: 74px; }
body.portrait .tp-throttle { right: calc(var(--tsafe-r) + 14px); height: calc(var(--gas) * 1.6); }
body.portrait .tp-nitro { right: calc(var(--tsafe-r) + 14px); bottom: calc(var(--tsafe-b) + 28px + var(--gas) * 1.6); }
body.portrait :is(.tp-brake, .tp-handbrake) { right: calc(var(--tsafe-r) + 24px + var(--gas)); width: calc(var(--gas) * .85); }
body.portrait .tbtn { width: 42px; height: 38px; }
body.portrait.touch-on .hud-br { bottom: calc(var(--tsafe-b) + var(--gas, 74px) * 2.3 + 40px); transform: translateX(-50%) scale(.8); }
body.portrait .hud-tl { top: calc(var(--tsafe-t) + 6px); left: calc(var(--tsafe-l) + 58px); transform: scale(.8); }
body.portrait .hud-tr { top: calc(var(--tsafe-t) + 100px); }
body.portrait .hud-msgs { top: 30vh; }
body.portrait .hud-wrong { top: 40vh; }
body.portrait .hud-countdown { top: 34vh; }   /* above the car on a tall screen */
/* landscape phones: the layout the player drew at 844 x 390 (#385); pad sizes follow --steer (30vh) */
body:not(.portrait) .touch { --steer-x: calc(var(--tsafe-l) + 24px); }
body:not(.portrait) :is(.tp-left, .tp-right) { bottom: calc(var(--tsafe-b) + 18px); width: calc(var(--steer) * .923); height: calc(var(--steer) * 1.128); }
body:not(.portrait) .tp-right { left: calc(var(--steer-x) + var(--steer) * .923 + 12px); }
body:not(.portrait) .tslider { bottom: calc(var(--tsafe-b) + 18px); width: calc(var(--steer) * 1.846 + 12px); height: calc(var(--steer) * 1.128); }   /* both steer pads and their gap (#796) */
body:not(.portrait) .tp-left::before { right: -6px; }
body:not(.portrait) .tp-right::before { left: -6px; }
body:not(.portrait) .tp-throttle { right: calc(var(--tsafe-r) + 16px); bottom: calc(var(--tsafe-b) + 18px); height: calc(var(--gas) * 1.524); }
body:not(.portrait) .tp-nitro { right: calc(var(--tsafe-r) + 16px + var(--gas) * .054); bottom: calc(var(--tsafe-b) + 26px + var(--gas) * 1.524); width: calc(var(--gas) * .892); height: calc(var(--gas) * .743); }
body:not(.portrait) :is(.tp-brake, .tp-handbrake) { right: calc(var(--tsafe-r) + 28px + var(--gas)); width: calc(var(--gas) * .855); height: calc(var(--gas) * .706); }
body:not(.portrait) .tp-brake { bottom: calc(var(--tsafe-b) + 18px); }
body:not(.portrait) .tp-handbrake { bottom: calc(var(--tsafe-b) + 30px + var(--gas) * .706); }   /* as big as the brake, right above it */
/* the same scale as the speed panel: the same width (#482); speed right under the time (#493), in rem: no overlap on a tablet (#443) */
body.touch-on.hud-small:not(.portrait) .hud-tl { top: calc(var(--tsafe-t) + 12px); left: calc(var(--tsafe-l) + 64px); transform: scale(.83); }
body.touch-on.hud-small:not(.portrait) .hud-br { top: calc(var(--tsafe-t) + 12px + 4.8rem); right: auto; bottom: auto; left: calc(var(--tsafe-l) + 64px); transform: scale(.83); transform-origin: top left; }
body.touch-on.hud-small:not(.portrait) .hud-tr { top: calc(var(--tsafe-t) + 44px); }
/* the time panel's extra lines (penalty, bonus, splits, ghost) in rows under the speed panel, the nitro gauge right of it:
   clear of the speed panel and the reset button (#650, CrazyGames QA) */
body.touch-on.hud-small:not(.portrait) .hud-tl { flex-flow: row wrap; align-content: flex-start; align-items: flex-start; width: 19rem; }
body.touch-on.hud-small:not(.portrait):not(.touch-swap) .hud-run { flex: 0 0 100%; }
body.touch-on.hud-small:not(.portrait):not(.touch-swap) .hud-tl > :not(.hud-run, .hud-rush) { position: relative; top: 5.4rem; }   /* moved, the panel's box stays the time panel's */
body.touch-on.hud-small:not(.portrait):not(.touch-swap) .hud-nitro { flex-direction: row; right: -3.6rem; bottom: .2rem; left: auto; }   /* side by side: stacked, they reach the x4 tag (#685) */
body.touch-on.hud-small:not(.portrait) .hud-minimap { top: calc(var(--tsafe-t) + 6px); right: calc(var(--tsafe-r) + 22px); width: min(100px, 25vh); height: min(100px, 25vh); }
/* the user's phone layout (#493): reset under pause (.tb-reset), the goal card at the bottom between the pads, the first-play tip where the card was */
body.touch-on.hud-small:not(.portrait) .hud-goal { top: auto; bottom: calc(var(--tsafe-b) + 18px); max-width: 40vw; }
body.touch-on.hud-small:not(.portrait) .hud-tip, body.touch-on.hud-small:not(.portrait).goal-on .hud-tip { top: calc(var(--tsafe-t) + 4px); bottom: auto; }   /* the strip above the pace note, off the road (#716) */
/* left-handed: pedals on the left, the speed panel to the right above the steering */
body.touch-swap:not(.portrait) .tp-right { right: var(--steer-x); left: auto; }
body.touch-swap:not(.portrait) .tp-left { right: calc(var(--steer-x) + var(--steer) * .923 + 12px); left: auto; }
body.touch-swap:not(.portrait) .tp-throttle { right: auto; left: calc(var(--tsafe-l) + 16px); }
body.touch-swap:not(.portrait) .tp-nitro { right: auto; left: calc(var(--tsafe-l) + 16px + var(--gas) * .054); }
body.touch-swap:not(.portrait) :is(.tp-brake, .tp-handbrake) { right: auto; left: calc(var(--tsafe-l) + 28px + var(--gas)); }
body.touch-swap.touch-on.hud-small:not(.portrait) .hud-br { top: calc(var(--tsafe-t) + 108px); right: calc(var(--tsafe-r) + 20px); left: auto; transform-origin: top right; }

/* ---------------------------------------------------------- short screens */
@media (max-height: 520px) {   /* a phone on its side */
  .screen { padding-block: 3vh; padding-inline: calc(4vw + var(--tsafe-l)) calc(4vw + var(--tsafe-r)); }
  .head h2 { font-size: 2rem; }
  .head p { margin-top: .5rem; }
  .set-row { grid-template-columns: minmax(0, 1fr) 20rem; }   /* a narrower control */
  .screen-settings .set-row { grid-template-columns: minmax(0, 1fr) min(30rem, 40vw); }   /* the longest value fits: AUTO (BY STAGE) (#1206) */
  .select .arr { flex: none; }
  .select .val { min-width: 0; overflow: hidden; }
  .panel { margin-top: 1rem; }   /* less air between panels */
  .menu-col { width: 26rem; gap: .8rem; }
  .ctl, .ctl-side { min-width: 18rem; }   /* key and touch columns side by side */
}
@media (max-height: 780px) {   /* tighter button columns on short screens */
  .menu-col { gap: .55rem; }
  .menu-col .btn.big { padding: .65rem 1.4rem; }
}
@media (max-height: 520px) {   /* the pause column whole on a phone on its side (#650, CrazyGames QA) */
  .screen-pause { justify-content: safe center; }
  .screen-pause .head { margin-bottom: .5rem; }
  .screen-pause .head h2 { font-size: 1.6rem; }
  .screen-pause .head h2::after { height: .3rem; margin-top: .4rem; }
  .screen-pause .head p { margin-top: .3rem; }
  .screen-pause .menu-col { gap: .4rem; }
  .screen-pause .menu-col .btn.big { min-height: 40px; padding: .3rem 1.4rem; }
}

/* the first run's name prompt: wider than a button column, also on a short screen */
.driver-col { align-self: center; width: 34rem; }

/* ----------------------------------------------------------- the car screen */
.thumb .tag { position: absolute; top: .6rem; left: .6rem; padding: .25rem .5rem; border: 3px solid #000; background: #2f8f3a; color: #fff; font-size: .9rem; }

/* ----------------------------------------------- results on one screen (#81)
 * rem follows min(w/1280, h/720) (HUD.resize): a 16:9 window is ~80 x 45 rem, and the whole summary (head, three
 * columns, buttons) is budgeted to that box; it never scrolls. */
.screen-results { padding: 1.8rem 3rem 1.4rem; }
.screen-results .head h2 { font-size: 2rem; }
.screen-results .head h2::after { height: .35rem; margin-top: .5rem; }
.screen-champion .head p { line-height: 1.7; }   /* a medal splits the line in two texts: their lines must not overlap (#1224) */
.screen-results .head p { max-width: none; margin-top: .5rem; font-size: 1rem; }
.screen-results .row-foot { padding-top: 1rem; }
.res-grid.res3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 1rem; margin-top: 1rem; }
.res-grid.res3.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); max-width: 62rem; }   /* no empty third column (#779) */
.screen-results:not(.res-more) :is(.res-lines .more, .rec) { display: none; }   /* the time sheet and records under DETAILS (#779) */
.res-time .res-best { display: block; margin-top: .2rem; font-style: normal; font-size: 1.15rem; text-align: right; }   /* the gap to the player's best (#779) */
.res-best.first { color: var(--dim); }
.res3 .res-badges .badge { margin-left: 0; }
.badge.xp { background: var(--yellow); color: #1a1206; }
.badge.lvl { background: var(--green-soft); color: #0e3a12; }
.badge.medal-b { display: inline-flex; align-items: center; gap: .3rem; background: #2a2414; color: var(--yellow); }
.badge.medal-b i.good { color: var(--green); font-style: normal; }
.badge.near { border-style: dashed; }   /* the gold not won yet (G15) */
.badge.near .medal { opacity: .6; }
.res-more-btn { display: block; margin: .5rem 0 0 auto; padding: .25rem .8rem; font-size: .85rem; }
.res3 .res-col { display: flex; flex-direction: column; gap: .7rem; min-width: 0; }
.res3 .res-col .panel, .res3 .res-col .panel:first-child { margin-top: 0; padding: .6rem .9rem; }
.res3 .panel h3 { margin: .2rem 0 .4rem; font-size: 1rem; }
.res-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.res3 .res-pos b { font-size: 3rem; }
.res3 .res-pos sup { font-size: 1.2rem; }
.res3 .res-pos em { font-size: .95rem; }
.res3 .res-time { text-align: right; }
.res3 .res-time b { font-size: 2.4rem; }
.res3 .res-pos small, .res3 .res-time small { font-size: .85rem; }
.res-badges { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.res3 .badge {   /* a long stage name stays inside the panel (#106) */
  overflow: hidden; max-width: 100%; margin: 0; padding: .15rem .5rem; font-size: .85rem; white-space: nowrap; text-overflow: ellipsis;
}
.res3 .badge.unlock { margin-left: 0; }
.res3 .res-lines { margin-top: .4rem; }
.res3 .res-lines > div { padding: .26rem 0; border-bottom-width: 2px; font-size: .95rem; }
.res3 .pen-why { contain: inline-size; flex-basis: 100%; font-size: .8em; font-style: normal; text-align: right; white-space: normal; }   /* its own line, wrapped to the value's width */
@media (max-height: 800px) { .res3 .pen-why { display: none; } }   /* a laptop: no room for the lines, the value alone (#720) */
.res3 .board { column-gap: .7rem; }   /* the columns: .board (#717) */
.res3 .board .brow { gap: .7rem; padding: .14rem .4rem; border-bottom-width: 2px; font-size: .95rem; }
@media (max-width: 1100px) { .res3 .brow em { display: none; } }   /* the gap to the leader, as on a phone: room for the names */
.res3 .brow i { font-size: .95rem; }
.res3 .brow.me { border-width: 2px; }
.res3 .tip { margin: .4rem 0 0; font-size: .85rem; line-height: 1.3; }
@media (max-width: 900px) { .res-grid.res3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); } }
/* phones: the pixel font never drops below 2 px a dot, so text is relatively bigger — the essentials only */
@media (max-height: 600px) {   /* the summary on a phone, and in a small window (960×540, #720) */
  .screen-results { padding: 1rem calc(2rem + var(--tsafe-r)) .8rem calc(2rem + var(--tsafe-l)); }
  .screen-results .head h2 { font-size: 1.6rem; }
  .screen-results .head h2::after { display: none; }
  .res3 .rec, .res3 .res-lines .split, .res3 .tip, .res3 .brow em, .screen-results .res3 .res-more-btn { display: none; }
  .res3 .res-lines .drive { display: none; }   /* the stage time above already adds drive, penalties and bonuses (#89) */
  .res3 .res-badges { gap: 3px; margin-top: 2px; }
  .res3 .badge { padding: .05rem .4rem; font-size: .72rem; }   /* up to three: record, stage, car (#117) */
  .screen-results .row-foot { padding-top: .6rem; }
  /* two columns in real pixels (~12 px a letter here): result + championship | classification */
  .res-grid.res3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 1fr; grid-auto-flow: column; align-items: start; gap: 8px 10px; margin-top: .6rem; }
  .res3 .res-col { display: contents; }
  .res3 .res-main { grid-row: 1; grid-column: 1; }
  .res3 .champ { grid-row: 2; grid-column: 1; }
  .res3 .cls { grid-row: 1; grid-column: 2; }
  .res3 .panel, .res3 .res-col .panel, .res3 .res-col .panel:first-child, .screen-results .res-grid .res-main { padding: 4px 10px 6px; }
  .res3 .panel h3 { margin: 2px 0 4px; }
  .res3 .res-lines > div { padding: 2px 0; }
  .res3 .res-pos b { font-size: 2.4rem; }
  .res3 .res-time b { font-size: 2rem; }
  .res3 .board .brow { padding: 1px 4px; }
  .res3 .res-hero { gap: 6px; }
  .res3 .res-badges { margin-top: 2px; }
  .res3 .res-pos small, .res3 .res-time small, .res3 .pen-why { display: none; }
  .screen-results .head p { margin-top: 2px; }
}
/* a phone on its side and a computer's small window (#1218): the panels scroll in their own box, the day's line (one
   line: tomorrow is on the start screen) and the buttons stay in the window; they ran under its bottom edge */
@media (max-height: 520px) {
  :is(.screen-results, .screen-champion) { overflow: hidden; }
  :is(.screen-results, .screen-champion) > .res-grid { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
  :is(.screen-results, .screen-champion) > :is(.head, .res-week, .row-foot) { flex: none; }
  .screen-results .res-week .tm { display: none; }
  .screen-champion { padding-block: 1rem .8rem; }
  .screen-champion .row-foot { padding-top: .6rem; }
}

/* ---------------------------------------------------- start screen (#314, #439) */
/* the score top-left, the logo between it and the icons, the goals over STAGES / CHAMPIONSHIP, PLAY bottom-right */
.screen-main {
  --gw: calc(52.5 * var(--u)); --pw: calc(32 * var(--u)); --bh: max(44px, calc(7.4 * var(--u)));
  justify-content: flex-start; align-items: center; overflow: hidden; padding: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 40%, rgba(0,0,0,.35) 100%), linear-gradient(180deg, rgba(0,0,0,.4) 0%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 66%, rgba(0,0,0,.6) 100%);   /* light (#183): the scene's colours show */
}
body.is-mobile .screen-main { --gw: calc(54 * var(--u)); }
.screen-main::before { content: ""; position: absolute; inset: calc(-1 * var(--tsafe-t)) calc(-1 * var(--tsafe-r)) calc(-1 * var(--tsafe-b)) calc(-1 * var(--tsafe-l)); pointer-events: none; background: linear-gradient(rgba(13,10,8,.4), rgba(13,10,8,0) 30%, rgba(13,10,8,0) 62%, rgba(13,10,8,.85)); }
.start-top { display: flex; align-items: flex-start; gap: calc(2 * var(--u)); position: absolute; top: calc(3 * var(--u)); right: calc(3 * var(--u)); left: calc(3 * var(--u)); }
/* the logo image (#296), the canvas logo when it does not load */
.logo-pic { width: auto; height: clamp(3rem, 11vh, 7.5rem); max-width: 92vw; animation: mcr-logo-in .7s steps(7, end) both; }
.logo-cv {
  width: auto; height: clamp(4.6rem, 17vh, 11rem); max-width: 92vw; image-rendering: pixelated; image-rendering: crisp-edges;
  filter: drop-shadow(0 0 10px rgba(232,57,46,.35)); animation: mcr-logo-in .7s steps(7, end) both;
}
.start-logo { display: flex; flex: 1; justify-content: center; min-width: 0; padding-top: calc(.2 * var(--u)); }
.start-logo .logo-pic { display: block; width: 100%; height: auto; max-width: calc(46 * var(--u)); max-height: none; filter: drop-shadow(0 4px 0 rgba(0,0,0,.6)); }
/* SCORE (#168): the total, the gain, gold medals and the level bar (#361) */
.screen-main .start-score { display: grid; gap: calc(.6 * var(--u)); padding: calc(1.3 * var(--u)) calc(2 * var(--u)) calc(1.6 * var(--u)); }
body.is-mobile .screen-main .start-score { gap: calc(.3 * var(--u)); padding: calc(.8 * var(--u)) calc(1.6 * var(--u)) calc(1 * var(--u)); }   /* a lower board (#439) */
.start-score .hd { display: flex; justify-content: space-between; align-items: center; gap: calc(2 * var(--u)); }
.start-score .lbl { font-size: calc(1.7 * var(--u)); letter-spacing: .14em; }
.start-score .num { position: relative; justify-self: end; text-align: right; font-size: calc(9 * var(--u) * var(--k, 1)); line-height: 1; white-space: nowrap; }   /* on the right of the board (#752) */
body.is-mobile .start-score .num { font-size: calc(7 * var(--u) * var(--k, 1)); }
.start-score .ghost { position: absolute; top: 0; right: 0; }
.start-score .val { position: relative; }
.start-score .sub { display: flex; align-items: center; gap: calc(1.4 * var(--u)); font-size: calc(1.7 * var(--u)); white-space: nowrap; }
.start-score .sub em { font-style: normal; }
.start-score .md { display: inline-flex; align-items: center; gap: calc(.4 * var(--u)); }
.start-score .medal { width: calc(1.4 * var(--u)); height: calc(1.4 * var(--u)); margin: 0; border-width: 2px; }
.start-score .lvl { display: flex; align-items: center; gap: calc(1 * var(--u)); font-size: calc(1.5 * var(--u)); letter-spacing: .06em; white-space: nowrap; }
.start-score .lvl b { font-weight: normal; }
.start-score .lvl i { flex: 1; min-width: calc(6 * var(--u)); height: calc(.9 * var(--u)); background: rgba(128, 128, 128, .3); }   /* the empty part shows on the board and on planks */
.start-score .lvl u { display: block; height: 100%; background: currentColor; }
html[data-ui="led"] .start-score { border: calc(.5 * var(--u)) solid var(--ui-asph); background: #050403; color: #ffb12e; box-shadow: var(--ring); }
html[data-ui="led"] .start-score .lbl { color: var(--ui-ember); }
html[data-ui="led"] .start-score .ghost { color: #2a1a08; }
html[data-ui="led"] .start-score .sub { color: #e6c9a0; }
html[data-ui="led"] .start-score .sub em { color: #ffb12e; }
html[data-ui="led"] .start-score .lvl { color: var(--yellow); }
html[data-ui="blocks"] .start-score {
  background: repeating-linear-gradient(#0000 0 calc(2.6 * var(--u)), rgba(0,0,0,.16) calc(2.6 * var(--u)) calc(2.9 * var(--u))), var(--ui-plank); color: #2a1a0a;
  box-shadow: inset 5px 5px 0 rgba(255,255,255,.27), inset -5px -5px 0 rgba(0,0,0,.4), 0 6px 0 rgba(0,0,0,.4);
}
html[data-ui="blocks"] .start-score .ghost { display: none; }
html[data-ui="blocks"] .start-score .num { font-size: calc(6.6 * var(--u) * var(--k, 1)); }
/* a long score: the digits get smaller from six on, so seven or eight still fit the board (the rules above multiply by --k) */
.start-score .num[data-len="6"] { --k: .85; }
.start-score .num[data-len="7"] { --k: .74; }
.start-score .num[data-len="8"], .start-score .num[data-len="9"] { --k: .65; }
html[data-ui="blocks"] .start-score .sub em { color: #7a2a00; }
html[data-ui="blocks"] .start-score .lvl { color: #2a1a0a; }
/* icons, the car's name */
.start-icons { display: flex; gap: calc(1.1 * var(--u)); }
.start-icons .icon-btn { display: grid; place-items: center; width: max(44px, calc(5.6 * var(--u))); height: max(44px, calc(5.6 * var(--u))); padding: 0; }
.start-icons .icon-btn svg { display: block; width: 56%; height: 56%; }
.start-ver { position: absolute; right: calc(3 * var(--u)); bottom: calc(.5 * var(--u)); color: rgba(255,255,255,.55); font-size: 12px; }

/* ----------------------------------------------------- road book (#315) */
/* stage list left, the focused stage's picture, route map and PLAY right */
.screen-stages { overflow: hidden; padding: 0; }
.stage-top { --u: var(--u-top); display: flex; align-items: center; gap: calc(1.6 * var(--u)); position: absolute; top: calc(2.4 * var(--u)); right: calc(3 * var(--u)); left: calc(3 * var(--u)); }
.stage-top .btn { display: flex; align-items: center; height: max(40px, calc(5.4 * var(--u))); padding: 0 calc(1.2 * var(--u)); font-size: calc(1.8 * var(--u)); white-space: nowrap; }
/* BACK of one size on every screen (#1209): the UI editor's 150 px at 1280x720 (120 px on a phone), never narrower than its label */
.stage-top > .top-back { justify-content: center; min-width: calc(11.72 * var(--u)); }
@media (max-height: 480px) { body.is-mobile .stage-top > .top-back { min-width: calc(15.03 * var(--u)); } }
.stage-title { margin: 0; color: #fff; font: 900 calc(3.6 * var(--u)) var(--font); position: relative; top: calc(.55 * var(--u)); }   /* the letters' middle on the BACK button's (#953) */
.stage-top .var-row { flex-wrap: nowrap; gap: calc(1 * var(--u)); margin: 0 0 0 auto; }
.stage-top .var-btn .vk { font-style: normal; opacity: .75; }
body.is-mobile .stage-top .var-btn .vk { display: none; }
.stage-body {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: calc(1.6 * var(--u)); min-height: 0;   /* the preview's head wraps, not the page (#720) */
  position: absolute; top: calc(10.6 * var(--u)); right: calc(3 * var(--u)); bottom: calc(3 * var(--u)); left: calc(3 * var(--u));
}
.stage-list { display: flex; flex-direction: column; min-height: 0; margin: 0; padding: calc(1.2 * var(--u)); }
.sl-head { display: flex; justify-content: space-between; padding: 0 calc(.6 * var(--u)) calc(.8 * var(--u)); color: var(--yellow); font-size: calc(1.6 * var(--u)); letter-spacing: .12em; }
.sl-rows { display: flex; flex: 1; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; padding: 4px; }
.stage-row {
  display: grid; grid-template-columns: calc(3.6 * var(--u)) minmax(0, 1fr) auto; align-items: center; gap: calc(1.4 * var(--u));
  flex: none; min-height: max(40px, calc(5.6 * var(--u))); padding: calc(.5 * var(--u)) calc(1 * var(--u)); appearance: none; cursor: pointer;
  border: 0; background: rgba(0,0,0,.25); color: #fff; font: inherit; text-align: left;
}
.stage-row.locked { cursor: help; opacity: .45; }   /* a click says what opens it (#358) */
html[data-ui="led"] .stage-row { border-bottom: 2px solid rgba(255,90,31,.25); }
html[data-ui="led"] .stage-row.focus { background: var(--ui-lava-d); box-shadow: var(--lava-press); }
html[data-ui="blocks"] .stage-row { border-bottom: 2px solid rgba(0,0,0,.25); }
html[data-ui="blocks"] .stage-row.focus { background: var(--ui-grass); box-shadow: var(--grass-press); }
.sr-cube { width: calc(3.6 * var(--u)); height: calc(3.6 * var(--u)); background: linear-gradient(var(--ct) 0 35%, var(--cs) 35%); box-shadow: inset 3px 3px 0 rgba(255,255,255,.25), inset -3px -3px 0 rgba(0,0,0,.35), 0 0 0 2px #000; }
.sr-txt { display: grid; min-width: 0; }
.sr-name { overflow: hidden; font-size: calc(2 * var(--u)); }
.sr-txt small { overflow: hidden; color: #e6c9a0; font-size: calc(1.4 * var(--u)); letter-spacing: .05em; }   /* the pixel font stays 2 px a dot: a long line wraps (#720) */
@media (max-width: 760px) {   /* a narrow phone or window (#1204): the facts on one line (the card's head says SS1, its bars the pace), a car's name too */
  body.is-mobile :is(.sr-ss, .cr-sprint) { display: none; }
  body.is-mobile .car-row { column-gap: calc(.8 * var(--u)); }
}
.sr-best { display: flex; align-items: center; gap: calc(.5 * var(--u)); color: var(--yellow); font-size: calc(1.6 * var(--u)); }
.sr-best .medal { margin: 0; }
.stage-right { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: calc(1.4 * var(--u)); min-height: 0; }
.stage-preview { display: flex; flex-direction: column; gap: calc(.8 * var(--u)); overflow: hidden; min-height: 0; margin: 0; padding: calc(1.4 * var(--u)) calc(1.6 * var(--u)); }
.sp-head { color: var(--yellow); font-size: calc(1.5 * var(--u)); letter-spacing: .12em; }
.sp-head > span { display: block; }   /* a block, so a long country wraps inside the preview (#720) */
html[data-ui="led"] :is(.sl-head, .sp-head) { color: var(--ui-ember); }
html[data-ui="blocks"] :is(.sl-head, .sp-head) { color: #fff; }
.sp-name { color: #fff; font-size: calc(2.6 * var(--u)); }
.sp-pics { display: grid; flex: 1; grid-template-columns: 1fr 1fr; gap: calc(1 * var(--u)); min-height: 0; }
.sp-art, .stage-map { overflow: hidden; position: relative; min-height: 0; background: rgba(0,0,0,.4); box-shadow: 0 0 0 2px #000; }
.sp-art img, .stage-map canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.sp-art img { object-fit: cover; }
.stage-preview .chips { margin: 0; }
.stage-preview .chip { font-size: calc(1.4 * var(--u)); }
.stage-preview .cstats { padding-top: calc(.6 * var(--u)); }
.stage-preview .cstats small { font-size: calc(1.3 * var(--u)); }
.stage-preview .cstats b { font-size: calc(1.8 * var(--u)); }
.stage-play { white-space: nowrap; }
body.is-mobile .sp-pics { grid-template-columns: 1fr; }
body.is-mobile .sp-art, body.is-mobile .stage-preview .chips { display: none; }
.stage-top .var-btn { font-size: calc(1.45 * var(--u)); }
body.is-mobile .stage-preview .cstats { grid-template-columns: auto auto; column-gap: calc(1.4 * var(--u)); }
body.is-mobile .stage-preview .cstats > div:first-child { display: none; }
body.is-mobile .stage-preview .cstats small { font-size: calc(1.2 * var(--u)); }
body.is-mobile .stage-preview .cstats b { font-size: calc(1.6 * var(--u)); }

/* -------------------------------------------- settings in tabs (#316) */
/* the tab bar, one section at a time, the panel scrolls */
.screen-settings { overflow: hidden; padding: 0; }
.set-tabs { display: flex; flex-wrap: nowrap; gap: calc(.8 * var(--u)); position: absolute; top: calc(9.6 * var(--u)); right: calc(3 * var(--u)); left: calc(3 * var(--u)); }
.set-tabs .btn { display: flex; flex: 1 1 auto; justify-content: center; align-items: center; min-width: 0; height: max(40px, calc(5 * var(--u))); padding: 0 calc(.8 * var(--u)); font-size: calc(1.6 * var(--u)); white-space: nowrap; }
.screen-settings .settings { overflow-y: auto; position: absolute; top: calc(16.4 * var(--u)); right: calc(3 * var(--u)); bottom: calc(3 * var(--u)); left: calc(3 * var(--u)); max-width: none; padding: 4px 1.8rem 4px 4px; }
body.is-mobile .screen-settings .settings { top: calc(9.6 * var(--u) + 48px); }
.screen-settings .set-group { margin: 0; }
.screen-settings .set-group h3 { display: none; }
/* the open tab is yellow with dark letters, the focus red like on any button; both: yellow in a red ring (#1205, docs/UI.md) */
html[data-ui] .set-tab.on, html[data-ui] .set-tab.on.focus { background: var(--yellow); color: #111; box-shadow: inset 0 0 0 3px #fff8; }
html[data-ui] .set-tab.on.focus { box-shadow: inset 0 0 0 4px var(--ui-lava); }

/* -------------------------------------------------------- goal card (#327) */
/* #444 (CrazyGames QA): over the sky under the pace note, not on the road ahead; the controls tip at the bottom */
.hud-goal {
  display: flex; flex-direction: column; align-items: center; gap: .35rem; position: absolute; top: 22vh; left: 50%; max-width: 92vw;
  padding: .55rem 1.2rem; transform: translateX(-50%); background: rgba(5, 4, 3, .72); box-shadow: var(--ring);
}
body.hud-small .hud-goal { flex-flow: row wrap; justify-content: center; gap: .1rem .8rem; top: 33vh; padding: .15rem .7rem .25rem; }   /* title and "gold = win" on one line */
body.hud-small .hud-goal .hg-medals { flex-basis: 100%; justify-content: center; }
.hud-goal .hg-medals { display: flex; gap: 1.4rem; }

/* ------------------------------------------------ the goals carousel (#439) */
/* ------------------------------------------------------------- ads (#326) */
/* x2 the run's points for an ad (#666): a wide green reward button that pulses, apart from the yellow CONTINUE (#848) */
html[data-ui] .screen-results .btn.res-boost {
  display: flex; align-items: center; justify-content: center; gap: .55rem; width: 100%; min-height: max(48px, 3.1rem); margin-top: .8rem;
  padding: .4rem 1rem; border-color: #000; background: linear-gradient(#63d65a 0 50%, #2f9a3a 50%); color: #fff; font-size: 1.2rem; letter-spacing: .04em;
  box-shadow: inset 4px 4px 0 #c2f7a8, inset -4px -4px 0 #1b5420, 0 0 0 2px #000; animation: boost-glow 1.4s ease-in-out infinite;
}
html[data-ui] .screen-results .btn.res-boost::before { content: ''; flex: none; border-left: .75em solid #fff; border-block: .45em solid transparent; }   /* the ad's play mark */
html[data-ui] .screen-results .btn.res-boost.focus { background: linear-gradient(#86ee6c 0 50%, #3fb64a 50%); box-shadow: inset 4px 4px 0 #e2ffd0, inset -4px -4px 0 #1b5420, 0 0 0 2px #000, 0 0 0 6px var(--yellow); }
html[data-ui] .screen-results .btn.res-boost.on { animation: none; background: rgba(0, 0, 0, .6); color: var(--yellow); box-shadow: 0 0 0 2px #000; }
html[data-ui] .screen-results .btn.res-boost.on::before { display: none; }
@keyframes boost-glow { 50% { box-shadow: inset 4px 4px 0 #c2f7a8, inset -4px -4px 0 #1b5420, 0 0 0 2px #000, 0 0 0 6px rgba(143, 238, 108, .55); } }
@media (prefers-reduced-motion: reduce) { html[data-ui] .screen-results .btn.res-boost { animation: none; } }
body.is-mobile .screen-results .btn.res-boost { min-height: 44px; margin-top: .4rem; font-size: 1rem; }
.ad-veil { z-index: 90; position: fixed; inset: 0; background: rgba(0, 0, 0, .85); }   /* over the menu while a midgame ad plays */
/* the garage like the road book (#619): a car row = picture, name, drive and 0-100, its state on the right */
.screen-cars { overflow: hidden; padding: 0; }
.screen-cars .stage-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.screen-cars :is(.stage-right, .stage-preview) { min-width: 0; }
.car-row { grid-template-columns: calc(8.4 * var(--u)) minmax(0, 1fr) auto; min-height: max(44px, calc(5.2 * var(--u))); }
.car-row.locked { opacity: .55; }
.car-row.locked .cr-pic, .cp-art.locked img { filter: grayscale(1) brightness(.55); }
.car-row.chosen { box-shadow: inset calc(.6 * var(--u)) 0 0 #6fe36f; }
.cr-pic { display: block; width: calc(8.4 * var(--u)); height: calc(4.2 * var(--u)); box-shadow: 0 0 0 2px #000; }
.cr-pic img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.car-row .sr-best { white-space: nowrap; }
.cr-sprint { display: inline-block; max-width: 100%; }   /* a box with a width: its 0-100 line wraps in the column, not past it (#1227) */
body.is-mobile .car-row .cr-tick { display: none; }   /* the green edge and the preview's head say it: room for the name (#720) */
body.is-mobile .car-row { grid-template-columns: calc(6.4 * var(--u)) minmax(0, 1fr) auto; }
body.is-mobile .car-row .cr-pic { width: calc(6.4 * var(--u)); height: calc(3.2 * var(--u)); }
.cr-tick { color: #6fe36f; }
.cr-lent { color: var(--yellow); }
.car-row .padlock, .cp-art .padlock { position: relative; width: calc(1.8 * var(--u)); height: calc(1.4 * var(--u)); margin-top: calc(.8 * var(--u)); background: #e6c9a0; box-shadow: 0 0 0 2px #000; }
.cp-art .padlock { position: absolute; top: 45%; left: 50%; width: calc(2.6 * var(--u)); height: calc(2 * var(--u)); margin: 0; transform: translate(-50%, -50%); }
:is(.car-row, .cp-art) .padlock::before { content: ''; position: absolute; right: 18%; bottom: 100%; left: 18%; height: 60%; border: calc(.35 * var(--u)) solid #e6c9a0; border-bottom: 0; }
:is(.car-row, .cp-art) .padlock::after { content: ''; position: absolute; top: 30%; left: 50%; width: calc(.35 * var(--u)); height: 40%; margin-left: calc(-.175 * var(--u)); background: #000; }
.cp-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: calc(1.6 * var(--u)); }
.cp-art { aspect-ratio: 2 / 1; }
.cp-art img { object-fit: contain; }
.cp-side { display: flex; flex-direction: column; gap: calc(.8 * var(--u)); min-width: 0; }
.cp-side .cbars { display: grid; grid-template-columns: max-content 1fr; align-items: center; gap: calc(.7 * var(--u)) calc(1 * var(--u)); font-size: calc(1.4 * var(--u)); letter-spacing: .06em; }
.cp-side .cbar { display: block; height: calc(1 * var(--u)); margin: 0; background: var(--bar-track); }
.cp-side .cbar u { display: block; height: 100%; background: var(--yellow); }
.cp-side .cdrive { color: #aeb7c4; font-size: calc(1.3 * var(--u)); letter-spacing: .06em; }
/* the run history (#840) like the road book: a run per row, its details beside the list (a phone: on a screen of their own) */
:is(.screen-history, .screen-historyRun) { overflow: hidden; padding: 0; }
.screen-history .stage-body { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
body.is-mobile .screen-history .stage-body, .screen-historyRun .stage-body { grid-template-columns: minmax(0, 1fr); }
.screen-history :is(.stage-right, .stage-preview) { min-width: 0; }
.hist-row {
  /* the run's date | its stage, the mode's tag under it | time | against the record | place | award | score. The pixel text
     never goes under scale 2 (12 px a letter) and steps to 3 (18 px) at about 15 u: every column with text fits its
     longest text at the step, with a px floor for small windows (#1001: 1:54.53 and +11900 were cut) */
  grid-template-columns: max(calc(5.8 * var(--u)), 62px) minmax(0, 1fr) max(calc(6.8 * var(--u)), 86px) max(calc(9.8 * var(--u)), 86px) max(calc(3.6 * var(--u)), 38px) max(calc(1.6 * var(--u)), 14px) max(calc(7.2 * var(--u)), 74px);
  grid-template-areas: 'when map time delta pos aw score' 'when mode time delta pos aw score'; grid-template-rows: auto auto; align-items: center; row-gap: calc(.3 * var(--u));
  gap: calc(.7 * var(--u)); min-height: max(40px, calc(5 * var(--u))); font-size: calc(1.3 * var(--u));
}
.hi-when { grid-area: when; } .hi-map { grid-area: map; } .hi-mode { grid-area: mode; }
body:not(.is-mobile) .hist-row .hi-map { align-self: end; } body:not(.is-mobile) .hist-row .hi-mode { align-self: start; }   /* the name and its tag as one block in the middle */
.hi-time { grid-area: time; } .hi-delta { grid-area: delta; } .hi-pos { grid-area: pos; } .hi-aw { grid-area: aw; } .hi-score { grid-area: score; }
.hist-row > * { min-width: 0; overflow: hidden; }
.hi-when { color: #e6c9a0; font-size: calc(1.15 * var(--u)); line-height: 1.25; }
.hi-mode { justify-self: start; max-width: 100%; padding: calc(.3 * var(--u)) calc(.45 * var(--u)); color: #1a1206; font-size: calc(1.05 * var(--u)); white-space: nowrap; box-shadow: inset -2px -2px 0 rgba(0,0,0,.25); }
.hi-mode.m-stage { background: var(--ui-stone-hi); } .hi-mode.m-cup { background: var(--yellow); } .hi-mode.m-daily { background: var(--ui-lava-l); }
.hi-mode.m-gym { background: var(--ui-grass-hi); } .hi-mode.m-online { background: var(--blue); color: #fff; }
body:not(.is-mobile) .hist-row .hi-delta { white-space: normal; line-height: 1.25; }   /* REC -0.12 and FIRST RUN: two lines, like the date */
.hi-map { line-height: 1.25; }   /* a long name wraps to a second line, like the date beside it */
:is(.hi-time, .hi-delta, .hi-pos, .hi-score) { text-align: right; white-space: nowrap; }
.hi-time { font-weight: normal; }
.hi-delta.d-rec { color: var(--green); } .hi-delta.d-slower { color: var(--red-soft); } .hi-delta.d-first { color: var(--yellow); }
.hi-score { color: var(--yellow); } .hi-score.zero { color: #8a7f76; }
.hi-aw .medal { width: calc(1.4 * var(--u)); height: calc(1.4 * var(--u)); margin: 0; }
/* a phone: two lines a row, mode | map / date | time / against | place / score | award */
body.is-mobile .hist-row {
  grid-template-columns: calc(13.4 * var(--u)) minmax(0, 1fr) calc(15 * var(--u)) calc(7.4 * var(--u)) calc(2.4 * var(--u)); grid-template-rows: auto auto;
  grid-template-areas: 'mode map time pos aw' 'mode when delta score aw'; row-gap: calc(.3 * var(--u)); min-height: max(44px, calc(8 * var(--u))); font-size: calc(2 * var(--u));
}
body.is-mobile .hi-mode { grid-area: mode; font-size: calc(1.4 * var(--u)); } body.is-mobile .hi-map { grid-area: map; white-space: nowrap; } body.is-mobile .hi-time { grid-area: time; }
body.is-mobile .hi-pos { grid-area: pos; } body.is-mobile .hi-aw { grid-area: aw; } body.is-mobile .hi-score { grid-area: score; font-size: calc(1.5 * var(--u)); }
body.is-mobile .hi-delta { grid-area: delta; font-size: calc(1.5 * var(--u)); }
body.is-mobile .hist-row .hi-delta { display: flex; justify-content: flex-end; overflow: visible; }   /* FIRST RUN runs left into the date's room, not cut (#1224) */
body.is-mobile .hi-when { grid-area: when; font-size: calc(1.5 * var(--u)); white-space: nowrap; }
body.is-mobile .hi-aw .medal { width: calc(2 * var(--u)); height: calc(2 * var(--u)); }
.hist-card { display: flex; flex-direction: column; gap: calc(1 * var(--u)); }
.hc-main { display: flex; flex-direction: column; gap: calc(.8 * var(--u)); }
.hc-field { display: flex; flex: 1; flex-direction: column; gap: calc(.5 * var(--u)); min-height: 0; }
.hist-card .hc-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: calc(.4 * var(--u)) calc(1.4 * var(--u)); }
.hist-card .hc-time { color: var(--yellow); font-weight: normal; font-size: calc(3.6 * var(--u)); line-height: 1; }
.hist-card .hc-big .hi-delta { font-size: calc(1.4 * var(--u)); }
.hist-card .cstats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hist-card .cstats b { font-size: calc(1.5 * var(--u)); }
.hc-cup { display: flex; align-items: center; gap: calc(.8 * var(--u)); padding: calc(.5 * var(--u)) calc(.8 * var(--u)); border: 2px solid var(--yellow); color: var(--yellow); font-size: calc(1.3 * var(--u)); }
.hc-cup .medal { width: calc(1.5 * var(--u)); height: calc(1.5 * var(--u)); margin: 0; flex: none; }
.hc-rv-h { color: #aeb7c4; font-size: calc(1.25 * var(--u)); letter-spacing: .08em; }
.hc-rivals { display: grid; align-content: start; gap: 2px; min-height: 0; overflow-y: auto; }
.hi-rv { display: grid; grid-template-columns: calc(2.6 * var(--u)) minmax(0, 1fr) calc(6.6 * var(--u)) calc(5.4 * var(--u)); gap: calc(.5 * var(--u)); padding: calc(.3 * var(--u)) calc(.5 * var(--u)); font-size: calc(1.15 * var(--u)); }
.hi-rv > * { min-width: 0; overflow: hidden; white-space: nowrap; }
.hi-rv b { font-weight: normal; text-align: right; } .hi-gap { color: #aeb7c4; text-align: right; }
.hi-rv.me { background: rgba(255,90,31,.28); color: var(--yellow); }
/* a phone's run screen: the run on the left, the table on the right */
.screen-historyRun .hist-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: calc(2 * var(--u)); }
body.is-mobile .hist-card .cstats > div:first-child { display: block; }   /* the stages' preview hides its first stat on a phone */
body.is-mobile .hist-card .cstats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
body.is-mobile .hi-rv { font-size: calc(1.7 * var(--u)); grid-template-columns: calc(3.8 * var(--u)) minmax(0, 1fr) calc(10.8 * var(--u)) calc(9.6 * var(--u)); }
body.is-mobile :is(.hc-rv-h, .hist-card .hc-big .hi-delta, .hc-cup) { font-size: calc(1.7 * var(--u)); }
/* the SCORE board opens the history once there is one (#842) */
.start-score .hist-link { justify-self: end; font-size: calc(1.3 * var(--u)); letter-spacing: .1em; color: var(--yellow); }
.start-score[data-nav] { cursor: pointer; }
.start-score[data-nav].focus { outline: max(3px, calc(.45 * var(--u))) solid var(--yellow); outline-offset: max(2px, calc(.25 * var(--u))); }
.car-preview .cblurb { color: #fff; font-size: calc(1.45 * var(--u)); line-height: 1.35; }
.cp-lock { color: var(--yellow); font-size: calc(1.5 * var(--u)); }
.cp-handling { margin: 0; padding: 0; }
.cp-handling .set-row { display: grid; grid-template-columns: 1fr; gap: calc(.4 * var(--u)); min-height: 0; margin: 0; padding: calc(.5 * var(--u)); background: rgba(0, 0, 0, .25); }
.cp-handling .set-label { font-size: calc(1.4 * var(--u)); }
.cp-handling .set-hint { display: block; margin-top: calc(.3 * var(--u)); color: #ffe08a; font-size: calc(1.1 * var(--u)); opacity: 1; }
.cp-handling .ends { display: flex; justify-content: space-between; gap: 1rem; color: #9fd6ff; font-size: calc(1.1 * var(--u)); opacity: 1; }
.cp-handling .ends em { font-style: normal; }   /* STABLE ... AGILE over the blocks */
.car-go { overflow: hidden; }
.car-go.ad { background: var(--yellow); }
body.is-mobile :is(.cp-art, .car-preview .cblurb) { display: none; }
@media (max-height: 600px) { .car-preview .cblurb { display: none; } }   /* a small window: the bars and the drive say it (#720) */
body.is-mobile .cp-row { grid-template-columns: 1fr; }
body.is-mobile .cp-side { gap: calc(.5 * var(--u)); }
body.is-mobile .cp-handling .set-row { grid-template-columns: auto 1fr; align-items: center; }
body.is-mobile .cp-handling :is(.ends, .set-hint) { display: none; }
@media (max-height: 360px) { body.is-mobile .cp-side .cdrive { display: none; } }   /* the row says the drive: room for HANDLING (#720) */

/* ------------------------------------------------- the other menus (#317) */
/* a top bar on the scrolling screens; the player's row and the key in the face's colours */
.stage-top.static { position: static; margin: 0 0 .6rem; }
:is(.screen-stages, .screen-settings, .screen-help, .screen-privacy, .screen-cars, .screen-history, .screen-historyRun) .stage-top.static { position: absolute; margin: 0; }   /* the screens laid out in --u units: the bar over their absolute rows */
body.goal-on .hud-tip { top: auto; bottom: 4vh; max-width: 54vw; }   /* #327, #444: at the bottom between the corner panels */
body.is-touch.goal-on .hud-tip { max-width: 44vw; }   /* between the steering pads and the pedals (#444) */
/* "what is missing" over a locked car or stage (#358) */
.lock-help { display: flex; justify-content: center; align-items: center; z-index: 20; position: fixed; inset: 0; background: rgba(0, 0, 0, .62); }
.lock-help .panel { display: grid; gap: .45rem; width: min(34rem, 90vw); padding: 1.2rem 1.6rem; }
.lock-help small { margin-top: .4rem; color: var(--dim); letter-spacing: .12em; }
.lock-help p { margin: 0; }
.lock-help .row-foot { justify-content: flex-start; margin-top: .8rem; }
.res-grid.daily-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin-top: .6rem; }
@media (max-height: 520px) {   /* a phone on its side: the whole tournament on one view */
  .screen-daily .top-sub { display: none; }
  .screen-daily .stage-top.static { margin-bottom: .3rem; }
  .daily-grid .panel { padding: 6px 10px; }
  .daily-grid h3 { margin: 2px 0 4px; font-size: .9rem; }
  .daily-grid .res-lines > div, .daily-board .brow { padding: 1px 0; font-size: .8rem; }
  .daily-board .brow em { display: none; }
  .screen-daily .row-foot { padding-top: .4rem; }
  /* the facts and the table scroll in their box, BACK and PLAY stay in the window (640x300: PLAY ran under it, #1224) */
  .screen-daily { overflow: hidden; }
  .screen-daily > .res-grid { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
  .screen-daily > :is(.stage-top, .row-foot) { flex: none; }
}
@media (max-height: 360px) { .screen-daily { padding-block: 4px; } .screen-daily .res-grid.daily-grid { margin-top: .2rem; } .screen-daily .row-foot { padding-top: 0; } }   /* 640x300: the whole table over PLAY */
/* the GYMKHANA on one screen (#696): the map takes what is left, DRIVE and the table always show */
.screen-gymkhana { overflow: hidden; padding: 2.5vh 5vw 2vh; }
.screen-gymkhana .stage-top.static { margin-bottom: .3rem; }
.screen-gymkhana .res-grid.daily-grid { flex: 1 1 0; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); align-items: stretch; min-height: 0; margin-top: .3rem; }
.screen-gymkhana .gym-route { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.screen-gymkhana .gym-map { flex: 1 1 0; height: 0; min-height: 0; object-fit: contain; }
.screen-gymkhana .row-foot { flex: none; padding-top: .7rem; }
@media (max-height: 420px) { .screen-gymkhana .gym-map { display: block; } }   /* one screen leaves it room here (#696) */
@media (max-height: 640px) {
  .screen-gymkhana { padding-top: 1.5vh; padding-bottom: 1.5vh; }
  .screen-gymkhana .top-sub { display: none; }
  .screen-gymkhana .panel { padding: 3px 10px; }
  .screen-gymkhana h3 { margin: 0 0 2px; font-size: .9rem; }
  .screen-gymkhana .res-lines > div, .screen-gymkhana .brow { padding: 0; font-size: .8rem; }
  .screen-gymkhana .brow em { display: none; }
  .screen-gymkhana .board { column-gap: 8px; }
  .screen-gymkhana .board .brow { gap: 8px; padding: 1px .2rem 1px 0; border-bottom-width: 1px; }
  .screen-gymkhana .brow i { font-size: .8rem; }
  .screen-gymkhana .row-foot { padding-top: .2rem; }
  .screen-gymkhana .btn { padding-top: .3rem; padding-bottom: .3rem; }
}
@media (max-width: 700px) {   /* a small phone: the facts one to a line, the names give way (#720) */
  :is(.screen-gymkhana, .screen-daily) .res-grid.daily-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: .6rem; }   /* 1.35fr cut every name (#1224) */
  :is(.screen-gymkhana, .screen-daily) .res-lines > div { column-gap: .6rem; }
  :is(.screen-gymkhana, .screen-daily) .daily-board { column-gap: 6px; padding-inline: 6px; }
  :is(.screen-gymkhana, .screen-daily) .daily-board .brow { gap: 6px; padding-inline: 0; }
}
.brow .ava { width: 1.3em; height: 1.3em; margin-right: .4em; vertical-align: middle; image-rendering: auto; box-shadow: 0 0 0 2px #000; }
/* a car's performance bars and drivetrain (#419) */
.cbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .25rem .5rem; margin: .5rem 0 .7rem; font-size: 1rem; }
.help-item .cbars { display: grid; grid-template-columns: max-content 1fr; align-items: center; gap: 4px .6em; margin: .35rem 0 .2rem; font-size: .72rem; letter-spacing: .06em; }
.help-item .cbar { display: block; height: 7px; background: var(--bar-track); }
.help-item .cbar u { display: block; height: 100%; background: var(--yellow); }
.help-item .cdrive { color: var(--dim); font-size: .72rem; letter-spacing: .06em; }

/* ---------------------------------------------------------- the guide (#429) */
/* like the settings: tabs over a scrolling list of entries */
.screen-help { overflow: hidden; padding: 0; }
.screen-help .help-body { overflow-y: auto; position: absolute; top: calc(16.4 * var(--u)); right: calc(3 * var(--u)); bottom: calc(3 * var(--u)); left: calc(3 * var(--u)); max-width: none; padding: 4px 1.8rem 4px 4px; }
body.is-mobile .screen-help .help-body { top: calc(9.6 * var(--u) + 48px); }
.screen-help .set-group { margin: 0; padding-top: .4rem; }
/* the privacy policy (#852): the guide's look without its tabs */
.screen-privacy { overflow: hidden; padding: 0; }
.screen-privacy .help-body { overflow-y: auto; position: absolute; top: calc(10.6 * var(--u)); right: calc(3 * var(--u)); bottom: calc(3 * var(--u)); left: calc(3 * var(--u)); max-width: none; padding: 4px 1.8rem 4px 4px; }
body.is-mobile .screen-privacy .help-body { top: calc(6 * var(--u) + 40px); }
.screen-privacy .set-group { margin: 0; padding-top: .4rem; }
.help-item { position: relative; margin: 0 -.9rem; padding: .6rem .9rem; border: 3px solid transparent; border-bottom-color: rgba(0, 0, 0, .45); }
/* long text (guide, privacy, the MP card): one readable size in --u, pixel scale 3 at 1280x720 and never under 2 (#1208) */
.screen-help, .screen-privacy, .screen-mp { --txt: max(16px, calc(1.9 * var(--u))); }
.help-item .hi-t { display: block; margin-bottom: .35rem; color: var(--yellow); font-size: var(--txt, 1.2rem); font-weight: normal; }
.help-item .hi-d { max-width: 64rem; margin: 0; color: #e6dccb; font-size: var(--txt, 1rem); line-height: 1.55; }
.help-item .cbars { max-width: 26rem; margin-top: .5rem; }
.help-item.focus { border-color: #fff; background: var(--row-pick); box-shadow: inset .55rem 0 0 var(--yellow), var(--ring); }
html[data-ui="led"] .help-item.focus { border-color: #000; background: var(--ui-lava-d); box-shadow: inset .55rem 0 0 var(--ui-spark), var(--ring); }
html[data-ui="blocks"] .help-item.focus { border-color: #000; background: var(--ui-grass); box-shadow: var(--grass-press), var(--ring); }
.help-ctl { margin: .9rem 0 .3rem; }

/* ------------------------------------------------------------------ motion */
/* stepped, retro: screens and their tiles come in one after another, the focus pulses, the chosen car idles */
@keyframes fadein { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes cd {   /* a countdown digit lands big, holds, fades */
  0% { transform: scale(1.5); opacity: 0; } 15% { transform: scale(1); opacity: 1; } 75% { opacity: 1; } 100% { transform: scale(1); opacity: 0; }
}
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes msg { 0%, 100% { opacity: 0; } 10%, 80% { opacity: 1; } }
@keyframes log-line { 0%, 100% { opacity: 0; } 4%, 85% { opacity: 1; } }
@keyframes log-flash { 50% { background: var(--red); } }
@keyframes mcr-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes mcr-glow { 50% { box-shadow: inset .45rem 0 0 var(--yellow), var(--ring), 0 0 0 6px #fff; } }
@keyframes mcr-nudge { 50% { transform: translate(.35rem, -50%); } }
@keyframes mcr-pop { 0% { transform: scale(1.45); } 60% { transform: scale(.9); } 100% { transform: scale(1); } }
@keyframes mcr-cur { 50% { background: #fff6b0; } }
@keyframes mcr-shine { 0% { left: -5rem; } 55%, 100% { left: 110%; } }
@keyframes mcr-bob { 50% { transform: translateY(-3%); } }
@keyframes mcr-float { 50% { transform: translateY(-.35rem); } }
@keyframes mcr-logo-in { from { opacity: 0; transform: translateY(24px) scale(1.06); } to { opacity: 1; transform: none; } }
@keyframes ui-glow { 50% { filter: brightness(1.28); } }
@keyframes rot-turn {   /* hold upright, turn in pixel steps, hold sideways while the car crosses, snap back */
  0% { transform: rotate(0); } 22% { transform: rotate(0); animation-timing-function: steps(5, end); } 42% { transform: rotate(-90deg); }
  92% { transform: rotate(-90deg); animation-timing-function: steps(1, end); } 100% { transform: rotate(0); }
}
@keyframes rot-show { 0%, 44% { opacity: 0; } 48%, 90% { opacity: 1; } 94%, 100% { opacity: 0; } }
@keyframes rot-drive {
  0%, 46% { opacity: 0; transform: translateY(-16px); } 48% { opacity: 1; transform: translateY(-16px); }
  88% { opacity: 1; transform: translateY(96px); } 90%, 100% { opacity: 0; transform: translateY(96px); }
}
@keyframes rot-arrow { 0%, 18% { opacity: 1; } 24%, 92% { opacity: 0; } 100% { opacity: 1; } }
:is(.menu-col > .btn, .settings > .panel, .row-foot > .btn, .set-group .set-row) { animation: mcr-in .36s steps(4, end) both; }
:is(.menu-col > .btn, .settings > .panel):nth-child(2), .set-group .set-row:nth-of-type(2) { animation-delay: .05s; }
:is(.menu-col > .btn, .settings > .panel):nth-child(3), .set-group .set-row:nth-of-type(3) { animation-delay: .1s; }
.menu-col > .btn:nth-child(4), .set-group .set-row:nth-of-type(4) { animation-delay: .15s; }
.menu-col > .btn:nth-child(5), .set-group .set-row:nth-of-type(5) { animation-delay: .2s; }
.menu-col > .btn:nth-child(6), .set-group .set-row:nth-of-type(6) { animation-delay: .25s; }
/* an entering element gets a list (mcr-in, pulse): the same first name does not replay the entrance when the focus leaves */
.btn.focus { animation: mcr-glow 1s steps(2, end) infinite; }
:is(.menu-col > .btn.focus, .row-foot > .btn.focus, .set-group .set-row.focus) { animation: mcr-in .36s steps(4, end) both, mcr-glow 1s steps(2, end) infinite; }
/* with a face: the entrance stays only where the button plays it on screen open (#346) */
html[data-ui] .btn.focus { animation: ui-glow 1s steps(2, end) infinite; }
html[data-ui] :is(.menu-col > .btn.focus, .row-foot > .btn.focus) { animation: mcr-in .36s steps(4, end) both, ui-glow 1s steps(2, end) infinite; }
@media (prefers-reduced-motion: reduce) {
  .menu-col > .btn, .settings > .panel, .row-foot > .btn, .set-group .set-row, .btn.focus, .menu-col > .btn.focus, .row-foot > .btn.focus,
  .set-group .set-row.focus, .set-row.focus::before, .notch .blk.cur, .set-group h3::after,
  .logo-cv, .logo-pic, .load-badge, .badge,
  html[data-ui] .btn.focus, html[data-ui] .menu-col > .btn.focus, html[data-ui] .row-foot > .btn.focus { animation: none; }
}
/* the CrazyGames account under the SCORE board (#625): picture, name, LOG IN for a guest */
.start-who { display: flex; align-items: center; gap: calc(1 * var(--u)); margin-top: calc(.8 * var(--u)); color: #e6c9a0; font-size: calc(1.5 * var(--u)); letter-spacing: .06em; }
.start-who .who-name { display: inline-flex; align-items: center; gap: calc(.6 * var(--u)); padding: calc(.4 * var(--u)) calc(.8 * var(--u)); background: rgba(0, 0, 0, .6); white-space: nowrap; }
.start-who .ava { width: calc(2.4 * var(--u)); height: calc(2.4 * var(--u)); box-shadow: 0 0 0 2px #000; }
.start-who .who-login { min-height: 0; padding: calc(.5 * var(--u)) calc(1.2 * var(--u)); font-size: calc(1.4 * var(--u)); }
/* the x4 points window (#639): under the logo, a countdown; gold and pulsing while it is on */
.start-logo { position: relative; }
.start-rush { position: absolute; top: calc(100% + .8 * var(--u)); left: 50%; transform: translateX(-50%); padding: calc(.5 * var(--u)) calc(1.4 * var(--u)); border: 3px solid #000; background: rgba(5, 4, 3, .78); color: var(--yellow); font-size: calc(1.6 * var(--u)); letter-spacing: .08em; white-space: nowrap; }
.start-rush .pxt { display: flex; justify-content: center; }   /* no line box under the drawn text (#799, as the buttons in #666) */
.start-rush.on { background: var(--yellow); color: #1a1206; font-size: calc(2 * var(--u)); }   /* the booster running (#856): calm, it counts down */
/* BOOSTER x2 (AD) (#856): green like the 2x SCORE button (#848), pulsing so it is seen */
.start-rush.offer { cursor: pointer; background: linear-gradient(#63d65a 0 50%, #2f9a3a 50%); color: #0c2a0e; font-size: calc(1.8 * var(--u)); box-shadow: inset 3px 3px 0 #c2f7a8, inset -3px -3px 0 #1b5420; animation: rush-pulse 1.2s ease-in-out infinite; }
.start-rush.offer.focus { background: linear-gradient(#86ee6c 0 50%, #3fb64a 50%); outline: max(3px, calc(.45 * var(--u))) solid var(--yellow); outline-offset: max(2px, calc(.25 * var(--u))); }
@keyframes rush-pulse { 50% { box-shadow: inset 3px 3px 0 #c2f7a8, inset -3px -3px 0 #1b5420, 0 0 0 calc(.6 * var(--u)) rgba(143, 238, 108, .55); } }
@media (prefers-reduced-motion: reduce) { .start-rush.offer { animation: none; } }
/* right of the time panel, out of the column: short screens have no height to spare (#639) */
.hud-rush { position: absolute; top: 0; left: calc(19rem + .5rem); padding: .2rem .5rem; border: 3px solid #000; background: var(--yellow); }
.badge.rush { background: var(--yellow); color: #1a1206; }
body.is-mobile .start-rush { font-size: calc(1.4 * var(--u)); }
body.is-mobile .start-rush:is(.on, .offer) { font-size: calc(1.6 * var(--u)); }

/* the always-visible scroll bar on touch screens (#644, scroll-bar.js) */
.sbar { z-index: 250; position: fixed; width: 5px; background: rgba(0, 0, 0, .45); pointer-events: none; }
.sbar i { display: block; width: 100%; background: #e6c9a0; }

.gym-map { display: block; width: 100%; height: auto; margin-top: .6rem; background: #2a2620; box-shadow: var(--ring); image-rendering: pixelated; }
@media (max-height: 420px) { .gym-map { display: none; } }   /* a phone on its side: the facts and the table */

/* ---------------------------------------------- the start screen's layout (#666)
   From the player's design in the layout editor: a left column (the x4 bar over SCORE at the top; the target card and
   GYMKHANA over STAGES + CARS at the bottom), PLAY's column on the right (the daily tournament over PLAY), CHAMPIONSHIP
   between them and the scene open in the middle. One gutter (--G) everywhere; the cards of one row one height (--ch).
   A phone on its side (2:1 and wider) moves GYMKHANA into the bottom row and the tournament up beside the target. */
.screen-main { --L: calc(28 * var(--u)); --R: var(--pw); --G: calc(1.6 * var(--u)); --bh: max(44px, calc(5.6 * var(--u))); --ch: max(44px, calc(5.2 * var(--u))); }
body.is-mobile .screen-main { --G: calc(1.3 * var(--u)); --bh: max(44px, calc(6.6 * var(--u))); --ch: max(44px, calc(6.6 * var(--u))); }
@media (min-aspect-ratio: 2/1) { body.is-mobile .screen-main { --L: calc(34 * var(--u)); } }   /* the x4 bar's text fits */
/* the dock's buttons along the bottom (#828, A2 #921): one height, the lines kept whole */
.start-dock .btn { display: grid; position: relative; grid-template-columns: minmax(0, 1fr); align-content: center; justify-items: center; gap: max(4px, calc(.5 * var(--u))); min-width: 0; height: max(64px, calc(11 * var(--u))); box-sizing: border-box; padding: calc(.8 * var(--u)); white-space: nowrap; }
.start-dock .btn small { font-size: calc(1.05 * var(--u)); letter-spacing: .08em; }
.choice-card .dot { position: absolute; top: calc(.9 * var(--u)); right: calc(.9 * var(--u)); width: max(8px, calc(1.1 * var(--u))); height: max(8px, calc(1.1 * var(--u))); background: var(--red); box-shadow: 0 0 0 2px #000; }
body:is(.is-touch, .is-mobile) :is(.start-dock .btn, .choice-card) { display: grid; }   /* the touch rule for buttons makes them flex rows */
:is(.start-dock .btn, .choice-card) > * { max-width: 100%; }   /* a line too long for the tile wraps (MenuText wraps at the parent's width) */
html[data-ui="led"] .choice-card {
  border: 3px solid #000; background: rgba(5, 4, 3, .86); color: var(--yellow); box-shadow: inset 4px 4px 0 #5a504a, inset -4px -4px 0 #000;
  clip-path: polygon(0 .6rem, .6rem 0, 100% 0, 100% calc(100% - .6rem), calc(100% - .6rem) 100%, 0 100%);
}
html[data-ui="led"] .choice-card.focus { background: var(--ui-lava-d); box-shadow: var(--lava-press); }
html[data-ui="led"] .choice-card small { color: #e6c9a0; }
html[data-ui="blocks"] .choice-card { background: var(--ui-plank); color: #2a1a0a; }
body.is-mobile .start-dock .btn { height: max(56px, calc(14 * var(--u))); padding: calc(.5 * var(--u)) calc(.2 * var(--u)); }   /* LIVE, ONLINE, QUICK, ROOM one under another clear of the bevel (#866) */
body.is-mobile .start-dock .btn small { font-size: calc(1.1 * var(--u)); }
body.is-mobile .start-dock .play-btn .tn { font-size: calc(3.4 * var(--u)); }
/* RACE's and TODAY's choice (#828): two big cards side by side */
.choice-row { display: flex; justify-content: center; gap: calc(3 * var(--u)); margin-top: calc(6 * var(--u)); padding: 0 calc(3 * var(--u)); }
.choice-card { display: grid; position: relative; grid-template-columns: minmax(0, 1fr); align-content: center; justify-items: center; gap: calc(1 * var(--u)); flex: 0 1 calc(40 * var(--u)); padding: calc(1 * var(--u)); min-width: 0; min-height: max(96px, calc(18 * var(--u))); box-sizing: border-box; }
.choice-card .tn { font-size: calc(2.4 * var(--u)); }
.choice-card small { font-size: calc(1.5 * var(--u)); letter-spacing: .08em; }
/* top left: the x4 bar, SCORE and the player, the column's width; the bar sits at the logo's height */
.screen-main .start-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--G); width: var(--L); flex: none; }
.screen-main .start-side .start-rush { position: static; transform: none; justify-self: stretch; padding-inline: calc(.8 * var(--u)); text-align: center; }
/* the column's one edge: the board draws a ring outside its box (#687) */
.screen-main .start-side > .start-score { margin-inline: 3px; }
.screen-main .start-side .start-who { flex: 1; justify-content: flex-end; min-width: 0; margin-top: 0; }
.screen-main .start-side .who-name { min-width: 0; overflow: hidden; }   /* a long nick is cut, LOG IN stays */
.screen-main .start-side .who-login { flex: none; }
.screen-main .start-side .sub { min-width: 0; }
.screen-main .start-side .start-score .num { font-size: calc(6.4 * var(--u) * var(--k, 1)); }   /* a lower board: the next car's line fits under it (#828) */
/* the left column holds its width: the board and the bar shrink to it, never push past it */
.screen-main .start-side > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
.screen-main .start-side .start-score .lvl i { min-width: calc(3 * var(--u)); }
body.is-mobile .screen-main .start-side .start-rush { padding-inline: calc(.6 * var(--u)); font-size: calc(1.2 * var(--u)); }
body.is-mobile .screen-main .start-side .start-rush:is(.on, .offer) { font-size: calc(1.3 * var(--u)); }
/* multiplayer screens (#747): the player's card, QUICK RACE's lobby */
.screen-mp .mp-card, .screen-mpLobby .mp-lobby { display: grid; gap: .6rem; width: min(34rem, 92vw); margin: 1rem auto 0; padding: 1rem 1.4rem; box-sizing: border-box; }
/* QUICK RACE's lobby (#1335): the pixel text is wider than 34 rem at the guide's size, so the frame takes its lines' width (never past
   the screen) and a column that may shrink: the bar, the rating and the ghosts' note ran past its right edge */
.screen-mpLobby .mp-lobby { grid-template-columns: minmax(0, 1fr); width: fit-content; min-width: min(34rem, 92vw); max-width: 92vw; }
.screen-mp .mp-card { grid-template-columns: minmax(0, 1fr); width: min(calc(48 * var(--u)), 92vw); font-size: var(--txt); }   /* the guide's text size (#1208); a long line wraps in the card, not past it (#1226) */
/* a computer's small window (#1226): the text stays 16 px while the editor's 52 u is 277 px at 640x300, so the card
   takes its lines' width (VANTA, LOSSES 0 ran past its edge) */
:root body.is-mobile.is-compact .screen-mp .panel.mp-card { width: fit-content; max-width: 92vw; }
.screen-mp .mp-who .ava { width: 1.3em; height: 1.3em; }
.mp-who, .mp-player { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.mp-who .ava, .mp-player .ava { width: 1.6rem; height: 1.6rem; image-rendering: pixelated; flex: none; }
.mp-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.mp-car { flex: none; color: var(--dim); font-weight: normal; }
.mp-conn, .mp-count { margin: 0; color: var(--dim); }
.mp-status { margin: 0; color: var(--accent, var(--yellow)); }
.mp-players { display: grid; gap: .35rem; }
.mp-player.me .mp-name { color: var(--accent, var(--yellow)); }
.screen-mp .row-foot, .screen-mpLobby .row-foot { justify-content: center; margin-top: 1rem; }
.screen-mpResults .mp-results { width: min(40rem, 92vw); margin: 1rem auto 0; box-sizing: border-box; }
.mp-results small { color: var(--dim); }
.mp-wait { margin: 0; text-align: center; }
.screen-mpResults .row-foot { justify-content: center; margin-top: 1rem; }
.screen-mpRoom .mp-lobby { display: grid; gap: .6rem; width: min(34rem, 92vw); margin: 1rem auto 0; padding: 1rem 1.4rem; box-sizing: border-box; }
.mp-room-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.mp-code { margin: 0; color: var(--accent, var(--yellow)); }
.mp-host { flex: none; font-style: normal; color: var(--accent, var(--yellow)); }
/* ghosts of real players' runs (#1275): a tag in the results, a note in the lobby that waits for them */
.mp-ghost { font-style: normal; color: #9fd8ff; }
.mp-ghost-note { margin: 0; color: var(--dim); }
.screen-mpRoom .row-foot { justify-content: center; align-items: center; gap: 1rem; margin-top: 1rem; }
.screen-mp .row-foot { gap: 1rem; }
@media (max-height: 420px) {   /* a low window: the card and the buttons fit, BACK never scrolls away (#1224) */
  .screen-mp .top-sub { display: none; }
  .screen-mp .mp-card { gap: .2rem; margin-top: .4rem; padding: .5rem 1rem; }
  .screen-mp .row-foot { margin-top: .5rem; }
}
@media (max-height: 420px) {   /* a phone held sideways: the room fits without scrolling (#751) */
  .screen-mpRoom .top-sub { display: none; }
  .screen-mpRoom .mp-lobby { margin-top: .4rem; padding: .6rem 1rem; gap: .35rem; }
  .screen-mpRoom .row-foot { margin-top: .5rem; }
}
/* waiting bars (#751): the QUICK RACE round running out, a busy block while a private room waits for players */
.mp-bar { display: block; position: relative; height: max(6px, calc(.7 * var(--u))); overflow: hidden; background: #0d0c0b; box-shadow: 0 0 0 2px #000; }
.mp-bar u { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; background: var(--accent, var(--yellow)); }
.mp-bar.busy u { width: 22%; animation: mp-busy 1.6s steps(20, end) infinite; }
@keyframes mp-busy { from { left: -22%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .mp-bar.busy u { animation: none; left: 0; width: 100%; opacity: .45; } }
.mp-waiting { display: grid; gap: .35rem; }
.mp-wait-text { margin: 0; color: var(--dim); }
/* a disabled START / QUICK RACE looks disabled: the buttons' entrance animation (mcr-in) ends at full opacity */
:is(.screen-mp, .screen-mpRoom) .btn.disabled { animation: none; }
/* the player's card, score changes, medals, race reports (#757) */
.mp-stats { display: grid; gap: .3rem; }
.mp-stats p { margin: 0; }
.mp-score b { color: var(--accent, var(--yellow)); }
.mp-medals { display: flex; gap: 1.2rem; }
.mp-medals > span { display: inline-flex; align-items: center; gap: .4rem; }
.mp-tally, .mp-fav, .mp-guest { color: var(--dim); }
.mp-login { justify-self: start; }
.mp-medal { display: inline-block; font-style: normal; vertical-align: middle; }
.mp-medal i { display: block; width: .8em; height: .8em; box-shadow: 0 0 0 2px #000; }
.mp-medal.gold i { background: var(--yellow); } .mp-medal.silver i { background: #c9d1d9; } .mp-medal.bronze i { background: #d08a4e; }
.mp-delta { font-style: normal; color: var(--dim); }
.mp-delta.up { color: var(--green-soft); } .mp-delta.down { color: var(--red-soft); }
.mp-pscore { flex: none; color: var(--dim); }
.mp-mine { margin: .6rem 0 0; text-align: center; color: var(--accent, var(--yellow)); }
.screen-mp .row-foot { flex-wrap: wrap; }
.screen-mpReports .mp-reports { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; width: min(60rem, 94vw); margin: 1rem auto 0; align-items: start; }
.mp-report-list { display: grid; gap: .4rem; max-height: 60vh; overflow-y: auto; overflow-x: hidden; padding: 1rem; }   /* never sideways: a long row wraps (CrazyGames, 13.11) */
.mp-report-list h3, .mp-records h3 { margin: 0 0 .3rem; }
.mp-report-btn { justify-content: flex-start; min-width: 0; white-space: normal; text-align: left; }   /* BALLOON VALLEY • 1ST OF 2 +12.40: two lines in a narrow column */
.mp-report-btn .pxt { justify-content: flex-start; }
.screen-mpReports .mp-records { padding: 1rem; }
@media (max-width: 1100px) { .screen-mpReports .mp-reports { grid-template-columns: minmax(0, 1fr); } .screen-mpReports .mp-report-list { max-height: 34vh; } }   /* a narrower window: the two panels one under the other, each the full width (RECORDS cut the stage's name against the time) */
.screen-mpReport .mp-report { width: min(44rem, 94vw); margin: 1rem auto 0; box-sizing: border-box; }
.mp-splits { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: 0 0 .4rem 2.2rem; color: var(--dim); font-size: .85em; }
@media (max-height: 420px) {   /* a phone held sideways */
  :is(.screen-mpResults, .screen-mpReport) .brow small { display: none; }   /* the car's name: room for the score change and the medal */
  .screen-mpReports .top-sub, .screen-mpReport .top-sub { display: none; }
  .screen-mpReports .mp-reports { margin-top: .4rem; }
  .mp-report-list { max-height: 62vh; }
}

/* ------------------------------------------------ menu layout from the UI editor (#754) */
/* source: docs/ui-layouts/2026-11-07-menu.json (tools/ui-editor.html). :root lifts the rules over the menu's own, like
   !important in the editor's preview; phone / tablet rules: a touch device of that height. No title drop here: the
   .stage-title's own top sets the letters on BACK's middle since #953, the two added up (#1088). BACK's widths moved to one
   rule at .stage-top > .top-back (#1209); the heights of DAILY's and GYMKHANA's PLAY and of the MP footers to --cta-h (#1210) */
:root .screen-main .val { translate: calc(var(--u) * -5.31) calc(var(--u) * 0); width: calc(var(--u) * 7.27); height: calc(var(--u) * 4.69); }
:root .screen-main .num { width: calc(var(--u) * 22.27); height: calc(var(--u) * 5.39); }
:root .screen-main .lvl { width: calc(var(--u) * 12.27); height: calc(var(--u) * 1.88); }
:root .screen-main .lvl > i { translate: calc(var(--u) * 0) calc(var(--u) * -0.31); }
:root .screen-stages .btn.ghost.var-btn.setup-btn { width: calc(var(--u) * 9.38); }
:root .screen-daily .btn.primary.daily-go { translate: calc(var(--u) * 0) calc(var(--u) * -1.48); width: calc(var(--u) * 14.07); }
:root .screen-gymkhana .btn.primary.gym-go { width: calc(var(--u) * 14.07); }
/* the editor's 56 px at 1280x720 grows with the root size (the UI unit) as the letters and padding do, and the label
   sits in the middle: a fixed 56 px pushed it onto the bottom edge in a window over 1280x720 (#1199) */
:root .screen-pause .menu-col > .btn.big { display: flex; justify-content: center; align-items: center; height: max(56px, 3.5rem); }
@media (max-height: 520px) { :root .screen-pause .menu-col > .btn.big { height: max(40px, min(42px, 10.8vh)); } }   /* a low window on a computer as the phone below: the column inside 640x300 */
@media (max-height: 480px) {
  :root body.is-mobile .screen-main .val { translate: calc(var(--u) * 0) calc(var(--u) * 0.25); width: calc(var(--u) * 12.4); height: calc(var(--u) * 5.39); }
  :root body.is-mobile .screen-main .num { translate: calc(var(--u) * 0) calc(var(--u) * 0.5); width: calc(var(--u) * 29.43); height: calc(var(--u) * 4.76); }
  :root body.is-mobile .screen-main .sub { translate: calc(var(--u) * 0) calc(var(--u) * 0.25); }
  :root body.is-mobile .screen-main .lvl { width: calc(var(--u) * 15.03); }
  :root body.is-mobile .screen-main .lvl > i { translate: calc(var(--u) * 0) calc(var(--u) * 0); }
  :root body.is-mobile .screen-stages .btn.ghost.var-btn.setup-btn { width: calc(var(--u) * 15.03); }
  :root body.is-mobile .screen-daily .btn.primary.daily-go { width: calc(var(--u) * 17.34); }
  :root body.is-mobile .screen-gymkhana .btn.primary.gym-go { translate: calc(var(--u) * 0) calc(var(--u) * -1.01); width: calc(var(--u) * 21.67); }
  :root body.is-mobile .screen-gymkhana .row-foot { margin-top: calc(var(--u) * 1.01); }   /* room for DRIVE moved up: a translate makes none (#774) */
  :root body.is-mobile .screen-gymkhana .panel.board.daily-board { width: calc(var(--u) * 54.03); max-width: 100%; justify-self: end; }   /* the editor's width, but never past its column: the times stayed off a small phone (#877) */
  :root body.is-mobile .screen-mp .panel.mp-card { width: calc(var(--u) * 52.01); }
  :root body.is-mobile .screen-mpLobby .btn.mp-cancel { width: calc(var(--u) * 17.34); }
  :root body.is-mobile .screen-mpRoom .btn.mp-copy { width: calc(var(--u) * 21.67); }
}
@media (min-height: 481px) {
  :root body.is-mobile .screen-stages .btn.ghost.var-btn.setup-btn { width: calc(var(--u) * 11.73); }
}
@media (max-height: 480px) {
  :root body.is-mobile .screen-main .val { width: min(calc(var(--u) * 12.4), 100%); }
  :root body.is-mobile .screen-main .num { width: min(calc(var(--u) * 29.43), 100%); }
  :root body.is-mobile .screen-pause .menu-col > .btn.big { height: max(40px, min(42px, 10.8vh)); }
}
@media (min-height: 401px) and (max-height: 480px) {   /* a small tablet: the gymkhana board as the game lays it out */
  :root body.is-mobile .screen-gymkhana .panel.board.daily-board { width: auto; justify-self: stretch; }   /* the whole column, not shrunk to its rows by the phone's justify-self: end (#830) */
}
@media (max-height: 400px) {   /* a phone: the two gymkhana panels as high as each other */
  :root body.is-mobile .screen-gymkhana .panel.board.daily-board, :root body.is-mobile .screen-gymkhana .panel.daily-route.gym-route { min-height: calc(var(--u) * 34.67); }
}

/* The start screen A2 test (#921, behind ?start=a2): the week card, the modes as small buttons, car | PLAY | stage */
.screen-main.a2 .a2-week { container: a2week / inline-size; box-sizing: border-box; width: 100%; min-width: 0; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr); gap: calc(.8 * var(--u)); margin-top: calc(1 * var(--u)); padding: calc(1.1 * var(--u)) calc(1.6 * var(--u)); border: calc(.5 * var(--u)) solid var(--ui-asph, #222); background: #050403; box-shadow: var(--ring, none); color: #ffb12e; }
.a2-week .wk-t { display: flex; align-items: center; gap: calc(.8 * var(--u)); font-size: calc(1.45 * var(--u)); letter-spacing: .06em; white-space: nowrap; min-width: 0; }
.a2-week .wk-t b { margin-left: auto; font-weight: normal; color: var(--yellow); }
.a2-week .fl { width: calc(1.5 * var(--u)); height: calc(1.9 * var(--u)); background: linear-gradient(var(--yellow), var(--ui-ember) 55%, #e8412c); clip-path: polygon(50% 0, 85% 45%, 75% 100%, 25% 100%, 15% 45%); flex: none; }
.a2-week.due .fl { filter: grayscale(.6) brightness(.8); }
.a2-week .wk-today { display: flex; align-items: center; gap: calc(1.2 * var(--u)); }
.a2-week .wk-today .mini s { width: calc(3.6 * var(--u)); height: calc(3.6 * var(--u)); }   /* today's stars: the big thing on the card */
.a2-week .wk-r { display: grid; justify-items: end; margin-left: auto; gap: calc(.3 * var(--u)); }
.a2-week .wk-r b { font-weight: normal; font-size: calc(1.45 * var(--u)); color: var(--yellow); }
.a2-week.won .mini s { animation: a2-won .7s ease-in-out 2; }
@keyframes a2-won { 50% { transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { .a2-week.won .mini s { animation: none; } }
body.is-mobile .a2-week .wk-goal { display: none; }   /* the phone: the streak and today's stars only */
.a2-week .mini, .res-week .mini { display: flex; gap: calc(.3 * var(--u)); }
.a2-week .mini s, .res-week .mini s { width: calc(2.4 * var(--u)); height: calc(2.4 * var(--u)); background: #3a322a; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.a2-week .mini s.on, .res-week .mini s.on { background: var(--yellow); }   /* today's three runs: three small stars make the big gold one (#921) */
.a2-week .wk-goal { display: flex; gap: calc(.8 * var(--u)); align-items: baseline; padding-top: calc(.6 * var(--u)); border-top: 1px solid #2b2520; font-size: calc(1 * var(--u)); letter-spacing: .04em; color: #fff; min-width: 0; }
.a2-week .wk-goal span { white-space: normal; min-width: 0; }   /* two lines on a narrow card, not cut */
.a2-week .wk-goal b { margin-left: auto; font-weight: normal; color: var(--yellow); }
.a2-sel.a2-today .sel-body { cursor: default; }
.a2-today .also { color: #9fe0ff; }   /* the other thing to play today (#921) */   /* the daily's stage is fixed: nothing to pick (#921) */
.a2-week .wk-today small { font-size: calc(1.05 * var(--u)); letter-spacing: .04em; color: #e6c9a0; white-space: nowrap; min-width: 0; }
.a2-week.due .wk-today small { color: var(--red-warm); }
/* a narrow card (a small window): the pixel text keeps its least size, the card does not, so the row is laid out again:
   today's stars with the star's XP, the race count under them; no flame, so the title fits (selectors as strong as the
   card's own rules above, or they lose) */
@container a2week (max-width: 260px) {
  .a2-week .wk-t .fl { display: none; }
  .a2-week .wk-today { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: calc(.8 * var(--u)); row-gap: calc(.6 * var(--u)); }
  .a2-week .wk-r { display: contents; margin-left: 0; }
  .a2-week .wk-r b { grid-column: 2; grid-row: 1; justify-self: end; }
  .a2-week .wk-r small { grid-column: 1 / -1; grid-row: 2; }
}
.screen-main.a2 .a2-pills { position: absolute; right: calc(3 * var(--u)); width: calc((100% - 6 * var(--u) - 2 * var(--G)) * 1.05 / 3.05); justify-content: flex-end; bottom: calc(17.5 * var(--u)); display: flex; gap: calc(1 * var(--u)); }   /* over PLAY, flush with its right edge (#972) */
.a2-pills .a2-pill { position: relative; min-width: calc(13 * var(--u)); height: max(40px, calc(5.4 * var(--u))); padding: 0 calc(1.6 * var(--u)); font-size: calc(1.9 * var(--u)); }
.a2-pills .a2-pill.sel { background: var(--yellow); color: #111; box-shadow: inset 0 0 0 3px #fff8; }
.a2-pills .a2-pill .dot, .a2-more .a2-link .dot { position: absolute; top: calc(.6 * var(--u)); right: calc(.6 * var(--u)); width: max(7px, calc(.9 * var(--u))); height: max(7px, calc(.9 * var(--u))); background: var(--red); box-shadow: 0 0 0 2px #000; }
.screen-main.a2 .a2-dock { position: absolute; left: calc(3 * var(--u)); right: calc(3 * var(--u)); bottom: calc(3 * var(--u)); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.05fr); gap: var(--G); height: max(76px, calc(13 * var(--u))); }
.screen-main.a2 .a2-dock .play-btn { grid-column: 3; }   /* car, stage, PLAY last in every mode (#972) */
.screen-main.a2 .a2-dock :is(.play-btn, .a2-arrow) { height: 100%; }   /* PLAY and the arrows the dock's height: .start-dock .btn sets its own on a phone (#972) */
.screen-main.a2 .a2-dock.no-stage .a2-sel[data-k="car"] { grid-column: 1 / 3; }   /* ONLINE: no stage to pick, the car takes its place */
.a2-sel { display: grid; grid-template-columns: max(44px, calc(4.4 * var(--u))) minmax(0, 1fr) max(44px, calc(4.4 * var(--u))); border: 3px solid #000; background: rgba(5, 4, 3, .88); box-shadow: inset 4px 4px 0 #5a504a, inset -4px -4px 0 #000; color: var(--yellow); min-width: 0; }
.a2-sel .a2-arrow { height: 100%; min-width: 0; padding: 0; font-size: calc(3.4 * var(--u)); border-radius: 0; }
.a2-sel .sel-body, .a2-sel .sel-body.btn { background: none; border: 0; box-shadow: none; clip-path: none; height: 100%; color: inherit; cursor: pointer; }
.a2-sel .sel-body { display: grid; align-content: center; justify-items: center; gap: calc(.5 * var(--u)); padding: calc(.6 * var(--u)); min-width: 0; text-align: center; }
.a2-sel .kind { font-size: calc(1.1 * var(--u)); letter-spacing: .14em; color: #e6c9a0; }
.a2-sel .nm { font-size: calc(1.9 * var(--u)); line-height: 1.1; color: #fff; max-width: 100%; overflow: hidden; }   /* a long name takes two lines */
.a2-sel .meta { font-size: calc(1 * var(--u)); letter-spacing: .03em; color: var(--yellow); max-width: 100%; overflow: hidden; white-space: normal; }   /* a narrow card: two lines, not cut (the pixel text keeps its least size) */
.a2-sel.locked .nm { color: #8d8478; }
/* the backdrop is loading the picked car (#1236): a running bar along the card's foot, as the MP waiting bar */
.a2-sel.car-busy .sel-body::after { content: ''; position: absolute; left: 0; bottom: calc(.6 * var(--u)); width: 30%; height: max(4px, calc(.6 * var(--u))); background: var(--yellow); pointer-events: none; animation: a2-car-load 1s steps(20, end) infinite alternate; }
@keyframes a2-car-load { from { left: 0; } to { left: 70%; } }
@media (prefers-reduced-motion: reduce) { .a2-sel.car-busy .sel-body::after { animation: none; left: 0; width: 100%; opacity: .45; } }
.a2-sel.locked .meta { color: #ff9a6a; }
.a2-sel.a2-today { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 900px), (max-height: 506px) {
  body:not(.is-mobile) .a2-sel:not(.a2-today) { grid-template-columns: max(30px, calc(3.4 * var(--u))) minmax(0, 1fr) max(30px, calc(3.4 * var(--u))); }   /* a small window: narrow arrows as on a phone, room for the text */
}
.a2-dock .play-btn { display: grid; align-content: center; justify-items: center; gap: max(4px, calc(.5 * var(--u))); height: 100%; min-width: 0; padding: calc(.6 * var(--u)); }
.a2-dock .play-btn .tn { font-size: calc(3.8 * var(--u)); }
.a2-dock .play-btn .play-line { font-size: calc(1.2 * var(--u)); max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.a2-dock .play-btn.locked { filter: grayscale(.85) brightness(.85); }
body:is(.is-touch, .is-mobile) .a2-dock .play-btn { display: grid; }
body.is-mobile .screen-main.a2 .a2-dock { height: max(56px, calc(14 * var(--u))); }   /* PLAY's height before #972: the carousels as tall */
body.is-mobile .screen-main.a2 .a2-pills { bottom: calc(21 * var(--u)); }
body.is-mobile .a2-sel .nm { font-size: calc(2.2 * var(--u)); }
body.is-mobile .a2-sel .kind { display: none; }   /* a phone: the name and one line */
body.is-mobile .a2-sel .meta { font-size: calc(1.4 * var(--u)); white-space: normal; text-overflow: clip; }
body.is-mobile .a2-sel:not(.a2-today) { grid-template-columns: max(44px, calc(3.4 * var(--u))) minmax(0, 1fr) max(44px, calc(3.4 * var(--u))); }   /* arrows at least a thumb's 44 px (U11), the dock's full height; the rest for the name */
body.is-mobile .a2-dock .play-btn .play-line { white-space: normal; font-size: calc(1.4 * var(--u)); }
body.is-mobile .a2-week .wk-t { font-size: calc(1.6 * var(--u)); }
body.is-mobile .a2-week .wk-today small { font-size: calc(1.3 * var(--u)); }
.a2-dock > [hidden] { display: none; }
.a2-pills .a2-pill small.live { position: absolute; left: 50%; top: calc(-2.2 * var(--u)); transform: translateX(-50%); font-size: calc(1.05 * var(--u)); letter-spacing: .08em; color: #6ee86e; white-space: nowrap; text-shadow: 0 2px 0 #000; }
@media (max-height: 360px) { .a2-pills .a2-pill small.live { display: none; } }   /* a low screen: no room over ONLINE, the streak card is there (#976) */
.screen-main.a2 .start-score .sub:empty { display: none; }
.a2-score .score-who { display: flex; min-width: 0; }   /* the account: a row of its own, the board's width for the name */
.a2-score .score-who .start-who { flex: 1 1 auto; justify-content: flex-start; min-width: 0; margin: 0; }
.a2-score .score-who .who-name { min-width: 0; overflow: hidden; }
.a2-score .sub .hist-link { flex: none; margin-left: auto; }   /* HISTORY at the end of the gain and medals' row */
.a2-dock .a2-sel .sel-body { white-space: normal; padding: calc(.5 * var(--u)) calc(.4 * var(--u)); }   /* .start-dock .btn keeps lines whole; a stage name may take two */
.a2-pills .a2-pill { min-width: calc(10.5 * var(--u)); padding: 0 calc(1.2 * var(--u)); }
.a2-pills .a2-pill[data-k="online"] { min-width: calc(15.5 * var(--u)); }   /* "12 PLAYING" over it stays within its width (#834) */
/* a phone: the left column holds BOOSTER and SCORE only; the week card goes top-right under the icons */
body.is-mobile .screen-main.a2 .a2-week { position: absolute; right: 0; top: calc(max(52px, 5.6 * var(--u)) + var(--G)); width: calc(38 * var(--u)); margin: 0; padding: calc(.8 * var(--u)) calc(1.2 * var(--u)); gap: calc(.5 * var(--u)); }
.res-week { --u: min(1vw, 1.7778vh); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: calc(.6 * var(--u)) calc(1.6 * var(--u)); margin: calc(.8 * var(--u)) auto 0; padding: calc(.7 * var(--u)) calc(1.6 * var(--u)); background: rgba(5, 4, 3, .82); border: 3px solid #000; color: var(--yellow); font-size: calc(1.4 * var(--u)); letter-spacing: .05em; width: fit-content; max-width: 100%; }
.res-week .tm { color: #e6c9a0; }
/* A2 on a small phone (#933): the names, today's stars and a one-row SCORE; 844x390 and up keep the full cards */
@media (max-width: 760px) {
  body.is-mobile .screen-main.a2 { --L: calc(30 * var(--u)); }
  body.is-mobile .screen-main.a2 :is(.a2-score .sub, .a2-score .lvl > i, .a2-score .hist-link, .a2-score .score-who, .a2-week .wk-t > span:not(.fl), .a2-week .wk-r small, .a2-sel .meta, .a2-dock .play-btn .play-line) { display: none; }   /* the clock icon opens the history; the stage's name is in its carousel */
  body.is-mobile .screen-main.a2 .a2-score { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  body.is-mobile .screen-main.a2 .a2-score .hd { flex-direction: column; align-items: flex-start; gap: calc(.6 * var(--u)); }
  body.is-mobile .screen-main.a2 .a2-score :is(.lbl, .lvl) { font-size: max(12px, calc(1.9 * var(--u))); }
  :root body.is-mobile .screen-main.a2 .a2-score .num { width: auto; height: auto; min-width: max-content; translate: none; font-size: calc(7 * var(--u) * var(--k, 1)); }
  body.is-mobile .screen-main.a2 .a2-week { width: calc(44 * var(--u)); grid-template-columns: auto minmax(0, 1fr); grid-auto-flow: column; align-items: center; gap: calc(.8 * var(--u)); }
  body.is-mobile .screen-main.a2 .a2-week .fl { width: calc(2.2 * var(--u)); height: calc(2.8 * var(--u)); }
  body.is-mobile .screen-main.a2 .a2-week .wk-today { gap: calc(.8 * var(--u)); }
  body.is-mobile .screen-main.a2 .a2-week .wk-today .mini s { width: calc(3.6 * var(--u)); height: calc(3.6 * var(--u)); }
  body.is-mobile .screen-main.a2 .a2-week :is(.wk-t b, .wk-r b) { font-size: max(12px, calc(2.1 * var(--u))); }   /* the streak's × by the flame, the star's XP */
  body.is-mobile .screen-main.a2 .a2-pills .a2-pill { font-size: max(12px, calc(1.9 * var(--u))); }
  body.is-mobile .screen-main.a2 .a2-sel .nm { font-size: max(13px, calc(2.4 * var(--u))); }
  body.is-mobile .screen-main.a2 .a2-dock .play-btn .tn { font-size: calc(4.6 * var(--u)); }
  body.is-mobile .screen-main.a2 .start-side .start-rush:is(.on, .offer) { font-size: max(12px, calc(1.6 * var(--u))); }
}
/* A2 on a computer (#947): the side column ends one gap over the dock; BOOSTER, SCORE and the streak card one gap apart,
   a short window shrinks SCORE */
body:not(.is-mobile) .screen-main.a2 .start-top { bottom: calc(3 * var(--u) + max(76px, 13 * var(--u)) + var(--G)); }
body:not(.is-mobile) .screen-main.a2 .start-side { display: flex; flex-direction: column; align-self: stretch; }
body:not(.is-mobile) .screen-main.a2 .start-side > .a2-score { flex: 0 1 auto; min-height: 0; margin-inline: 0; }   /* its own height, less in a short window; never stretched (#953) */
body:not(.is-mobile) .screen-main.a2 .a2-week { flex: none; margin-top: 0; }
/* a small window (#1195): the pixel letters keep their least size, so the side column keeps room for the streak card's
   stars and XP; ×1.4 drops under the title when it does not fit beside it; a low window leaves out the next goal's line,
   as a phone does, so SCORE keeps its rows */
body:not(.is-mobile) .screen-main.a2 { --L: max(calc(28 * var(--u)), 194px); }   /* 194: BOOSTER ×2 (AD) whole in the least letters (#1202) */
body:not(.is-mobile) .screen-main.a2 .a2-week .wk-t { flex-wrap: wrap; row-gap: calc(.4 * var(--u)); }
body:not(.is-mobile) .screen-main.a2 .start-side .start-rush { white-space: normal; }   /* a longer line (×2 BOOSTER · 29:59) wraps, not cut (#1202) */
@media (max-height: 400px) { body:not(.is-mobile) .screen-main.a2 .a2-week .wk-goal { display: none; } }
/* A2's modes (#948): the picked one is yellow with dark letters; a pointer or the keyboard on a mode draws a frame,
   not a pressed button's red (the red dot in the corner says "new"); the letters keep their colour (drawn once) */
html[data-ui] .a2-pills .a2-pill.focus { border-color: #000; color: #fff3dc; animation: none; box-shadow: inset 0 0 0 4px var(--ui-lava); }   /* the cursor: a red ring, no red fill (#948, #1205) */
html[data-ui="led"] .a2-pills .a2-pill.focus { background: var(--ui-asph); }
html[data-ui="blocks"] .a2-pills .a2-pill.focus { background: var(--stone-dots), var(--ui-stone); color: #fff; }
html[data-ui] .a2-pills .a2-pill.sel, html[data-ui] .a2-pills .a2-pill.sel.focus { background: var(--yellow); color: #111; }
html[data-ui] .a2-pills .a2-pill.sel { box-shadow: inset 0 0 0 3px #fff8; }
html[data-ui] .a2-pills .a2-pill.sel.focus { box-shadow: inset 0 0 0 4px var(--ui-lava); }
/* A2's modes (#953, #972): over PLAY; three (with ONLINE) share its width */
body:not(.is-mobile) .screen-main.a2 .a2-pills .a2-pill { flex: 0 1 auto; min-width: min(calc(10.5 * var(--u)), calc((100% - 2 * var(--u)) / 3)); }
/* A2's links (#1047): CUPS › / TABLE › GYMKHANA › on the modes' line, over the middle card from its left edge; dark with
   yellow letters as HISTORY ›, smaller than a mode; a pointer or the keyboard draws the modes' frame. A phone: the
   letters are as big as the modes', so the modes and the links share one row from the right: the modes over PLAY (or
   wider, with ONLINE), the links just left of them, over the middle card and maybe the car's (#1087) */
.screen-main.a2 .a2-more { position: absolute; left: calc(3 * var(--u) + (100% - 6 * var(--u) - 2 * var(--G)) / 3.05 + var(--G)); width: calc((100% - 6 * var(--u) - 2 * var(--G)) / 3.05); bottom: calc(17.5 * var(--u)); display: flex; gap: calc(1 * var(--u)); }
.screen-main.a2 .a2-row { display: contents; }
body.is-mobile .screen-main.a2 .a2-row { display: flex; flex-direction: row-reverse; align-items: flex-end; gap: var(--G); position: absolute; left: calc(3 * var(--u)); right: calc(3 * var(--u)); bottom: calc(21 * var(--u)); pointer-events: none; }
body.is-mobile .screen-main.a2 .a2-row > :is(.a2-pills, .a2-more) { position: static; flex: none; width: auto; pointer-events: auto; }
body.is-mobile .screen-main.a2 .a2-row > .a2-pills { min-width: calc((100% - 2 * var(--G)) * 1.05 / 3.05); }   /* PLAY's width, as before */
.a2-more .a2-link { position: relative; flex: none; height: max(40px, calc(5.4 * var(--u))); padding: 0 calc(1.4 * var(--u)); font-size: calc(1.5 * var(--u)); white-space: nowrap; }
body.is-mobile .a2-more .a2-link { font-size: max(12px, calc(1.6 * var(--u))); padding: 0 calc(1.2 * var(--u)); }
html[data-ui] .a2-more .a2-link { color: var(--yellow); }   /* over the theme's button letters */
html[data-ui] .a2-more .a2-link.focus { border-color: #000; color: var(--yellow); animation: none; box-shadow: inset 0 0 0 4px var(--yellow); }
html[data-ui="led"] .a2-more .a2-link.focus { background: #241e1b; }
html[data-ui="blocks"] .a2-more .a2-link.focus { background: var(--stone-dots), #5a5a5a; }
.screen-main.a2 .a2-more > [hidden] { display: none; }   /* over .btn's display: flex on a phone */
