/* Layout: one-screen arcade cabinet — header strip, full-bleed 3D stage, HUD on top, pedals on the bottom corners,
   menu cards over the stage (side panel on wide screens, bottom sheet on phones). Single dark-cabinet look. */
:root {
  --ink: #fff4e2;
  --ink-dim: #e9d6b8;
  --cabinet: #191a22;
  --panel: rgba(22, 20, 28, 0.82);
  --amber: #ffb23e;
  --signal: #e2382c;
  --line: rgba(255, 244, 226, 0.18);
  --f-display: "Racing Sans One", "Arial Black", Impact, sans-serif;
  --f-ui: "Saira Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--cabinet); color: var(--ink); font-family: var(--f-ui); font-size: 16px; overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
button { font-family: var(--f-ui); }
.app {
  height: 100%; display: flex; flex-direction: column; gap: 10px; padding-block: 10px 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h1 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(22px, 4vw, 30px); color: var(--amber); line-height: 1; }
.who { font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.who b { color: var(--ink); }
.stage { position: relative; flex: 1; min-height: 0; border-radius: 14px; overflow: hidden; background: #24212c; touch-action: none; }
canvas { display: block; width: 100%; height: 100%; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); }

/* HUD */
.hud { position: absolute; inset: 10px 10px auto 10px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; pointer-events: none; }
.gauge { background: var(--panel); border-radius: 10px; padding: 6px 12px 8px; line-height: 1; min-width: 0; }
.gauge small { display: block; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 3px; }
.gauge strong { font-family: var(--f-display); font-weight: 400; font-size: clamp(22px, 4.2vw, 36px); font-variant-numeric: tabular-nums; }
.gauge em { font-style: normal; font-size: 14px; color: var(--ink-dim); margin-left: 3px; }
.g-speed { justify-self: start; } .g-dist { justify-self: center; text-align: center; } .g-time { justify-self: end; text-align: right; }
.g-time.low strong { color: var(--signal); } .g-speed.turbo strong { color: #7fd3ff; }
.sub { position: absolute; top: 76px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; pointer-events: none; }
.chip { background: var(--panel); border-radius: 999px; padding: 3px 11px; font-size: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.chip-btn { pointer-events: auto; border: 1px solid var(--line); color: var(--ink); cursor: pointer; }
.chip.cp { color: var(--ink-dim); font-weight: 500; } .chip.cp b { color: var(--ink); }
.chip.bad { background: var(--signal); color: #fff; } .chip.turbo { background: #2a7fc0; color: #fff; } .chip.shield { background: #2f9b6a; color: #fff; }
.toast { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); font-family: var(--f-display); font-size: clamp(26px, 6vw, 46px);
  text-shadow: 0 3px 0 rgba(0,0,0,0.45), 0 0 18px rgba(0,0,0,0.35); white-space: nowrap; pointer-events: none; opacity: 0; }
.toast.show { animation: toast 1.1s ease-out forwards; } .toast.good { color: #ffe08a; } .toast.bad { color: #ff8a7a; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.85); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  70% { opacity: 1; transform: translate(-50%, -56%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -66%) scale(1); } }
.hint { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); background: var(--panel); padding: 8px 16px; border-radius: 10px; font-size: 19px;
  letter-spacing: 0.06em; text-transform: uppercase; pointer-events: none; white-space: nowrap; }
.controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 12px; pointer-events: none; }
.pad { display: flex; gap: 10px; align-items: flex-end; }
.btn { pointer-events: auto; touch-action: none; border: 2px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 700; cursor: pointer;
  display: grid; place-items: center; transition: transform 80ms ease-out, background-color 80ms ease-out; }
.btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.btn.on { transform: scale(0.94); background: rgba(255, 178, 62, 0.35); border-color: var(--amber); }
.btn-steer { width: 66px; height: 66px; border-radius: 50%; } .btn-steer svg { width: 28px; height: 28px; }
.btn-gas { width: 88px; height: 112px; border-radius: 16px 16px 22px 22px; font-size: 21px; letter-spacing: 0.12em;
  background-image: repeating-linear-gradient(0deg, transparent 0 12px, rgba(255,244,226,0.08) 12px 15px); }
.btn-brake { width: 66px; height: 76px; border-radius: 14px; font-size: 15px; letter-spacing: 0.08em; }
.keys { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--panel); padding: 4px 10px; border-radius: 6px; white-space: nowrap; pointer-events: none; }
@media (hover: none), (max-width: 760px) { .keys { display: none; } }

/* Cards */
.card { position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid;
  grid-template-columns: minmax(0, 1fr); align-content: start; gap: 12px; overflow-y: auto; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  -webkit-user-select: text; user-select: text; }
.center-card { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(440px, calc(100% - 24px)); max-height: calc(100% - 24px); }
.side-card { right: 12px; top: 12px; bottom: 12px; width: min(400px, calc(100% - 24px)); }
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .side-card { left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; max-height: 58%; }
  .garage { max-height: 54%; }
}
.card h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 30px; color: var(--amber); text-align: center; text-wrap: balance; line-height: 1.05; }
.card h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); font-weight: 500; }
.card p { margin: 0; font-size: 16px; line-height: 1.35; color: var(--ink-dim); text-wrap: pretty; }
.note { font-size: 15px !important; text-align: center; }
.err { color: #ff9b8c !important; font-size: 15px !important; }
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.form label { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); margin-top: 4px; }
input[type="text"], input[type="password"] { width: 100%; font: 700 20px var(--f-ui); color: var(--ink); background: rgba(0,0,0,0.3); border: 2px solid var(--line);
  border-radius: 10px; padding: 8px 12px; letter-spacing: 0.04em; }
