:root {
  --bg: rgba(14, 16, 20, 0.72);
  --fg: #eef1f5;
  --muted: #9aa3ae;
  --accent: #ffd23f;
  --good: #3ddc84;
  --bad: #ff5a5a;
  --warn: #ffb020;
  --line: rgba(255, 255, 255, 0.12);
  --display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--fg); }
#app { position: fixed; inset: 0; }
#app canvas { display: block; touch-action: none; cursor: grab; }
.hidden { display: none !important; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; font-size: 20px; background: #0d0f13; z-index: 50; }

.panel { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; backdrop-filter: blur(6px); }
#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; }
.hud-top { position: absolute; top: 12px; left: 12px; display: flex; gap: 10px; align-items: flex-start; max-width: 46vw; }
.lvl #hud-level { font: 700 19px/1.15 var(--display); letter-spacing: 0.02em; text-transform: uppercase; }
.lvl #hud-objective { color: var(--muted); font-size: 12px; margin-top: 2px; }
.timer { font-variant-numeric: tabular-nums; font: 800 28px/1 var(--display); }
#hud-timer.warn { color: var(--bad); }

.hud-bottom { position: absolute; bottom: 12px; left: 12px; right: 12px; display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.dash { display: flex; align-items: center; gap: 14px; }
.speed { font-family: var(--display); font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; line-height: 1; }
.speed small { font-size: 11px; color: var(--muted); margin-left: 4px; font-weight: 500; }
.ind { font-size: 22px; color: #3a3f46; }
.ind.on { color: #3ddc84; text-shadow: 0 0 10px #3ddc84; }
#hud-gear { display: flex; gap: 4px; font-weight: 800; font-size: 18px; }
#hud-gear span { width: 26px; height: 30px; display: grid; place-items: center; border-radius: 6px; color: #5b626b; }
#hud-gear span.on { background: var(--accent); color: #111; }
.wheelbox { display: flex; flex-direction: column; align-items: center; width: 64px; }
#hud-wheel { width: 46px; height: 46px; color: #cfd5dc; transition: transform 0.03s linear; }
.wheelbox small { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
#hud-pedals { display: flex; gap: 4px; height: 44px; }
.ped { width: 8px; background: #2a2e34; border-radius: 3px; position: relative; overflow: hidden; }
.ped i { position: absolute; bottom: 0; left: 0; right: 0; background: var(--bad); }
.ped.thr i { background: var(--good); }
.icons { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.icons span { opacity: 0.25; }
.icons span.on { opacity: 1; }
#hud-handbrake.on { color: var(--bad); font-weight: 800; }
#hud-hold { font: 800 11px/1 var(--display); letter-spacing: 0.08em; opacity: 0.25; }
#hud-hold.on { opacity: 1; color: var(--good); }

.sensors { display: flex; flex-direction: column; gap: 6px; min-width: 170px; }
.sensor { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.sensor b { width: 40px; font-weight: 600; }
.sensor .bars { display: flex; gap: 3px; }
.sensor .bars i { width: 22px; height: 8px; border-radius: 2px; background: #2a2e34; }
.sensor.s1 .bars i:nth-child(1) { background: var(--good); }
.sensor.s2 .bars i:nth-child(-n + 2) { background: var(--warn); }
.sensor.s3 .bars i { background: var(--bad); }
.sensor em { font-style: normal; color: var(--fg); font-variant-numeric: tabular-nums; }
.cam { margin-left: auto; display: flex; flex-direction: column; font-size: 13px; }
.cam small { color: var(--muted); font-size: 11px; }

#toasts { position: absolute; top: 150px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { background: var(--bg); border: 1px solid var(--line); padding: 8px 16px; border-radius: 999px; font-size: 14px; transition: opacity 0.4s; }
.toast.bad { border-color: var(--bad); color: #ffd0d0; }
.toast.warn { border-color: var(--warn); }
.toast.good { border-color: var(--good); }
.toast.out { opacity: 0; }

#hud-align { position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%); background: var(--bg); padding: 6px 14px; border-radius: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
#hud-align b { color: var(--fg); font-variant-numeric: tabular-nums; }
#park-ring { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 120px; height: 120px; display: grid; place-items: center; }
#park-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
#park-ring circle { fill: none; stroke-width: 3; }
#park-ring .bg { stroke: rgba(255, 255, 255, 0.15); }
#park-ring .fg { stroke: var(--good); stroke-dasharray: 100; stroke-dashoffset: 100; stroke-linecap: round; }
#park-text { font-weight: 700; text-shadow: 0 1px 4px #000; }

#hud-signal { position: absolute; top: 12px; right: 230px; display: flex; gap: 4px; align-items: center; background: #111; padding: 6px 8px; border-radius: 10px; }
#hud-signal i { width: 14px; height: 14px; border-radius: 50%; background: #333; }
#hud-signal[data-state='red'] .r { background: #ff2a1a; box-shadow: 0 0 8px #ff2a1a; }
#hud-signal[data-state='yellow'] .y { background: #ffb000; box-shadow: 0 0 8px #ffb000; }
#hud-signal[data-state='green'] .g { background: #20e070; box-shadow: 0 0 8px #20e070; }
#hud-signal .t { font-size: 12px; min-width: 16px; text-align: center; color: var(--muted); }

#pip-labels .pip-label { position: absolute; font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(255, 255, 255, 0.75); text-shadow: 0 1px 2px #000; }

/* menus */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(5, 7, 10, 0.55); z-index: 10; overflow: auto; padding: 16px; }
#menu { background: linear-gradient(180deg, rgba(5, 7, 10, 0.25), rgba(5, 7, 10, 0.85)); align-items: start; }
.menu-box { width: min(1100px, 100%); padding: 12px 0 40px; }
.menu-box header .brand { display: inline-flex; align-items: center; gap: 12px; color: var(--fg); text-decoration: none; margin: 10px 0 6px; }
.menu-box header .brand svg { width: 44px; height: 44px; flex: none; }
.menu-box header h1 { margin: 0; font: 800 48px/1 var(--display); letter-spacing: 0.02em; text-transform: uppercase; }
.menu-box header p { margin: 0 0 18px; color: #c9ced4; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9); }
.menu-box h2 { font: 700 15px/1.2 var(--display); text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); margin: 22px 0 10px; }
#level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.level-card { text-align: left; background: var(--bg); border: 1px solid var(--line); color: var(--fg); border-radius: 12px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; font: inherit; transition: transform 0.1s, border-color 0.1s; }
.level-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.lc-top { display: flex; justify-content: space-between; }
.lc-num { font-weight: 800; color: var(--accent); }
.lc-stars { color: var(--accent); letter-spacing: 2px; }
.lc-name { font-weight: 700; font-size: 16px; }
.lc-desc { font-size: 12px; color: var(--muted); flex: 1; }
.lc-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
#vehicle-select { display: flex; gap: 10px; flex-wrap: wrap; }
.veh { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer; font: inherit; max-width: 300px; }
.veh small { color: var(--muted); font-size: 11px; }
.veh.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } .hud-top { max-width: 90vw; } #hud-signal { right: 12px; top: 90px; } }
#settings { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.tog, .sel { display: flex; gap: 8px; align-items: center; }
.controls-list { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
kbd { background: #2a2e34; border: 1px solid #3a3f46; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 12px; color: var(--fg); font-family: inherit; }
button { background: var(--accent); color: #111; border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 700; cursor: pointer; }
.dialog button, .row > button { font: 700 17px/1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; padding: 12px 18px; }
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
#btn-help { margin-top: 12px; }
.dialog { background: #14171c; border: 1px solid var(--line); border-radius: 16px; padding: 24px; min-width: 300px; max-width: 520px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.dialog.wide { max-width: 720px; text-align: left; }
.dialog.wide li { margin-bottom: 8px; color: #cfd5dc; font-size: 14px; }
.dialog h2 { margin: 0; font: 800 34px/1.05 var(--display); text-transform: uppercase; letter-spacing: 0.02em; }
.dialog h2.ok { color: var(--good); }
.dialog h2.bad { color: var(--bad); }
#result-stars { font-size: 40px; color: var(--accent); letter-spacing: 6px; }
#result-reason { color: var(--muted); margin: 0; }
#result-stats { font-size: 14px; }
#result-stats ul { text-align: left; color: var(--bad); font-size: 13px; }
#result-stats .metrics { color: var(--muted); font-size: 12px; margin-top: 6px; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
#color-select { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; padding: 0; border: 2px solid rgba(255, 255, 255, 0.25); font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; }
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.hint { color: var(--muted); font-size: 11px; }
#settings select { max-width: 320px; }

/* on-screen controls */
#touch-ui { position: absolute; inset: 0; pointer-events: none; }
#touch-ui .t-btn, #t-wheel, .t-pedal { pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
#t-wheel-wrap { position: absolute; left: 16px; bottom: 96px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#t-wheel { width: min(210px, 30vw); height: min(210px, 30vw); cursor: grab; border-radius: 50%; }
#t-wheel.active { cursor: grabbing; }
#t-wheel svg { width: 100%; height: 100%; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5)); }
.t-row { display: flex; gap: 10px; align-items: center; }
#t-wheel-deg { font-size: 12px; color: var(--muted); min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; background: var(--bg); padding: 2px 8px; border-radius: 6px; }
.t-btn { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-weight: 800; }
.t-ind.on { color: #3ddc84; border-color: #3ddc84; box-shadow: 0 0 10px rgba(61, 220, 132, 0.6); }
#t-right { position: absolute; right: 16px; bottom: 96px; display: flex; gap: 10px; align-items: flex-end; }
#t-gears { display: flex; flex-direction: column; gap: 6px; }
#t-gears .t-btn { width: 44px; height: 40px; padding: 0; font-size: 16px; }
#t-gears .t-btn.on { background: var(--accent); color: #111; }
#t-pedal-col { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
#t-hand { font-size: 11px; letter-spacing: 0.05em; }
#t-hand.on { background: var(--bad); color: #fff; }
#t-pedals { display: flex; gap: 10px; align-items: flex-end; }
.t-pedal { position: relative; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: repeating-linear-gradient(0deg, #1b1d21 0 10px, #24272c 10px 14px); display: grid; place-items: end center; padding-bottom: 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: #cfd5dc; }
.t-pedal i { position: absolute; left: 0; right: 0; top: 0; height: 0; background: rgba(255, 90, 90, 0.35); }
#t-gas i { background: rgba(61, 220, 132, 0.35); }
.t-pedal span { position: relative; }
#t-brake { width: 86px; height: 110px; }
#t-gas { width: 62px; height: 150px; }
.t-pedal.on { border-color: var(--fg); }
body.touch-ui .hud-bottom { left: 50%; right: auto; transform: translateX(-50%); justify-content: center; flex-wrap: nowrap; }
body.touch-ui .hud-bottom .cam { display: none; }
.t-top { display: none; pointer-events: auto; touch-action: manipulation; color: var(--fg); min-width: 48px; height: 44px; padding: 0 12px; font: 800 18px/1 var(--display); }
body.touch-ui .t-top { display: block; }
body.touch-ui #hud-pedals { display: none; }
@media (max-width: 760px) { body.touch-ui .hud-bottom .dash { transform: scale(0.8); transform-origin: bottom center; } }
#controller { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.axbar { display: inline-block; width: 90px; height: 8px; background: #2a2e34; border-radius: 4px; overflow: hidden; vertical-align: middle; }
.axbar i { display: block; height: 100%; width: 0; background: var(--accent); }
#ctl-axes { font-family: ui-monospace, monospace; font-size: 10px; word-break: break-all; }
/* wheel on the right, pedals + selector on the left */
body.wheel-right #t-wheel-wrap { left: auto; right: 16px; }
body.wheel-right #t-right { right: auto; left: 16px; flex-direction: row-reverse; }

/* --- v3 additions -------------------------------------------------------- */
#hud-extra { font-size: 12px; color: var(--muted); margin-top: 4px; }
#hud-extra b { color: var(--fg); }
#hud-extra b.bad { color: var(--bad); }
#hud-extra small { color: var(--muted); }
#hud-gear.manual span { width: 22px; font-size: 15px; }
.ped.clt i { background: #4fc3f7; }
#hud-stall { position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%); background: rgba(255, 90, 90, 0.85); color: #fff; padding: 8px 16px; border-radius: 10px; font-weight: 800; letter-spacing: 0.05em; }
#coach { position: absolute; top: 96px; left: 12px; max-width: min(460px, 46vw); background: rgba(20, 60, 40, 0.82); border: 1px solid rgba(61, 220, 132, 0.6); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
#coach b { color: var(--good); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
@media (max-width: 760px) { #coach { top: 120px; max-width: 70vw; font-size: 12px; } }

#rain-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
#rain-overlay i { position: absolute; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), rgba(180, 200, 220, 0.12) 60%, rgba(0, 0, 0, 0.12)); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
#rain-overlay.wipe::after { content: ''; position: absolute; left: -10%; bottom: -60%; width: 120%; height: 160%; background: linear-gradient(90deg, transparent 45%, rgba(10, 10, 10, 0.55) 49%, rgba(10, 10, 10, 0.55) 51%, transparent 55%); transform-origin: 50% 100%; animation: wipe 0.6s ease-in-out; }
@keyframes wipe { from { transform: rotate(-70deg); } to { transform: rotate(70deg); } }

#replay-bar { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 12; display: flex; gap: 14px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 13px; }
#replay-bar .legend i { display: inline-block; width: 18px; height: 4px; border-radius: 2px; vertical-align: middle; margin-left: 6px; }
#replay-bar .legend .g { background: var(--good); }
#replay-bar .legend .r { background: var(--bad); }
#replay-bar .legend .w { background: #fff; opacity: 0.6; }
#replay-bar .prog { width: 140px; height: 6px; background: #2a2e34; border-radius: 3px; overflow: hidden; }
#replay-bar .prog i { display: block; height: 100%; width: 0; background: var(--accent); }
#replay-bar button { padding: 4px 10px; }

.row.left { justify-content: flex-start; margin-top: 10px; }
.daily { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-color: rgba(255, 210, 63, 0.5); }
.daily small { color: var(--muted); }
#custom-levels { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.custom-row { display: flex; gap: 10px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.custom-row b { flex: 1; }
.custom-row button { padding: 6px 10px; }

table.rec { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
table.rec td, table.rec th { border-bottom: 1px solid var(--line); padding: 6px 4px; vertical-align: top; }
table.rec ol { margin: 0; padding-left: 18px; }
.bar { display: inline-block; width: 60px; height: 6px; background: #2a2e34; border-radius: 3px; overflow: hidden; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--good); }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 10px; }
.stat-tiles div { background: #1c2026; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.stat-tiles b { font-size: 24px; }
.stat-tiles span { color: var(--muted); font-size: 12px; }
#modal .dialog { max-height: 86vh; overflow: auto; }

#t-gears.manual { display: grid; grid-template-columns: repeat(2, 44px); gap: 6px; }
#t-gears.manual .t-btn { height: 36px; }
#t-clutch { width: 70px; height: 110px; }
#t-clutch i { background: rgba(79, 195, 247, 0.4); }

/* level editor */
#editor { position: fixed; top: 12px; left: 12px; bottom: 12px; width: min(340px, 92vw); z-index: 11; background: rgba(14, 16, 20, 0.88); border: 1px solid var(--line); border-radius: 14px; padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.ed-head { display: flex; flex-direction: column; gap: 4px; }
.ed-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ed-tools button { background: #1c2026; color: var(--fg); border: 1px solid var(--line); padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 18px; font-weight: 400; }
.ed-tools button small { font-size: 10px; color: var(--muted); }
.ed-tools button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.ed-props { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ed-props.sel { border-top: 1px solid var(--line); padding-top: 8px; }
.ed-props b { grid-column: 1 / -1; }
.ed-props label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 11px; }
.ed-props input, .ed-props select { background: #1c2026; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; font: inherit; }
.ed-props button { grid-column: 1 / -1; }
.ed-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.ed-actions button { padding: 8px 10px; }
.ed-flash { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); }

#stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.stage-tile { position: relative; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; cursor: pointer; }
.stage-tile b { font: 800 22px/1 var(--display); }
.stage-tile small { font-size: 10px; color: var(--accent); letter-spacing: 1px; }
.stage-tile.done { border-color: rgba(61, 220, 132, 0.6); }
.stage-tile.multi { background: linear-gradient(180deg, rgba(79, 195, 247, 0.18), var(--bg)); }
.stage-tile i { position: absolute; top: 3px; right: 5px; font-size: 10px; font-style: normal; color: #4fc3f7; }
.stage-tile:hover { border-color: var(--accent); }
#stage-count { color: var(--muted); font-weight: 400; }
.stage-tile .diff { width: 80%; height: 3px; border-radius: 2px; background: #2a2e34; position: relative; overflow: hidden; }
.stage-tile .diff::after { content: ''; position: absolute; inset: 0; width: var(--w); background: hsl(var(--h) 70% 50%); }

.chapter-head { grid-column: 1 / -1; margin-top: 12px; padding-top: 10px; border-top: 1px dashed rgba(255, 255, 255, 0.18); font: 700 17px/1.2 var(--display); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg); }
.chapter-head:first-child { border-top: 0; margin-top: 0; }
.stage-tile.locked { opacity: 0.4; cursor: not-allowed; }
.stage-tile .lock { position: absolute; top: 2px; left: 4px; font-size: 10px; font-style: normal; }
.stage-tile .badge { position: absolute; bottom: -7px; font-size: 8px; font-style: normal; font-weight: 800; letter-spacing: 0.06em; padding: 1px 5px; border-radius: 6px; background: var(--good); color: #062; }
.stage-tile .badge.test { background: var(--accent); color: #111; }
.pack-head { color: #8fd3ff; }
.stage-tile.pack { background: linear-gradient(180deg, rgba(143, 211, 255, 0.12), var(--bg)); }
.stage-tile.intro { border-color: rgba(61, 220, 132, 0.5); }
#lesson { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, 90vw); background: rgba(14, 16, 20, 0.94); border: 1px solid var(--good); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; pointer-events: auto; z-index: 3; }
#lesson small { color: var(--good); text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; font-weight: 700; }
#lesson b { font-size: 22px; }
#lesson p { margin: 0; line-height: 1.5; color: #d6dbe1; }
#lesson button { align-self: flex-end; }

/* --- phone layout (touch screen or short window): controls in the corners, one small
       strip of readouts, nothing over the game view ------------------------------------- */
body.compact .hud-top { top: 6px; left: 8px; gap: 6px; max-width: none; }
body.compact .lvl { padding: 4px 10px; max-width: 26vw; }
body.compact .lvl #hud-level { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.compact .lvl #hud-objective, body.compact #hud-extra { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
body.compact .timer { padding: 4px 10px; font-size: 20px; }
body.compact .t-top { position: fixed; top: 6px; height: 38px; min-width: 42px; padding: 0 10px; font-size: 16px; }
body.compact #t-pause { right: 8px; }
body.compact #t-cam { right: 58px; }
body.compact #t-full { right: 108px; }
:fullscreen body.compact #t-full, body.compact:fullscreen #t-full { opacity: 0.6; }
body.compact #toasts { top: 52px; }
body.compact .toast { font-size: 12px; padding: 5px 12px; }
body.compact #coach { top: 52px; max-width: 46vw; font-size: 12px; }
/* bottom centre: speed, current gear, HOLD and the parking sensors in one strip */
body.compact .hud-bottom { bottom: 6px; gap: 6px; }
body.compact .hud-bottom .dash { padding: 4px 10px; gap: 8px; transform: none; }
body.compact .speed { font-size: 26px; min-width: 40px; }
body.compact .speed small { font-size: 9px; }
body.compact .wheelbox, body.compact .ind, body.compact #hud-pedals { display: none; }
body.compact #hud-gear span { width: 22px; height: 24px; font-size: 14px; }
body.compact #hud-gear span:not(.on) { display: none; }
body.compact .icons { flex-direction: row; gap: 6px; font-size: 11px; align-items: center; }
body.compact .sensors { min-width: 0; padding: 4px 10px; gap: 2px; }
body.compact .sensor { gap: 5px; font-size: 10px; }
body.compact .sensor b { width: auto; min-width: 34px; }
body.compact .sensor .bars i { width: 12px; height: 6px; }
body.compact .sensor em { font-size: 11px; min-width: 40px; }
/* wheel and pedals in the corners, sized by the screen height */
body.compact #t-wheel-wrap { bottom: 8px; left: 10px; gap: 4px; }
body.compact #t-wheel { width: clamp(120px, 42vh, 210px); height: clamp(120px, 42vh, 210px); }
body.compact .t-row .t-btn { padding: 4px 12px; }
body.compact #t-wheel-deg { font-size: 11px; min-width: 52px; }
body.compact #t-right { bottom: 8px; right: 10px; gap: 8px; }
body.compact.wheel-right #t-wheel-wrap { left: auto; right: 10px; }
body.compact.wheel-right #t-right { right: auto; left: 10px; }
body.compact #t-gears { gap: 4px; }
body.compact #t-gears .t-btn { width: 40px; height: clamp(28px, 8.5vh, 40px); font-size: 14px; }
body.compact #t-pedal-col { gap: 6px; }
body.compact #t-hand { font-size: 10px; padding: 6px 8px; }
body.compact #t-brake { width: clamp(60px, 11vw, 86px); height: clamp(80px, 27vh, 110px); }
body.compact #t-gas { width: clamp(48px, 8vw, 62px); height: clamp(100px, 37vh, 150px); }
body.compact #lesson { max-height: 80vh; overflow: auto; }
body.compact .t-pedal { font-size: 9px; letter-spacing: 0; padding-bottom: 6px; }
/* phones: the space around the pedals, gears and wheel swallows near-miss touches so they
   never reach the game view (where a drag would turn the camera) */
body.compact #t-right, body.compact #t-wheel-wrap { pointer-events: auto; touch-action: none; padding: 10px; margin: -10px; }
body.compact #t-pedals, body.compact #t-gears, body.compact #t-pedal-col { pointer-events: auto; touch-action: none; }
