:root {
  --g: #0F7B4D;
  --lime: #74e02e;
  --panel: rgba(20, 28, 40, .75);
  --panel2: rgba(34, 44, 60, .82);
  --red: #ff4d4d;
  --u: min(calc(min(100vh, 56vw) / 100), 6.4px);
  font-family: 'Manrope', 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
:root { --vh: 100vh; } /* phone: dynamic viewport height, the browser bar must not clip the bottom controls */
@supports (height: 100dvh) { :root { --vh: 100dvh; } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #9fcdf2; overflow: hidden; overscroll-behavior: none; color: #fff; }
body { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; position: fixed; inset: 0; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: none; }
#hud button, #hud .ctl, #hud .pedal, #minimap { pointer-events: auto; } /* the pedals are divs: without .pedal here they never got a touch */
.topbar { position: absolute; left: calc(var(--u) * 1.5); top: calc(var(--u) * 1.5); display: flex; align-items: center; gap: calc(var(--u) * 1.4); }
.ic { width: calc(var(--u) * 9); height: calc(var(--u) * 9); border-radius: 50%; background: var(--panel); font-size: calc(var(--u) * 4.4); display: grid; place-items: center; }
.pillbtn { height: calc(var(--u) * 9); padding: 0 calc(var(--u) * 3.4); border-radius: calc(var(--u) * 4.5); background: var(--panel); display: flex; align-items: center; gap: calc(var(--u) * 1.4); font-weight: 700; font-size: calc(var(--u) * 3.4); }
.pillbtn svg { width: calc(var(--u) * 4); height: calc(var(--u) * 4); }
.logo { font-size: calc(var(--u) * 3.6); display: flex; align-items: center; gap: .42em; text-shadow: 0 1px 4px rgba(0, 0, 0, .55); }
/* original logo (brand book): traffic-light pill + «svetofor» + justified «AVTOMAKTAB» */
@font-face { font-family: 'SvtLogo'; font-style: normal; font-weight: 600 800; font-display: swap; src: url(/assets/fonts/manrope-latin.woff2) format('woff2'); } /* the site's Manrope, used only by the logo */
.brand__ico { height: 1.95em; width: auto; flex: none; display: block; }
.brand__txt { display: inline-flex; flex-direction: column; align-items: stretch; }
.brand__name { font-family: 'SvtLogo', 'Manrope', system-ui, sans-serif; font-weight: 800; font-size: 1em; line-height: .94; letter-spacing: -.015em; color: #F4F6F3; }
.brand__sub { display: flex; justify-content: space-between; gap: .12em; font-family: 'SvtLogo', 'Manrope', system-ui, sans-serif; font-weight: 600; font-size: .4em; line-height: 1; text-transform: uppercase; color: #5FE39B; margin-top: .39em; }
.brand__sub i { font-style: normal; }
#statPill { position: absolute; left: 50%; top: calc(var(--u) * 1.5); transform: translateX(-50%); display: flex; gap: calc(var(--u) * 3.2); background: var(--panel); border-radius: calc(var(--u) * 4); padding: calc(var(--u) * 1.4) calc(var(--u) * 4); text-align: center; min-width: calc(var(--u) * 52); justify-content: center; }
#statPill div { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
#statPill b { font-size: calc(var(--u) * 3.9); font-weight: 800; font-variant-numeric: tabular-nums; }
#statPill i { font-style: normal; font-size: calc(var(--u) * 2.2); opacity: .7; margin-left: 2px; }
#statPill em { font-style: normal; font-size: calc(var(--u) * 1.9); opacity: .62; font-weight: 700; letter-spacing: .05em; }
#statPill .pts b.bad { color: var(--red); }
#failTag { position: absolute; left: 50%; top: calc(var(--u) * 13.4); transform: translateX(-50%); background: rgba(190, 25, 25, .9); padding: calc(var(--u) * .7) calc(var(--u) * 3); border-radius: 999px; font-weight: 800; font-size: calc(var(--u) * 2.8); letter-spacing: .06em; }
#hint { position: absolute; left: 50%; top: calc(var(--u) * 13.4); transform: translateX(-50%); background: var(--panel); border-radius: calc(var(--u) * 2.6); padding: calc(var(--u) * .9) calc(var(--u) * 3.4); font-weight: 700; font-size: calc(var(--u) * 3); white-space: nowrap; max-width: min(72vw, 820px); overflow: hidden; text-overflow: ellipsis; text-align: center; }
#hint .act { display: block; white-space: normal; font-size: .82em; font-weight: 600; opacity: .9; color: #c9f7da; line-height: 1.25; margin-top: .15em; }
#hint.withfail ~ #toasts { top: calc(var(--u) * 33); }
/* instruction card before each exercise (with voice-over) */
#coach { position: absolute; left: 50%; top: calc(var(--u) * 24); transform: translateX(-50%); width: min(64vw, 640px); background: rgba(15, 123, 77, .93); color: #fff; border-radius: calc(var(--u) * 2.4); padding: calc(var(--u) * 1.5) calc(var(--u) * 2.6); font-size: calc(var(--u) * 2.6); line-height: 1.3; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); animation: coachIn .35s ease-out; cursor: pointer; }
#coach b { display: block; font-size: 1.08em; margin-bottom: .25em; }
#coach.hidden { display: none; }
#hint.withfail ~ #coach { top: calc(var(--u) * 30); }
#coach:not(.hidden) ~ #toasts { top: calc(var(--u) * 46); }
@keyframes coachIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
#hint small { opacity: .8; font-weight: 600; }
#hint.withfail { top: calc(var(--u) * 19.5); }
#toasts { position: absolute; left: 50%; top: calc(var(--u) * 27); transform: translateX(-50%); width: min(560px, 70vw); display: flex; flex-direction: column; gap: calc(var(--u) * 1.2); align-items: center; }
.toast { background: var(--panel2); backdrop-filter: blur(3px); border-radius: calc(var(--u) * 3); padding: calc(var(--u) * 1.4) calc(var(--u) * 2.6); display: flex; gap: calc(var(--u) * 2); align-items: center; width: 100%; font-size: max(11px, calc(var(--u) * 2.5)); line-height: 1.2; animation: tin .18s ease-out; border-left: calc(var(--u) * .8) solid var(--red); }
.toast .n { opacity: .65; font-weight: 800; min-width: 1.6em; flex: 0 0 auto; }
.toast .tx { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast .pts { flex: 0 0 auto; white-space: nowrap; margin-left: auto; color: var(--red); font-weight: 800; font-size: calc(var(--u) * 3.1); }
.toast.ok { border-left-color: var(--lime); } .toast.ok .pts { color: var(--lime); }
.toast.small { border-left-color: #ffb21a; }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
#banner { position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%); font-weight: 900; font-size: calc(var(--u) * 9); text-shadow: 0 3px 16px rgba(0, 0, 0, .55); text-align: center; white-space: nowrap; opacity: 0; transition: opacity .25s; }
#banner.show { opacity: 1; }
#banner.small { font-size: calc(var(--u) * 3.6); white-space: normal; width: min(80vw, calc(var(--u) * 100)); background: var(--panel); padding: calc(var(--u) * 1.6) calc(var(--u) * 3); border-radius: calc(var(--u) * 3); top: 34%; }
#coach:not(.hidden) ~ #banner.small { display: none; } /* the coach card says the same: never overlap */
body.tutOn #banner.small { display: none; } /* the finger tutorial shows the same steps one by one */
#banner.em { color: #fff; background: rgba(210, 20, 20, .9); padding: calc(var(--u) * 1.6) calc(var(--u) * 5); border-radius: calc(var(--u) * 3); font-size: calc(var(--u) * 6); animation: blinkr .5s infinite alternate; }
@keyframes blinkr { from { background: rgba(210, 20, 20, .95); } to { background: rgba(120, 10, 10, .9); } }
#flash { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 calc(var(--u) * 28) calc(var(--u) * 6) rgba(255, 20, 20, .75); opacity: 0; transition: opacity .6s; }
#flash.on { opacity: 1; transition: none; }

/* minimap */
#minimap { position: absolute; right: calc(var(--u) * 1.5); top: calc(var(--u) * 1.5); width: calc(var(--u) * 26); height: calc(var(--u) * 26); border-radius: calc(var(--u) * 2); background: rgba(20, 28, 40, .8); border: 2px solid rgba(255, 255, 255, .25); }
#minimap.big { width: min(86vw, 150vh); height: min(60vh, 56vw); right: 50%; top: 50%; transform: translate(50%, -50%); z-index: 40; }
#hud.mapopen .rbtn, #hud.mapopen .gears, #hud.mapopen .pedal, #hud.mapopen #wheel, #hud.mapopen .speedo, #hud.mapopen #btnBelt { visibility: hidden; }

/* left controls */
.speedo { position: absolute; left: calc(var(--u) * 1.5); top: calc(var(--u) * 34.5); width: calc(var(--u) * 21); height: calc(var(--u) * 21); }
.speedo svg { width: 100%; height: 100%; }
.speedo .num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: calc(var(--u) * 6.6); line-height: 1; padding-top: calc(var(--u) * 1); }
.speedo .num small { font-size: calc(var(--u) * 2.4); font-weight: 600; opacity: .65; margin-top: calc(var(--u) * .6); }
#btnBelt { position: absolute; left: calc(var(--u) * 24.5); top: calc(var(--u) * 39); width: calc(var(--u) * 12); height: calc(var(--u) * 12); border-radius: 50%; background: rgba(120, 30, 30, .85); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: max(11px, calc(var(--u) * 1.8)); font-weight: 700; gap: 1px; }
#btnBelt.on { background: rgba(15, 123, 77, .92); }
#btnBelt svg { width: calc(var(--u) * 5); height: calc(var(--u) * 5); }
.gears { position: absolute; left: calc(var(--u) * 1.5); top: calc(var(--u) * 57.5); display: flex; gap: calc(var(--u) * .8); background: var(--panel); padding: calc(var(--u) * .9); border-radius: calc(var(--u) * 2.4); }
.gears button { width: calc(var(--u) * 8.4); height: calc(var(--u) * 7.4); border-radius: calc(var(--u) * 1.8); background: transparent; font-weight: 800; font-size: calc(var(--u) * 4.4); color: rgba(255, 255, 255, .8); }
.gears button.act { background: var(--lime); color: #12320a; }
.gears button.act[data-g="R"] { background: #ff5a5a; color: #fff; }
.pedal { position: absolute; bottom: calc(var(--u) * 1.5); width: calc(var(--u) * 22); height: calc(var(--u) * 30); border-radius: calc(var(--u) * 3); background: rgba(30, 40, 56, .85); display: grid; place-items: center; border: calc(var(--u) * .5) solid rgba(255, 255, 255, .22); }
.pedal { align-content: start; justify-items: center; padding-top: 6%; }
.pedal svg { width: 62%; height: 56%; }
.pedal.down { background: rgba(116, 224, 46, .9); }
#pedBrake { left: calc(var(--u) * 1.5); } #pedGas { left: calc(var(--u) * 25); }
#pedBrake.down { background: rgba(255, 90, 90, .92); }
.pedal span { position: absolute; bottom: calc(var(--u) * 1); font-size: calc(var(--u) * 2); opacity: .7; font-weight: 700; }

/* right controls */
.rbtn { position: absolute; width: calc(var(--u) * 9.5); height: calc(var(--u) * 9.5); border-radius: 50%; background: var(--panel); display: grid; place-items: center; }
.rbtn svg { width: 60%; height: 60%; }
.rbtn.on { background: rgba(255, 178, 26, .92); color: #3a2600; }
#btnHaz { right: calc(var(--u) * 13.5); top: calc(var(--u) * 29.5); } #btnHaz.on { background: rgba(255, 70, 70, .95); color: #fff; }
#btnCam { right: calc(var(--u) * 1.5); top: calc(var(--u) * 29.5); }
#btnL { right: calc(var(--u) * 13.5); top: calc(var(--u) * 40.5); } #btnR { right: calc(var(--u) * 1.5); top: calc(var(--u) * 40.5); }
#wheel { position: absolute; right: calc(var(--u) * 1.5); bottom: calc(var(--u) * 1.5); width: calc(var(--u) * 46); height: calc(var(--u) * 46); touch-action: none; }
#wheel svg { width: 100%; height: 100%; transition: none; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .4)); }
#legend { position: absolute; left: 50%; bottom: calc(var(--u) * 1.2); transform: translateX(-50%); font-size: calc(var(--u) * 2.3); background: rgba(20, 28, 40, .6); padding: calc(var(--u) * .6) calc(var(--u) * 2); border-radius: 999px; opacity: .85; white-space: nowrap; }
@media (pointer: coarse) { #legend { display: none; } }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(1200px 700px at 50% 10%, rgba(15, 123, 77, .55), rgba(12, 18, 28, .92)); z-index: 30; padding: 12px; overflow: auto; touch-action: pan-y; }
.card { width: min(94vw, 560px); background: rgba(18, 26, 38, .88); border: 1px solid rgba(255, 255, 255, .12); border-radius: 18px; padding: clamp(14px, 3vh, 26px); box-shadow: 0 18px 60px rgba(0, 0, 0, .5); max-height: 96vh; overflow: auto; }
.card h1, .card .ttl { margin: 6px 0 4px; font-size: clamp(22px, 5.5vh, 34px); letter-spacing: -.02em; }
.card .sub { opacity: .8; font-size: clamp(13px, 2.8vh, 16px); margin-bottom: clamp(8px, 2vh, 16px); }
.card .intro { opacity: .72; font-size: clamp(12px, 2.5vh, 14px); line-height: 1.35; margin: calc(-1 * clamp(4px, 1vh, 10px)) 0 clamp(8px, 2vh, 14px); max-width: 34em; }
.brand { font-size: clamp(22px, 5vh, 32px); display: flex; align-items: center; gap: .42em; }
.langs, .modes { display: flex; gap: 8px; margin: clamp(6px, 1.6vh, 12px) 0; }
.langs button, .modes button { flex: 1; padding: clamp(8px, 1.8vh, 12px); border-radius: 12px; background: rgba(255, 255, 255, .08); font-weight: 700; font-size: clamp(13px, 2.6vh, 16px); border: 2px solid transparent; touch-action: manipulation; }
.langs button.act, .modes button.act { border-color: var(--lime); background: rgba(116, 224, 46, .16); }
.modes button small { display: block; font-weight: 500; opacity: .7; font-size: .78em; margin-top: 2px; }
.big { width: 100%; padding: clamp(12px, 2.6vh, 18px); border-radius: 14px; background: var(--lime); color: #12320a; font-weight: 800; font-size: clamp(17px, 3.6vh, 22px); margin-top: clamp(6px, 1.6vh, 12px); touch-action: manipulation; }
.big.alt { background: rgba(255, 255, 255, .12); color: #fff; font-size: clamp(14px, 2.8vh, 17px); }
.links { display: flex; justify-content: space-between; margin-top: 12px; font-size: clamp(13px, 2.6vh, 15px); }
.links a, .links button { color: #bfe9ff; background: none; text-decoration: underline; padding: 4px 0; font-size: inherit; touch-action: manipulation; }
.how h3 { margin: 12px 0 6px; font-size: 16px; color: #8dffbd; }
.how ul { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.45; opacity: .92; }
.res-head { font-size: clamp(22px, 5vh, 32px); font-weight: 800; margin: 0 0 6px; }
.res-head.pass { color: #7dffa6; } .res-head.fail { color: #ff7777; }
.res-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 10px; }
.res-stats div { background: rgba(255, 255, 255, .08); border-radius: 10px; padding: 6px 4px; text-align: center; }
.res-stats b { display: block; font-size: clamp(16px, 3.4vh, 22px); } .res-stats span { font-size: 11px; opacity: .7; text-transform: uppercase; letter-spacing: .04em; }
.errs { max-height: 28vh; overflow: auto; margin: 6px 0; display: flex; flex-direction: column; gap: 5px; touch-action: pan-y; }
.err { display: flex; gap: 8px; align-items: flex-start; background: rgba(255, 255, 255, .06); border-radius: 10px; padding: 6px 8px; font-size: 13px; line-height: 1.25; }
.err .n { opacity: .55; font-weight: 800; min-width: 1.5em; } .err .tx { flex: 1; } .err .sum { text-align: right; font-weight: 800; color: #ff8e8e; white-space: nowrap; } .err .sum small { display: block; font-weight: 500; opacity: .75; color: #fff; }
.err.nd { background: rgba(255, 90, 90, .14); }
.cta { margin-top: 10px; background: linear-gradient(135deg, #0F7B4D, #0a5a38); border-radius: 14px; padding: 12px; text-align: center; }
.cta b { display: block; font-size: clamp(14px, 2.8vh, 17px); margin-bottom: 8px; }
.cta .row { display: flex; gap: 8px; }
.cta a { flex: 1; padding: 11px 6px; border-radius: 10px; font-weight: 800; text-decoration: none; text-align: center; font-size: 15px; }
.cta a.tel { background: rgba(255, 255, 255, .16); color: #fff; } .cta a.enr { background: var(--lime); color: #12320a; }
.rowbtns { display: flex; gap: 8px; margin-top: 10px; } .rowbtns button, .rowbtns a { flex: 1; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, .12); font-weight: 800; text-align: center; text-decoration: none; color: #fff; font-size: 15px; }
.rowbtns .pri { background: var(--lime); color: #12320a; }
#rotate { position: fixed; inset: 0; background: radial-gradient(1200px 700px at 50% 10%, rgba(15, 123, 77, .55), rgba(12, 18, 28, .92)), #0b1420; z-index: 99; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; font-size: 20px; font-weight: 700; padding: 24px; overflow: auto; }
#rotate svg { width: 120px; height: 120px; animation: rot 2.4s infinite ease-in-out; margin-bottom: 4px; }
#rotate .rt { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
#rotate .rs { font-size: 14px; font-weight: 500; opacity: .75; max-width: 24em; line-height: 1.35; margin-bottom: 8px; }
#rotate .big { width: min(82vw, 320px); margin-top: 0; }
@keyframes rot { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (pointer: coarse) { html:not(.portrait-ok) #rotate { display: flex; } }

/* neutral-start hint: highlight gear 1 during the ready phase (+ text next to it on desktop) */
.gears.nudge button[data-g="1"] { background: var(--lime); color: #12320a; animation: gnudge .7s infinite alternate; }
@keyframes gnudge { from { box-shadow: 0 0 0 0 rgba(116, 224, 46, .8); } to { box-shadow: 0 0 0 calc(var(--u) * 1.2) rgba(116, 224, 46, 0); transform: scale(1.08); } }
#gearHint { position: absolute; left: calc(var(--u) * 1.5); top: calc(var(--u) * 67); background: var(--lime); color: #12320a; font-weight: 800; font-size: calc(var(--u) * 2.6); padding: calc(var(--u) * .8) calc(var(--u) * 2.2); border-radius: calc(var(--u) * 2); white-space: nowrap; }
@media (pointer: coarse) { #gearHint { display: none !important; } }

/* portrait plate: way back to the exercise hub */
#rotate a { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px; border-radius: 14px; background: rgba(255, 255, 255, .14); color: #fff; font-size: 16px; font-weight: 700; text-decoration: none; margin-top: 8px; }
#rotate a::before { content: "\2190\00a0"; }

/* new elements: hidden on desktop, the phone block below shows them */
.steerbtn, #btnSteer { display: none; }
#hint .hi { display: none; }
@keyframes hpulse { 0% { box-shadow: 0 0 0 0 rgba(141, 255, 189, .85); background: rgba(15, 123, 77, .92); } 100% { box-shadow: 0 0 0 9px rgba(141, 255, 189, 0); } }

/* pause menu: two columns on short screens (the new Graphics / End buttons must not push it off) */
@media (max-height: 800px), (pointer: coarse) {
  #scrPause .card { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8px; align-content: start; }
  #scrPause .card > .ttl { grid-column: 1; align-self: center; margin: 0; }
  #scrPause .langs { grid-column: 2; margin: 0; }
  #btnCont { grid-column: 1 / -1; }
}
@media (max-height: 800px) and (pointer: fine) { #btnExit { grid-column: 1 / -1; } }

/* ---------- phone / tablet (touch). Sizes follow the dynamic viewport height; the bottom groups are anchored with bottom: ---------- */
@media (pointer: coarse) {
  :root {
    --u: min(calc(min(var(--vh), 56vw) / 100), 6.4px);
    --eL: max(10px, env(safe-area-inset-left)); --eR: max(10px, env(safe-area-inset-right)); --eT: max(10px, env(safe-area-inset-top)); --eB: max(10px, env(safe-area-inset-bottom));
    --mm: clamp(80px, calc(var(--vh) * .27), 132px); --spd: clamp(60px, calc(var(--vh) * .20), 96px);
    --pw: clamp(64px, calc(var(--vh) * .20), 96px); --pbh: clamp(84px, calc(var(--vh) * .28), 140px); --pgh: calc(var(--pbh) * 1.14);
    --wh: clamp(116px, calc(var(--vh) * .39), 190px); --sbw: clamp(68px, calc(var(--vh) * .22), 100px); --sbh: clamp(84px, calc(var(--vh) * .30), 140px);
    --rh: var(--wh); --plateTop: calc(var(--eT) + 52px); --plateW: min(44vw, 400px);
  }
  html, body { height: var(--vh); }
  #hud, .screen, #rotate { height: var(--vh); }
  .card { max-height: calc(var(--vh) * .96); }
  /* top-left: menu + stat pill */
  .topbar { left: var(--eL); top: var(--eT); }
  .ic { width: 44px; height: 44px; font-size: 20px; }
  #btnStop, .logo, #failTag { display: none !important; }
  #statPill { left: calc(var(--eL) + 52px); top: var(--eT); transform: none; height: 44px; min-width: 0; padding: 0 12px; gap: 12px; justify-content: flex-start; align-items: center; border-radius: 22px; border: 2px solid transparent; }
  #statPill b { font-size: 15px; } #statPill i { font-size: 9px; } #statPill em { font-size: 8.5px; }
  #statPill.failed { border-color: rgba(255, 77, 77, .9); background: rgba(110, 20, 20, .6); }
  #statPill.failed::after { content: attr(data-fail); background: #d21f1f; color: #fff; font-weight: 800; font-size: 10px; letter-spacing: .05em; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
  /* top-right: minimap, camera + hazard column on its left */
  #minimap { right: var(--eR); top: var(--eT); width: var(--mm); height: var(--mm); }
  #btnCam, #btnHaz { width: 44px; height: 44px; right: calc(var(--eR) + var(--mm) + 8px); }
  #btnCam { top: var(--eT); } #btnHaz { top: calc(var(--eT) + 52px); }
  /* left, under the menu: speedometer + belt */
  .speedo { left: var(--eL); top: var(--plateTop); width: var(--spd); height: var(--spd); }
  .speedo .num { font-size: calc(var(--spd) * .3); } .speedo .num small { font-size: calc(var(--spd) * .12); }
  #btnBelt { left: calc(var(--eL) + var(--spd) + 8px); top: calc(var(--plateTop) + (var(--spd) - 48px) / 2); width: 48px; height: 48px; font-size: 11px; }
  #btnBelt svg { width: 18px; height: 18px; }
  /* bottom-left: pedals, gears above them */
  .pedal { width: var(--pw); height: var(--pbh); bottom: var(--eB); border-radius: 12px; }
  #pedBrake { left: var(--eL); } #pedGas { left: calc(var(--eL) + var(--pw) + 8px); height: var(--pgh); }
  .gears { left: var(--eL); top: auto; bottom: calc(var(--eB) + var(--pgh) + 8px); padding: 4px; gap: 4px; border-radius: 12px; }
  .gears button { width: 44px; height: 44px; font-size: 18px; border-radius: 9px; }
  /* bottom-right: wheel (or two hold buttons), signal pills above */
  #wheel { width: var(--wh); height: var(--wh); right: var(--eR); bottom: var(--eB); }
  .rbtn { width: 44px; height: 44px; }
  #btnL, #btnR { width: 56px; border-radius: 22px; top: auto; bottom: calc(var(--eB) + var(--rh) + 8px); }
  #btnR { right: var(--eR); } #btnL { right: calc(var(--eR) + 64px); }
  .steerbtn { position: absolute; bottom: var(--eB); width: var(--sbw); height: var(--sbh); border-radius: 14px; background: rgba(30, 40, 56, .85); border: 2px solid rgba(255, 255, 255, .22); place-items: center; padding: 0; }
  .steerbtn svg { width: 46%; height: 46%; }
  .steerbtn.down { background: rgba(116, 224, 46, .9); color: #12320a; }
  #steerR { right: var(--eR); } #steerL { right: calc(var(--eR) + var(--sbw) + 10px); }
  #hud.btnsteer { --rh: var(--sbh); }
  #hud.btnsteer #wheel { display: none; }
  #hud.btnsteer .steerbtn { display: grid; }
  #hud.mapopen .steerbtn, #hud.mapopen #hint { visibility: hidden; }
  #btnSteer { display: block; }
  /* one hint plate: collapsed chip with the live action, expanded green card (new exercise or tap) */
  #hint { top: var(--plateTop); left: 50%; width: max-content; max-width: var(--plateW); min-height: 34px; padding: 5px 12px; display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; background: rgba(20, 28, 40, .66); border-radius: 17px; overflow: visible; pointer-events: auto; text-align: left; }
  #hint::after { content: ""; position: absolute; inset: -5px -4px; }
  #hint .hi { display: block; flex: 0 0 auto; width: 16px; height: 16px; color: #8dffbd; }
  #hint .ht { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.18; white-space: normal; } /* wraps to two lines instead of cutting the word off */
  #hint.withfail { top: var(--plateTop); }
  #hint.pulse { animation: hpulse .6s ease-out; }
  #hud.plateopen #hint { display: none; }
  #coach { top: var(--plateTop); width: var(--plateW); font-size: 12px; line-height: 1.28; padding: 7px 11px; border-radius: 12px; pointer-events: auto; z-index: 4; }
  #coach b { font-size: 12.5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #coach span { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
  #hint.withfail ~ #coach { top: var(--plateTop); }
  /* toasts: newest only, same slot, drawn over the plate */
  #toasts, #hint.withfail ~ #toasts, #coach:not(.hidden) ~ #toasts { top: var(--plateTop); width: var(--plateW); z-index: 6; }
  .toast { padding: 6px 10px; font-size: 12.5px; line-height: 1.2; border-radius: 12px; background: rgba(34, 44, 60, .95); gap: 8px; }
  .toast .pts { font-size: 13px; }
  .toast .tx { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  #banner.small { top: 42%; width: min(70vw, 480px); font-size: 14px; padding: 8px 12px; border-radius: 12px; }
}
/* pause card must fit without scrolling on a short landscape screen */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  #scrPause { padding: 6px; }
  #scrPause .card { width: min(94vw, 560px); padding: 8px 10px; border-radius: 14px; }
  #scrPause .ttl { font-size: 20px; }
  #scrPause .langs button { padding: 6px; font-size: 14px; min-height: 36px; }
  #scrPause .big { padding: 0 8px; min-height: 40px; font-size: 14px; margin-top: 6px; border-radius: 11px; line-height: 1.1; }
  #scrPause .big.alt { font-size: 13px; }
}
/* portrait (the player chose "play anyway"): wheel bottom-centre, pedals in the corners, the middle stays free */
@media (pointer: coarse) and (orientation: portrait) {
  :root {
    --mm: clamp(84px, 26vw, 120px); --spd: clamp(64px, 20vw, 90px); --pw: clamp(64px, 20vw, 96px); --pbh: clamp(84px, 30vw, 140px);
    --wh: clamp(116px, 44vw, 200px); --sbw: clamp(68px, 22vw, 100px); --sbh: clamp(84px, 32vw, 140px);
    --plateTop: calc(var(--eT) + 52px + max(var(--mm), var(--spd)) + 8px); --plateW: min(92vw, 420px);
  }
  #minimap { top: calc(var(--eT) + 52px); }
  #btnCam { top: calc(var(--eT) + 52px); } #btnHaz { top: calc(var(--eT) + 104px); }
  .speedo { top: calc(var(--eT) + 52px); } #btnBelt { top: calc(var(--eT) + 52px + (var(--spd) - 48px) / 2); }
  #pedGas { left: auto; right: var(--eR); }
  .gears { bottom: calc(var(--eB) + max(var(--pgh), var(--rh)) + 8px); }
  #wheel { right: auto; left: 50%; transform: translateX(-50%); }
  #steerL { right: auto; left: calc(50% - var(--sbw) - 5px); } #steerR { right: auto; left: calc(50% + 5px); }
}

/* ---------- first start: steering choice + first-ride tutorial finger ---------- */
#scrSteer { z-index: 50; background: radial-gradient(1200px 700px at 50% 10%, rgba(15, 123, 77, .6), rgba(12, 18, 28, 1)), #0b1420; }
.steerask { text-align: center; width: min(92vw, 560px); }
.steerask .ttl { margin: 0 0 14px; }
.scards { display: flex; gap: 14px; justify-content: center; }
.scard { flex: 1 1 0; min-width: 0; min-height: 150px; border-radius: 18px; background: rgba(34, 44, 60, .9); border: 2px solid rgba(255, 255, 255, .22); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 14px 8px; font-size: 18px; font-weight: 800; color: #fff; }
.scard:active { background: var(--g); border-color: #8dffbd; }
.scard svg { width: 84px; height: 84px; }
.scard .arrs { display: flex; gap: 10px; }
.scard .arrs i { width: 56px; height: 76px; border-radius: 14px; background: rgba(30, 40, 56, .95); border: 2px solid rgba(255, 255, 255, .3); display: grid; place-items: center; color: #8dffbd; }
.scard .arrs svg { width: 40px; height: 40px; }
.ssub { margin-top: 14px; font-size: 13px; font-weight: 600; opacity: .72; }
.scard__t { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.scard__t small { font-size: 13px; font-weight: 600; line-height: 1.3; opacity: .8; max-width: 230px; }
.scard.act { border-color: #8dffbd; box-shadow: 0 0 0 3px rgba(141, 255, 189, .22); }
@media (orientation: portrait) and (max-width: 420px) { .scards { flex-direction: column; } .scard { min-height: 120px; flex-direction: row; gap: 18px; padding: 12px 14px; } .scard__t { align-items: flex-start; text-align: left; } }
@media (max-height: 420px) { .steerask .ttl { font-size: 20px; margin-bottom: 8px; } .scard { min-height: 110px; padding: 8px; } .scard svg { width: 60px; height: 60px; } .scard .arrs i { width: 46px; height: 56px; } .ssub { margin-top: 8px; } .scard__t small { font-size: 12px; } }

#tut { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#tut > * { position: absolute; left: 0; top: 0; }
#tutRing { border-radius: 50%; border: 3px solid #8dffbd; background: rgba(141, 255, 189, .16); box-shadow: 0 0 0 4px rgba(141, 255, 189, .25), 0 0 22px rgba(141, 255, 189, .7); animation: tutring 1.1s ease-in-out infinite; }
@keyframes tutring { 0%, 100% { opacity: 1; scale: 1; } 50% { opacity: .55; scale: 1.1; } }
#tutHand { width: 52px; height: 68px; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .55)); }
#tutHand svg { width: 100%; height: 100%; display: block; animation: tuttap 1.1s ease-in-out infinite; transform-origin: 44.5% 2.4%; rotate: -20deg; }
@keyframes tuttap { 0%, 100% { transform: translateY(8px); } 45% { transform: translateY(-2px) scale(1.04); } 60% { transform: translateY(6px) scale(.97); } }
#tutCap { display: flex; align-items: center; gap: 10px; background: rgba(15, 123, 77, .96); color: #fff; font-weight: 800; font-size: 14px; line-height: 1.2; padding: 8px 8px 8px 14px; border-radius: 16px; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); width: max-content; max-width: min(78vw, 340px); pointer-events: none; }
#tutSkip { pointer-events: auto; touch-action: manipulation; flex: 0 0 auto; background: rgba(255, 255, 255, .2); border-radius: 12px; font-size: 12px; font-weight: 700; padding: 8px 10px; min-height: 34px; }

/* ---------- loading state: the Start button is dead until the scripts are ready ---------- */
html.loading #btnStart { position: relative; overflow: hidden; color: transparent; background: rgba(116, 224, 46, .4); cursor: progress; }
html.loading #btnStart::before { content: attr(data-loading); position: absolute; inset: 0; display: grid; place-items: center; color: #e8f9d7; font-weight: 800; }
html.loading #btnStart::after { content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 35%; background: #e8f9d7; border-radius: 2px; animation: ldbar 1.1s linear infinite; }
@keyframes ldbar { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
html.loading #scrStart .langs button { opacity: .45; pointer-events: none; }
html.loading #rotate .big, html.loading #rotate a { visibility: hidden; } /* their texts arrive with the script: no empty green buttons meanwhile */
button:disabled { cursor: default; }

/* ---------- no WebGL / scripts failed ---------- */
#scrNoGL { z-index: 80; background: radial-gradient(1200px 700px at 50% 10%, rgba(15, 123, 77, .55), rgba(12, 18, 28, 1)), #0b1420; }
.nogl { text-align: center; } .nogl .intro { max-width: none; margin: 8px 0 14px; font-size: 15px; opacity: .85; }
#loadFailP { display: none; } html.loadfail #loadFailP { display: block; } html.loadfail #noglP { display: none; }

/* ---------- "How to play": solid, the menu must not show through ---------- */
#scrHow { z-index: 40; background: radial-gradient(1200px 700px at 50% 10%, rgba(15, 123, 77, .6), rgba(12, 18, 28, 1)), #0b1420; }
#scrHow .card { background: #121a26; }

/* ---------- end the ride? ---------- */
#scrConfirm { z-index: 45; background: rgba(8, 12, 20, .82); }
.confirm { text-align: center; width: min(92vw, 440px); background: #121a26; }
.cf-text { margin: 0 0 6px; font-size: clamp(16px, 3.4vh, 20px); font-weight: 700; line-height: 1.3; }

/* ---------- result: the header and the buttons stay on screen, only the list of errors scrolls ---------- */
#resCard { display: flex; flex-direction: column; overflow: hidden; }
#resCard > * { flex: none; }
#resCard > .errs { flex: 1 1 auto; min-height: 72px; max-height: none; overflow: auto; }
.res-why { margin: 0 0 6px; padding: 6px 9px; border-radius: 10px; background: rgba(255, 90, 90, .16); border: 1px solid rgba(255, 120, 120, .4); font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.res-why .pl { color: #ff8e8e; white-space: nowrap; }
@media (max-height: 460px) and (orientation: landscape) { /* short landscape phone: summary + buttons on the left, the whole list on the right */
  #resCard { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-template-rows: auto auto auto auto auto 1fr; column-gap: 12px; align-content: start; height: calc(var(--vh) * .94); width: min(96vw, 720px); padding: 8px 12px; }
  #resCard > :not(.errs) { grid-column: 1; }
  #resCard > .errs { grid-column: 2; grid-row: 1 / -1; min-height: 0; margin: 0; }
  #resCard .res-head { font-size: 20px; margin: 0 0 4px; }
  #resCard .res-stats { margin: 0 0 6px; gap: 4px; } #resCard .res-stats b { font-size: 15px; } #resCard .res-stats span { font-size: 9px; }
  #resCard .res-why { font-size: 12px; margin-bottom: 5px; -webkit-line-clamp: 2; }
  #resCard .rowbtns { margin-top: 0; } #resCard .rowbtns button, #resCard .rowbtns a { padding: 9px 6px; font-size: 14px; }
  #resCard .cta { margin-top: 6px; padding: 8px; } #resCard .cta b { font-size: 13px; margin-bottom: 6px; } #resCard .cta a { padding: 9px 4px; font-size: 14px; } #resCard .cta a.tel { font-size: 12px; white-space: nowrap; padding: 9px 2px; }
}

/* ---------- first-ride tutorial on a computer: key caps ---------- */
#tutKeys { display: none; }
body.tutKb #tutHand { display: none; }
body.tutKb #tutKeys { display: flex; align-items: center; gap: 6px; }
body.tutKb #tutCap { font-size: 20px; gap: 14px; padding: 10px 10px 10px 12px; border-radius: 18px; max-width: min(70vw, 560px); }
body.tutKb #tutSkip { font-size: 14px; min-height: 40px; padding: 8px 14px; }
#tutKeys kbd { min-width: 54px; height: 54px; padding: 0 12px; display: grid; place-items: center; font: 800 28px/1 'Manrope', system-ui, sans-serif; border-radius: 11px; background: #fff; color: #12203a; box-shadow: 0 4px 0 #9db0a5, 0 7px 14px rgba(0, 0, 0, .35); }
#tutKeys i { font-style: normal; font-weight: 700; opacity: .75; }
body.tutOn #gearHint { display: none !important; }

/* ---------- permanent captions on the controls (text from data-lbl; on a computer it also names the key) ---------- */
[data-lbl]::after { content: attr(data-lbl); position: absolute; pointer-events: none; font-size: 11px; font-weight: 700; line-height: 1; white-space: nowrap; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .85); }
.pedal[data-lbl]::after { left: 0; right: 0; bottom: 6px; text-align: center; }
.gears[data-lbl]::after { left: 4px; top: -14px; }
#btnHaz[data-lbl]::after { left: 50%; top: calc(100% + 3px); transform: translateX(-50%); } /* phone: under the button (the camera button is right above it) */
#btnL[data-lbl]::after { left: 0; top: -15px; width: 120px; display: flex; justify-content: center; } /* one caption centred over the pair of signal buttons */
#btnBelt[data-key]:not([data-key=""])::after { content: attr(data-key); font-size: 11px; background: rgba(255, 255, 255, .9); color: #12203a; border-radius: 4px; padding: 2px 5px; text-shadow: none; position: static; }
@media (pointer: fine) { #btnL[data-lbl]::after { top: calc(100% + 3px); width: calc(var(--u) * 21.5); } #btnHaz[data-lbl]::after { top: -14px; } }
@media (pointer: coarse) and (orientation: landscape) { #tutCap { max-width: 290px; } } /* fits the free band between the left controls and the wheel */