input[type="password"] { letter-spacing: 0.4em; }
input:focus { outline: none; border-color: var(--amber); }
.go { border: 0; border-radius: 10px; padding: 10px 22px; background: var(--amber); color: #24170a; font: 700 19px var(--f-ui); letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; }
.go:disabled { opacity: 0.45; cursor: not-allowed; }
.big-go { font-size: 24px; padding: 12px; }
.ghost { border: 2px solid var(--line); border-radius: 10px; padding: 8px 16px; background: transparent; color: var(--ink); font: 700 17px var(--f-ui); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
.go:focus-visible, .ghost:focus-visible, .tab:focus-visible, .opt:focus-visible, .arrow:focus-visible, .track:focus-visible, .sw:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tabs { display: flex; gap: 6px; justify-content: center; }
.tabs.scroll { overflow-x: auto; justify-content: flex-start; padding-bottom: 2px; }
.tab { border: 2px solid var(--line); background: transparent; color: var(--ink-dim); border-radius: 999px; padding: 5px 14px; font: 700 15px var(--f-ui); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; white-space: nowrap; }
.tab.on { background: var(--amber); border-color: var(--amber); color: #24170a; }
.pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.pick small, .stats small { display: block; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-dim); }
.pick b { font-size: 19px; overflow-wrap: anywhere; }

/* Garage */
.car-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.car-title { text-align: center; } .car-title small { color: var(--ink-dim); letter-spacing: 0.1em; text-transform: uppercase; font-size: 13px; }
.arrow { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.arrow svg { width: 22px; height: 22px; }
.lock { background: rgba(226, 56, 44, 0.18); border: 1px solid rgba(226, 56, 44, 0.5); border-radius: 10px; padding: 8px 10px; text-align: center; color: var(--ink) !important; }
.stats-bars { display: grid; gap: 7px; }
.bar { display: grid; grid-template-columns: 92px minmax(0, 1fr) 76px; align-items: center; gap: 8px; font-size: 14px; }
.bar span:first-child { letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); font-size: 12px; }
.bar .track-bar { height: 8px; border-radius: 4px; background: rgba(255,244,226,0.12); overflow: hidden; }
.bar .fill { height: 100%; background: var(--amber); border-radius: 4px; transition: width 200ms ease-out; }
.bar b { text-align: right; font-variant-numeric: tabular-nums; }
.part { display: grid; gap: 5px; }
.part > small { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }
.opts { display: flex; gap: 6px; flex-wrap: wrap; }
.opt { border: 2px solid var(--line); background: transparent; color: var(--ink); border-radius: 8px; padding: 4px 10px; font: 700 15px var(--f-ui); cursor: pointer; }
.opt.on { border-color: var(--amber); background: rgba(255,178,62,0.2); }
.opt:disabled { opacity: 0.4; cursor: not-allowed; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.sw.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--amber); }
#gParts { display: grid; gap: 10px; }

/* Tracks */
.track-list { display: grid; gap: 8px; }
.track { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 12px; align-items: center; text-align: left; border: 2px solid var(--line); border-radius: 12px;
  background: rgba(0,0,0,0.2); color: var(--ink); padding: 8px; cursor: pointer; font-family: var(--f-ui); }
.track.on { border-color: var(--amber); }
.track:disabled { cursor: not-allowed; opacity: 0.6; }
.track .sw-big { width: 54px; height: 54px; border-radius: 10px; }
.track b { font-size: 19px; display: block; } .track span { font-size: 14px; color: var(--ink-dim); display: block; line-height: 1.25; }

/* Board */
.board ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.board li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline; padding: 4px 8px; border-radius: 6px; font-size: 17px; }
.board li:nth-child(odd) { background: rgba(255,244,226,0.05); }
.board li.me { background: rgba(255,178,62,0.25); }
.board li.empty { display: block; color: var(--ink-dim); font-size: 15px; }
.board .pos { color: var(--ink-dim); font-weight: 700; }
.board .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.board .nm small { font-weight: 500; color: var(--ink-dim); font-size: 13px; margin-left: 6px; }
.board .m { font-weight: 700; } .board .t { color: var(--ink-dim); font-size: 15px; }

