:root {
  --bg: #0b1410; --panel: #12201a; --panel2: #182b22; --line: #2a4436;
  --text: #eef5f0; --muted: #8fa89a; --accent: #ffd23f; --accent2: #3ee08f; --nitro: #ffb13b;
  --danger: #ff5a5f;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.h { font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: .02em; }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #hud .stickzone { pointer-events: auto; }
.panel, .posbox, .clock, .mini, .speed { background: rgba(8, 14, 11, .84); border: 1px solid #ffffff22; border-radius: 12px; box-shadow: 0 6px 20px #0008; }
.posbox { position: absolute; top: calc(10px + var(--sat)); left: calc(10px + var(--sal)); padding: 4px 11px 6px; text-align: left; min-width: 76px; }
.posbox .pos { font-weight: 900; font-style: italic; line-height: 1; white-space: nowrap; }
.posbox .pos b { font-size: 34px; color: var(--accent); }
.posbox .pos sup { font-size: 14px; color: var(--accent); vertical-align: 15px; margin-left: 1px; }
.posbox .pos span { font-size: 15px; color: var(--muted); margin-left: 3px; }
.posbox .lap { font-size: 11px; font-weight: 900; letter-spacing: .1em; color: var(--text); margin-top: 2px; white-space: nowrap; }
.posbox .lap.fin { color: var(--accent); }
.clock { position: absolute; top: calc(10px + var(--sat)); left: 50%; transform: translateX(-50%); padding: 4px 12px 5px; text-align: center; white-space: nowrap; }
.clock b { display: block; font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.clock span { display: block; font-size: 10px; font-weight: 800; letter-spacing: .08em; color: var(--muted); font-variant-numeric: tabular-nums; }
.clock span.good { color: var(--accent2); } .clock span.bad { color: #ff8a8d; }
.pause { position: absolute; top: calc(12px + var(--sat)); right: calc(12px + var(--sar)); width: 38px; height: 38px; border-radius: 10px; border: 1px solid #ffffff2a;
  background: rgba(8, 14, 11, .8); font-weight: 900; display: grid; place-items: center; font-size: 13px; }
.mini { position: absolute; top: calc(58px + var(--sat)); right: calc(10px + var(--sar)); padding: 3px; }
.mini canvas { display: block; width: 96px; height: 96px; }
.speed { position: absolute; left: 50%; transform: translateX(-50%); top: calc(62px + var(--sat)); padding: 3px 10px; display: flex; align-items: baseline; gap: 4px; }
.speed b { font-size: 20px; font-weight: 900; font-style: italic; font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.speed span { font-size: 9px; font-weight: 900; color: var(--muted); letter-spacing: .1em; }
body.desk .speed { display: none; }
.lights { position: absolute; top: 24%; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; background: #0b0f0dee; border: 2px solid #ffffff22; border-radius: 18px; padding: 10px 14px; }
.lights i { width: 34px; height: 34px; border-radius: 50%; background: #2a1414; border: 2px solid #0008; box-shadow: inset 0 3px 6px #0009; }
.lights i.on { background: radial-gradient(circle at 40% 35%, #ff8a8a, #e01818); box-shadow: 0 0 18px #ff2a2a; }
.lights.go i { background: radial-gradient(circle at 40% 35%, #b6ffcf, #18c060); box-shadow: 0 0 18px #3ee08f; }
.warn { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; font-weight: 900; font-style: italic; font-size: 22px; letter-spacing: .06em;
  padding: 6px 16px; border-radius: 10px; animation: blink .6s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.feed { position: absolute; top: calc(66px + var(--sat)); left: calc(10px + var(--sal)); display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.feed div { background: rgba(8, 14, 11, .85); border: 1px solid #ffffff1c; border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 800; white-space: nowrap; animation: fin .2s ease-out; }
.feed i { color: var(--accent); font-style: normal; font-weight: 900; } .feed i.up { color: var(--accent2); } .feed i.dn { color: #ff8a8d; }
@keyframes fin { from { opacity: 0; transform: translateY(-4px); } }
.tip { position: absolute; left: 50%; transform: translateX(-50%); top: calc(150px + var(--sat)); background: rgba(8, 14, 11, .9);
  border: 1px solid #ffffff22; border-left: 4px solid var(--accent); padding: 8px 12px; border-radius: 10px; font-size: 13px;
  width: max-content; max-width: min(92vw, 460px); line-height: 1.35; }
.tip b { color: var(--accent); }

/* touch controls */
.stickzone { position: absolute; left: 0; bottom: 0; width: 52vw; height: 55vh; touch-action: none; }
.stick { position: absolute; left: calc(26px + var(--sal)); bottom: calc(40px + var(--sab)); width: 124px; height: 124px; border-radius: 50%;
  background: radial-gradient(circle, #ffffff14, #ffffff08); border: 2px solid #ffffff30; transition: opacity .2s; }
.stick.idle { opacity: .55; }
.knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffffcc, #ffffff66); box-shadow: 0 4px 12px #0007; }
.arrows { position: absolute; left: calc(14px + var(--sal)); bottom: calc(28px + var(--sab)); display: flex; gap: 12px; }
.ab { width: 84px; height: 84px; border-radius: 22px; background: rgba(255, 255, 255, .12); border: 2px solid #ffffff40; font-size: 30px; color: #fff; touch-action: none; pointer-events: auto; box-shadow: 0 6px 16px #0006; }
.ab.down { background: rgba(255, 210, 63, .45); border-color: var(--accent); }
.btns { position: absolute; right: calc(16px + var(--sar)); bottom: calc(28px + var(--sab)); width: 210px; height: 200px; pointer-events: none; }
.tb { position: absolute; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; text-align: center;
  border: 2px solid #ffffff55; box-shadow: 0 6px 16px #0008; line-height: 1.05; letter-spacing: .02em; touch-action: none; pointer-events: auto; transition: transform .06s; }
.tb.down { transform: scale(.93); filter: brightness(1.15); }
.tb.nitro { right: 0; bottom: 0; width: 108px; height: 108px; background: radial-gradient(circle at 35% 30%, #ffd08a, #f07a1a); color: #2a1200; font-size: 13px; }
.tb.nitro svg { position: absolute; inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); transform: rotate(-90deg); pointer-events: none; }
.tb.nitro b { font-size: 22px; line-height: 1; font-style: italic; }
.tb.nitro.empty { filter: grayscale(.7) brightness(.8); }
.tb.drift { right: 120px; bottom: 4px; width: 80px; height: 80px; background: radial-gradient(circle at 35% 30%, #a3f7ff, #22a5c7); color: #001a22; font-size: 13px; }
.tb.brake { right: 128px; bottom: 98px; width: 70px; height: 70px; background: radial-gradient(circle at 35% 30%, #ff9a9d, #c0262d); color: #2a0002; font-size: 12px; }
.tb.gas { right: 0; bottom: 0; width: 96px; height: 132px; border-radius: 24px; background: linear-gradient(180deg, #7af0b4, #1fb46d); color: #00230f; font-size: 15px; }
/* auto gas off: GAS pedal bottom right, BRAKE beside it, NITRO and DRIFT above */
body.manual .btns { width: 186px; height: 236px; }
body.manual .tb.gas { width: 90px; }
body.manual .tb.nitro { right: 3px; bottom: 146px; width: 84px; height: 84px; font-size: 11px; }
body.manual .tb.nitro b { font-size: 18px; }
body.manual .tb.brake { right: 100px; bottom: 0; width: 78px; height: 78px; }
body.manual .tb.drift { right: 106px; bottom: 92px; width: 68px; height: 68px; font-size: 12px; }
body.manual .ab { width: 70px; height: 76px; }
body.manual .arrows { gap: 8px; }
svg .trk { fill: none; stroke: #0007; stroke-width: 7; }
svg .val { fill: none; stroke: var(--nitro); stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset .08s linear; }

/* desktop speedo + nitro gauge */
.gauge { position: absolute; right: calc(20px + var(--sar)); bottom: calc(20px + var(--sab)); width: 124px; height: 124px; border-radius: 50%; background: rgba(8, 14, 11, .85);
  display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid #ffffff1c; }
.gauge svg { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); transform: rotate(-90deg); }
.gauge b { font-size: 34px; font-weight: 900; font-style: italic; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge span { font-size: 9px; font-weight: 900; color: var(--muted); letter-spacing: .14em; }
.gauge small { font-size: 9px; font-weight: 900; color: var(--nitro); letter-spacing: .1em; margin-top: 3px; }
.keys { position: absolute; bottom: calc(12px + var(--sab)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 320px); }
.key { white-space: nowrap; background: rgba(8, 14, 11, .88); border: 1px solid #ffffff22; border-radius: 8px; padding: 4px 8px; }
.key kbd { font-family: inherit; font-weight: 900; color: var(--text); background: #ffffff14; border-radius: 4px; padding: 1px 5px; margin-right: 4px; }

.banner { position: absolute; left: 0; right: 0; top: 36%; text-align: center; }
.banner .big { font-size: min(70px, 16vw); color: var(--accent); text-shadow: 0 4px 0 #0007, 0 0 30px #ffd23f66; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
.banner.good .big { color: var(--accent2); text-shadow: 0 4px 0 #0007, 0 0 30px #3ee08f55; }
.banner.bad .big { color: #ff8a8d; text-shadow: 0 4px 0 #0007, 0 0 30px #ff5a5f55; }
.banner.info .big { font-size: min(42px, 10vw); color: var(--text); }
.banner .small { font-size: min(14px, 3.6vw); font-weight: 800; letter-spacing: .1em; padding: 0 12px; text-shadow: 0 2px 6px #000a; text-transform: uppercase; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ------------------------------------------------------------ screens */
.screen { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  background: radial-gradient(120% 60% at 50% 0%, #1e4a30 0%, var(--bg) 60%); padding: var(--sat) var(--sar) var(--sab) var(--sal); }
.screen.overlay { background: rgba(6, 11, 8, .86); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.screen .wrap { padding: 22px 16px 28px; max-width: 540px; margin: 0 auto; }
.logo { text-align: center; margin: 6px 0 14px; }
.logo .t1, .logo .t2 { font-size: 40px; line-height: .9; }
.logo .t2 { color: var(--accent); }
.logo .sub { color: var(--muted); font-size: 11px; letter-spacing: .3em; margin-top: 6px; font-weight: 700; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.card p, .card li { font-size: 13px; line-height: 1.45; color: #cfdcd4; }
.card ul { padding-left: 18px; display: grid; gap: 5px; }
.card b { color: var(--text); }
.lbl { font-size: 11px; font-weight: 900; color: var(--muted); letter-spacing: .14em; margin-bottom: 8px; text-transform: uppercase; }
.lbl.mt { margin-top: 12px; }
.inp { width: 100%; min-width: 0; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-weight: 800; font-size: 15px; text-transform: uppercase; user-select: text; -webkit-user-select: text; outline: none; margin-bottom: 6px; }
.inp:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel2); border: 1px solid var(--line); padding: 7px 13px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.chip.sel { background: var(--accent); color: #1a1400; border-color: var(--accent); }
.player { display: flex; gap: 12px; align-items: center; }
.pinfo { flex: 1; min-width: 0; }
.note { font-size: 11px; color: var(--muted); }
.hint { font-size: 11px; color: var(--muted); margin-top: 9px; line-height: 1.35; }
.hint b { color: var(--accent); }
.go { display: block; width: 100%; padding: 14px; border-radius: 14px; background: linear-gradient(180deg, #ffe066, #f0b400);
  color: #241900; font-size: 20px; box-shadow: 0 8px 20px #f0b40044; text-align: center; }
.go:active { transform: translateY(1px); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 12px; }
.set { background: var(--panel2); border-radius: 10px; padding: 8px 9px; display: flex; justify-content: space-between; align-items: center; gap: 6px; text-align: left; }
.set b { color: var(--accent); white-space: nowrap; }
.record { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 12px; letter-spacing: .04em; }
.foot { display: flex; justify-content: center; gap: 18px; margin-top: 12px; flex-wrap: wrap; }
.link { color: var(--muted); font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px; gap: 10px; }
.head .t { font-size: 26px; }
.head .s { font-size: 12px; color: var(--muted); font-weight: 700; text-align: right; }
.btn { padding: 9px 12px; border-radius: 10px; font-weight: 900; font-size: 13px; letter-spacing: .03em; }
.btn.ghost { background: var(--panel2); border: 1px solid var(--line); }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 2px; text-align: center; font-size: 13px; font-weight: 900; line-height: 1.15; text-transform: uppercase; font-style: italic; }
.seg button.sel { background: var(--accent); color: #1a1400; border-color: var(--accent); }

/* scoreboard tables */
.board { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px 8px; margin-bottom: 10px; font-size: 12px; overflow-x: auto; }
.board table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.board th { color: var(--muted); font-size: 10px; letter-spacing: .08em; font-weight: 900; text-align: center; padding: 5px 3px; }
.board th:first-child, .board td:first-child { text-align: left; }
.board td { padding: 6px 3px; text-align: center; font-weight: 800; border-top: 1px solid #ffffff10; }
.board td.nm { white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.board td.nm i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.board tr.you td { color: var(--accent); }
.board tr.sep td { border-top: 2px solid var(--line); }
.board .mvp { font-size: 9px; background: var(--accent); color: #1a1400; border-radius: 4px; padding: 1px 4px; margin-left: 5px; font-style: italic; }
.statgrid.small { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.statgrid.small div { background: var(--panel2); border-radius: 10px; padding: 7px 4px; }
.statgrid.small b { display: block; font-size: 18px; }
.statgrid.small span { font-size: 10px; color: var(--muted); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.ft-head { text-align: center; font-size: 34px; color: var(--accent); margin-top: 8px; }
.ft-head.bad { color: #ff8a8d; }
.ft-score { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 8px 0 6px; font-weight: 900; font-size: 15px; letter-spacing: .06em; }
.ft-score b { font-size: 46px; font-style: italic; }
.ft-goals { text-align: center; color: var(--muted); font-size: 12px; line-height: 1.6; margin-bottom: 12px; }
.card.you .rating { display: flex; align-items: baseline; gap: 8px; justify-content: center; margin-bottom: 10px; }
.card.you .rating b { font-size: 40px; font-style: italic; color: var(--accent); }
.card.you .rating span { color: var(--muted); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; font-size: 12px; }
.card.you .rating span.mvp { color: #1a1400; background: var(--accent); border-radius: 6px; padding: 2px 7px; font-style: italic; }

/* menu extras */
.tracks { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; touch-action: pan-x pan-y; scrollbar-width: thin; }
.trk-card { flex: 0 0 116px; scroll-snap-align: start; background: var(--panel2); border: 2px solid transparent; border-radius: 12px; padding: 5px; text-align: left; }
.trk-card canvas { display: block; width: 102px; height: 68px; border-radius: 8px; }
.trk-card .nm { font-size: 11px; font-weight: 900; margin-top: 5px; line-height: 1.15; }
.trk-card .mt2 { font-size: 10px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.trk-card.sel { border-color: var(--accent); background: #2a2a10; }
.trk-card.done .nm::after { content: " ✓"; color: var(--accent2); }
.tinfo { font-size: 12px; color: #cfdcd4; line-height: 1.4; margin-top: 6px; }
.tinfo b { color: var(--accent); }
.livs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 2px; }
.liv { width: 22px; height: 22px; border-radius: 50%; border: 3px solid; }
.liv.sel { outline: 2px solid var(--accent); outline-offset: 2px; }
.carprev { width: 96px; height: 64px; flex: 0 0 96px; background: radial-gradient(circle at 50% 60%, #3b3f46, #12201a 80%); border-radius: 12px; border: 1px solid var(--line); }
.ft-sub { text-align: center; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; margin: 2px 0 12px; text-transform: uppercase; }
.board td.gap { color: var(--muted); }
.board td.pb { color: var(--accent2); }
.board .new { font-size: 9px; background: var(--accent2); color: #002a12; border-radius: 4px; padding: 1px 4px; margin-left: 5px; font-style: italic; }
.board caption { text-align: left; font-size: 10px; font-weight: 900; color: var(--muted); letter-spacing: .14em; padding: 4px 3px 2px; }
@media (max-height: 560px) and (orientation: landscape) {
  .tip { top: auto; bottom: calc(14px + var(--sab)); }
  .stickzone { height: 100vh; width: 50vw; }
  .stick { bottom: calc(22px + var(--sab)); }
  .btns { bottom: calc(14px + var(--sab)); }
  .lights { top: 18%; }
  .mini canvas { width: 80px; height: 80px; }
  .feed { top: calc(62px + var(--sat)); }
}
body.desk .mini canvas { width: 168px; height: 168px; }
body.desk .posbox .pos b { font-size: 40px; }
@media (min-width: 900px) { .screen .wrap { max-width: 600px; } }

/* Studio credit and link back to the games page, the same on every Game Golem Studios title screen */
.ggs-foot { text-align: center; font-size: 11px; margin-top: 12px; }
.ggs-foot a { color: var(--muted); text-underline-offset: 2px; }

/* multiplayer */
.mp { display: flex; gap: 6px; align-items: stretch; }
.mp .btn { background: var(--panel2); border: 1px solid var(--line); }
.mp .mp-host { flex: 1.2; background: var(--accent); color: #1a1400; border-color: var(--accent); }
.mp .mp-code { flex: 1; margin: 0; text-align: center; letter-spacing: .3em; font-size: 16px; min-width: 0; }
.mp .mp-join { flex: .8; }
#mp-msg.err { color: #ff8a8d; }
.seg.two { grid-template-columns: 1fr 1fr; }
.mptabs { margin-bottom: 9px; }
.mp-quick { padding: 11px; font-size: 16px; }
.srvl { display: grid; gap: 6px; margin-top: 8px; }
.srow { display: flex; align-items: center; gap: 8px; width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; text-align: left; }
.srow div { flex: 1; min-width: 0; }
.srow b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow span { font-size: 12px; font-weight: 900; color: var(--accent); white-space: nowrap; }
.srow.off { opacity: .5; }
.codecard { text-align: center; }
.bigcode { font-size: 56px; letter-spacing: .18em; color: var(--accent); line-height: 1.05; margin: 2px 0 6px; padding-left: .18em; }
.roster { display: grid; gap: 6px; }
.roster .pl { display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 10px; padding: 7px 10px; font-weight: 800; font-size: 14px; }
.roster .pl i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid; flex: 0 0 14px; }
.roster .pl span { color: var(--muted); font-size: 11px; margin-left: auto; letter-spacing: .06em; text-transform: uppercase; }
.roster .pl.you { outline: 1px solid var(--accent); }
.roster .pl.bot { opacity: .6; font-weight: 700; }
.mt8 { margin-top: 8px; }
#lb-tracks .chip:disabled { opacity: 1; }

/* cloud saves */
.cloudline { text-align: center; color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 8px; padding: 0 8px; }
.cloudline b { color: var(--text); }
.cloudline .link { font-size: 12px; }