/* Over */
.bignum { font-family: var(--f-display); font-size: 54px; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; }
.bignum em { font-style: normal; font-size: 22px; color: var(--ink-dim); margin-left: 4px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; font-variant-numeric: tabular-nums; }
.stats b { font-size: 20px; }
.save { text-align: center; font-size: 16px; color: var(--ink-dim); min-height: 1.3em; }
.unlocks { display: grid; gap: 6px; }
.unlocks div { background: rgba(63,191,174,0.2); border: 1px solid rgba(63,191,174,0.6); border-radius: 10px; padding: 8px 10px; text-align: center; font-weight: 700; font-size: 17px; }
@media (prefers-reduced-motion: reduce) { .toast.show { animation-duration: 1.4s; } .bar .fill { transition: none; } }
.toast { z-index: 5; }
.coin, .chip.coins { color: #f2c14e; }
.opt.shop { border-style: dashed; }
.opt small { display: block; font-size: 12px; font-weight: 500; color: #f2c14e; line-height: 1; }
.sw.shop { position: relative; }
.sw.shop::after { content: "M"; position: absolute; inset: 0; display: grid; place-items: center; font: 700 12px var(--f-ui); color: rgba(0,0,0,0.55); }
.garage .actions { position: sticky; bottom: -18px; margin: 0 -18px -18px; padding: 10px 18px 14px; background: #1e1c26; border-top: 1px solid var(--line); }
.bar { grid-template-columns: 78px minmax(0, 1fr) 96px; }
.bar .track-bar { position: relative; overflow: visible; }
.bar .fill { overflow: hidden; }
.bar .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.bar b small { display: block; font-size: 12px; font-weight: 500; line-height: 1.1; }
.bar b small.up { color: #7fe0a8; }
.bar b small.down { color: #ff9b8c; }
.bar { grid-template-columns: 72px minmax(0, 1fr) 82px; }
.cmp { font-size: 13px !important; color: var(--ink-dim); margin: 0; }
.wide { width: 100%; }
.order { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 10px; font-size: 15px; }
.order li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-dim); }
.order li b { color: var(--ink); margin-right: 4px; }
.order li.me { color: var(--amber); }
.hint.count { font-family: var(--f-display); font-size: 64px; background: transparent; text-shadow: 0 4px 0 rgba(0,0,0,0.45); padding: 0; }
.board li { align-items: center; }
.board .nm small { display: block; margin-left: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filters { justify-content: center; }
.filters .opt { font-size: 14px; padding: 3px 9px; }
.chip.corner { color: #fff; font-size: 15px; }
.chip.corner.sev0 { background: #2f9b6a; }
.chip.corner.sev1 { background: #d98a12; }
.chip.corner.sev2 { background: #d8352a; }
.order { grid-template-columns: minmax(0, 1fr); gap: 2px; }
.order li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; align-items: center; white-space: normal; padding: 3px 6px; border-radius: 6px; }
.order li:nth-child(odd) { background: rgba(255,244,226,0.05); }
.order .on { color: var(--ink); font-weight: 700; min-width: 0; }
.order li.me .on { color: var(--amber); }
.order .on small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order .ot { font-variant-numeric: tabular-nums; color: var(--ink); }
.sub { right: 64px; }
.rear-btn { position: absolute; top: 76px; right: 10px; width: 46px; height: 46px; border-radius: 12px; }
.rear-btn svg { width: 24px; height: 24px; }
.minimap { position: absolute; left: 10px; top: 150px; width: 112px; height: 112px; pointer-events: none; }
@media (min-width: 761px) { .minimap { width: 150px; height: 150px; top: 120px; } }
/* garage: car name + performance bars stay put, only the options scroll */
.card.garage { display: flex; flex-direction: column; overflow: hidden; gap: 10px; }
.garage > * { flex: none; }
.garage #gParts { flex: 1 1 auto; min-height: 90px; overflow-y: auto; padding-right: 4px; border-top: 1px solid var(--line); padding-top: 10px;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 18px), transparent); mask-image: linear-gradient(180deg, #000 calc(100% - 18px), transparent); }
.garage .actions { position: static; margin: 0; padding: 0; background: none; border: 0; }
@media (max-width: 760px), (max-aspect-ratio: 1/1) { .garage { max-height: 66%; } }
/* rear-view button on the left, under the map */
.sub { right: 10px; }
.rear-btn { left: 10px; right: auto; top: 270px; }
.rear-btn.nomap { top: 150px; }
@media (min-width: 761px) { .rear-btn { top: 280px; } .rear-btn.nomap { top: 120px; } }

/* Home: track is a button, steering choice */
.pick-btn { border: 2px dashed var(--line); background: transparent; color: var(--ink); border-radius: 10px; padding: 4px 6px; cursor: pointer; font: inherit; }
.pick-btn:hover, .pick-btn:focus-visible { border-color: var(--amber); }
.ctrl-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctrl-row > span { font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-dim); }
body.tilt-mode .btn-steer { display: none; }

/* Championship */
.champ { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.champ .order, #oChamp .order { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.champ .actions { margin-top: 2px; }
#oChamp { display: grid; gap: 6px; }

/* Phone held sideways (or any short screen): give the road the whole height */
@media (max-height: 520px) and (orientation: landscape) {
  body.racing header { display: none; }
  body.racing .app { padding: 0 env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px); gap: 0; }
  body.racing .stage { border-radius: 0; }
  .app { padding-block: 6px 6px; gap: 6px; }
  h1 { font-size: 20px; }
  .hud { inset: 6px 8px auto 8px; }
  .gauge { padding: 4px 9px 5px; }
  .gauge small { font-size: 10px; margin-bottom: 1px; }
  .gauge strong { font-size: 24px; }
  .gauge em { font-size: 12px; }
  .sub { top: 56px; left: 110px; right: 110px; }
  .chip { font-size: 12px; padding: 2px 9px; }
  .minimap { top: 62px; width: 92px; height: 92px; }
  .rear-btn { top: 160px; width: 42px; height: 42px; }
  .rear-btn.nomap { top: 62px; }
  .controls { padding: 8px 10px; }
  .btn-steer { width: 62px; height: 62px; }
  .btn-gas { width: 80px; height: 96px; }
  .btn-brake { width: 62px; height: 66px; }
  .hint { top: 40%; font-size: 16px; padding: 6px 12px; }
  .toast { top: 32%; }
  .card { padding: 12px; gap: 8px; }
  .card h2 { font-size: 24px; }
  .center-card { max-height: calc(100% - 12px); }
  .side-card { top: 6px; bottom: 6px; }
  .big-go { padding-block: 8px; }
}

/* Retroview: a rectangle with a tap symbol and the word, clearly a button */
.rear-btn { width: auto; height: 40px; padding: 0 10px 0 8px; border-radius: 9px; display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--f-ui, inherit); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: lowercase; }
.rear-btn svg { width: 20px; height: 20px; flex: none; }
@media (max-height: 520px) and (orientation: landscape) { .rear-btn { width: auto; height: 36px; font-size: 12px; } }

/* Pause: a big P */
.pause-btn { font-family: var(--f-display); font-size: 20px; min-width: 44px; min-height: 36px; padding: 0 12px; font-weight: 800; }
@media (max-height: 520px) and (orientation: landscape) { .pause-btn { font-size: 17px; min-height: 30px; } }

/* Pre-race */
.big-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.big-opts .opt { padding: 12px 8px; font-size: 17px; font-weight: 700; }
.big-opts .opt small { color: var(--ink-dim); font-weight: 500; margin-top: 4px; }
.pre h3 { margin: 4px 0 0; }

/* Garage stats: grey = factory car, green = gained by parts, red = lost by parts */
.bar .track-bar { position: relative; overflow: hidden; }
.bar .seg { position: absolute; top: 0; bottom: 0; }
.bar .seg.base { background: #8f8a99; border-radius: 4px 0 0 4px; }
.bar .seg.gain { background: #3ccf7e; }
.bar .seg.loss { background: repeating-linear-gradient(135deg, #e0574a 0 4px, rgba(224,87,74,0.45) 4px 8px); }
.bar b small.vsnow { display: block; color: #6fb8ff; font-weight: 600; }
.cmp { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.cmp .lg { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-left: 6px; }
.cmp .lg:first-child { margin-left: 0; }
.cmp .lg.base { background: #8f8a99; } .cmp .lg.gain { background: #3ccf7e; } .cmp .lg.loss { background: #e0574a; }
.cmp .trying { color: #6fb8ff; flex-basis: 100%; }
.cmp > span { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.cmp .lg { margin-left: 0; }
.bar { grid-template-columns: 70px minmax(0, 1fr) 118px; }
.bar b small { font-size: 11px; line-height: 1.25; white-space: nowrap; }

/* Retroview sits right above the steering buttons, under the left thumb (map or no map) */
.rear-btn, .rear-btn.nomap { top: auto; right: auto; left: 12px; bottom: 90px; }
body.tilt-mode .rear-btn { bottom: 14px; }
@media (min-width: 761px) { .rear-btn, .rear-btn.nomap { top: auto; bottom: 90px; } }
@media (max-height: 520px) and (orientation: landscape) { .rear-btn, .rear-btn.nomap { top: auto; left: 10px; bottom: 80px; } }

/* Online */
.online { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.online h3 { margin: 0; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.people li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; }
.people li.empty { color: var(--ink-dim); font-size: 13px; border-style: dashed; }
.people li small { color: var(--ink-dim); }
button.small { padding: 6px 12px; font-size: 14px; min-height: 0; }
.field { display: grid; gap: 4px; }
.field span { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); }
.field select, #oMp select { font: inherit; padding: 8px 10px; border-radius: 10px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.invite-bar { position: fixed; z-index: 50; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 24px); padding: 10px 14px; border-radius: 14px; background: #2b2836; border: 2px solid var(--amber);
  box-shadow: 0 8px 30px rgba(0,0,0,0.45); color: var(--ink); font-weight: 600; }
#oMp { display: grid; gap: 6px; }
#oMp .actions { flex-wrap: wrap; }

/* NOS (online challenges with bonus): charges stack, one press = 4 s of boost */
.gas-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.controls .btn-nos { width: 88px; height: 52px; border-radius: 14px; font-family: var(--f-display); font-size: 20px; letter-spacing: 0.08em;
  background: linear-gradient(180deg, #2f7fd6, #1b4f9a); color: #fff; border: 2px solid #8cc4ff; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.controls .btn-nos small { font-size: 13px; background: rgba(0,0,0,0.35); border-radius: 8px; padding: 1px 6px; }
.controls .btn-nos.empty { opacity: 0.45; filter: grayscale(0.6); }
.controls .btn-nos.boosting { box-shadow: 0 0 18px #6fb8ff; }
@media (max-height: 520px) and (orientation: landscape) { .controls .btn-nos { width: 80px; height: 42px; font-size: 17px; } .gas-col { gap: 6px; } }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--amber); }
.check small { color: var(--ink-dim); font-weight: 500; }
.board small .when, .order small .when, ol small.when { color: var(--ink-dim); white-space: nowrap; }
/* four leaderboard tabs: wrap onto two lines on narrow phones instead of being cut off */
#boardTabs { flex-wrap: wrap; justify-content: center; overflow: visible; }

/* Voice radio */
.radio-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#radioBtn.on-air { border-color: #3ccf7e; color: #3ccf7e; }
.mic-btn { font-weight: 800; min-width: 52px; min-height: 36px; background: rgba(60,207,126,0.25); border-color: #3ccf7e; }
.mic-btn.muted { background: rgba(224,87,74,0.3); border-color: #e0574a; }
.car-filter { grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.vmax { font-weight: 600; color: var(--ink); }
#boardList small.when, #oBoard small.when { display: block; white-space: normal; overflow: visible; text-overflow: clip; }

/* Garage v2: one scroll for the whole panel, parts by category, buy bar always visible at the bottom */
.card.garage { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; gap: 10px; padding-bottom: 0; }
.garage > * { flex: none; }
.garage #gParts { flex: none; min-height: 0; overflow: visible; padding: 0; border: 0; -webkit-mask-image: none; mask-image: none; display: block; }
.part-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 8px 0 2px; border-top: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.part-tabs::-webkit-scrollbar { display: none; }
.ptab { flex: none; border: 2px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 7px 14px; font: 700 14px var(--f-ui); cursor: pointer; }
.ptab.on { background: var(--amber); border-color: var(--amber); color: #1e1c26; }
.popts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.popt { display: grid; gap: 2px; text-align: left; border: 2px solid var(--line); background: rgba(255,244,226,0.04); color: var(--ink); border-radius: 12px; padding: 10px 12px; font: inherit; cursor: pointer; min-height: 64px; }
.popt b { font-size: 16px; }
.popt small { font-size: 12px; line-height: 1.25; }
.popt .st { font-weight: 700; color: var(--ink-dim); }
.popt.shop { border-style: dashed; }
.popt.shop .st { color: #f2c14e; }
.popt.mine .st { color: #7fe0a8; }
.popt.mounted { border-color: var(--amber); background: rgba(255,178,62,0.16); }
.popt.mounted .st { color: var(--amber); }
.popt.trying { border-color: #6fb8ff; border-style: solid; background: rgba(111,184,255,0.14); }
.popt.trying .st { color: #8cc4ff; }
.popt .fx { color: var(--ink-dim); }
.popt:disabled { opacity: 0.45; cursor: not-allowed; }
.swatches.big { gap: 10px; }
.swatches.big .sw { width: 40px; height: 40px; }
.sw.mounted { box-shadow: 0 0 0 3px var(--amber); border-color: var(--ink); }
.sw.trying { box-shadow: 0 0 0 3px #6fb8ff; }
.small-note { font-size: 13px; margin: 8px 0 0; }
.garage .actions.g-bar { position: sticky; bottom: 0; margin: auto -18px 0; padding: 10px 18px 12px; background: #1e1c26; border-top: 1px solid var(--line);
  z-index: 2; flex-wrap: nowrap; align-items: center; }
.g-bar #gMsg { flex: 1 0 100%; margin: 0; font-size: 13px; text-align: center; }
.g-bar { flex-wrap: wrap !important; }
.g-bar #gUse { flex: 1 1 auto; min-width: 0; }
.g-bar #gBack { flex: none; }
@media (max-width: 760px), (max-aspect-ratio: 1/1) { .card.garage { max-height: 70%; } }
@media (max-height: 520px) and (orientation: landscape) {
  .garage .actions.g-bar { margin: auto -12px 0; padding: 8px 12px 8px; }
  .g-bar .go, .g-bar .ghost { padding-block: 8px; font-size: 16px; }
  .garage .cmp .trying { display: none; }
  .popt { min-height: 54px; padding: 7px 10px; }
}
/* garage v2b: parts first, stats after; one-row action bar */
.garage #gStats { border-top: 1px solid var(--line); padding-top: 8px; }
.garage .actions.g-bar { flex-wrap: wrap; gap: 8px; }
.g-bar .go { font-size: 16px; letter-spacing: 0.06em; padding: 11px 12px; }
.g-bar .ghost { padding: 9px 14px; }
.g-bar #gUse { flex: 1 1 0; }
.g-bar #gMsg { font-size: 12.5px; line-height: 1.3; }
@media (max-height: 520px) and (orientation: landscape) { .g-bar #gMsg.pv { display: none; } }
/* online: way out while waiting at the finish line */
.mp-leave { position: fixed; left: 50%; top: calc(40% + 64px); transform: translateX(-50%); z-index: 6; background: var(--panel); padding: 10px 18px; }
@media (max-height: 520px) and (orientation: landscape) { .mp-leave { top: calc(40% + 46px); padding: 7px 14px; } }
.keys-note { font-size: 13px; }
@media (hover: none) and (pointer: coarse) { .keys-note { display: none; } }
/* intermediates: red = gap to the car ahead, green = lead on the car behind */
.split-box { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); display: grid; gap: 2px; justify-items: center;
  background: rgba(22,20,28,0.82); border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px 7px; pointer-events: none; z-index: 3; min-width: 170px; }
.split-box small { font: 700 11px var(--f-ui); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }
.split-box b { font: 800 19px var(--f-display); font-variant-numeric: tabular-nums; white-space: pre; }
.split-box .sp-a { color: #ff6b5e; }
.split-box .sp-b { color: #5fe39a; }
@media (max-height: 520px) and (orientation: landscape) { .split-box { top: 64px; padding: 4px 12px 5px; } .split-box b { font-size: 16px; } }
/* the split box sits on its own line under the chips, never over them */
.split-row { flex: 0 0 100%; display: flex; justify-content: center; pointer-events: none; }
.split-row .split-box { position: static; transform: none; margin-top: 2px; }
.split-row:has(.split-box[hidden]) { display: none; }
@media (orientation: portrait) { .split-row { justify-content: flex-end; } }

/* steering: the whole area around the two arrows reacts (gap included, out to the screen edge), and the thumb can slide from one to the other */
.steer-pad { pointer-events: auto; touch-action: none; margin: -12px; padding: 8px 18px 12px 12px; }
.steer-pad .btn-steer { pointer-events: none; }
body.tilt-mode .steer-pad { pointer-events: none; }
