Death242 commited on
Commit
4530d29
·
verified ·
1 Parent(s): 2bd378f

Static site

Browse files
Files changed (5) hide show
  1. index.html +3 -3
  2. static/game.js +5 -4
  3. static/goals.js +3 -2
  4. static/main.js +527 -509
  5. static/style.css +406 -394
index.html CHANGED
@@ -8,7 +8,7 @@
8
  <meta name="theme-color" content="#10131b">
9
  <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
  <link href="https://fonts.googleapis.com/css2?family=Unbounded:wght@500;800;900&family=Inter:wght@400;500;600;700&family=Noto+Kufi+Arabic:wght@700&display=swap" rel="stylesheet">
11
- <link rel="stylesheet" href="/static/style.css?v=1792911712">
12
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 64 64%27%3E%3Crect width=%2764%27 height=%2764%27 rx=%2714%27 fill=%27%23050506%27/%3E%3Ccircle cx=%2732%27 cy=%2732%27 r=%2716%27 fill=%27none%27 stroke=%27%23fff%27 stroke-width=%275%27/%3E%3C/svg%3E">
13
  <script type="importmap">
14
  { "imports": {
@@ -107,7 +107,7 @@
107
  <div class="hud-tr">
108
  <canvas class="g-map" id="gMap" width="180" height="180" aria-label="Minimap (tap for GPS)"></canvas>
109
  <div class="g-btns"><button class="pill solid" id="gFly">Fly</button><button class="pill" id="gMenuBtn" aria-haspopup="dialog">☰ Menu</button></div>
110
- <div class="chips" id="gChips"></div><div class="chips"><span id="gCoins">🪙 0/40</span></div>
111
  <div class="g-players" id="gPlayers"></div>
112
  </div>
113
  <div class="g-trophy" id="gTrophy" aria-live="polite"></div>
@@ -202,6 +202,6 @@
202
  <div id="toast" role="status"></div>
203
  <noscript><p style="position:fixed;inset:auto 0 0;padding:16px;background:#111;color:#fff;text-align:center">VOID needs JavaScript for the 3D car.</p></noscript>
204
  <script src="/static/hub.js" data-app="void" defer></script>
205
- <script type="module" src="/static/main.js?v=1792911712"></script>
206
  </body>
207
  </html>
 
8
  <meta name="theme-color" content="#10131b">
9
  <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
  <link href="https://fonts.googleapis.com/css2?family=Unbounded:wght@500;800;900&family=Inter:wght@400;500;600;700&family=Noto+Kufi+Arabic:wght@700&display=swap" rel="stylesheet">
11
+ <link rel="stylesheet" href="/static/style.css?v=1792928107">
12
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 64 64%27%3E%3Crect width=%2764%27 height=%2764%27 rx=%2714%27 fill=%27%23050506%27/%3E%3Ccircle cx=%2732%27 cy=%2732%27 r=%2716%27 fill=%27none%27 stroke=%27%23fff%27 stroke-width=%275%27/%3E%3C/svg%3E">
13
  <script type="importmap">
14
  { "imports": {
 
107
  <div class="hud-tr">
108
  <canvas class="g-map" id="gMap" width="180" height="180" aria-label="Minimap (tap for GPS)"></canvas>
109
  <div class="g-btns"><button class="pill solid" id="gFly">Fly</button><button class="pill" id="gMenuBtn" aria-haspopup="dialog">☰ Menu</button></div>
110
+ <div class="chips" id="gChips"></div><div class="chips"><span id="gCoins">🪙 0/40</span><span id="gCash">$0</span></div>
111
  <div class="g-players" id="gPlayers"></div>
112
  </div>
113
  <div class="g-trophy" id="gTrophy" aria-live="polite"></div>
 
202
  <div id="toast" role="status"></div>
203
  <noscript><p style="position:fixed;inset:auto 0 0;padding:16px;background:#111;color:#fff;text-align:center">VOID needs JavaScript for the 3D car.</p></noscript>
204
  <script src="/static/hub.js" data-app="void" defer></script>
205
+ <script type="module" src="/static/main.js?v=1792928107"></script>
206
  </body>
207
  </html>
static/game.js CHANGED
@@ -134,6 +134,7 @@ export function createGame(W, car, sound, life, opts = {}) {
134
  const impact = (x, y, z, p) => { if (p > 3 && g.impacts.length < 8) g.impacts.push({ x, y, z, p }); };
135
  function hurt(n, why) {
136
  if (n <= 0 || g.wreck > 0) return;
 
137
  g.hp -= n; g.hurtT = 0; g.shake = Math.min(1, (g.shake || 0) + n / 40); document.body.classList.add("g-hurt"); setTimeout(() => document.body.classList.remove("g-hurt"), 160);
138
  if (g.hp <= 0) { g.hp = 0; wreck(why + ". The car is wrecked"); }
139
  }
@@ -259,7 +260,7 @@ export function createGame(W, car, sound, life, opts = {}) {
259
  service(dt);
260
  const wantNitro = held("nitro") && g.nitro > .02 && g.fuel > 0;
261
  g.nitroOn = lerp(g.nitroOn, wantNitro ? 1 : 0, clamp(dt * 8));
262
- if (wantNitro) g.nitro = Math.max(0, g.nitro - dt / 5); else g.nitro = Math.min(1, g.nitro + dt / 14);
263
 
264
  if (g.veh && g.veh !== "car" && opts.vehicles) {
265
  const I = { turn, gas, brake, up: g.fuel > 0 && (g.ap ? g.ap.up : held("up")) ? 1 : 0, down: (g.ap ? g.ap.down : held("down")) ? 1 : 0, nitro: g.nitroOn > .3, stickY: -stick.y };
@@ -279,13 +280,13 @@ export function createGame(W, car, sound, life, opts = {}) {
279
  g.yaw += yawRate * dt;
280
  const fx = Math.cos(g.yaw), fz = Math.sin(g.yaw), sx = -fz, sz = fx;
281
  u = g.vel.x * fx + g.vel.z * fz; let w = g.vel.x * sx + g.vel.z * sz;
282
- const top = 92 + g.nitroOn * 22;
283
- if (gas) u += (u < -.5 ? 20 : 11.5 * (1 - clamp(u / top) ** 2) + g.nitroOn * 11) * gas * dt;
284
  else if (g.nitroOn > .1) u += g.nitroOn * 11 * dt;
285
  if (brake) u -= (u > .5 ? 26 : 8) * brake * dt;
286
  u = Math.max(-16, u - Math.sign(u) * (.3 + .00034 * u * u) * dt);
287
  if (!gas && !brake && Math.abs(u) < .25) u = 0;
288
- const grip = hand ? 1.4 : 9 + Math.min(9, Math.abs(u) * .09);
289
  w *= Math.exp(-grip * dt);
290
  g.vel.set(fx * u + sx * w, 0, fz * u + sz * w);
291
  // drift scoring
 
134
  const impact = (x, y, z, p) => { if (p > 3 && g.impacts.length < 8) g.impacts.push({ x, y, z, p }); };
135
  function hurt(n, why) {
136
  if (n <= 0 || g.wreck > 0) return;
137
+ n *= 1 - .14 * ((opts.upg || {}).armor || 0); // armour upgrades soak some of every hit
138
  g.hp -= n; g.hurtT = 0; g.shake = Math.min(1, (g.shake || 0) + n / 40); document.body.classList.add("g-hurt"); setTimeout(() => document.body.classList.remove("g-hurt"), 160);
139
  if (g.hp <= 0) { g.hp = 0; wreck(why + ". The car is wrecked"); }
140
  }
 
260
  service(dt);
261
  const wantNitro = held("nitro") && g.nitro > .02 && g.fuel > 0;
262
  g.nitroOn = lerp(g.nitroOn, wantNitro ? 1 : 0, clamp(dt * 8));
263
+ if (wantNitro) g.nitro = Math.max(0, g.nitro - dt / (5 * (1 + .35 * ((opts.upg || {}).nitro || 0)))); else g.nitro = Math.min(1, g.nitro + dt / 14);
264
 
265
  if (g.veh && g.veh !== "car" && opts.vehicles) {
266
  const I = { turn, gas, brake, up: g.fuel > 0 && (g.ap ? g.ap.up : held("up")) ? 1 : 0, down: (g.ap ? g.ap.down : held("down")) ? 1 : 0, nitro: g.nitroOn > .3, stickY: -stick.y };
 
280
  g.yaw += yawRate * dt;
281
  const fx = Math.cos(g.yaw), fz = Math.sin(g.yaw), sx = -fz, sz = fx;
282
  u = g.vel.x * fx + g.vel.z * fz; let w = g.vel.x * sx + g.vel.z * sz;
283
+ const U = opts.upg || {}, top = (92 + g.nitroOn * 22) * (1 + .07 * (U.engine || 0));
284
+ if (gas) u += (u < -.5 ? 20 : 11.5 * (1 + .1 * (U.engine || 0)) * (1 - clamp(u / top) ** 2) + g.nitroOn * 11) * gas * dt;
285
  else if (g.nitroOn > .1) u += g.nitroOn * 11 * dt;
286
  if (brake) u -= (u > .5 ? 26 : 8) * brake * dt;
287
  u = Math.max(-16, u - Math.sign(u) * (.3 + .00034 * u * u) * dt);
288
  if (!gas && !brake && Math.abs(u) < .25) u = 0;
289
+ const grip = hand ? 1.4 + .15 * (U.grip || 0) : 9 * (1 + .12 * (U.grip || 0)) + Math.min(9, Math.abs(u) * .09);
290
  w *= Math.exp(-grip * dt);
291
  g.vel.set(fx * u + sx * w, 0, fz * u + sz * w);
292
  // drift scoring
static/goals.js CHANGED
@@ -1,4 +1,4 @@
1
- // Challenges: twelve goals tracked from what you do (kept on this device), each worth a trophy and 1000 points.
2
  const store = { get(k) { try { return JSON.parse(localStorage.getItem(k)); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { } } };
3
  export const GOALS = [
4
  { id: "speed", icon: "🏎️", name: "Speed demon", text: "Hit 300 km/h", stat: "top", need: 300 },
@@ -14,10 +14,11 @@ export const GOALS = [
14
  { id: "fuel", icon: "⛽", name: "Pit stop", text: "Fill up at a station", stat: "refuels", need: 1 },
15
  { id: "coins", icon: "🪙", name: "Collector", text: "Find 20 hidden coins", stat: "coins", need: 20 },
16
  { id: "taxi", icon: "🚕", name: "Cabbie", text: "Complete 5 taxi fares", stat: "fares", need: 5 },
 
17
  { id: "brooklyn", icon: "🌉", name: "Bridge and tunnel", text: "Cross the bridge to Brooklyn", stat: "brooklyn", need: 1 },
18
  ];
19
  export function createGoals(onDone) {
20
- const S = Object.assign({ top: 0, smashed: 0, drift: 0, air: 0, pads: 0, butter: 0, wins: 0, escapes: 0, rings: 0, km: 0, refuels: 0, brooklyn: 0, best: 0, coins: 0, fares: 0 }, store.get("void.stats") || {});
21
  const done = new Set(store.get("void.goals") || []);
22
  let saveT = 0, lastSmash = null, lastRings = null, lastFuel = null, pads = new Set();
23
  function check() { for (const g of GOALS) if (!done.has(g.id) && S[g.stat] >= g.need) { done.add(g.id); store.set("void.goals", [...done]); onDone(g); } }
 
1
+ // Challenges: fifteen goals tracked from what you do (kept on this device), each worth a trophy and 1000 points.
2
  const store = { get(k) { try { return JSON.parse(localStorage.getItem(k)); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { } } };
3
  export const GOALS = [
4
  { id: "speed", icon: "🏎️", name: "Speed demon", text: "Hit 300 km/h", stat: "top", need: 300 },
 
14
  { id: "fuel", icon: "⛽", name: "Pit stop", text: "Fill up at a station", stat: "refuels", need: 1 },
15
  { id: "coins", icon: "🪙", name: "Collector", text: "Find 20 hidden coins", stat: "coins", need: 20 },
16
  { id: "taxi", icon: "🚕", name: "Cabbie", text: "Complete 5 taxi fares", stat: "fares", need: 5 },
17
+ { id: "tuner", icon: "🔧", name: "Tuner", text: "Buy 4 garage upgrades", stat: "upg", need: 4 },
18
  { id: "brooklyn", icon: "🌉", name: "Bridge and tunnel", text: "Cross the bridge to Brooklyn", stat: "brooklyn", need: 1 },
19
  ];
20
  export function createGoals(onDone) {
21
+ const S = Object.assign({ top: 0, smashed: 0, drift: 0, air: 0, pads: 0, butter: 0, wins: 0, escapes: 0, rings: 0, km: 0, refuels: 0, brooklyn: 0, best: 0, coins: 0, fares: 0, upg: 0 }, store.get("void.stats") || {});
22
  const done = new Set(store.get("void.goals") || []);
23
  let saveT = 0, lastSmash = null, lastRings = null, lastFuel = null, pads = new Set();
24
  function check() { for (const g of GOALS) if (!done.has(g.id) && S[g.stat] >= g.need) { done.add(g.id); store.set("void.goals", [...done]); onDone(g); } }
static/main.js CHANGED
@@ -1,509 +1,527 @@
1
- // VOID: one WebGL canvas, three modes on top of a showroom home screen.
2
- // Watch: a 48 s film whose clock is the music. Play: drive it, fly it, land it. Build: paint it.
3
- import * as THREE from "three";
4
-
5
- const V = new URL(import.meta.url).search;
6
- const $ = id => document.getElementById(id);
7
- const setLoad = p => { $("ldbar").style.width = p + "%"; $("ldpct").textContent = Math.round(p); };
8
- setLoad(15);
9
- const [{ createWorld, clamp, lerp, smooth, frame, PAD_R, ZONES }, { buildCar, MODELS }, { addInterior, HEAD }, { Sound, BAR }, { createWatch, TOTAL, CHAPTERS }, { createGame }, { createLife }] = await Promise.all(
10
- ["world", "car", "interior", "sound", "watch", "game", "npc"].map(n => import(`./${n}.js${V}`)));
11
- const [{ createPolice }, { createRaces }, { createNet, EMOTES }, { createNav }, { createVehicles }, { createAtmos, WEATHERS }, { createGoals, GOALS }, { createExtras }] = await Promise.all(["police", "race", "net", "nav", "vehicles", "atmos", "goals", "extras"].map(n => import(`./${n}.js${V}`)));
12
- setLoad(40);
13
-
14
- const COARSE = matchMedia("(pointer: coarse)").matches, REDUCED = matchMedia("(prefers-reduced-motion: reduce)").matches;
15
- const store = { get(k) { try { return JSON.parse(localStorage.getItem(k)); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { } } };
16
- const W = await createWorld($("gl"), COARSE), { renderer, scene, camera, composer, bloom, camLight, fx } = W;
17
- setLoad(55);
18
-
19
- // the car you drive: a fixed root the game and the film move around, with the chosen model swapped inside it
20
- const carRoot = new THREE.Group(); scene.add(carRoot);
21
- const car = { group: carRoot, wheels: [] };
22
- const carMats = new Set();
23
- let inner = null;
24
- function useModel(id, force) {
25
- if (inner && inner.model === id && !force) return;
26
- if (inner) carRoot.remove(inner.group);
27
- inner = buildCar(id); carRoot.add(inner.group);
28
- for (const k of Object.keys(inner)) if (typeof inner[k] === "function") car[k] = inner[k];
29
- Object.assign(car, { wheels: inner.wheels, clip: car.clip || inner.clip, materials: inner.materials, model: id, name: inner.name });
30
- carMats.clear();
31
- inner.group.traverse(o => { if (o.isMesh) { o.castShadow = true; if (o.material && o.material.isMeshStandardMaterial) carMats.add(o.material); } });
32
- for (const m of carMats) { m.envMap = null; m.needsUpdate = true; } // the paint reflects the city capture (scene.environment) // phones skip the live cube and use the city reflection
33
- }
34
- // live reflections on the paint: a small cube camera that rides with the car
35
- const carEnv = new THREE.WebGLCubeRenderTarget(COARSE ? 64 : 128, { type: THREE.HalfFloatType, generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter });
36
- const carCube = new THREE.CubeCamera(.5, 320, carEnv);
37
- for (const c of carCube.children) c.layers.set(0);
38
- camera.layers.enable(1); // layer 1: the crowds, seen by the main camera only
39
- let cubeN = 0;
40
- useModel((store.get("void.build3") || {}).model != null ? Object.keys(MODELS)[(store.get("void.build3") || {}).model] || "hydra" : "hydra");
41
- setLoad(80);
42
- const interior = addInterior(car, renderer);
43
- const sound = new Sound();
44
- const watch = createWatch(W, car, interior);
45
- const life = createLife(scene, W.roads, W.walkways, COARSE);
46
- const TIMES = ["night", "sunset", "day"];
47
- function cycleTime() { const k = TIMES[(TIMES.indexOf(W.timeOfDay) + 1) % 3]; W.setTime(k); store.set("void.time", k); toast({ night: "Night in the city", sunset: "Golden hour", day: "Daytime" }[k]); cubeN = 0; }
48
- let police, races, nav;
49
- const net = createNet();
50
- setInterval(() => { if (document.hidden) net.tick(.5, null); }, 500); // a hosting tab in the background still relays everyone
51
- // settings: graphics quality, look speed, auto gas, touch steering (kept on this device)
52
- // a strong graphics card starts on High; everything else starts on Medium (it can be raised in the Menu)
53
- const GPU = (() => { try { const c = renderer.getContext(), e = c.getExtension("WEBGL_debug_renderer_info"); return e ? c.getParameter(e.UNMASKED_RENDERER_WEBGL) : ""; } catch { return ""; } })();
54
- const STRONG = /RTX|GTX 1[06-9]|GTX 9[78]|Radeon RX|Radeon Pro|Apple M[1-9]/i.test(GPU) && !COARSE;
55
- const TOP = /RTX\s?(40[6-9]0|50[5-9]0)|RTX\s?A?[45]\d{3}/i.test(GPU) && !COARSE; // recent RTX cards start on Ultra
56
- const SET = Object.assign({ q: TOP ? "ultra" : STRONG ? "high" : COARSE ? "low" : "medium", sens: 1, autogas: "off", steer: "stick", weather: "clear", radio: "score", cycle: "off" }, store.get("void.settings") || {});
57
- const gameOpts = {
58
- garage: () => openGarage(true), cycleTime, hornType: () => build.horn, autoGas: () => SET.autogas === "on", onRepair: () => car.repair && car.repair(),
59
- onScore: (n, why) => { if (why === "Drift") goals.drift(n); goals.note(why); },
60
- onSmash: kind => police && police.event("smash", kind), policeClear: () => police && police.clear(),
61
- autopilot: (g, dt, over) => nav ? nav.controls(g, dt, over) : null, openGps: () => document.getElementById("gGpsBtn").click(),
62
- mapExtra(mx, g, MM) {
63
- const P = (x, z) => [(x - g.x) / MM, (z - g.z) / MM];
64
- if (nav && nav.pts.length > 1) { mx.strokeStyle = "#3dfcff"; mx.lineWidth = 3; mx.beginPath(); nav.pts.forEach(([x, z], k) => { const [a, b] = P(x, z); k ? mx.lineTo(a, b) : mx.moveTo(a, b); }); mx.stroke(); }
65
- if (police) for (const c of police.cops) if (c.on) { const [a, b] = P(c.x, c.z); mx.fillStyle = Math.sin(performance.now() / 90) > 0 ? "#ff3040" : "#3060ff"; mx.beginPath(); mx.arc(a, b, 4, 0, 7); mx.fill(); }
66
- if (races && races.race && races.race.next) { const [a, b] = P(races.race.next[0], races.race.next[2]); mx.strokeStyle = "#ffd23d"; mx.lineWidth = 3; mx.beginPath(); mx.arc(a, b, 7, 0, 7); mx.stroke(); }
67
- for (const r of remotes.values()) if (r.at) { const [a, b] = P(r.at.x, r.at.z); mx.fillStyle = "#c07dff"; mx.beginPath(); mx.arc(a, b, 4.5, 0, 7); mx.fill(); }
68
- mx.font = "bold 12px sans-serif"; mx.textAlign = "center"; for (const st of W.city.stations) { const [a, b] = P(st.x, st.z); if (Math.abs(a) < 90 && Math.abs(b) < 90) { mx.save(); mx.translate(a, b); mx.rotate(g.yaw + Math.PI / 2); mx.fillText("⛽", 0, 4); mx.restore(); } }
69
- },
70
- };
71
- const game = createGame(W, car, sound, life, gameOpts);
72
- const vehicles = createVehicles(scene, game.api, W); gameOpts.vehicles = vehicles;
73
- const atmos = createAtmos(W, sound, COARSE);
74
- // trophies: a banner slides in at the top when a challenge is done
75
- const goals = createGoals(gl => { const t = document.getElementById("gTrophy"); t.innerHTML = `<b>${gl.icon}</b><div><span>Challenge complete</span>${gl.name}<em>+1000</em></div>`; t.classList.remove("on"); void t.offsetWidth; t.classList.add("on"); if (game.state) { game.state.score += 1000; } sound.win(); renderGoals(); });
76
- function renderGoals() {
77
- const S = goals.stats;
78
- document.getElementById("gGoals").innerHTML = GOALS.map(g => { const v = Math.min(1, (S[g.stat] || 0) / g.need), ok = goals.done.has(g.id); return `<div class="goal${ok ? " ok" : ""}"><b>${g.icon}</b><div><span>${g.name}</span><small>${g.text}</small><i style="--v:${v}"></i></div>${ok ? "🏆" : `<em>${Math.floor(v * 100)}%</em>`}</div>`; }).join("");
79
- document.getElementById("gStatsRow").innerHTML = `<div><b>${(S.best || 0).toLocaleString()}</b><span>Best score</span></div><div><b>${Math.round(S.top)}</b><span>Top km/h</span></div><div><b>${S.km.toFixed(1)}</b><span>km travelled</span></div><div><b>${goals.done.size}/${GOALS.length}</b><span>Trophies</span></div>`;
80
- }
81
- const WX_ICON = { clear: "☀️ Clear", rain: "🌧 Rain", storm: "⛈ Storm", fog: "🌫 Fog", snow: "❄️ Snow" }, RADIO = { score: "🎵 VOID Score", voidfm: "📻 VOID FM", off: "🔇 Radio off" };
82
- function chips() { document.getElementById("gChips").innerHTML = `<span>${{ night: "🌙", sunset: "🌇", day: "☀️" }[W.timeOfDay]} ${W.timeOfDay}</span><span>${WX_ICON[atmos.weather]}</span>`; document.getElementById("gWeather").innerHTML = `<b>${WX_ICON[SET.weather].split(" ")[0]}</b>${WX_ICON[SET.weather].split(" ").slice(1).join(" ")}`; document.getElementById("gRadio").innerHTML = `<b>${RADIO[SET.radio].split(" ")[0]}</b>${RADIO[SET.radio].split(" ").slice(1).join(" ")}`; }
83
- document.getElementById("gWeather").onclick = () => { SET.weather = WEATHERS[(WEATHERS.indexOf(SET.weather) + 1) % WEATHERS.length]; atmos.setWeather(SET.weather); store.set("void.settings", SET); chips(); toast(WX_ICON[SET.weather]); };
84
- document.getElementById("gRadio").onclick = () => { const k = Object.keys(RADIO); SET.radio = k[(k.indexOf(SET.radio) + 1) % k.length]; if (!sound.on) setSound(true); sound.setRadio(SET.radio); store.set("void.settings", SET); chips(); toast(RADIO[SET.radio]); };
85
- // ---------- the menu (☰ or Esc): everything that isn't driving lives here ----------
86
- const menuEl = document.getElementById("gMenu");
87
- function menu(open) {
88
- if (open == null) open = menuEl.hidden;
89
- menuEl.hidden = !open; document.body.classList.toggle("g-menu-open", open); if (open) { renderGoals(); chips(); }
90
- if (open && document.pointerLockElement) document.exitPointerLock();
91
- if (!net.online()) game.pause(open);
92
- }
93
- document.getElementById("gMenuBtn").onclick = () => menu(true);
94
- document.getElementById("gMenuClose").onclick = () => menu(false);
95
- document.getElementById("gExit").onclick = () => { menu(false); go("home"); };
96
- menuEl.addEventListener("click", e => { const t = e.target.closest(".tile"); if (t && !t.closest(".set")) setTimeout(() => menu(false), 60); if (e.target === menuEl) menu(false); });
97
- menuEl.querySelectorAll("[data-veh]").forEach(b => b.onclick = () => game.api.setVehicle(b.dataset.veh));
98
- document.getElementById("gFuelNav").onclick = () => { const st = game.state; if (!st) return; const best = W.city.stations.slice().sort((a, b) => Math.hypot(a.x - st.x, a.z - st.z) - Math.hypot(b.x - st.x, b.z - st.z))[0]; nav.setDest({ name: "⛽ Fuel station", x: best.x, z: best.z }); };
99
- function applySettings(save = true) {
100
- for (const seg of menuEl.querySelectorAll(".seg[data-set]")) for (const b of seg.children) b.classList.toggle("on", SET[seg.dataset.set] === b.dataset.v);
101
- const weak = /Intel|UHD|Iris|Radeon\(TM\) Graphics|Vega|SwiftShader|llvmpipe|Basic Render/i.test(GPU);
102
- const masked = !/ANGLE|NVIDIA|Intel|AMD|Radeon|Apple|Mali|Adreno/i.test(GPU); // Brave and some others hide the chip name for privacy
103
- const name = (GPU || "unknown").replace(/^ANGLE \([^,]+, /, "").replace(/ \(0x[0-9A-Fa-f]+\).*$/, "").replace(/ Direct3D.*$/, "").replace(/, D3D.*$/, "");
104
- document.getElementById("gGpu").innerHTML = `${masked ? "Your browser hides which graphics chip it uses" : `Running on: <b>${name}</b>`} · <b id="gFps">${fpsNow ? fpsNow + " fps" : "measuring…"}</b>${weak ? '<br><span class="warn">This is the built-in laptop graphics. For full speed, make your browser use the RTX: Windows Settings → System → Display → Graphics → your browser → High performance, then restart the browser.</span>' : masked ? '<br><span class="small">Smooth is 60 fps or more. Under 40, check the browser is set to your RTX in Windows graphics settings.</span>' : ""}`;
105
- document.getElementById("gSens").value = SET.sens; game.api.sens = +SET.sens;
106
- document.body.classList.toggle("steer-buttons", SET.steer === "buttons");
107
- const cap = W.setQuality(SET.q); perf.max = cap; perf.pr = Math.min(perf.pr, cap); if (renderer.getPixelRatio() > cap) { renderer.setPixelRatio(cap); composer.setPixelRatio(cap); } lastW = 0; resize();
108
- if (save) store.set("void.settings", SET);
109
- }
110
- menuEl.querySelectorAll(".seg[data-set]").forEach(seg => seg.addEventListener("click", e => { const b = e.target.closest("button"); if (!b) return; e.preventDefault(); SET[seg.dataset.set] = b.dataset.v; if (seg.dataset.set === "q") { perf.pr = W.QUALITY[b.dataset.v].pr; perf.down = 0; } applySettings();
111
- atmos.setWeather(SET.weather);
112
- if (/Intel|UHD|Iris/i.test(GPU) && !COARSE && !store.get("void.gpuWarned")) { store.set("void.gpuWarned", 1); setTimeout(() => toast("Running on built-in graphics: see Menu → Settings to switch to your RTX"), 4000); } }));
113
- document.getElementById("gSens").addEventListener("input", e => { SET.sens = +e.target.value; applySettings(); });
114
- // the touch joystick: drag the knob; left/right steers, up/down pitches when flying
115
- {
116
- const st = document.getElementById("gStick"), knob = st.querySelector("i"); let id = null, cx = 0, cy = 0;
117
- const set = (x, y) => { const r = st.clientWidth / 2 - 10, l = Math.min(1, Math.hypot(x, y) / r), a = Math.atan2(y, x), kx = Math.cos(a) * l * r, ky = Math.sin(a) * l * r; knob.style.transform = `translate(${kx}px, ${ky}px)`; game.api.setStick(kx / r, ky / r); };
118
- st.addEventListener("pointerdown", e => { id = e.pointerId; const b = st.getBoundingClientRect(); cx = b.left + b.width / 2; cy = b.top + b.height / 2; try { st.setPointerCapture(id); } catch { } set(e.clientX - cx, e.clientY - cy); e.preventDefault(); });
119
- st.addEventListener("pointermove", e => { if (e.pointerId === id) set(e.clientX - cx, e.clientY - cy); });
120
- const end = e => { if (e.pointerId !== id) return; id = null; knob.style.transform = ""; game.api.setStick(0, 0); };
121
- st.addEventListener("pointerup", end); st.addEventListener("pointercancel", end);
122
- }
123
- // headlights that light the road at night
124
- const heads = new THREE.SpotLight(0xfff1d6, 0, 70, .55, .6, 1.2); heads.position.set(2.2, .7, 0); heads.target.position.set(18, -1.5, 0); carRoot.add(heads, heads.target);
125
- police = createPolice(scene, game.api, sound, life);
126
- races = createRaces(scene, game.api, sound, W.canvasTex, net);
127
- nav = createNav(scene, game.api, W, ZONES, races.starts);
128
- const extras = createExtras(W, game.api, nav, sound);
129
- document.getElementById("gTaxi").onclick = () => extras.toggle();
130
-
131
- // ---------- online: other real players' cars, name tags, emotes, proximity voice ----------
132
- const remotes = new Map();
133
- const tagTex = (text, col = "#ffffff") => W.canvasTex(512, 96, (g, w, h) => { g.fillStyle = "rgba(0,0,0,.55)"; g.fillRect(0, 0, w, h); g.fillStyle = col; g.font = "800 50px Inter, sans-serif"; g.textAlign = "center"; g.fillText(text, w / 2, 66); });
134
- function remoteFor(p) {
135
- let r = remotes.get(p.id);
136
- const model = Object.keys(MODELS)[p.model | 0] || "hydra";
137
- if (r && r.model !== model) { scene.remove(r.root); remotes.delete(p.id); r = null; }
138
- if (!r) {
139
- const c = buildCar(model), root = new THREE.Group(); root.add(c.group); c.setReveal(1); c.setThrust(0, 0, 0, 0); c.setWings(0, 0);
140
- c.group.traverse(o => { if (o.isMesh) o.castShadow = true; });
141
- const tag = new THREE.Sprite(new THREE.SpriteMaterial({ map: tagTex(p.name), depthTest: false, toneMapped: false })); tag.scale.set(5, .95, 1); tag.position.y = 2.6; root.add(tag);
142
- const emo = new THREE.Sprite(new THREE.SpriteMaterial({ map: tagTex(""), depthTest: false, toneMapped: false })); emo.scale.set(6, 1.15, 1); emo.position.y = 3.8; emo.visible = false; root.add(emo);
143
- scene.add(root); r = { root, car: c, tag, emo, model, name: p.name, paint: null, emoT: 0 }; remotes.set(p.id, r);
144
- }
145
- if (r.name !== p.name) { r.name = p.name; r.tag.material.map = tagTex(p.name); }
146
- if (p.paint && r.paint !== p.paint) { r.paint = p.paint; r.car.setPaint(p.paint); }
147
- return r;
148
- }
149
- net.on("change", () => { for (const id of [...remotes.keys()]) if (!net.players().some(p => p.id === id)) { scene.remove(remotes.get(id).root); remotes.delete(id); } renderPlayers(); });
150
- net.on("status", t => { document.getElementById("gNetStatus").textContent = t; document.getElementById("gNetBtn").classList.toggle("on", net.online()); });
151
- net.on("mic", on => { const b = document.getElementById("gMic"); b.classList.toggle("on", on); b.textContent = on ? "🎙 Mic on" : "🎙 Voice chat"; });
152
- net.on("emote", (m, from) => { const r = remotes.get(from), e = EMOTES[m.e | 0]; if (r) { r.emo.material.map = tagTex(e, "#ffd23d"); r.emo.visible = true; r.emoT = 4; } feed(`${net.nameOf(from)}: ${e}`); });
153
- function feed(t) { const f = document.getElementById("gFeed"); const d = document.createElement("div"); d.textContent = t; f.prepend(d); setTimeout(() => d.remove(), 7000); while (f.children.length > 5) f.lastChild.remove(); }
154
- function renderPlayers() { document.getElementById("gPlayers").innerHTML = net.online() ? [`<b>${net.name} (you)</b>`, ...net.players().map(p => `<span>${p.vc ? "🎙 " : ""}${p.name}</span>`)].join("") : ""; }
155
- {
156
- const $ = id => document.getElementById(id), panel = $("gNetPanel");
157
- $("gNetName").value = store.get("void.name") || "";
158
- $("gNetBtn").onclick = () => { panel.hidden = !panel.hidden; };
159
- $("gNetClose").onclick = () => panel.hidden = true;
160
- const go = room => { const nm = $("gNetName").value; store.set("void.name", nm); net.join(room, nm); panel.hidden = true; };
161
- $("gNetPublic").onclick = () => go("public-1");
162
- $("gNetCreate").onclick = () => { const code = Math.random().toString(36).slice(2, 7); $("gNetCode").value = code; go("room-" + code); toast(`Room code: ${code}. Tell your friends!`); };
163
- $("gNetJoin").onclick = () => { const code = $("gNetCode").value.trim().toLowerCase(); if (code) go("room-" + code); };
164
- $("gNetLeave").onclick = () => { net.leave(); panel.hidden = true; };
165
- $("gMic").onclick = () => net.setMic(!net.mic);
166
- $("gEmotes").innerHTML = EMOTES.map((e, k) => `<button class="pill" data-e="${k}">${e}</button>`).join("");
167
- $("gEmotes").onclick = ev => { const b = ev.target.closest("[data-e]"); if (!b || !net.online()) return; net.send({ t: "emote", e: +b.dataset.e }); feed(`You: ${EMOTES[+b.dataset.e]}`); };
168
- }
169
- W.setTime(store.get("void.time") || "night");
170
- // fill the car's reflection cube once before the first frame, so the paint never samples an empty one
171
-
172
- $("osmCredit").textContent = W.credit;
173
- // the garage: the Build panel over the game, the game paused underneath
174
- function openGarage(on) { document.body.classList.toggle("garage", on); game.pause(on); if (on && car.repair) { car.repair(); applyBuild(); if (game.state) game.state.hp = 100; } }
175
- $("gGarageClose").onclick = () => openGarage(false);
176
- const nozzles = (car.nozzles || [[.9, .3, 1], [.9, .3, -1], [-.95, .38, 1], [-.95, .38, -1]]).map(([x, y, s]) => new THREE.Vector3(x, y - .5, s));
177
-
178
- // ---------- configurator ----------
179
- const OPTS = {
180
- paint: { label: "Paint", items: [["Void Black", "#0a0a0c"], ["Stealth Grey", "#2b2d32"], ["Liquid Silver", "#9fa3aa"], ["Ghost White", "#e9e9ea"], ["Blood Red", "#6f0a12"], ["Ember Orange", "#c9480c"], ["Ion Blue", "#123a8c"], ["Venom Green", "#2d6a1e"], ["Candy Purple", "#4a1270"], ["Sunset Gold", "#b8862a"], ["Pearl Pink", "#e8a6c0"], ["Arctic Teal", "#1f8a8a"], ["Lime Rush", "#8acb1a"], ["Cherry Pop", "#d2163c"], ["Midnight Navy", "#0d1838"], ["Chrome", "#d8dadd"]] },
181
- finish: { label: "Finish", seg: true, items: [["Gloss", "gloss"], ["Satin", "satin"], ["Matte", "matte"]] },
182
- rim: { label: "Wheels", items: [["Black", "#121215"], ["Gunmetal", "#3a3d44"], ["Silver", "#b8bcc4"], ["Bronze", "#7a5a32"], ["Gold", "#c9a227"], ["Red", "#b0141f"], ["White", "#e8e8ea"], ["Ion", "#2ad8e8"]] },
183
- cal: { label: "Calipers", items: [["Red", "#c1121f"], ["Black", "#2a2a30"], ["Yellow", "#e0b000"], ["White", "#e8e8e8"], ["Ion", "#3df5ff"]] },
184
- trim: { label: "Accents", items: [["Red", "#c1121f"], ["Black", "#16161a"], ["White", "#e8e8e8"], ["Gold", "#b8912e"], ["Ion", "#3df5ff"]] },
185
- light: { label: "Lights", items: [["Ice", "#e8fbff"], ["Amber", "#ffb347"], ["Ion", "#6ad8ff"], ["Violet", "#b38cff"]] },
186
- glow: { label: "Underglow", items: [["Off", ""], ["White", "#ffffff"], ["Red", "#ff2233"], ["Ion", "#3df5ff"], ["Violet", "#9b5cff"]] },
187
- spoiler: { label: "Spoiler", seg: true, items: [["Stock", "none"], ["Ducktail", "ducktail"], ["GT wing", "gt"], ["Swan neck", "swan"], ["Rally", "rally"]] },
188
- livery: { label: "Livery", seg: true, items: [["Clean", "none"], ["Twin stripes", "stripes"], ["Centre stripe", "center"], ["Side stripe", "side"], ["Race #42", "race"]] },
189
- livc: { label: "Livery colour", items: [["White", "#f2f2f2"], ["Red", "#c1121f"], ["Black", "#101012"], ["Gold", "#c9a227"], ["Ion", "#3df5ff"], ["Orange", "#ff6a00"]] },
190
- tint: { label: "Windows", seg: true, items: [["Light", "light"], ["Dark", "dark"], ["Limo", "limo"], ["Mirror", "mirror"]] },
191
- flame: { label: "Nitro flames", items: [["Blue", "#4fa8ff"], ["Orange", "#ff7a1a"], ["Green", "#3dff6a"], ["Purple", "#b05cff"], ["Pink", "#ff4fd8"]] },
192
- horn: { label: "Horn", seg: true, items: [["Classic", 0], ["Air horn", 1], ["Tune", 2]] },
193
- };
194
- OPTS.model = { label: "Car", seg: true, items: Object.entries(MODELS).map(([k, m]) => [m.name, k]) };
195
- const DEFAULT = { model: 0, paint: 0, finish: 0, rim: 0, cal: 0, trim: 0, light: 0, glow: 0, spoiler: 0, livery: 0, livc: 0, tint: 1, flame: 0, horn: 0 };
196
- let build = { ...DEFAULT, ...(store.get("void.build2") || {}), ...(store.get("void.build3") || {}) };
197
- try { const h = new URLSearchParams(location.hash.slice(1)).get("b"); if (h) { const v = h.split(".").map(Number); Object.keys(DEFAULT).forEach((k, i) => { if (OPTS[k].items[v[i]]) build[k] = v[i]; }); } } catch { }
198
- function applyBuild() {
199
- useModel(OPTS.model.items[build.model][1]);
200
- car.setSpoiler(OPTS.spoiler.items[build.spoiler][1]); car.setLivery(OPTS.livery.items[build.livery][1], OPTS.livc.items[build.livc][1]);
201
- car.setTint(OPTS.tint.items[build.tint][1]); car.setFlameColor(OPTS.flame.items[build.flame][1]);
202
- car.setPaint(OPTS.paint.items[build.paint][1]); car.setFinish(OPTS.finish.items[build.finish][1]);
203
- car.setRim(OPTS.rim.items[build.rim][1]); car.setAccent(OPTS.cal.items[build.cal][1]); car.setTrim(OPTS.trim.items[build.trim][1]); car.setLight(OPTS.light.items[build.light][1]);
204
- const gl = OPTS.glow.items[build.glow][1]; if (gl) fx.glow.material.color.set(gl).multiplyScalar(1.4);
205
- store.set("void.build3", build);
206
- $("sum").innerHTML = `<b>${car.name.toUpperCase()} &middot; ${OPTS.paint.items[build.paint][0]}</b>${OPTS.spoiler.items[build.spoiler][0]} spoiler, ${OPTS.livery.items[build.livery][0].toLowerCase()} livery, ${OPTS.finish.items[build.finish][0]} paint, ${OPTS.rim.items[build.rim][0].toLowerCase()} wheels, ${OPTS.cal.items[build.cal][0].toLowerCase()} calipers, ${OPTS.trim.items[build.trim][0].toLowerCase()} accents, ${OPTS.light.items[build.light][0].toLowerCase()} lights${gl ? ", " + OPTS.glow.items[build.glow][0].toLowerCase() + " underglow" : ""}`;
207
- for (const b of document.querySelectorAll("#cfgBody button")) b.setAttribute("aria-pressed", String(build[b.dataset.k] === +b.dataset.i));
208
- for (const k in OPTS) { const n = document.querySelector(`[data-name="${k}"]`); if (n) n.textContent = OPTS[k].items[build[k]][0]; }
209
- }
210
- const ORDER = ["model", "paint", "finish", "livery", "livc", "spoiler", "rim", "cal", "trim", "tint", "light", "glow", "flame", "horn"];
211
- $("cfgBody").innerHTML = ORDER.map(k => [k, OPTS[k]]).map(([k, o]) => `<div class="grp"><div class="grp-h">${o.label}<b data-name="${k}"></b></div><div class="${o.seg ? "seg" : "sw"}">${o.items.map(([n, c], i) => o.seg
212
- ? `<button data-k="${k}" data-i="${i}">${n}</button>`
213
- : `<button data-k="${k}" data-i="${i}" title="${n}" aria-label="${o.label}: ${n}" style="background:${c || "repeating-linear-gradient(45deg,#222 0 4px,#111 4px 8px)"}"></button>`).join("")}</div></div>`).join("");
214
- $("cfgBody").addEventListener("click", e => { const b = e.target.closest("button"); if (!b) return; build[b.dataset.k] = +b.dataset.i; applyBuild(); });
215
- $("reset").onclick = () => { build = { ...DEFAULT, model: build.model }; applyBuild(); toast("Back to black and red"); };
216
- $("share").onclick = async () => {
217
- const url = location.origin + location.pathname + "#b=" + Object.keys(DEFAULT).map(k => build[k]).join(".");
218
- try { await navigator.clipboard.writeText(url); toast("Link to your build copied"); } catch { prompt("Copy your build link", url); }
219
- };
220
- applyBuild();
221
- let toastT;
222
- function toast(t) { const el = $("toast"); el.textContent = t; el.classList.add("on"); clearTimeout(toastT); toastT = setTimeout(() => el.classList.remove("on"), 2200); }
223
-
224
- // ---------- sound ----------
225
- function setSound(on) { sound.setOn(on); $("snd").setAttribute("aria-pressed", String(on)); $("snd").textContent = on ? "Sound on" : "Sound off"; if (on && mode === "watch" && w.playing) sound.startSong(w.t); }
226
- $("snd").onclick = () => setSound(!sound.on);
227
- $("rev").onclick = () => { if (!sound.on) setSound(true); sound.rev(); };
228
-
229
- // ---------- modes ----------
230
- let mode = "home";
231
- const w = { t: 0, playing: false, dragging: false };
232
- function go(next) {
233
- if (next === mode) return;
234
- $("fade").classList.add("on");
235
- setTimeout(() => {
236
- if (mode === "play") { game.exit(); openGarage(false); }
237
- if (mode === "watch") { sound.stopSong(); w.playing = false; }
238
- mode = next; document.body.dataset.mode = next;
239
- if (next === "home") scrollTo(0, 0);
240
- if (next === "watch") { if (!sound.on) setSound(true); playFrom(0); }
241
- if (next === "play") { game.enter(); if (SET.radio !== "score") sound.setRadio(SET.radio); }
242
- if (mode !== "play" && sound.radio && sound.radio !== "score") sound.setRadio("score");
243
- $("fade").classList.remove("on");
244
- }, 320);
245
- }
246
- document.addEventListener("click", e => { const b = e.target.closest("[data-go]"); if (b) { e.preventDefault(); go(b.dataset.go); } });
247
- $("exit").onclick = () => go("home");
248
- addEventListener("keydown", e => {
249
- if (e.code === "Escape" && mode === "play" && !document.body.classList.contains("garage")) { menu(); return; }
250
- if (e.code === "Escape" && mode !== "home") go("home");
251
- if (mode === "watch") {
252
- if (e.code === "Space") { e.preventDefault(); togglePlay(); }
253
- if (e.code === "ArrowRight") seek(w.t + 4); if (e.code === "ArrowLeft") seek(w.t - 4);
254
- }
255
- });
256
-
257
- // watch player
258
- function playFrom(t) { w.t = clamp(t, 0, TOTAL); w.playing = true; $("wEnd").classList.remove("on"); if (sound.on) sound.startSong(w.t); setPlayIcon(); }
259
- function pause() { w.playing = false; sound.stopSong(); setPlayIcon(); }
260
- function togglePlay() { if (w.playing) pause(); else playFrom(w.t >= TOTAL - .05 ? 0 : w.t); }
261
- function seek(t) { w.t = clamp(t, 0, TOTAL); if (w.playing) playFrom(w.t); }
262
- function setPlayIcon() { $("wPlay").innerHTML = w.playing ? "&#10074;&#10074;" : "&#9654;"; $("wPlay").setAttribute("aria-label", w.playing ? "Pause" : "Play"); }
263
- $("wPlay").onclick = togglePlay;
264
- $("wAgain").onclick = () => playFrom(0);
265
- const scrub = $("wScrub"); scrub.max = TOTAL;
266
- scrub.addEventListener("input", () => { w.dragging = true; w.t = +scrub.value; if (w.playing) { sound.stopSong(); } });
267
- scrub.addEventListener("change", () => { w.dragging = false; if (w.playing) playFrom(+scrub.value); });
268
- $("wTicks").innerHTML = CHAPTERS.filter(c => c[1]).map(c => `<button style="left:${c[0] * BAR / TOTAL * 100}%" data-t="${c[0] * BAR}">${c[1]}</button>`).join("");
269
- $("wTicks").addEventListener("click", e => { const b = e.target.closest("button"); if (b) { seek(+b.dataset.t); if (!w.playing) playFrom(+b.dataset.t); } });
270
- const fmt = s => `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, "0")}`;
271
-
272
- // drag to turn the car on the home and build screens
273
- const orbit = { a: .7, v: 0, drag: false, x: 0 };
274
- addEventListener("pointerdown", e => { if ((mode !== "build" && mode !== "home") || e.target !== $("gl") && !e.target.closest(".drag-hint, #buildUI") || e.target.closest(".cfg, button")) return; orbit.drag = true; orbit.x = e.clientX; });
275
- addEventListener("pointermove", e => { if (!orbit.drag) return; orbit.v = (e.clientX - orbit.x) * -.006; orbit.a += orbit.v; orbit.x = e.clientX; });
276
- addEventListener("pointerup", () => { orbit.drag = false; });
277
-
278
- // ---------- resize: ignore the phone address bar sliding, follow rotation and folding ----------
279
- let lastW = 0, lastH = 0;
280
- function resize() {
281
- const ww = innerWidth, hh = Math.max(innerHeight, document.documentElement.clientHeight);
282
- if (!ww || !hh) return;
283
- if (ww === lastW && Math.abs(hh - lastH) < 140 && lastW) return;
284
- lastW = ww; lastH = hh; renderer.setSize(ww, hh, false); composer.setSize(ww, hh);
285
- bloom.resolution.set(Math.max(1, ww * W.bloomRes), Math.max(1, hh * W.bloomRes)); camera.aspect = ww / hh;
286
- }
287
- addEventListener("resize", resize); addEventListener("orientationchange", () => setTimeout(resize, 200));
288
- if (window.visualViewport) visualViewport.addEventListener("resize", resize);
289
- resize();
290
- const fovFor = f => { const a = camera.aspect; if (a >= 1.5) return f; const h = 2 * Math.atan(Math.tan(f * Math.PI / 360) * 1.5); return Math.min(88, 2 * Math.atan(Math.tan(h / 2) / a) * 180 / Math.PI); };
291
-
292
- // ---------- the showroom pose (home and build) ----------
293
- const showFr = frame(); W.track.sample(W.track.D[W.track.idxX(0)], showFr);
294
- const intro = { t: -1 }; // the car drives in once the loader lifts
295
- function showroom(dt, time) {
296
- let introX = 0, introV = 0;
297
- if (intro.t >= 0 && intro.t < 3.2) { intro.t += dt; const u = Math.min(1, intro.t / 3.2); introX = -46 * Math.pow(1 - u, 3); introV = 46 * 3 * Math.pow(1 - u, 2) / 3.2; }
298
- else if (intro.t < 0) introX = -46;
299
- if (!orbit.drag) { orbit.v *= .94; orbit.a += orbit.v + (REDUCED ? 0 : dt * (mode === "home" ? .16 : .1)); }
300
- const hf = 2 * Math.atan(Math.tan(fovFor(38) * Math.PI / 360) * camera.aspect), fit = 3.1 / Math.tan(hf / 2); // fit the whole car across the screen
301
- const scrolled = mode === "home" ? clamp(scrollY / innerHeight) : 0, dist = Math.max(mode === "build" ? 8.8 : 8.2, fit) + scrolled * 2;
302
- const cam = { pos: new THREE.Vector3(Math.cos(orbit.a) * dist, 1.5 + scrolled * 4, Math.sin(orbit.a) * dist), look: new THREE.Vector3(0, .5 - scrolled * .4, 0), fov: 38 };
303
- if (camera.aspect < 1) cam.look.y = mode === "build" ? -1.1 : -.2;
304
- else if (mode === "build") { const right = new THREE.Vector3().subVectors(cam.look, cam.pos).cross(new THREE.Vector3(0, 1, 0)).normalize(); cam.look.addScaledVector(right, 1.7); }
305
- const pos = showFr.p.clone(); pos.x += introX; const fr = { ...showFr, p: pos };
306
- if (introX < -.01) cam.look.x = Math.max(introX * .35, -8);
307
- return { pos, quat: new THREE.Quaternion(), fr, speed: introV * 3.6, g: 1, alt: 0, vs: 0, thrust: { power: 0, angle: 0, deploy: 0 }, wings: 0, air: false, cam, inside: false, screenOn: false, reveal: 1, rpm: 900, gear: 1, load: .1, engine: .6, mode: "PARK", zones: [] };
308
- }
309
-
310
- // ---------- per frame ----------
311
- const clock = new THREE.Clock();
312
- let lastGauge = 0, lastChips = 0, cycleT = 0;
313
- // the speedometer: a dial with a glowing arc, the speed, the gear (or altitude when flying) and what you're in
314
- const gauge = document.getElementById("gGauge"), gx = gauge.getContext("2d");
315
- function drawGauge(S) {
316
- const W2 = gauge.width, c = W2 / 2, r = c - 22, a0 = Math.PI * .75, a1 = Math.PI * 2.25, max = S.veh === "plane" ? 600 : S.veh === "boat" ? 140 : 360, f = Math.min(1, S.speed / max);
317
- gx.clearRect(0, 0, W2, W2);
318
- gx.beginPath(); gx.arc(c, c, r + 14, 0, 7); gx.fillStyle = "rgba(6,8,14,.62)"; gx.fill();
319
- gx.lineCap = "round"; gx.lineWidth = 14; gx.beginPath(); gx.arc(c, c, r, a0, a1); gx.strokeStyle = "rgba(255,255,255,.12)"; gx.stroke();
320
- const grd = gx.createLinearGradient(0, W2, W2, 0); grd.addColorStop(0, "#3df5ff"); grd.addColorStop(.6, "#ffffff"); grd.addColorStop(1, "#ff2a3a");
321
- gx.beginPath(); gx.arc(c, c, r, a0, a0 + (a1 - a0) * f); gx.strokeStyle = grd; gx.shadowColor = "#3df5ff"; gx.shadowBlur = 16; gx.stroke(); gx.shadowBlur = 0;
322
- gx.lineWidth = 2; gx.strokeStyle = "rgba(255,255,255,.5)"; for (let k = 0; k <= 12; k++) { const a = a0 + (a1 - a0) * k / 12, i = r - 18, o = r - (k % 3 ? 24 : 30); gx.beginPath(); gx.moveTo(c + Math.cos(a) * i, c + Math.sin(a) * i); gx.lineTo(c + Math.cos(a) * o, c + Math.sin(a) * o); gx.stroke(); }
323
- gx.fillStyle = "#fff"; gx.textAlign = "center"; gx.font = `900 ${W2 * .22}px Unbounded, Inter, sans-serif`; gx.fillText(Math.round(S.speed), c, c + W2 * .06);
324
- gx.font = `700 ${W2 * .055}px Inter, sans-serif`; gx.fillStyle = "rgba(255,255,255,.6)"; gx.fillText("KM/H", c, c + W2 * .14);
325
- gx.font = `800 ${W2 * .07}px Unbounded, Inter, sans-serif`; gx.fillStyle = S.air ? "#3df5ff" : "#ffd23d";
326
- gx.fillText(S.air || S.veh === "plane" || S.veh === "heli" ? `${Math.round(S.alt)} m` : S.veh === "boat" ? "BOAT" : `GEAR ${S.gear}`, c, c + W2 * .3);
327
- if (S.nitro > .1) { gx.font = `800 ${W2 * .05}px Inter, sans-serif`; gx.fillStyle = "#3df5ff"; gx.fillText("NITRO", c, c - W2 * .16); }
328
- }
329
- let wasWrecked = false, wreckPose = null; const wrecks = [];
330
- let fpsNow = 0;
331
- const perf = { t: 0, n: 0, pr: renderer.getPixelRatio(), max: renderer.getPixelRatio(), down: 0 };
332
- applySettings();
333
- let lastHud = 0, prevGear = 1, feedFlip = 0;
334
- function frameLoop(fixed) {
335
- const raw = fixed ? 0 : clock.getDelta(), dt = fixed || Math.min(.05, raw), time = clock.elapsedTime;
336
- // adaptive resolution: drop the pixel count when frames run slow, bring it back when there is headroom
337
- if (!fixed && raw < .5) {
338
- perf.t += raw; perf.n++;
339
- if (perf.t > 1.5) {
340
- const avg = perf.t / perf.n, was = perf.pr; fpsNow = Math.round(1 / avg); const fe = document.getElementById("gFps"); if (fe) fe.textContent = fpsNow + " fps";
341
- if (avg > 1 / 25 && mode === "play" && SET.q !== "low") perf.down = 3; // very slow: skip straight to a lower level
342
- if (avg > 1 / 45 && perf.pr > .6 && perf.down < 3) perf.pr = Math.max(.6, perf.pr - .12);
343
- else if (avg > 1 / 40 && mode === "play" && ++perf.down >= 3 && SET.q !== "low") { // still slow at the lowest resolution: drop a quality level
344
- perf.down = 0; SET.q = { ultra: "high", high: "medium", medium: "low" }[SET.q]; perf.pr = W.QUALITY[SET.q].pr; applySettings(false); toast(`Graphics set to ${SET.q} to keep it smooth`);
345
- }
346
- else if (avg < 1 / 58 && perf.pr < perf.max) perf.pr = Math.min(perf.max, perf.pr + .08);
347
- if (perf.pr !== was) { renderer.setPixelRatio(perf.pr); composer.setPixelRatio(perf.pr); lastW = 0; resize(); }
348
- perf.t = perf.n = 0;
349
- }
350
- }
351
- let S;
352
- if (mode === "watch") {
353
- if (w.playing && !w.dragging) {
354
- const st = sound.on ? sound.songTime() : null;
355
- w.t = st != null ? st : w.t + dt;
356
- if (w.t >= TOTAL) { w.t = TOTAL; pause(); $("wEnd").classList.add("on"); }
357
- }
358
- S = watch.at(w.t, time, camera.aspect, fovFor);
359
- if (!w.dragging) scrub.value = w.t;
360
- scrub.style.setProperty("--p", (w.t / TOTAL * 100) + "%");
361
- $("wTime").textContent = `${fmt(w.t)} / ${fmt(TOTAL)}`;
362
- const ch = S.chapter, cap = $("wCap");
363
- if (cap.dataset.ch !== ch[1]) { cap.dataset.ch = ch[1]; cap.classList.add("hide"); setTimeout(() => { $("wNum").textContent = ch[1] ? String(CHAPTERS.indexOf(ch) + 1).padStart(2, "0") : ""; $("wTitle").textContent = ch[1]; $("wSub").textContent = ch[2]; cap.classList.toggle("hide", !ch[1]); }, 250); }
364
- $("telem").style.opacity = S.bar > 2 && !S.inside && S.bar < 17.5 ? 1 : 0;
365
- $("tSpd").textContent = Math.round(S.speed); $("tG").textContent = S.g.toFixed(1); $("tAlt").textContent = Math.round(S.alt);
366
- $("dream").style.opacity = S.dream; $("fade").style.opacity = S.fade;
367
- } else if (mode === "play") S = game.update(dt, time, camera.aspect);
368
- else S = showroom(dt, time);
369
- life.update(dt, time, mode === "play" ? S.player : null, camera.position);
370
- if (mode === "play") {
371
- police.update(dt, time); races.update(dt, time); nav.update();
372
- const st = game.state, stars = police.stars;
373
- document.getElementById("gStars").textContent = stars ? "★".repeat(stars) + "☆".repeat(5 - stars) : "";
374
- document.getElementById("gStars").classList.toggle("bust", police.bust > .5);
375
- const pr = races.progress();
376
- net.tick(dt, { p: [st.x, st.y, st.z, st.yaw, st.pitch, st.roll].map(v => Math.round(v * 100) / 100), m: Object.keys(MODELS).indexOf(car.model), c: OPTS.paint.items[build.paint][1], v: Math.round(S.speed), a: S.air ? 1 : 0, r: pr ? pr.race : 0, rp: pr ? pr.rp : 0, rf: pr ? pr.rf : 0, w: stars });
377
- for (const p of net.players()) {
378
- const at = net.sample(p); const r = remoteFor(p); r.at = at;
379
- if (!at || at.stale) { r.root.visible = false; continue; }
380
- r.root.visible = true; r.root.position.set(at.x, at.y, at.z); r.root.rotation.set(0, -at.yaw, 0); r.car.group.rotation.set(at.roll, 0, at.pitch, "XYZ");
381
- r.car.setThrust(at.air ? .6 : 0, at.air && at.v > 90 ? 1 : 0, at.air ? 1 : 0, time); r.car.setWings(at.air && at.v > 100 ? 1 : 0, time);
382
- for (const wh of r.car.wheels) wh.rotation.z -= at.v / 3.6 * dt / .37;
383
- if (r.emoT > 0 && (r.emoT -= dt) <= 0) r.emo.visible = false;
384
- const dx = st.x - at.x, dz = st.z - at.z, d = Math.hypot(dx, dz);
385
- net.setVolume(p.id, 1 - d / 260);
386
- if (d < 3.4 && d > .01 && Math.abs(st.y - at.y) < 2) { st.x += dx / d * (3.4 - d) * .5; st.z += dz / d * (3.4 - d) * .5; st.vel.multiplyScalar(.9); }
387
- }
388
- } else { for (const r of remotes.values()) r.root.visible = false; net.tick(dt, null); } // the host keeps relaying from the menus
389
- W.city.update(time, camera.position);
390
- W.follow(S.pos);
391
- if (mode !== "watch") $("fade").style.opacity = "";
392
-
393
- // the car, or the plane / helicopter / boat
394
- const veh = mode === "play" ? S.veh || "car" : "car";
395
- carRoot.visible = veh === "car";
396
- vehicles.show(veh === "car" ? null : veh, S.pos, S.quat, S, time, dt);
397
- if (S.splash) for (let k = 0; k < 6; k++) { const pf = fx.puffs[fx.puffI++ % fx.puffs.length]; pf.s.position.copy(S.pos).add(new THREE.Vector3((Math.random() - .5) * 3, .3, (Math.random() - .5) * 3)); pf.life = 1; pf.s.visible = true; pf.grow = .8; pf.s.scale.setScalar(.8); pf.s.material.color.set(0xeaf6ff); pf.v.set((Math.random() - .5) * 6, 4 + Math.random() * 4, (Math.random() - .5) * 6); }
398
- if (veh === "boat" && S.speed > 12 && Math.random() < .6) { const back = new THREE.Vector3(-3.6, .1, (Math.random() - .5) * 2).applyQuaternion(S.quat).add(S.pos); const pf = fx.puffs[fx.puffI++ % fx.puffs.length]; pf.s.position.copy(back); pf.life = 1; pf.s.visible = true; pf.grow = .5; pf.s.scale.setScalar(.5); pf.s.material.color.set(0xf4fbff); pf.v.set((Math.random() - .5) * 2, .6, (Math.random() - .5) * 2); }
399
- const night = W.timeOfDay !== "day";
400
- heads.intensity = night && veh === "car" ? (W.timeOfDay === "night" ? 260 : 120) : 0;
401
- W.sky.position.copy(camera.position); W.grade.uniforms.time.value = time % 100;
402
- W.grade.uniforms.blur.value = mode === "play" ? Math.max(0, Math.min(1, (S.speed - 160) / 220)) * .9 + (S.nitro || 0) * .5 : 0;
403
- atmos.update(dt, time, S, mode === "play" ? game.state : null);
404
- W.city.poolMat.opacity = W.timeOfDay === "night" ? 1 : W.timeOfDay === "sunset" ? .45 : 0; W.city.poolMat.visible = W.timeOfDay !== "day";
405
- extras.sky(dt, time);
406
- // the living city: when switched on, the day turns and the weather changes on its own
407
- if (SET.cycle === "on" && mode === "play" && (cycleT += dt) > 150) { cycleT = 0; cycleTime(); if (Math.random() < .5) { const w = ["clear", "clear", "rain", "fog", "storm", "snow"][Math.floor(Math.random() * 6)]; atmos.setWeather(w); SET.weather = w; } }
408
- if (mode === "play") { extras.update(dt, time); goals.stats.coins = extras.coins().got; goals.update(dt, game.state, S.speed); if (time - lastChips > 2) { lastChips = time; chips(); } }
409
- if (mode === "play" && time - lastGauge > .05) { lastGauge = time; drawGauge(S); const fu = document.getElementById("gFuel"); if (fu && S.fuel != null) { fu.style.setProperty("--v", S.fuel); fu.classList.toggle("low", S.fuel < .2); } }
410
- car.group.position.copy(S.pos); car.group.quaternion.copy(S.quat);
411
- car.setReveal(S.reveal);
412
- car.setThrust(S.thrust.power, S.thrust.angle, S.thrust.deploy, time);
413
- car.setFlame(S.nitro || 0, time);
414
- // damage: dent the model where it was hit; a destroyed car is left where it crashed and a fresh one is built for you
415
- const gs = mode === "play" ? game.state : null;
416
- if (gs && gs.impacts && gs.impacts.length && car.damage) { carRoot.updateMatrixWorld(true); for (const im of gs.impacts.splice(0)) car.damage(carRoot.worldToLocal(new THREE.Vector3(im.x, im.y, im.z)), im.p); }
417
- if (S.wrecked && !wasWrecked) { car.wreck && car.wreck(); wreckPose = { p: carRoot.position.clone(), q: carRoot.quaternion.clone() }; }
418
- if (!S.wrecked && wasWrecked && wreckPose && inner) {
419
- const wg = inner.group; carRoot.remove(wg); wg.position.copy(wreckPose.p); wg.quaternion.copy(wreckPose.q); scene.add(wg);
420
- wrecks.push({ g: wg, t: 30 }); if (wrecks.length > 4) { const o = wrecks.shift(); scene.remove(o.g); }
421
- useModel(car.model, true); applyBuild(); wreckPose = null;
422
- }
423
- wasWrecked = !!S.wrecked;
424
- for (const w of wrecks) { w.t -= dt; if (Math.random() < .25 && w.t > 10) { const pf = fx.puffs[fx.puffI++ % fx.puffs.length]; pf.s.position.copy(w.g.position).add(new THREE.Vector3((Math.random() - .5) * 2, 1, (Math.random() - .5) * 2)); pf.life = 1; pf.s.visible = true; pf.grow = .6; pf.s.scale.setScalar(.6); pf.s.material.color.set(0x2a2a2a); pf.v.set(0, 2, 0); } }
425
- for (let k = wrecks.length - 1; k >= 0; k--) if (wrecks[k].t <= 0) { scene.remove(wrecks[k].g); wrecks.splice(k, 1); }
426
- car.setWings(S.wings, time);
427
- const roll = S.speed / 3.6 * dt / .37;
428
- for (const wh of car.wheels) wh.rotation.z -= S.air ? roll * .15 : roll;
429
- car.group.updateMatrixWorld(true);
430
-
431
- // shadow, underglow, exhaust, speed lines
432
- const fr = S.fr, ground = clamp(1 - S.pos.y / 3) * (fr.u.y > .8 ? 1 : 0);
433
- fx.shadow.position.set(S.pos.x, S.pos.y > .5 ? .07 : S.pos.y + .07, S.pos.z); fx.shadow.material.opacity = veh === "car" ? ground : 0; fx.shadow.rotation.z = Math.atan2(-fr.f.z, fr.f.x);
434
- const glowOn = !!OPTS.glow.items[build.glow][1];
435
- fx.glow.position.copy(fx.shadow.position).y += .01; fx.glow.rotation.z = fx.shadow.rotation.z; fx.glow.material.opacity = glowOn ? ground * .85 : 0;
436
- if (S.thrust.power > .3) for (const n of nozzles) if (Math.random() < .18) {
437
- const pf = fx.puffs[fx.puffI++ % fx.puffs.length], wp = n.clone().applyMatrix4(car.group.matrixWorld);
438
- pf.s.position.copy(wp); pf.life = 1; pf.s.visible = true; pf.s.scale.setScalar(.4); pf.grow = .4; pf.s.material.color.set(0xc8d2e1);
439
- pf.v.copy(fr.u).multiplyScalar(-(1 - S.thrust.angle) * 7).addScaledVector(fr.f, -S.thrust.angle * 9 - S.speed / 3.6 * .2).add(new THREE.Vector3(Math.random() - .5, Math.random() - .5, Math.random() - .5).multiplyScalar(1.5));
440
- }
441
- const emit = (p, v, col, size, life = 1) => { const pf = fx.puffs[fx.puffI++ % fx.puffs.length]; pf.s.position.copy(p); pf.life = life; pf.s.visible = true; pf.s.scale.setScalar(size); pf.s.material.color.set(col); pf.v.copy(v); pf.grow = size; };
442
- if (mode === "play" && S.hp != null) {
443
- const eng = new THREE.Vector3(-1.2, .9, 0).applyMatrix4(car.group.matrixWorld);
444
- if (S.hp < 55 && !S.wrecked && Math.random() < (S.hp < 25 ? .5 : .2)) emit(eng, new THREE.Vector3((Math.random() - .5), 1.5 + Math.random(), (Math.random() - .5)), S.hp < 25 ? 0x222222 : 0x9a9a9a, .5);
445
- if (S.hp < 20 && !S.wrecked && Math.random() < .35) emit(eng, new THREE.Vector3(0, 2.5, 0), 0xff7a1a, .35, .5);
446
- if (S.sparks > .5) for (let k = 0; k < 4; k++) emit(S.pos.clone().add(new THREE.Vector3(0, .5, 0)), new THREE.Vector3((Math.random() - .5) * 12, Math.random() * 6, (Math.random() - .5) * 12), 0xffd27a, .12, .35);
447
- if (S.boom > .95) for (let k = 0; k < 40; k++) emit(S.pos.clone().add(new THREE.Vector3(0, 1, 0)), new THREE.Vector3((Math.random() - .5) * 18, Math.random() * 14, (Math.random() - .5) * 18), k % 3 ? 0xff7a1a : 0x333333, 1.2, 1.4);
448
- }
449
- for (const pf of fx.puffs) if (pf.life > 0) {
450
- pf.life -= dt * .9; pf.s.position.addScaledVector(pf.v, dt); pf.v.multiplyScalar(.97);
451
- pf.s.scale.setScalar((pf.grow || .4) + (1 - pf.life) * 4.5); pf.s.material.opacity = Math.max(0, pf.life) * .5; if (pf.life <= 0) pf.s.visible = false;
452
- }
453
- const lineA = smooth(240, 320, S.speed) * (S.inside ? 0 : 1);
454
- fx.lines.material.opacity = lineA * .08;
455
- if (lineA > .01) {
456
- const d = new THREE.Object3D();
457
- for (let i = 0; i < fx.LINES; i++) {
458
- const sd = fx.lineSeed[i]; sd[0] -= S.speed / 3.6 * dt * 1.6; if (sd[0] < -40) sd[0] += 80;
459
- d.position.copy(fr.p).addScaledVector(fr.f, sd[0]).addScaledVector(fr.u, sd[1]).addScaledVector(fr.s, sd[2]); d.quaternion.copy(S.quat); d.scale.set(1.5 + S.speed * .018, 1, 1);
460
- d.updateMatrix(); fx.lines.setMatrixAt(i, d.matrix);
461
- }
462
- fx.lines.instanceMatrix.needsUpdate = true;
463
- }
464
-
465
- // the front seat and its screens
466
- if (S.screenOn) {
467
- if (!COARSE || (feedFlip++ & 1)) interior.renderFeed(scene);
468
- if (time - lastHud > .1) {
469
- lastHud = time;
470
- const hud = { time, speed: S.speed, alt: S.alt, vs: S.vs, mode: S.mode, zones: S.zones, gear: S.gear, rpm: S.rpm };
471
- interior.drawHud(hud); interior.drawCluster(hud);
472
- }
473
- }
474
- interior.wheel.rotation.x = 0;
475
-
476
- // camera
477
- const c = S.cam, shake = REDUCED ? 0 : (Math.max(0, S.g - 2) * .004 + S.thrust.power * .01 + (S.shake || 0) * .25 + (S.nitro || 0) * .02) * (S.inside ? .25 : 1);
478
- camera.position.copy(c.pos).add(new THREE.Vector3(Math.sin(time * 53) * shake, Math.sin(time * 61 + 1) * shake, Math.sin(time * 47 + 2) * shake));
479
- camera.up.copy(c.up || new THREE.Vector3(0, 1, 0)); camera.lookAt(c.look);
480
- camera.fov = fovFor(c.fov); camera.near = S.inside || S.screenOn ? .06 : .35; camera.updateProjectionMatrix();
481
- camLight.position.copy(camera.position).add(new THREE.Vector3(0, 3, 0)); camLight.target.position.copy(S.pos);
482
- scene.fog.far = lerp(950, 2600, smooth(20, 160, S.alt)) * W.weatherFog; scene.fog.near = lerp(120, 400, smooth(20, 160, S.alt)) * W.weatherFog;
483
- const DET = { low: .55, medium: .8, high: 1, ultra: 1.2 }[W.quality] || 1; life.detail = DET; W.city.detail = DET;
484
- scene.fog.far *= Math.min(1, DET + .2); camera.far = scene.fog.far * 1.1 + 150; camera.updateProjectionMatrix(); // nothing past the fog gets drawn
485
- // refresh the car's reflections every few frames (the car hides from its own camera)
486
- // (no shadows, no crowds, a short view: it only has to look right in the paint)
487
-
488
-
489
- // the car's own sound
490
- if (S.gear > prevGear && !S.air && S.speed > 20) sound.pop();
491
- prevGear = S.gear;
492
- sound.car({ rpm: S.rpm, load: S.load, engine: mode === "build" || mode === "home" ? .4 : S.engine, thrust: S.thrust.power, speed: S.speed, inside: S.inside });
493
-
494
- composer.render();
495
- }
496
-
497
- setLoad(95);
498
- renderer.compile(scene, camera);
499
- let raf;
500
- let frameErr = 0;
501
- const loop = () => { raf = requestAnimationFrame(loop); try { frameLoop(); } catch (e) { if (frameErr++ < 3) console.error(e); } }; // one bad frame never stops the game
502
- loop();
503
- setLoad(100);
504
- setTimeout(() => { $("loader").classList.add("done"); setTimeout(() => { intro.t = 0; if (sound.on) sound.rev(); }, 450); }, 900);
505
- document.addEventListener("visibilitychange", () => {
506
- if (document.hidden) { cancelAnimationFrame(raf); if (mode === "watch" && w.playing) pause(); if (sound.ctx) sound.ctx.suspend(); }
507
- else { clock.getDelta(); loop(); if (sound.on && sound.ctx) sound.ctx.resume(); }
508
- });
509
- window.VOID = { step: (n = 1, dt = 1 / 30) => { for (let i = 0; i < n; i++) frameLoop(dt); }, W, car, life, carCube, carEnv, get police() { return police; }, get races() { return races; }, get nav() { return nav; }, net, orbit, go, seek: t => { w.t = t; if (w.playing) playFrom(t); }, pause, get w() { return w; }, game }; // handy for testing in the console
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // VOID: one WebGL canvas, three modes on top of a showroom home screen.
2
+ // Watch: a 48 s film whose clock is the music. Play: drive it, fly it, land it. Build: paint it.
3
+ import * as THREE from "three";
4
+
5
+ const V = new URL(import.meta.url).search;
6
+ const $ = id => document.getElementById(id);
7
+ const setLoad = p => { $("ldbar").style.width = p + "%"; $("ldpct").textContent = Math.round(p); };
8
+ setLoad(15);
9
+ const [{ createWorld, clamp, lerp, smooth, frame, PAD_R, ZONES }, { buildCar, MODELS }, { addInterior, HEAD }, { Sound, BAR }, { createWatch, TOTAL, CHAPTERS }, { createGame }, { createLife }] = await Promise.all(
10
+ ["world", "car", "interior", "sound", "watch", "game", "npc"].map(n => import(`./${n}.js${V}`)));
11
+ const [{ createPolice }, { createRaces }, { createNet, EMOTES }, { createNav }, { createVehicles }, { createAtmos, WEATHERS }, { createGoals, GOALS }, { createExtras }] = await Promise.all(["police", "race", "net", "nav", "vehicles", "atmos", "goals", "extras"].map(n => import(`./${n}.js${V}`)));
12
+ setLoad(40);
13
+
14
+ const COARSE = matchMedia("(pointer: coarse)").matches, REDUCED = matchMedia("(prefers-reduced-motion: reduce)").matches;
15
+ const store = { get(k) { try { return JSON.parse(localStorage.getItem(k)); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { } } };
16
+ const W = await createWorld($("gl"), COARSE), { renderer, scene, camera, composer, bloom, camLight, fx } = W;
17
+ setLoad(55);
18
+
19
+ // the car you drive: a fixed root the game and the film move around, with the chosen model swapped inside it
20
+ const carRoot = new THREE.Group(); scene.add(carRoot);
21
+ const car = { group: carRoot, wheels: [] };
22
+ const carMats = new Set();
23
+ let inner = null;
24
+ function useModel(id, force) {
25
+ if (inner && inner.model === id && !force) return;
26
+ if (inner) carRoot.remove(inner.group);
27
+ inner = buildCar(id); carRoot.add(inner.group);
28
+ for (const k of Object.keys(inner)) if (typeof inner[k] === "function") car[k] = inner[k];
29
+ Object.assign(car, { wheels: inner.wheels, clip: car.clip || inner.clip, materials: inner.materials, model: id, name: inner.name });
30
+ carMats.clear();
31
+ inner.group.traverse(o => { if (o.isMesh) { o.castShadow = true; if (o.material && o.material.isMeshStandardMaterial) carMats.add(o.material); } });
32
+ for (const m of carMats) { m.envMap = null; m.needsUpdate = true; } // the paint reflects the city capture (scene.environment) // phones skip the live cube and use the city reflection
33
+ }
34
+ // live reflections on the paint: a small cube camera that rides with the car
35
+ const carEnv = new THREE.WebGLCubeRenderTarget(COARSE ? 64 : 128, { type: THREE.HalfFloatType, generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter });
36
+ const carCube = new THREE.CubeCamera(.5, 320, carEnv);
37
+ for (const c of carCube.children) c.layers.set(0);
38
+ camera.layers.enable(1); // layer 1: the crowds, seen by the main camera only
39
+ let cubeN = 0;
40
+ useModel((store.get("void.build3") || {}).model != null ? Object.keys(MODELS)[(store.get("void.build3") || {}).model] || "hydra" : "hydra");
41
+ setLoad(80);
42
+ const interior = addInterior(car, renderer);
43
+ const sound = new Sound();
44
+ const watch = createWatch(W, car, interior);
45
+ const life = createLife(scene, W.roads, W.walkways, COARSE);
46
+ const TIMES = ["night", "sunset", "day"];
47
+ function cycleTime() { const k = TIMES[(TIMES.indexOf(W.timeOfDay) + 1) % 3]; W.setTime(k); store.set("void.time", k); toast({ night: "Night in the city", sunset: "Golden hour", day: "Daytime" }[k]); cubeN = 0; }
48
+ let police, races, nav;
49
+ const net = createNet();
50
+ setInterval(() => { if (document.hidden) net.tick(.5, null); }, 500); // a hosting tab in the background still relays everyone
51
+ // settings: graphics quality, look speed, auto gas, touch steering (kept on this device)
52
+ // a strong graphics card starts on High; everything else starts on Medium (it can be raised in the Menu)
53
+ const GPU = (() => { try { const c = renderer.getContext(), e = c.getExtension("WEBGL_debug_renderer_info"); return e ? c.getParameter(e.UNMASKED_RENDERER_WEBGL) : ""; } catch { return ""; } })();
54
+ const STRONG = /RTX|GTX 1[06-9]|GTX 9[78]|Radeon RX|Radeon Pro|Apple M[1-9]/i.test(GPU) && !COARSE;
55
+ const TOP = /RTX\s?(40[6-9]0|50[5-9]0)|RTX\s?A?[45]\d{3}/i.test(GPU) && !COARSE; // recent RTX cards start on Ultra
56
+ const SET = Object.assign({ q: TOP ? "ultra" : STRONG ? "high" : COARSE ? "low" : "medium", sens: 1, autogas: "off", steer: "stick", weather: "clear", radio: "score", cycle: "off" }, store.get("void.settings") || {});
57
+ const gameOpts = {
58
+ garage: () => openGarage(true), cycleTime, hornType: () => build.horn, autoGas: () => SET.autogas === "on", onRepair: () => car.repair && car.repair(),
59
+ onScore: (n, why) => { if (why === "Drift") goals.drift(n); goals.note(why); earn(n); },
60
+ onSmash: kind => police && police.event("smash", kind), policeClear: () => police && police.clear(),
61
+ autopilot: (g, dt, over) => nav ? nav.controls(g, dt, over) : null, openGps: () => document.getElementById("gGpsBtn").click(),
62
+ mapExtra(mx, g, MM) {
63
+ const P = (x, z) => [(x - g.x) / MM, (z - g.z) / MM];
64
+ if (nav && nav.pts.length > 1) { mx.strokeStyle = "#3dfcff"; mx.lineWidth = 3; mx.beginPath(); nav.pts.forEach(([x, z], k) => { const [a, b] = P(x, z); k ? mx.lineTo(a, b) : mx.moveTo(a, b); }); mx.stroke(); }
65
+ if (police) for (const c of police.cops) if (c.on) { const [a, b] = P(c.x, c.z); mx.fillStyle = Math.sin(performance.now() / 90) > 0 ? "#ff3040" : "#3060ff"; mx.beginPath(); mx.arc(a, b, 4, 0, 7); mx.fill(); }
66
+ if (races && races.race && races.race.next) { const [a, b] = P(races.race.next[0], races.race.next[2]); mx.strokeStyle = "#ffd23d"; mx.lineWidth = 3; mx.beginPath(); mx.arc(a, b, 7, 0, 7); mx.stroke(); }
67
+ for (const r of remotes.values()) if (r.at) { const [a, b] = P(r.at.x, r.at.z); mx.fillStyle = "#c07dff"; mx.beginPath(); mx.arc(a, b, 4.5, 0, 7); mx.fill(); }
68
+ mx.font = "bold 12px sans-serif"; mx.textAlign = "center"; for (const st of W.city.stations) { const [a, b] = P(st.x, st.z); if (Math.abs(a) < 90 && Math.abs(b) < 90) { mx.save(); mx.translate(a, b); mx.rotate(g.yaw + Math.PI / 2); mx.fillText("⛽", 0, 4); mx.restore(); } }
69
+ },
70
+ };
71
+ const game = createGame(W, car, sound, life, gameOpts);
72
+ const vehicles = createVehicles(scene, game.api, W); gameOpts.vehicles = vehicles;
73
+ const atmos = createAtmos(W, sound, COARSE);
74
+ // trophies: a banner slides in at the top when a challenge is done
75
+ const goals = createGoals(gl => { const t = document.getElementById("gTrophy"); t.innerHTML = `<b>${gl.icon}</b><div><span>Challenge complete</span>${gl.name}<em>+1000</em></div>`; t.classList.remove("on"); void t.offsetWidth; t.classList.add("on"); if (game.state) { game.state.score += 1000; } sound.win(); renderGoals(); });
76
+ function renderGoals() {
77
+ const S = goals.stats;
78
+ document.getElementById("gGoals").innerHTML = GOALS.map(g => { const v = Math.min(1, (S[g.stat] || 0) / g.need), ok = goals.done.has(g.id); return `<div class="goal${ok ? " ok" : ""}"><b>${g.icon}</b><div><span>${g.name}</span><small>${g.text}</small><i style="--v:${v}"></i></div>${ok ? "🏆" : `<em>${Math.floor(v * 100)}%</em>`}</div>`; }).join("");
79
+ document.getElementById("gStatsRow").innerHTML = `<div><b>${(S.best || 0).toLocaleString()}</b><span>Best score</span></div><div><b>${Math.round(S.top)}</b><span>Top km/h</span></div><div><b>${S.km.toFixed(1)}</b><span>km travelled</span></div><div><b>${goals.done.size}/${GOALS.length}</b><span>Trophies</span></div><div><b>$${cash.toLocaleString()}</b><span>Cash · spend in Garage</span></div>`;
80
+ }
81
+ const WX_ICON = { clear: "☀️ Clear", rain: "🌧 Rain", storm: "⛈ Storm", fog: "🌫 Fog", snow: "❄️ Snow" }, RADIO = { score: "🎵 VOID Score", voidfm: "📻 VOID FM", off: "🔇 Radio off" };
82
+ function chips() { document.getElementById("gChips").innerHTML = `<span>${{ night: "🌙", sunset: "🌇", day: "☀️" }[W.timeOfDay]} ${W.timeOfDay}</span><span>${WX_ICON[atmos.weather]}</span>`; document.getElementById("gWeather").innerHTML = `<b>${WX_ICON[SET.weather].split(" ")[0]}</b>${WX_ICON[SET.weather].split(" ").slice(1).join(" ")}`; document.getElementById("gRadio").innerHTML = `<b>${RADIO[SET.radio].split(" ")[0]}</b>${RADIO[SET.radio].split(" ").slice(1).join(" ")}`; }
83
+ document.getElementById("gWeather").onclick = () => { SET.weather = WEATHERS[(WEATHERS.indexOf(SET.weather) + 1) % WEATHERS.length]; atmos.setWeather(SET.weather); store.set("void.settings", SET); chips(); toast(WX_ICON[SET.weather]); };
84
+ document.getElementById("gRadio").onclick = () => { const k = Object.keys(RADIO); SET.radio = k[(k.indexOf(SET.radio) + 1) % k.length]; if (!sound.on) setSound(true); sound.setRadio(SET.radio); store.set("void.settings", SET); chips(); toast(RADIO[SET.radio]); };
85
+ // ---------- the menu (☰ or Esc): everything that isn't driving lives here ----------
86
+ const menuEl = document.getElementById("gMenu");
87
+ function menu(open) {
88
+ if (open == null) open = menuEl.hidden;
89
+ menuEl.hidden = !open; document.body.classList.toggle("g-menu-open", open); if (open) { renderGoals(); chips(); }
90
+ if (open && document.pointerLockElement) document.exitPointerLock();
91
+ if (!net.online()) game.pause(open);
92
+ }
93
+ document.getElementById("gMenuBtn").onclick = () => menu(true);
94
+ document.getElementById("gMenuClose").onclick = () => menu(false);
95
+ document.getElementById("gExit").onclick = () => { menu(false); go("home"); };
96
+ menuEl.addEventListener("click", e => { const t = e.target.closest(".tile"); if (t && !t.closest(".set")) setTimeout(() => menu(false), 60); if (e.target === menuEl) menu(false); });
97
+ menuEl.querySelectorAll("[data-veh]").forEach(b => b.onclick = () => game.api.setVehicle(b.dataset.veh));
98
+ document.getElementById("gFuelNav").onclick = () => { const st = game.state; if (!st) return; const best = W.city.stations.slice().sort((a, b) => Math.hypot(a.x - st.x, a.z - st.z) - Math.hypot(b.x - st.x, b.z - st.z))[0]; nav.setDest({ name: "⛽ Fuel station", x: best.x, z: best.z }); };
99
+ function applySettings(save = true) {
100
+ for (const seg of menuEl.querySelectorAll(".seg[data-set]")) for (const b of seg.children) b.classList.toggle("on", SET[seg.dataset.set] === b.dataset.v);
101
+ const weak = /Intel|UHD|Iris|Radeon\(TM\) Graphics|Vega|SwiftShader|llvmpipe|Basic Render/i.test(GPU);
102
+ const masked = !/ANGLE|NVIDIA|Intel|AMD|Radeon|Apple|Mali|Adreno/i.test(GPU); // Brave and some others hide the chip name for privacy
103
+ const name = (GPU || "unknown").replace(/^ANGLE \([^,]+, /, "").replace(/ \(0x[0-9A-Fa-f]+\).*$/, "").replace(/ Direct3D.*$/, "").replace(/, D3D.*$/, "");
104
+ document.getElementById("gGpu").innerHTML = `${masked ? "Your browser hides which graphics chip it uses" : `Running on: <b>${name}</b>`} · <b id="gFps">${fpsNow ? fpsNow + " fps" : "measuring…"}</b>${weak ? '<br><span class="warn">This is the built-in laptop graphics. For full speed, make your browser use the RTX: Windows Settings → System → Display → Graphics → your browser → High performance, then restart the browser.</span>' : masked ? '<br><span class="small">Smooth is 60 fps or more. Under 40, check the browser is set to your RTX in Windows graphics settings.</span>' : ""}`;
105
+ document.getElementById("gSens").value = SET.sens; game.api.sens = +SET.sens;
106
+ document.body.classList.toggle("steer-buttons", SET.steer === "buttons");
107
+ const cap = W.setQuality(SET.q); perf.max = cap; perf.pr = Math.min(perf.pr, cap); if (renderer.getPixelRatio() > cap) { renderer.setPixelRatio(cap); composer.setPixelRatio(cap); } lastW = 0; resize();
108
+ if (save) store.set("void.settings", SET);
109
+ }
110
+ menuEl.querySelectorAll(".seg[data-set]").forEach(seg => seg.addEventListener("click", e => { const b = e.target.closest("button"); if (!b) return; e.preventDefault(); SET[seg.dataset.set] = b.dataset.v; if (seg.dataset.set === "q") { perf.pr = W.QUALITY[b.dataset.v].pr; perf.down = 0; } applySettings();
111
+ atmos.setWeather(SET.weather);
112
+ if (/Intel|UHD|Iris/i.test(GPU) && !COARSE && !store.get("void.gpuWarned")) { store.set("void.gpuWarned", 1); setTimeout(() => toast("Running on built-in graphics: see Menu → Settings to switch to your RTX"), 4000); } }));
113
+ document.getElementById("gSens").addEventListener("input", e => { SET.sens = +e.target.value; applySettings(); });
114
+ // the touch joystick: drag the knob; left/right steers, up/down pitches when flying
115
+ {
116
+ const st = document.getElementById("gStick"), knob = st.querySelector("i"); let id = null, cx = 0, cy = 0;
117
+ const set = (x, y) => { const r = st.clientWidth / 2 - 10, l = Math.min(1, Math.hypot(x, y) / r), a = Math.atan2(y, x), kx = Math.cos(a) * l * r, ky = Math.sin(a) * l * r; knob.style.transform = `translate(${kx}px, ${ky}px)`; game.api.setStick(kx / r, ky / r); };
118
+ st.addEventListener("pointerdown", e => { id = e.pointerId; const b = st.getBoundingClientRect(); cx = b.left + b.width / 2; cy = b.top + b.height / 2; try { st.setPointerCapture(id); } catch { } set(e.clientX - cx, e.clientY - cy); e.preventDefault(); });
119
+ st.addEventListener("pointermove", e => { if (e.pointerId === id) set(e.clientX - cx, e.clientY - cy); });
120
+ const end = e => { if (e.pointerId !== id) return; id = null; knob.style.transform = ""; game.api.setStick(0, 0); };
121
+ st.addEventListener("pointerup", end); st.addEventListener("pointercancel", end);
122
+ }
123
+ // headlights that light the road at night
124
+ const heads = new THREE.SpotLight(0xfff1d6, 0, 70, .55, .6, 1.2); heads.position.set(2.2, .7, 0); heads.target.position.set(18, -1.5, 0); carRoot.add(heads, heads.target);
125
+ police = createPolice(scene, game.api, sound, life);
126
+ races = createRaces(scene, game.api, sound, W.canvasTex, net);
127
+ nav = createNav(scene, game.api, W, ZONES, races.starts);
128
+ const extras = createExtras(W, game.api, nav, sound);
129
+ document.getElementById("gTaxi").onclick = () => extras.toggle();
130
+
131
+ // ---------- online: other real players' cars, name tags, emotes, proximity voice ----------
132
+ const remotes = new Map();
133
+ const tagTex = (text, col = "#ffffff") => W.canvasTex(512, 96, (g, w, h) => { g.fillStyle = "rgba(0,0,0,.55)"; g.fillRect(0, 0, w, h); g.fillStyle = col; g.font = "800 50px Inter, sans-serif"; g.textAlign = "center"; g.fillText(text, w / 2, 66); });
134
+ function remoteFor(p) {
135
+ let r = remotes.get(p.id);
136
+ const model = Object.keys(MODELS)[p.model | 0] || "hydra";
137
+ if (r && r.model !== model) { scene.remove(r.root); remotes.delete(p.id); r = null; }
138
+ if (!r) {
139
+ const c = buildCar(model), root = new THREE.Group(); root.add(c.group); c.setReveal(1); c.setThrust(0, 0, 0, 0); c.setWings(0, 0);
140
+ c.group.traverse(o => { if (o.isMesh) o.castShadow = true; });
141
+ const tag = new THREE.Sprite(new THREE.SpriteMaterial({ map: tagTex(p.name), depthTest: false, toneMapped: false })); tag.scale.set(5, .95, 1); tag.position.y = 2.6; root.add(tag);
142
+ const emo = new THREE.Sprite(new THREE.SpriteMaterial({ map: tagTex(""), depthTest: false, toneMapped: false })); emo.scale.set(6, 1.15, 1); emo.position.y = 3.8; emo.visible = false; root.add(emo);
143
+ scene.add(root); r = { root, car: c, tag, emo, model, name: p.name, paint: null, emoT: 0 }; remotes.set(p.id, r);
144
+ }
145
+ if (r.name !== p.name) { r.name = p.name; r.tag.material.map = tagTex(p.name); }
146
+ if (p.paint && r.paint !== p.paint) { r.paint = p.paint; r.car.setPaint(p.paint); }
147
+ return r;
148
+ }
149
+ net.on("change", () => { for (const id of [...remotes.keys()]) if (!net.players().some(p => p.id === id)) { scene.remove(remotes.get(id).root); remotes.delete(id); } renderPlayers(); });
150
+ net.on("status", t => { document.getElementById("gNetStatus").textContent = t; document.getElementById("gNetBtn").classList.toggle("on", net.online()); });
151
+ net.on("mic", on => { const b = document.getElementById("gMic"); b.classList.toggle("on", on); b.textContent = on ? "🎙 Mic on" : "🎙 Voice chat"; });
152
+ net.on("emote", (m, from) => { const r = remotes.get(from), e = EMOTES[m.e | 0]; if (r) { r.emo.material.map = tagTex(e, "#ffd23d"); r.emo.visible = true; r.emoT = 4; } feed(`${net.nameOf(from)}: ${e}`); });
153
+ function feed(t) { const f = document.getElementById("gFeed"); const d = document.createElement("div"); d.textContent = t; f.prepend(d); setTimeout(() => d.remove(), 7000); while (f.children.length > 5) f.lastChild.remove(); }
154
+ function renderPlayers() { document.getElementById("gPlayers").innerHTML = net.online() ? [`<b>${net.name} (you)</b>`, ...net.players().map(p => `<span>${p.vc ? "🎙 " : ""}${p.name}</span>`)].join("") : ""; }
155
+ {
156
+ const $ = id => document.getElementById(id), panel = $("gNetPanel");
157
+ $("gNetName").value = store.get("void.name") || "";
158
+ $("gNetBtn").onclick = () => { panel.hidden = !panel.hidden; };
159
+ $("gNetClose").onclick = () => panel.hidden = true;
160
+ const go = room => { const nm = $("gNetName").value; store.set("void.name", nm); net.join(room, nm); panel.hidden = true; };
161
+ $("gNetPublic").onclick = () => go("public-1");
162
+ $("gNetCreate").onclick = () => { const code = Math.random().toString(36).slice(2, 7); $("gNetCode").value = code; go("room-" + code); toast(`Room code: ${code}. Tell your friends!`); };
163
+ $("gNetJoin").onclick = () => { const code = $("gNetCode").value.trim().toLowerCase(); if (code) go("room-" + code); };
164
+ $("gNetLeave").onclick = () => { net.leave(); panel.hidden = true; };
165
+ $("gMic").onclick = () => net.setMic(!net.mic);
166
+ $("gEmotes").innerHTML = EMOTES.map((e, k) => `<button class="pill" data-e="${k}">${e}</button>`).join("");
167
+ $("gEmotes").onclick = ev => { const b = ev.target.closest("[data-e]"); if (!b || !net.online()) return; net.send({ t: "emote", e: +b.dataset.e }); feed(`You: ${EMOTES[+b.dataset.e]}`); };
168
+ }
169
+ W.setTime(store.get("void.time") || "night");
170
+ // fill the car's reflection cube once before the first frame, so the paint never samples an empty one
171
+
172
+ $("osmCredit").textContent = W.credit;
173
+ // the garage: the Build panel over the game, the game paused underneath
174
+ function openGarage(on) { if (on) renderUpg(); document.body.classList.toggle("garage", on); game.pause(on); if (on && car.repair) { car.repair(); applyBuild(); if (game.state) game.state.hp = 100; } }
175
+ $("gGarageClose").onclick = () => openGarage(false);
176
+ const nozzles = (car.nozzles || [[.9, .3, 1], [.9, .3, -1], [-.95, .38, 1], [-.95, .38, -1]]).map(([x, y, s]) => new THREE.Vector3(x, y - .5, s));
177
+
178
+ // ---------- configurator ----------
179
+ const OPTS = {
180
+ paint: { label: "Paint", items: [["Void Black", "#0a0a0c"], ["Stealth Grey", "#2b2d32"], ["Liquid Silver", "#9fa3aa"], ["Ghost White", "#e9e9ea"], ["Blood Red", "#6f0a12"], ["Ember Orange", "#c9480c"], ["Ion Blue", "#123a8c"], ["Venom Green", "#2d6a1e"], ["Candy Purple", "#4a1270"], ["Sunset Gold", "#b8862a"], ["Pearl Pink", "#e8a6c0"], ["Arctic Teal", "#1f8a8a"], ["Lime Rush", "#8acb1a"], ["Cherry Pop", "#d2163c"], ["Midnight Navy", "#0d1838"], ["Chrome", "#d8dadd"]] },
181
+ finish: { label: "Finish", seg: true, items: [["Gloss", "gloss"], ["Satin", "satin"], ["Matte", "matte"]] },
182
+ rim: { label: "Wheels", items: [["Black", "#121215"], ["Gunmetal", "#3a3d44"], ["Silver", "#b8bcc4"], ["Bronze", "#7a5a32"], ["Gold", "#c9a227"], ["Red", "#b0141f"], ["White", "#e8e8ea"], ["Ion", "#2ad8e8"]] },
183
+ cal: { label: "Calipers", items: [["Red", "#c1121f"], ["Black", "#2a2a30"], ["Yellow", "#e0b000"], ["White", "#e8e8e8"], ["Ion", "#3df5ff"]] },
184
+ trim: { label: "Accents", items: [["Red", "#c1121f"], ["Black", "#16161a"], ["White", "#e8e8e8"], ["Gold", "#b8912e"], ["Ion", "#3df5ff"]] },
185
+ light: { label: "Lights", items: [["Ice", "#e8fbff"], ["Amber", "#ffb347"], ["Ion", "#6ad8ff"], ["Violet", "#b38cff"]] },
186
+ glow: { label: "Underglow", items: [["Off", ""], ["White", "#ffffff"], ["Red", "#ff2233"], ["Ion", "#3df5ff"], ["Violet", "#9b5cff"]] },
187
+ spoiler: { label: "Spoiler", seg: true, items: [["Stock", "none"], ["Ducktail", "ducktail"], ["GT wing", "gt"], ["Swan neck", "swan"], ["Rally", "rally"]] },
188
+ livery: { label: "Livery", seg: true, items: [["Clean", "none"], ["Twin stripes", "stripes"], ["Centre stripe", "center"], ["Side stripe", "side"], ["Race #42", "race"]] },
189
+ livc: { label: "Livery colour", items: [["White", "#f2f2f2"], ["Red", "#c1121f"], ["Black", "#101012"], ["Gold", "#c9a227"], ["Ion", "#3df5ff"], ["Orange", "#ff6a00"]] },
190
+ tint: { label: "Windows", seg: true, items: [["Light", "light"], ["Dark", "dark"], ["Limo", "limo"], ["Mirror", "mirror"]] },
191
+ flame: { label: "Nitro flames", items: [["Blue", "#4fa8ff"], ["Orange", "#ff7a1a"], ["Green", "#3dff6a"], ["Purple", "#b05cff"], ["Pink", "#ff4fd8"]] },
192
+ horn: { label: "Horn", seg: true, items: [["Classic", 0], ["Air horn", 1], ["Tune", 2]] },
193
+ };
194
+ OPTS.model = { label: "Car", seg: true, items: Object.entries(MODELS).map(([k, m]) => [m.name, k]) };
195
+ const DEFAULT = { model: 0, paint: 0, finish: 0, rim: 0, cal: 0, trim: 0, light: 0, glow: 0, spoiler: 0, livery: 0, livc: 0, tint: 1, flame: 0, horn: 0 };
196
+ let build = { ...DEFAULT, ...(store.get("void.build2") || {}), ...(store.get("void.build3") || {}) };
197
+ try { const h = new URLSearchParams(location.hash.slice(1)).get("b"); if (h) { const v = h.split(".").map(Number); Object.keys(DEFAULT).forEach((k, i) => { if (OPTS[k].items[v[i]]) build[k] = v[i]; }); } } catch { }
198
+ function applyBuild() {
199
+ useModel(OPTS.model.items[build.model][1]);
200
+ car.setSpoiler(OPTS.spoiler.items[build.spoiler][1]); car.setLivery(OPTS.livery.items[build.livery][1], OPTS.livc.items[build.livc][1]);
201
+ car.setTint(OPTS.tint.items[build.tint][1]); car.setFlameColor(OPTS.flame.items[build.flame][1]);
202
+ car.setPaint(OPTS.paint.items[build.paint][1]); car.setFinish(OPTS.finish.items[build.finish][1]);
203
+ car.setRim(OPTS.rim.items[build.rim][1]); car.setAccent(OPTS.cal.items[build.cal][1]); car.setTrim(OPTS.trim.items[build.trim][1]); car.setLight(OPTS.light.items[build.light][1]);
204
+ const gl = OPTS.glow.items[build.glow][1]; if (gl) fx.glow.material.color.set(gl).multiplyScalar(1.4);
205
+ store.set("void.build3", build);
206
+ $("sum").innerHTML = `<b>${car.name.toUpperCase()} &middot; ${OPTS.paint.items[build.paint][0]}</b>${OPTS.spoiler.items[build.spoiler][0]} spoiler, ${OPTS.livery.items[build.livery][0].toLowerCase()} livery, ${OPTS.finish.items[build.finish][0]} paint, ${OPTS.rim.items[build.rim][0].toLowerCase()} wheels, ${OPTS.cal.items[build.cal][0].toLowerCase()} calipers, ${OPTS.trim.items[build.trim][0].toLowerCase()} accents, ${OPTS.light.items[build.light][0].toLowerCase()} lights${gl ? ", " + OPTS.glow.items[build.glow][0].toLowerCase() + " underglow" : ""}`;
207
+ for (const b of document.querySelectorAll("#cfgBody button")) b.setAttribute("aria-pressed", String(build[b.dataset.k] === +b.dataset.i));
208
+ for (const k in OPTS) { const n = document.querySelector(`[data-name="${k}"]`); if (n) n.textContent = OPTS[k].items[build[k]][0]; }
209
+ }
210
+ const ORDER = ["model", "paint", "finish", "livery", "livc", "spoiler", "rim", "cal", "trim", "tint", "light", "glow", "flame", "horn"];
211
+ $("cfgBody").innerHTML = `<div id="upgBody"></div>` + ORDER.map(k => [k, OPTS[k]]).map(([k, o]) => `<div class="grp"><div class="grp-h">${o.label}<b data-name="${k}"></b></div><div class="${o.seg ? "seg" : "sw"}">${o.items.map(([n, c], i) => o.seg
212
+ ? `<button data-k="${k}" data-i="${i}">${n}</button>`
213
+ : `<button data-k="${k}" data-i="${i}" title="${n}" aria-label="${o.label}: ${n}" style="background:${c || "repeating-linear-gradient(45deg,#222 0 4px,#111 4px 8px)"}"></button>`).join("")}</div></div>`).join("");
214
+ $("cfgBody").addEventListener("click", e => { const b = e.target.closest("button[data-k]"); if (!b) return; build[b.dataset.k] = +b.dataset.i; applyBuild(); });
215
+ $("reset").onclick = () => { build = { ...DEFAULT, model: build.model }; applyBuild(); toast("Back to black and red"); };
216
+ $("share").onclick = async () => {
217
+ const url = location.origin + location.pathname + "#b=" + Object.keys(DEFAULT).map(k => build[k]).join(".");
218
+ try { await navigator.clipboard.writeText(url); toast("Link to your build copied"); } catch { prompt("Copy your build link", url); }
219
+ };
220
+ applyBuild();
221
+ // ---------- performance upgrades: every point you score is also cash, spent here (kept on this device) ----------
222
+ const UPG = { engine: ["⚙️", "Engine", "More power and top speed"], grip: ["🛞", "Tyres", "Grip in corners, longer drifts"], nitro: ["🔥", "Nitro", "A bigger nitro tank"], armor: ["🛡️", "Armour", "Takes less damage"] };
223
+ const PRICE = [2500, 6000, 15000];
224
+ const upg = Object.assign({ engine: 0, grip: 0, nitro: 0, armor: 0 }, store.get("void.upg") || {});
225
+ let cash = store.get("void.cash") ?? 3000, cashSaveT = 0;
226
+ gameOpts.upg = upg;
227
+ function earn(n) { cash += Math.max(0, Math.round(n)); clearTimeout(cashSaveT); cashSaveT = setTimeout(() => store.set("void.cash", cash), 800); const el = document.getElementById("gCash"); if (el) el.textContent = "$" + cash.toLocaleString(); }
228
+ function renderUpg() {
229
+ $("upgBody").innerHTML = `<div class="grp"><div class="grp-h">Performance<b>$${cash.toLocaleString()}</b></div><div class="upg">${Object.entries(UPG).map(([k, [ic, name, txt]]) => { const lv = upg[k], p = PRICE[lv]; return `<div class="up-row"><b>${ic}</b><div><span>${name}</span><small>${txt}</small><i>${[0, 1, 2].map(i => `<u class="${i < lv ? "on" : ""}"></u>`).join("")}</i></div>${p ? `<button data-u="${k}" ${cash < p ? "disabled" : ""}>$${p.toLocaleString()}</button>` : "<em>MAX</em>"}</div>`; }).join("")}</div><p class="up-note">Every point you score is also cash. Fully upgraded is about 20% faster and takes 40% less damage.</p></div>`;
230
+ }
231
+ $("upgBody").addEventListener("click", e => {
232
+ const b = e.target.closest("button[data-u]"); if (!b) return; const k = b.dataset.u, p = PRICE[upg[k]];
233
+ if (!p || cash < p) return; cash -= p; upg[k]++; store.set("void.cash", cash); store.set("void.upg", upg);
234
+ goals.stats.upg = Object.values(upg).reduce((a, v) => a + v, 0); goals.note(""); earn(0); renderUpg(); if (!sound.on) setSound(true); sound.rev(); toast(`${UPG[k][1]} upgraded to level ${upg[k]}`);
235
+ });
236
+ goals.stats.upg = Object.values(upg).reduce((a, v) => a + v, 0); renderUpg(); earn(0);
237
+ // one bonus a day for coming back
238
+ try { const day = new Date().toDateString(); if (store.get("void.day") !== day) { const first = store.get("void.day") == null; store.set("void.day", day); if (!first) { cash += 2000; store.set("void.cash", cash); setTimeout(() => toast("Daily bonus: $2,000 for upgrades in the Garage"), 2500); } } } catch { }
239
+ let toastT;
240
+ function toast(t) { const el = $("toast"); el.textContent = t; el.classList.add("on"); clearTimeout(toastT); toastT = setTimeout(() => el.classList.remove("on"), 2200); }
241
+
242
+ // ---------- sound ----------
243
+ function setSound(on) { sound.setOn(on); $("snd").setAttribute("aria-pressed", String(on)); $("snd").textContent = on ? "Sound on" : "Sound off"; if (on && mode === "watch" && w.playing) sound.startSong(w.t); }
244
+ $("snd").onclick = () => setSound(!sound.on);
245
+ $("rev").onclick = () => { if (!sound.on) setSound(true); sound.rev(); };
246
+
247
+ // ---------- modes ----------
248
+ let mode = "home";
249
+ const w = { t: 0, playing: false, dragging: false };
250
+ function go(next) {
251
+ if (next === mode) return;
252
+ $("fade").classList.add("on");
253
+ setTimeout(() => {
254
+ if (mode === "play") { game.exit(); openGarage(false); }
255
+ if (mode === "watch") { sound.stopSong(); w.playing = false; }
256
+ mode = next; document.body.dataset.mode = next;
257
+ if (next === "home") scrollTo(0, 0);
258
+ if (next === "watch") { if (!sound.on) setSound(true); playFrom(0); }
259
+ if (next === "play") { game.enter(); if (SET.radio !== "score") sound.setRadio(SET.radio); }
260
+ if (mode !== "play" && sound.radio && sound.radio !== "score") sound.setRadio("score");
261
+ $("fade").classList.remove("on");
262
+ }, 320);
263
+ }
264
+ document.addEventListener("click", e => { const b = e.target.closest("[data-go]"); if (b) { e.preventDefault(); go(b.dataset.go); } });
265
+ $("exit").onclick = () => go("home");
266
+ addEventListener("keydown", e => {
267
+ if (e.code === "Escape" && mode === "play" && !document.body.classList.contains("garage")) { menu(); return; }
268
+ if (e.code === "Escape" && mode !== "home") go("home");
269
+ if (mode === "watch") {
270
+ if (e.code === "Space") { e.preventDefault(); togglePlay(); }
271
+ if (e.code === "ArrowRight") seek(w.t + 4); if (e.code === "ArrowLeft") seek(w.t - 4);
272
+ }
273
+ });
274
+
275
+ // watch player
276
+ function playFrom(t) { w.t = clamp(t, 0, TOTAL); w.playing = true; $("wEnd").classList.remove("on"); if (sound.on) sound.startSong(w.t); setPlayIcon(); }
277
+ function pause() { w.playing = false; sound.stopSong(); setPlayIcon(); }
278
+ function togglePlay() { if (w.playing) pause(); else playFrom(w.t >= TOTAL - .05 ? 0 : w.t); }
279
+ function seek(t) { w.t = clamp(t, 0, TOTAL); if (w.playing) playFrom(w.t); }
280
+ function setPlayIcon() { $("wPlay").innerHTML = w.playing ? "&#10074;&#10074;" : "&#9654;"; $("wPlay").setAttribute("aria-label", w.playing ? "Pause" : "Play"); }
281
+ $("wPlay").onclick = togglePlay;
282
+ $("wAgain").onclick = () => playFrom(0);
283
+ const scrub = $("wScrub"); scrub.max = TOTAL;
284
+ scrub.addEventListener("input", () => { w.dragging = true; w.t = +scrub.value; if (w.playing) { sound.stopSong(); } });
285
+ scrub.addEventListener("change", () => { w.dragging = false; if (w.playing) playFrom(+scrub.value); });
286
+ $("wTicks").innerHTML = CHAPTERS.filter(c => c[1]).map(c => `<button style="left:${c[0] * BAR / TOTAL * 100}%" data-t="${c[0] * BAR}">${c[1]}</button>`).join("");
287
+ $("wTicks").addEventListener("click", e => { const b = e.target.closest("button"); if (b) { seek(+b.dataset.t); if (!w.playing) playFrom(+b.dataset.t); } });
288
+ const fmt = s => `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, "0")}`;
289
+
290
+ // drag to turn the car on the home and build screens
291
+ const orbit = { a: .7, v: 0, drag: false, x: 0 };
292
+ addEventListener("pointerdown", e => { if ((mode !== "build" && mode !== "home") || e.target !== $("gl") && !e.target.closest(".drag-hint, #buildUI") || e.target.closest(".cfg, button")) return; orbit.drag = true; orbit.x = e.clientX; });
293
+ addEventListener("pointermove", e => { if (!orbit.drag) return; orbit.v = (e.clientX - orbit.x) * -.006; orbit.a += orbit.v; orbit.x = e.clientX; });
294
+ addEventListener("pointerup", () => { orbit.drag = false; });
295
+
296
+ // ---------- resize: ignore the phone address bar sliding, follow rotation and folding ----------
297
+ let lastW = 0, lastH = 0;
298
+ function resize() {
299
+ const ww = innerWidth, hh = Math.max(innerHeight, document.documentElement.clientHeight);
300
+ if (!ww || !hh) return;
301
+ if (ww === lastW && Math.abs(hh - lastH) < 140 && lastW) return;
302
+ lastW = ww; lastH = hh; renderer.setSize(ww, hh, false); composer.setSize(ww, hh);
303
+ bloom.resolution.set(Math.max(1, ww * W.bloomRes), Math.max(1, hh * W.bloomRes)); camera.aspect = ww / hh;
304
+ }
305
+ addEventListener("resize", resize); addEventListener("orientationchange", () => setTimeout(resize, 200));
306
+ if (window.visualViewport) visualViewport.addEventListener("resize", resize);
307
+ resize();
308
+ const fovFor = f => { const a = camera.aspect; if (a >= 1.5) return f; const h = 2 * Math.atan(Math.tan(f * Math.PI / 360) * 1.5); return Math.min(88, 2 * Math.atan(Math.tan(h / 2) / a) * 180 / Math.PI); };
309
+
310
+ // ---------- the showroom pose (home and build) ----------
311
+ const showFr = frame(); W.track.sample(W.track.D[W.track.idxX(0)], showFr);
312
+ const intro = { t: -1 }; // the car drives in once the loader lifts
313
+ function showroom(dt, time) {
314
+ let introX = 0, introV = 0;
315
+ if (intro.t >= 0 && intro.t < 3.2) { intro.t += dt; const u = Math.min(1, intro.t / 3.2); introX = -46 * Math.pow(1 - u, 3); introV = 46 * 3 * Math.pow(1 - u, 2) / 3.2; }
316
+ else if (intro.t < 0) introX = -46;
317
+ if (!orbit.drag) { orbit.v *= .94; orbit.a += orbit.v + (REDUCED ? 0 : dt * (mode === "home" ? .16 : .1)); }
318
+ const hf = 2 * Math.atan(Math.tan(fovFor(38) * Math.PI / 360) * camera.aspect), fit = 3.1 / Math.tan(hf / 2); // fit the whole car across the screen
319
+ const scrolled = mode === "home" ? clamp(scrollY / innerHeight) : 0, dist = Math.max(mode === "build" ? 8.8 : 8.2, fit) + scrolled * 2;
320
+ const cam = { pos: new THREE.Vector3(Math.cos(orbit.a) * dist, 1.5 + scrolled * 4, Math.sin(orbit.a) * dist), look: new THREE.Vector3(0, .5 - scrolled * .4, 0), fov: 38 };
321
+ if (camera.aspect < 1) cam.look.y = mode === "build" ? -1.1 : -.2;
322
+ else if (mode === "build") { const right = new THREE.Vector3().subVectors(cam.look, cam.pos).cross(new THREE.Vector3(0, 1, 0)).normalize(); cam.look.addScaledVector(right, 1.7); }
323
+ const pos = showFr.p.clone(); pos.x += introX; const fr = { ...showFr, p: pos };
324
+ if (introX < -.01) cam.look.x = Math.max(introX * .35, -8);
325
+ return { pos, quat: new THREE.Quaternion(), fr, speed: introV * 3.6, g: 1, alt: 0, vs: 0, thrust: { power: 0, angle: 0, deploy: 0 }, wings: 0, air: false, cam, inside: false, screenOn: false, reveal: 1, rpm: 900, gear: 1, load: .1, engine: .6, mode: "PARK", zones: [] };
326
+ }
327
+
328
+ // ---------- per frame ----------
329
+ const clock = new THREE.Clock();
330
+ let lastGauge = 0, lastChips = 0, cycleT = 0;
331
+ // the speedometer: a dial with a glowing arc, the speed, the gear (or altitude when flying) and what you're in
332
+ const gauge = document.getElementById("gGauge"), gx = gauge.getContext("2d");
333
+ function drawGauge(S) {
334
+ const W2 = gauge.width, c = W2 / 2, r = c - 22, a0 = Math.PI * .75, a1 = Math.PI * 2.25, max = S.veh === "plane" ? 600 : S.veh === "boat" ? 140 : 360, f = Math.min(1, S.speed / max);
335
+ gx.clearRect(0, 0, W2, W2);
336
+ gx.beginPath(); gx.arc(c, c, r + 14, 0, 7); gx.fillStyle = "rgba(6,8,14,.62)"; gx.fill();
337
+ gx.lineCap = "round"; gx.lineWidth = 14; gx.beginPath(); gx.arc(c, c, r, a0, a1); gx.strokeStyle = "rgba(255,255,255,.12)"; gx.stroke();
338
+ const grd = gx.createLinearGradient(0, W2, W2, 0); grd.addColorStop(0, "#3df5ff"); grd.addColorStop(.6, "#ffffff"); grd.addColorStop(1, "#ff2a3a");
339
+ gx.beginPath(); gx.arc(c, c, r, a0, a0 + (a1 - a0) * f); gx.strokeStyle = grd; gx.shadowColor = "#3df5ff"; gx.shadowBlur = 16; gx.stroke(); gx.shadowBlur = 0;
340
+ gx.lineWidth = 2; gx.strokeStyle = "rgba(255,255,255,.5)"; for (let k = 0; k <= 12; k++) { const a = a0 + (a1 - a0) * k / 12, i = r - 18, o = r - (k % 3 ? 24 : 30); gx.beginPath(); gx.moveTo(c + Math.cos(a) * i, c + Math.sin(a) * i); gx.lineTo(c + Math.cos(a) * o, c + Math.sin(a) * o); gx.stroke(); }
341
+ gx.fillStyle = "#fff"; gx.textAlign = "center"; gx.font = `900 ${W2 * .22}px Unbounded, Inter, sans-serif`; gx.fillText(Math.round(S.speed), c, c + W2 * .06);
342
+ gx.font = `700 ${W2 * .055}px Inter, sans-serif`; gx.fillStyle = "rgba(255,255,255,.6)"; gx.fillText("KM/H", c, c + W2 * .14);
343
+ gx.font = `800 ${W2 * .07}px Unbounded, Inter, sans-serif`; gx.fillStyle = S.air ? "#3df5ff" : "#ffd23d";
344
+ gx.fillText(S.air || S.veh === "plane" || S.veh === "heli" ? `${Math.round(S.alt)} m` : S.veh === "boat" ? "BOAT" : `GEAR ${S.gear}`, c, c + W2 * .3);
345
+ if (S.nitro > .1) { gx.font = `800 ${W2 * .05}px Inter, sans-serif`; gx.fillStyle = "#3df5ff"; gx.fillText("NITRO", c, c - W2 * .16); }
346
+ }
347
+ let wasWrecked = false, wreckPose = null; const wrecks = [];
348
+ let fpsNow = 0;
349
+ const perf = { t: 0, n: 0, pr: renderer.getPixelRatio(), max: renderer.getPixelRatio(), down: 0 };
350
+ applySettings();
351
+ let lastHud = 0, prevGear = 1, feedFlip = 0;
352
+ function frameLoop(fixed) {
353
+ const raw = fixed ? 0 : clock.getDelta(), dt = fixed || Math.min(.05, raw), time = clock.elapsedTime;
354
+ // adaptive resolution: drop the pixel count when frames run slow, bring it back when there is headroom
355
+ if (!fixed && raw < .5) {
356
+ perf.t += raw; perf.n++;
357
+ if (perf.t > 1.5) {
358
+ const avg = perf.t / perf.n, was = perf.pr; fpsNow = Math.round(1 / avg); const fe = document.getElementById("gFps"); if (fe) fe.textContent = fpsNow + " fps";
359
+ if (avg > 1 / 25 && mode === "play" && SET.q !== "low") perf.down = 3; // very slow: skip straight to a lower level
360
+ if (avg > 1 / 45 && perf.pr > .6 && perf.down < 3) perf.pr = Math.max(.6, perf.pr - .12);
361
+ else if (avg > 1 / 40 && mode === "play" && ++perf.down >= 3 && SET.q !== "low") { // still slow at the lowest resolution: drop a quality level
362
+ perf.down = 0; SET.q = { ultra: "high", high: "medium", medium: "low" }[SET.q]; perf.pr = W.QUALITY[SET.q].pr; applySettings(false); toast(`Graphics set to ${SET.q} to keep it smooth`);
363
+ }
364
+ else if (avg < 1 / 58 && perf.pr < perf.max) perf.pr = Math.min(perf.max, perf.pr + .08);
365
+ if (perf.pr !== was) { renderer.setPixelRatio(perf.pr); composer.setPixelRatio(perf.pr); lastW = 0; resize(); }
366
+ perf.t = perf.n = 0;
367
+ }
368
+ }
369
+ let S;
370
+ if (mode === "watch") {
371
+ if (w.playing && !w.dragging) {
372
+ const st = sound.on ? sound.songTime() : null;
373
+ w.t = st != null ? st : w.t + dt;
374
+ if (w.t >= TOTAL) { w.t = TOTAL; pause(); $("wEnd").classList.add("on"); }
375
+ }
376
+ S = watch.at(w.t, time, camera.aspect, fovFor);
377
+ if (!w.dragging) scrub.value = w.t;
378
+ scrub.style.setProperty("--p", (w.t / TOTAL * 100) + "%");
379
+ $("wTime").textContent = `${fmt(w.t)} / ${fmt(TOTAL)}`;
380
+ const ch = S.chapter, cap = $("wCap");
381
+ if (cap.dataset.ch !== ch[1]) { cap.dataset.ch = ch[1]; cap.classList.add("hide"); setTimeout(() => { $("wNum").textContent = ch[1] ? String(CHAPTERS.indexOf(ch) + 1).padStart(2, "0") : ""; $("wTitle").textContent = ch[1]; $("wSub").textContent = ch[2]; cap.classList.toggle("hide", !ch[1]); }, 250); }
382
+ $("telem").style.opacity = S.bar > 2 && !S.inside && S.bar < 17.5 ? 1 : 0;
383
+ $("tSpd").textContent = Math.round(S.speed); $("tG").textContent = S.g.toFixed(1); $("tAlt").textContent = Math.round(S.alt);
384
+ $("dream").style.opacity = S.dream; $("fade").style.opacity = S.fade;
385
+ } else if (mode === "play") S = game.update(dt, time, camera.aspect);
386
+ else S = showroom(dt, time);
387
+ life.update(dt, time, mode === "play" ? S.player : null, camera.position);
388
+ if (mode === "play") {
389
+ police.update(dt, time); races.update(dt, time); nav.update();
390
+ const st = game.state, stars = police.stars;
391
+ document.getElementById("gStars").textContent = stars ? "★".repeat(stars) + "☆".repeat(5 - stars) : "";
392
+ document.getElementById("gStars").classList.toggle("bust", police.bust > .5);
393
+ const pr = races.progress();
394
+ net.tick(dt, { p: [st.x, st.y, st.z, st.yaw, st.pitch, st.roll].map(v => Math.round(v * 100) / 100), m: Object.keys(MODELS).indexOf(car.model), c: OPTS.paint.items[build.paint][1], v: Math.round(S.speed), a: S.air ? 1 : 0, r: pr ? pr.race : 0, rp: pr ? pr.rp : 0, rf: pr ? pr.rf : 0, w: stars });
395
+ for (const p of net.players()) {
396
+ const at = net.sample(p); const r = remoteFor(p); r.at = at;
397
+ if (!at || at.stale) { r.root.visible = false; continue; }
398
+ r.root.visible = true; r.root.position.set(at.x, at.y, at.z); r.root.rotation.set(0, -at.yaw, 0); r.car.group.rotation.set(at.roll, 0, at.pitch, "XYZ");
399
+ r.car.setThrust(at.air ? .6 : 0, at.air && at.v > 90 ? 1 : 0, at.air ? 1 : 0, time); r.car.setWings(at.air && at.v > 100 ? 1 : 0, time);
400
+ for (const wh of r.car.wheels) wh.rotation.z -= at.v / 3.6 * dt / .37;
401
+ if (r.emoT > 0 && (r.emoT -= dt) <= 0) r.emo.visible = false;
402
+ const dx = st.x - at.x, dz = st.z - at.z, d = Math.hypot(dx, dz);
403
+ net.setVolume(p.id, 1 - d / 260);
404
+ if (d < 3.4 && d > .01 && Math.abs(st.y - at.y) < 2) { st.x += dx / d * (3.4 - d) * .5; st.z += dz / d * (3.4 - d) * .5; st.vel.multiplyScalar(.9); }
405
+ }
406
+ } else { for (const r of remotes.values()) r.root.visible = false; net.tick(dt, null); } // the host keeps relaying from the menus
407
+ W.city.update(time, camera.position);
408
+ W.follow(S.pos);
409
+ if (mode !== "watch") $("fade").style.opacity = "";
410
+
411
+ // the car, or the plane / helicopter / boat
412
+ const veh = mode === "play" ? S.veh || "car" : "car";
413
+ carRoot.visible = veh === "car";
414
+ vehicles.show(veh === "car" ? null : veh, S.pos, S.quat, S, time, dt);
415
+ if (S.splash) for (let k = 0; k < 6; k++) { const pf = fx.puffs[fx.puffI++ % fx.puffs.length]; pf.s.position.copy(S.pos).add(new THREE.Vector3((Math.random() - .5) * 3, .3, (Math.random() - .5) * 3)); pf.life = 1; pf.s.visible = true; pf.grow = .8; pf.s.scale.setScalar(.8); pf.s.material.color.set(0xeaf6ff); pf.v.set((Math.random() - .5) * 6, 4 + Math.random() * 4, (Math.random() - .5) * 6); }
416
+ if (veh === "boat" && S.speed > 12 && Math.random() < .6) { const back = new THREE.Vector3(-3.6, .1, (Math.random() - .5) * 2).applyQuaternion(S.quat).add(S.pos); const pf = fx.puffs[fx.puffI++ % fx.puffs.length]; pf.s.position.copy(back); pf.life = 1; pf.s.visible = true; pf.grow = .5; pf.s.scale.setScalar(.5); pf.s.material.color.set(0xf4fbff); pf.v.set((Math.random() - .5) * 2, .6, (Math.random() - .5) * 2); }
417
+ const night = W.timeOfDay !== "day";
418
+ heads.intensity = night && veh === "car" ? (W.timeOfDay === "night" ? 260 : 120) : 0;
419
+ W.sky.position.copy(camera.position); W.grade.uniforms.time.value = time % 100;
420
+ W.grade.uniforms.blur.value = mode === "play" ? Math.max(0, Math.min(1, (S.speed - 160) / 220)) * .9 + (S.nitro || 0) * .5 : 0;
421
+ atmos.update(dt, time, S, mode === "play" ? game.state : null);
422
+ W.city.poolMat.opacity = W.timeOfDay === "night" ? 1 : W.timeOfDay === "sunset" ? .45 : 0; W.city.poolMat.visible = W.timeOfDay !== "day";
423
+ extras.sky(dt, time);
424
+ // the living city: when switched on, the day turns and the weather changes on its own
425
+ if (SET.cycle === "on" && mode === "play" && (cycleT += dt) > 150) { cycleT = 0; cycleTime(); if (Math.random() < .5) { const w = ["clear", "clear", "rain", "fog", "storm", "snow"][Math.floor(Math.random() * 6)]; atmos.setWeather(w); SET.weather = w; } }
426
+ if (mode === "play") { extras.update(dt, time); goals.stats.coins = extras.coins().got; goals.update(dt, game.state, S.speed); if (time - lastChips > 2) { lastChips = time; chips(); } }
427
+ if (mode === "play" && time - lastGauge > .05) { lastGauge = time; drawGauge(S); const fu = document.getElementById("gFuel"); if (fu && S.fuel != null) { fu.style.setProperty("--v", S.fuel); fu.classList.toggle("low", S.fuel < .2); } }
428
+ car.group.position.copy(S.pos); car.group.quaternion.copy(S.quat);
429
+ car.setReveal(S.reveal);
430
+ car.setThrust(S.thrust.power, S.thrust.angle, S.thrust.deploy, time);
431
+ car.setFlame(S.nitro || 0, time);
432
+ // damage: dent the model where it was hit; a destroyed car is left where it crashed and a fresh one is built for you
433
+ const gs = mode === "play" ? game.state : null;
434
+ if (gs && gs.impacts && gs.impacts.length && car.damage) { carRoot.updateMatrixWorld(true); for (const im of gs.impacts.splice(0)) car.damage(carRoot.worldToLocal(new THREE.Vector3(im.x, im.y, im.z)), im.p); }
435
+ if (S.wrecked && !wasWrecked) { car.wreck && car.wreck(); wreckPose = { p: carRoot.position.clone(), q: carRoot.quaternion.clone() }; }
436
+ if (!S.wrecked && wasWrecked && wreckPose && inner) {
437
+ const wg = inner.group; carRoot.remove(wg); wg.position.copy(wreckPose.p); wg.quaternion.copy(wreckPose.q); scene.add(wg);
438
+ wrecks.push({ g: wg, t: 30 }); if (wrecks.length > 4) { const o = wrecks.shift(); scene.remove(o.g); }
439
+ useModel(car.model, true); applyBuild(); wreckPose = null;
440
+ }
441
+ wasWrecked = !!S.wrecked;
442
+ for (const w of wrecks) { w.t -= dt; if (Math.random() < .25 && w.t > 10) { const pf = fx.puffs[fx.puffI++ % fx.puffs.length]; pf.s.position.copy(w.g.position).add(new THREE.Vector3((Math.random() - .5) * 2, 1, (Math.random() - .5) * 2)); pf.life = 1; pf.s.visible = true; pf.grow = .6; pf.s.scale.setScalar(.6); pf.s.material.color.set(0x2a2a2a); pf.v.set(0, 2, 0); } }
443
+ for (let k = wrecks.length - 1; k >= 0; k--) if (wrecks[k].t <= 0) { scene.remove(wrecks[k].g); wrecks.splice(k, 1); }
444
+ car.setWings(S.wings, time);
445
+ const roll = S.speed / 3.6 * dt / .37;
446
+ for (const wh of car.wheels) wh.rotation.z -= S.air ? roll * .15 : roll;
447
+ car.group.updateMatrixWorld(true);
448
+
449
+ // shadow, underglow, exhaust, speed lines
450
+ const fr = S.fr, ground = clamp(1 - S.pos.y / 3) * (fr.u.y > .8 ? 1 : 0);
451
+ fx.shadow.position.set(S.pos.x, S.pos.y > .5 ? .07 : S.pos.y + .07, S.pos.z); fx.shadow.material.opacity = veh === "car" ? ground : 0; fx.shadow.rotation.z = Math.atan2(-fr.f.z, fr.f.x);
452
+ const glowOn = !!OPTS.glow.items[build.glow][1];
453
+ fx.glow.position.copy(fx.shadow.position).y += .01; fx.glow.rotation.z = fx.shadow.rotation.z; fx.glow.material.opacity = glowOn ? ground * .85 : 0;
454
+ if (S.thrust.power > .3) for (const n of nozzles) if (Math.random() < .18) {
455
+ const pf = fx.puffs[fx.puffI++ % fx.puffs.length], wp = n.clone().applyMatrix4(car.group.matrixWorld);
456
+ pf.s.position.copy(wp); pf.life = 1; pf.s.visible = true; pf.s.scale.setScalar(.4); pf.grow = .4; pf.s.material.color.set(0xc8d2e1);
457
+ pf.v.copy(fr.u).multiplyScalar(-(1 - S.thrust.angle) * 7).addScaledVector(fr.f, -S.thrust.angle * 9 - S.speed / 3.6 * .2).add(new THREE.Vector3(Math.random() - .5, Math.random() - .5, Math.random() - .5).multiplyScalar(1.5));
458
+ }
459
+ const emit = (p, v, col, size, life = 1) => { const pf = fx.puffs[fx.puffI++ % fx.puffs.length]; pf.s.position.copy(p); pf.life = life; pf.s.visible = true; pf.s.scale.setScalar(size); pf.s.material.color.set(col); pf.v.copy(v); pf.grow = size; };
460
+ if (mode === "play" && S.hp != null) {
461
+ const eng = new THREE.Vector3(-1.2, .9, 0).applyMatrix4(car.group.matrixWorld);
462
+ if (S.hp < 55 && !S.wrecked && Math.random() < (S.hp < 25 ? .5 : .2)) emit(eng, new THREE.Vector3((Math.random() - .5), 1.5 + Math.random(), (Math.random() - .5)), S.hp < 25 ? 0x222222 : 0x9a9a9a, .5);
463
+ if (S.hp < 20 && !S.wrecked && Math.random() < .35) emit(eng, new THREE.Vector3(0, 2.5, 0), 0xff7a1a, .35, .5);
464
+ if (S.sparks > .5) for (let k = 0; k < 4; k++) emit(S.pos.clone().add(new THREE.Vector3(0, .5, 0)), new THREE.Vector3((Math.random() - .5) * 12, Math.random() * 6, (Math.random() - .5) * 12), 0xffd27a, .12, .35);
465
+ if (S.boom > .95) for (let k = 0; k < 40; k++) emit(S.pos.clone().add(new THREE.Vector3(0, 1, 0)), new THREE.Vector3((Math.random() - .5) * 18, Math.random() * 14, (Math.random() - .5) * 18), k % 3 ? 0xff7a1a : 0x333333, 1.2, 1.4);
466
+ }
467
+ for (const pf of fx.puffs) if (pf.life > 0) {
468
+ pf.life -= dt * .9; pf.s.position.addScaledVector(pf.v, dt); pf.v.multiplyScalar(.97);
469
+ pf.s.scale.setScalar((pf.grow || .4) + (1 - pf.life) * 4.5); pf.s.material.opacity = Math.max(0, pf.life) * .5; if (pf.life <= 0) pf.s.visible = false;
470
+ }
471
+ const lineA = smooth(240, 320, S.speed) * (S.inside ? 0 : 1);
472
+ fx.lines.material.opacity = lineA * .08;
473
+ if (lineA > .01) {
474
+ const d = new THREE.Object3D();
475
+ for (let i = 0; i < fx.LINES; i++) {
476
+ const sd = fx.lineSeed[i]; sd[0] -= S.speed / 3.6 * dt * 1.6; if (sd[0] < -40) sd[0] += 80;
477
+ d.position.copy(fr.p).addScaledVector(fr.f, sd[0]).addScaledVector(fr.u, sd[1]).addScaledVector(fr.s, sd[2]); d.quaternion.copy(S.quat); d.scale.set(1.5 + S.speed * .018, 1, 1);
478
+ d.updateMatrix(); fx.lines.setMatrixAt(i, d.matrix);
479
+ }
480
+ fx.lines.instanceMatrix.needsUpdate = true;
481
+ }
482
+
483
+ // the front seat and its screens
484
+ if (S.screenOn) {
485
+ if (!COARSE || (feedFlip++ & 1)) interior.renderFeed(scene);
486
+ if (time - lastHud > .1) {
487
+ lastHud = time;
488
+ const hud = { time, speed: S.speed, alt: S.alt, vs: S.vs, mode: S.mode, zones: S.zones, gear: S.gear, rpm: S.rpm };
489
+ interior.drawHud(hud); interior.drawCluster(hud);
490
+ }
491
+ }
492
+ interior.wheel.rotation.x = 0;
493
+
494
+ // camera
495
+ const c = S.cam, shake = REDUCED ? 0 : (Math.max(0, S.g - 2) * .004 + S.thrust.power * .01 + (S.shake || 0) * .25 + (S.nitro || 0) * .02) * (S.inside ? .25 : 1);
496
+ camera.position.copy(c.pos).add(new THREE.Vector3(Math.sin(time * 53) * shake, Math.sin(time * 61 + 1) * shake, Math.sin(time * 47 + 2) * shake));
497
+ camera.up.copy(c.up || new THREE.Vector3(0, 1, 0)); camera.lookAt(c.look);
498
+ camera.fov = fovFor(c.fov); camera.near = S.inside || S.screenOn ? .06 : .35; camera.updateProjectionMatrix();
499
+ camLight.position.copy(camera.position).add(new THREE.Vector3(0, 3, 0)); camLight.target.position.copy(S.pos);
500
+ scene.fog.far = lerp(950, 2600, smooth(20, 160, S.alt)) * W.weatherFog; scene.fog.near = lerp(120, 400, smooth(20, 160, S.alt)) * W.weatherFog;
501
+ const DET = { low: .55, medium: .8, high: 1, ultra: 1.2 }[W.quality] || 1; life.detail = DET; W.city.detail = DET;
502
+ scene.fog.far *= Math.min(1, DET + .2); camera.far = scene.fog.far * 1.1 + 150; camera.updateProjectionMatrix(); // nothing past the fog gets drawn
503
+ // refresh the car's reflections every few frames (the car hides from its own camera)
504
+ // (no shadows, no crowds, a short view: it only has to look right in the paint)
505
+
506
+
507
+ // the car's own sound
508
+ if (S.gear > prevGear && !S.air && S.speed > 20) sound.pop();
509
+ prevGear = S.gear;
510
+ sound.car({ rpm: S.rpm, load: S.load, engine: mode === "build" || mode === "home" ? .4 : S.engine, thrust: S.thrust.power, speed: S.speed, inside: S.inside });
511
+
512
+ composer.render();
513
+ }
514
+
515
+ setLoad(95);
516
+ renderer.compile(scene, camera);
517
+ let raf;
518
+ let frameErr = 0;
519
+ const loop = () => { raf = requestAnimationFrame(loop); try { frameLoop(); } catch (e) { if (frameErr++ < 3) console.error(e); } }; // one bad frame never stops the game
520
+ loop();
521
+ setLoad(100);
522
+ setTimeout(() => { $("loader").classList.add("done"); setTimeout(() => { intro.t = 0; if (sound.on) sound.rev(); }, 450); }, 900);
523
+ document.addEventListener("visibilitychange", () => {
524
+ if (document.hidden) { cancelAnimationFrame(raf); if (mode === "watch" && w.playing) pause(); if (sound.ctx) sound.ctx.suspend(); }
525
+ else { clock.getDelta(); loop(); if (sound.on && sound.ctx) sound.ctx.resume(); }
526
+ });
527
+ window.VOID = { step: (n = 1, dt = 1 / 30) => { for (let i = 0; i < n; i++) frameLoop(dt); }, W, car, life, carCube, carEnv, get police() { return police; }, get races() { return races; }, get nav() { return nav; }, net, orbit, go, seek: t => { w.t = t; if (w.playing) playFrom(t); }, pause, get w() { return w; }, game }; // handy for testing in the console
static/style.css CHANGED
@@ -1,396 +1,408 @@
1
- /* VOID: matte black, white type, one clear thing per screen */
2
- :root {
3
- --bg: #10131b; --ink: #f6f7fa; --mute: #a3a8b6; --dim: #5a6070; --line: rgba(255,255,255,.18);
4
- --panel: rgba(40,46,62,.55); --ok: #3dff8a; --bad: #ff4455;
5
- --wide: "Unbounded", "Inter", system-ui, sans-serif; --body: "Inter", system-ui, sans-serif;
6
- --pad: clamp(16px, 4vw, 40px); --top: env(safe-area-inset-top); --bot: env(safe-area-inset-bottom);
7
- }
8
- * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
9
- html { background: var(--bg); }
10
- body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
11
- button { font: inherit; color: inherit; cursor: pointer; }
12
- a { color: inherit; text-decoration: none; }
13
- kbd { font: 600 12px var(--body); border: 1px solid rgba(255,255,255,.3); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }
14
- [hidden] { display: none !important; }
15
-
16
- #gl { position: fixed; left: 0; top: 0; width: 100%; height: 100vh; height: 100lvh; display: block; z-index: 0; touch-action: pan-y; }
17
- body:not([data-mode="home"]) #gl { touch-action: none; }
18
- #grain { position: fixed; inset: -50%; z-index: 1; pointer-events: none; opacity: .05;
19
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
20
- animation: grain 1.2s steps(6) infinite; }
21
- @keyframes grain { 0% { transform: translate(0,0) } 33% { transform: translate(-3%,2%) } 66% { transform: translate(2%,-3%) } 100% { transform: translate(0,0) } }
22
- #fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 6; transition: opacity .35s; }
23
- #fade.on { opacity: 1; }
24
-
25
- /* loader */
26
- #loader { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 22px; transition: opacity .8s ease, visibility .8s; }
27
- #loader.done { opacity: 0; visibility: hidden; }
28
- .ld-word { font: 900 clamp(64px, 16vw, 180px)/1 var(--wide); letter-spacing: .04em; display: flex; }
29
- .ld-word span { display: inline-block; color: transparent; -webkit-text-stroke: 1.5px rgba(255,255,255,.55); animation: ldIn .9s cubic-bezier(.2,.8,.2,1) both; }
30
- .ld-word span:nth-child(2) { animation-delay: .08s } .ld-word span:nth-child(3) { animation-delay: .16s } .ld-word span:nth-child(4) { animation-delay: .24s }
31
- @keyframes ldIn { from { opacity: 0; transform: translateY(40%); } }
32
- .ld-bar { width: min(260px, 60vw); height: 2px; background: var(--line); overflow: hidden; }
33
- .ld-bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .25s ease; }
34
- .ld-pct { font: 500 12px var(--wide); color: var(--mute); letter-spacing: .2em; }
35
-
36
- /* nav: the same three things everywhere */
37
- #nav { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: calc(14px + var(--top)) var(--pad) 14px; }
38
- .logo { font: 900 20px var(--wide); letter-spacing: .12em; background: none; border: 0; padding: 0; }
39
- .credit { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600; color: #d6d6dc; }
40
- .right { margin-left: auto; display: flex; gap: 10px; }
41
- #exit { display: none; padding: 8px 14px; }
42
- body:not([data-mode="home"]) #exit { display: inline-block; }
43
- .pill { border: 1px solid rgba(255,255,255,.28); background: rgba(0,0,0,.35); border-radius: 999px; padding: 9px 16px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; transition: background .2s, color .2s, border-color .2s; white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
44
- .pill:hover { border-color: #fff; }
45
- .pill.solid, .pill[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
46
-
47
- /* home */
48
- #page { position: relative; z-index: 2; }
49
- body:not([data-mode="home"]) #page { display: none; }
50
- body:not([data-mode="home"]) { overflow: hidden; }
51
- #home { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: space-between; padding: calc(84px + var(--top)) var(--pad) calc(28px + var(--bot)); }
52
- .home-copy { text-align: center; }
53
- .kicker { font: 500 11px var(--wide); letter-spacing: .36em; color: var(--mute); text-transform: uppercase; }
54
- .mega { font: 900 clamp(84px, 20vw, 280px)/.86 var(--wide); letter-spacing: -.02em; margin: 12px 0 8px;
55
- background: linear-gradient(180deg, #fff 0%, #c9c9cf 55%, rgba(255,255,255,.08) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
56
- .lede { color: #b9b9c1; font-size: clamp(15px, 1.6vw, 19px); margin: 0; }
57
- .choices { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; width: min(860px, 100%); margin: 0 auto; }
58
- .choice { text-align: left; padding: 18px 20px; border-radius: 18px; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: border-color .2s, transform .15s; }
59
- .choice:hover { border-color: rgba(255,255,255,.5); transform: translateY(-2px); }
60
- .choice b { display: block; font: 800 clamp(18px, 2.2vw, 24px) var(--wide); }
61
- .choice span { display: block; font-size: 13px; color: var(--mute); margin-top: 4px; }
62
- .choice.main { background: #fff; color: #000; border-color: #fff; }
63
- .choice.main span { color: #444; }
64
- .more { align-self: center; margin-top: 16px; font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--mute); }
65
- .more::after { content: " \2193"; }
66
-
67
- #specs { background: linear-gradient(180deg, transparent, rgba(5,5,6,.8) 18%, var(--bg) 45%); }
68
- .specs-wrap { padding: 18vh var(--pad) 8vh; max-width: 1200px; margin: 0 auto; }
69
- .sec-label { font: 500 11px var(--wide); letter-spacing: .28em; text-transform: uppercase; color: var(--mute); margin-bottom: 16px; }
70
- h2 { font: 800 clamp(28px, 4.6vw, 60px)/1.04 var(--wide); letter-spacing: -.01em; margin: 0 0 14px; }
71
- .specs-title { margin-bottom: 40px; }
72
- .specs { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
73
- .specs div { padding: 26px 16px 26px 0; border-bottom: 1px solid var(--line); }
74
- .specs b { display: block; font: 800 clamp(32px, 4.2vw, 56px)/1 var(--wide); letter-spacing: -.02em; }
75
- .specs small { font-size: .42em; color: var(--mute); margin-left: 4px; }
76
- .specs span { display: block; margin-top: 10px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); }
77
- footer { padding: 36px var(--pad) calc(36px + var(--bot)); max-width: 1200px; margin: 0 auto; border-top: 1px solid var(--line); display: flex; gap: 32px; align-items: flex-start; }
78
- .foot-logo { font: 900 44px/1 var(--wide); letter-spacing: .06em; color: transparent; -webkit-text-stroke: 1px rgba(255,255,255,.5); }
79
- footer p { margin: 0; color: var(--mute); font-size: 13px; max-width: 70ch; }
80
- footer b, footer a { color: var(--ink); }
81
-
82
- /* modes */
83
- .mode { position: fixed; inset: 0; z-index: 10; pointer-events: none; display: none; }
84
- body[data-mode="watch"] #watchUI, body[data-mode="play"] #playUI, body[data-mode="build"] #buildUI { display: block; }
85
- .mode button, .mode input, .mode aside, .mode .g-card { pointer-events: auto; }
86
-
87
- /* watch */
88
- .cap { position: absolute; left: var(--pad); bottom: calc(96px + var(--bot)); width: min(440px, calc(100% - 2 * var(--pad))); transition: opacity .4s ease, transform .4s ease; }
89
- .cap.hide { opacity: 0; transform: translateY(12px); }
90
- .cap .num { font: 500 11px var(--wide); letter-spacing: .3em; color: var(--mute); margin-bottom: 6px; }
91
- .cap h2 { font-size: clamp(28px, 4vw, 52px); margin: 0 0 6px; }
92
- .cap p { margin: 0; color: #b6b6bf; text-shadow: 0 1px 12px #000; }
93
- .telem { position: absolute; right: var(--pad); bottom: calc(96px + var(--bot)); display: flex; gap: 22px; transition: opacity .4s; }
94
- .telem div { display: grid; justify-items: end; }
95
- .telem span, .g-stats span { font: 500 10px var(--wide); letter-spacing: .22em; text-transform: uppercase; color: var(--mute); }
96
- .telem b { font: 800 clamp(24px, 3.4vw, 42px)/1.05 var(--wide); font-variant-numeric: tabular-nums; }
97
- .telem i, .g-stats i { font-style: normal; font-size: 11px; color: var(--mute); }
98
- .dream { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 0 20px; opacity: 0; background: radial-gradient(closest-side, rgba(0,0,0,.55), rgba(0,0,0,.85)); }
99
- .dream .d0 { font: 600 12px var(--wide); letter-spacing: .4em; color: var(--mute); margin-bottom: 18px; }
100
- .dream .d1 { font: 800 clamp(26px, 4.4vw, 62px)/1.08 var(--wide); }
101
- .dream .d2 { font: 500 clamp(18px, 2.4vw, 28px) var(--wide); color: #b9b9c2; margin-top: 14px; letter-spacing: .06em; }
102
- .dream .d3 { margin-top: 24px; font: 600 12px var(--wide); letter-spacing: .3em; text-transform: uppercase; color: var(--mute); }
103
- .end { position: absolute; inset: 0; display: none; place-content: center; justify-items: center; text-align: center; gap: 22px; background: rgba(0,0,0,.75); padding: 0 20px; }
104
- .end.on { display: grid; }
105
- .end-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
106
- .player { position: absolute; left: var(--pad); right: var(--pad); bottom: calc(22px + var(--bot)); display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); pointer-events: auto; }
107
- .pbtn { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: #fff; color: #000; font-size: 13px; letter-spacing: -2px; }
108
- .scrub { position: relative; flex: 1; height: 28px; display: flex; align-items: center; }
109
- .scrub input { width: 100%; margin: 0; -webkit-appearance: none; appearance: none; background: transparent; height: 28px; position: relative; z-index: 1; }
110
- .scrub input::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(90deg, #fff var(--p, 0%), rgba(255,255,255,.18) var(--p, 0%)); border-radius: 2px; }
111
- .scrub input::-moz-range-track { height: 3px; background: rgba(255,255,255,.18); border-radius: 2px; }
112
- .scrub input::-moz-range-progress { height: 3px; background: #fff; }
113
- .scrub input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; margin-top: -6.5px; }
114
- .scrub input::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; }
115
- .ticks { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; }
116
- .ticks button { position: absolute; top: -20px; transform: translateX(-50%); background: none; border: 0; padding: 0 2px; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); pointer-events: auto; white-space: nowrap; }
117
- .ticks button::after { content: ""; position: absolute; left: 50%; top: 17px; width: 1px; height: 8px; background: rgba(255,255,255,.35); }
118
- .wtime { font: 600 12px var(--body); color: var(--mute); font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
119
-
120
- /* play */
121
- .g-hint { position: absolute; top: calc(70px + var(--top)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); text-align: center; font: 600 14px var(--body); letter-spacing: .02em; padding: 8px 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
122
- .g-hint:empty { display: none; }
123
- .g-target { position: absolute; top: calc(118px + var(--top)); left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 4px; }
124
- .g-target i { font-style: normal; font-size: 30px; color: var(--ok); transition: opacity .3s; display: inline-block; text-shadow: 0 0 14px rgba(61,255,138,.6); }
125
- .g-target span { font: 700 12px var(--wide); letter-spacing: .1em; color: var(--ok); }
126
- .g-stats { position: absolute; left: var(--pad); bottom: calc(22px + var(--bot)); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(480px, calc(100% - 2 * var(--pad))); }
127
- .g-stats em { font-style: normal; }
128
- .g-stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(340px, calc(100% - 2 * var(--pad))); }
129
- .g-stats > div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
130
- .g-stats b { display: block; font: 800 clamp(18px, 2.4vw, 26px)/1.2 var(--wide); font-variant-numeric: tabular-nums; }
131
- .fbar { height: 3px; background: rgba(255,255,255,.12); border-radius: 2px; margin-top: 4px; overflow: hidden; }
132
- .fbar i { display: block; height: 100%; width: 100%; background: var(--ok); }
133
- .g-btns { position: absolute; right: var(--pad); top: calc(64px + var(--top)); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
134
- .g-score { position: absolute; left: var(--pad); top: calc(64px + var(--top)); display: grid; }
135
- .g-score span { font: 500 10px var(--wide); letter-spacing: .22em; text-transform: uppercase; color: var(--mute); }
136
- .g-score b { font: 800 26px var(--wide); }
137
- .g-map { position: absolute; right: var(--pad); bottom: calc(22px + var(--bot)); width: 180px; height: 180px; border-radius: 50%; box-shadow: 0 6px 30px rgba(0,0,0,.5); }
138
- #gGarageClose { display: none; }
139
- body.garage[data-mode="play"] #buildUI { display: block; z-index: 15; }
140
- body.garage[data-mode="play"] #gGarageClose { display: inline-block; }
141
- body.garage[data-mode="play"] #playUI > *:not(.g-card) { opacity: .25; pointer-events: none; }
142
- .pads { display: none; }
143
- .g-card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100% - 32px)); max-height: calc(100% - 140px); overflow: auto; padding: 26px; border-radius: 22px; background: rgba(10,10,13,.88); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
144
- .g-card h2 { font-size: clamp(24px, 3.6vw, 34px); }
145
- .g-card h2.win { color: var(--ok); } .g-card h2.crash, .g-card h2.lose { color: var(--bad); }
146
- .g-card ol { margin: 0 0 12px; padding-left: 20px; color: #c4c4cc; font-size: 14px; display: grid; gap: 8px; }
147
- .g-card .small { font-size: 12px; color: var(--mute); margin: 10px 0; }
148
- .g-card .ok { color: var(--ok); font-weight: 700; }
149
- .g-card p { color: #c4c4cc; }
150
- .g-res { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 14px 0; }
151
- .g-res div { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
152
- .g-res b { display: block; font: 800 22px var(--wide); }
153
- .g-res span { font-size: 11px; color: var(--mute); letter-spacing: .1em; text-transform: uppercase; }
154
-
155
- /* build */
156
- .drag-hint { position: absolute; left: var(--pad); bottom: calc(26px + var(--bot)); font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--mute); }
157
- .cfg { position: absolute; right: clamp(16px, 3vw, 32px); top: calc(72px + var(--top)); bottom: 24px; width: min(360px, calc(100% - 32px)); display: flex; flex-direction: column;
158
- background: var(--panel); border: 1px solid var(--line); border-radius: 20px; backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px); overflow: hidden; }
159
- .cfg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
160
- .cfg-head h2 { font-size: 20px; margin: 0; }
161
- #cfgBody { flex: 1; overflow-y: auto; padding: 4px 20px 10px; scrollbar-width: thin; }
162
- .grp { padding: 13px 0; border-bottom: 1px solid var(--line); }
163
- .grp:last-child { border-bottom: 0; }
164
- .grp-h { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--mute); margin-bottom: 10px; }
165
- .grp-h b { color: var(--ink); font-weight: 600; letter-spacing: .08em; text-transform: none; font-size: 13px; }
166
- .sw { display: flex; flex-wrap: wrap; gap: 10px; }
167
- .sw button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18); position: relative; padding: 0; transition: transform .15s; }
168
- .sw button:hover { transform: scale(1.08); }
169
- .sw button[aria-pressed="true"]::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 1.5px solid #fff; }
170
- .seg { display: flex; gap: 6px; }
171
- .seg button { flex: 1; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-size: 12px; letter-spacing: .06em; }
172
- .seg button[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
173
- .cfg-foot { border-top: 1px solid var(--line); padding: 14px 20px 18px; display: grid; gap: 12px; }
174
- .sum { font-size: 12px; color: var(--mute); }
175
- .sum b { color: var(--ink); font: 800 13px var(--wide); letter-spacing: .08em; display: block; margin-bottom: 2px; }
176
- .cfg-btns { display: flex; gap: 8px; }
177
- .cfg-btns .pill { flex: 1; }
178
-
179
- #toast { position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); z-index: 30; background: #fff; color: #000; padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
180
- #toast.on { opacity: 1; transform: translate(-50%, 0); }
181
-
182
- /* touch controls (phones, tablets, anything without a mouse) */
183
- @media (pointer: coarse) {
184
- .pads { display: flex; justify-content: space-between; align-items: flex-end; position: absolute; left: 12px; right: 12px; bottom: calc(92px + var(--bot)); pointer-events: none; }
185
- .pads button { pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; width: 64px; height: 64px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.45); font: 700 11px var(--body); letter-spacing: .08em; text-transform: uppercase; backdrop-filter: blur(8px); }
186
- .pads button.on { background: #fff; color: #000; }
187
- .pads .big { width: 78px; height: 78px; }
188
- .pad-l, .pad-r { display: flex; gap: 10px; align-items: flex-end; }
189
- .pad-l button { font-size: 20px; }
190
- body:not(.g-air) .pads .air { display: none; }
191
- }
192
- @media (max-width: 820px) {
193
- .credit { font-size: 9px; letter-spacing: .1em; }
194
- .choices { grid-template-columns: 1fr 1fr; }
195
- .choice.main { grid-column: 1 / -1; }
196
- .choice { padding: 14px 16px; }
197
- .specs { grid-template-columns: repeat(2, 1fr); }
198
- footer { flex-direction: column; gap: 16px; }
199
- .cap { bottom: auto; top: calc(70px + var(--top)); }
200
- .telem { bottom: calc(92px + var(--bot)); gap: 14px; }
201
- .g-stats > div { padding: 6px 9px; }
202
- .g-btns { top: calc(112px + var(--top)); right: 12px; }
203
- .g-map { width: 120px; height: 120px; bottom: auto; top: calc(160px + var(--top)); right: 12px; }
204
- .pads { bottom: calc(150px + var(--bot)); }
205
- .cfg { top: auto; bottom: calc(12px + var(--bot)); left: 12px; right: 12px; width: auto; height: 50vh; }
206
- .drag-hint { bottom: auto; top: calc(70px + var(--top)); }
207
- .ticks button { font-size: 0; } .ticks button::after { top: 17px; }
208
- }
209
- @media (max-height: 520px) and (orientation: landscape) {
210
- .cap p { display: none; }
211
- .mega { font-size: 64px; }
212
- #home { padding-top: calc(64px + var(--top)); }
213
- .pads { bottom: calc(84px + var(--bot)); }
214
- }
215
- @media (prefers-reduced-motion: reduce) { #grain, .ld-word span { animation: none; } }
216
-
217
- /* VOID City HUD: health and nitro, combo, hurt flash, photo mode */
218
- .g-score em { font: 800 15px var(--wide); color: #ffd23d; font-style: normal; min-height: 18px; }
219
- .g-bars { position: absolute; left: var(--pad); top: calc(128px + var(--top)); display: grid; gap: 6px; width: 160px; }
220
- .g-btns { max-width: min(560px, 58vw); }
221
- .g-bars .bar { position: relative; height: 16px; border-radius: 8px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.18); overflow: hidden; backdrop-filter: blur(6px); }
222
- .g-bars .bar i { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--v, 1)); transition: transform .2s; }
223
- .g-bars .hp i { background: linear-gradient(90deg, #ff2a3a, #3dff8a); } .g-bars .hp.low i { background: #ff2a3a; animation: hpPulse .6s infinite alternate; }
224
- .g-bars .nos i { background: linear-gradient(90deg, #3d7bff, #3df5ff); }
225
- .g-bars .bar span { position: relative; font: 700 9px var(--wide); letter-spacing: .18em; text-transform: uppercase; padding-left: 8px; line-height: 16px; text-shadow: 0 1px 3px #000; }
226
- @keyframes hpPulse { to { opacity: .45; } }
227
- body.g-hurt #gl { filter: saturate(1.6) brightness(1.15) sepia(.35) hue-rotate(-25deg); }
228
- body.g-photo #playUI > *:not(.g-hint) { opacity: 0; pointer-events: none; }
229
- .pads .nos { background: rgba(40,90,255,.45) !important; } .pads .nos.on { background: #3df5ff !important; }
230
- body.g-air .pads .ground { display: none; }
231
- @media (max-width: 560px) { .g-bars { top: calc(112px + var(--top)); width: 130px; } .g-btns .pill { padding: 7px 11px; font-size: 11px; } }
232
-
233
- /* police, races, GPS, online */
234
- .g-stars { position: absolute; left: 50%; top: calc(14px + var(--top)); transform: translateX(-50%); font-size: 26px; letter-spacing: 4px; color: #ffd23d; text-shadow: 0 0 12px rgba(255,60,60,.8), 0 2px 4px #000; pointer-events: none; }
235
- .g-stars.bust { color: #ff3040; animation: hpPulse .3s infinite alternate; }
236
- .g-race { position: absolute; left: 50%; top: calc(52px + var(--top)); transform: translateX(-50%); display: flex; gap: 14px; align-items: center; padding: 8px 10px 8px 18px; border-radius: 999px; background: rgba(0,0,0,.6); border: 1px solid rgba(255,210,61,.5); font: 700 13px var(--body); white-space: nowrap; backdrop-filter: blur(8px); }
237
- .g-race b { font: 800 13px var(--wide); color: #ffd23d; } .g-race .pill { padding: 5px 12px; font-size: 11px; }
238
- .g-count { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); font: 900 120px var(--wide); color: #fff; text-shadow: 0 0 40px rgba(255,210,61,.9); pointer-events: none; }
239
- .g-raceres { max-width: 380px; } .g-raceres ol { padding-left: 20px; margin: 10px 0 14px; } .g-raceres li { display: flex; justify-content: space-between; padding: 4px 0; } .g-raceres li.me { color: #ffd23d; font-weight: 800; }
240
- .g-racego { position: absolute; left: 50%; bottom: calc(110px + var(--bot)); transform: translateX(-50%); }
241
- .g-gps { position: absolute; left: 50%; top: calc(96px + var(--top)); transform: translateX(-50%); padding: 7px 16px; border-radius: 12px; background: rgba(8,40,52,.75); border: 1px solid rgba(61,252,255,.45); color: #bff9ff; font: 700 14px var(--body); white-space: nowrap; pointer-events: none; }
242
- .g-gps:empty { display: none; }
243
- .g-panel { max-width: 460px; width: calc(100% - 32px); max-height: 80vh; overflow: auto; z-index: 30; }
244
- .g-panel h3 { margin: 0 0 8px; font: 800 18px var(--wide); } .g-panel .row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
245
- .g-panel input { flex: 1; min-width: 120px; padding: 10px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.35); color: #fff; font: inherit; }
246
- .g-panel label { display: flex; gap: 10px; align-items: center; font-size: 13px; }
247
- .g-panel .places { display: flex; flex-wrap: wrap; gap: 8px; } .g-panel .emotes { display: flex; flex-wrap: wrap; gap: 6px; }
248
- .g-panel .emotes .pill { padding: 6px 10px; font-size: 12px; }
249
- .pill.on { background: #3dfcff !important; color: #001 !important; }
250
- .g-feed { position: absolute; left: var(--pad); bottom: calc(130px + var(--bot)); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
251
- .g-feed div { padding: 5px 10px; border-radius: 8px; background: rgba(0,0,0,.55); font-size: 13px; animation: rise .3s ease; }
252
- .g-players { position: absolute; right: var(--pad); top: calc(300px + var(--top)); display: grid; gap: 3px; text-align: right; font-size: 12px; pointer-events: none; text-shadow: 0 1px 3px #000; }
253
- .g-lookhint { position: absolute; left: 50%; bottom: calc(14px + var(--bot)); transform: translateX(-50%); font-size: 11px; color: rgba(255,255,255,.55); pointer-events: none; }
254
- body.g-locked .g-lookhint, .pads ~ .g-lookhint { display: none; }
255
- @media (pointer: coarse) { .g-lookhint { display: none; } }
256
- @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
257
- @media (max-width: 560px) { .g-race { gap: 8px; font-size: 11px; padding-left: 12px; } .g-gps { font-size: 12px; top: calc(150px + var(--top)); } .g-players { top: calc(250px + var(--top)); } }
258
-
259
- /* phones: one Fly button and a More menu instead of nine buttons, a 2x2 pedal block, and the banners stacked under the top bar */
260
- #gMore { display: none; }
261
- @media (max-width: 820px) {
262
- #gMore { display: inline-flex; }
263
- .g-btns { flex-direction: column; align-items: flex-end; max-width: none; }
264
- .g-btns .pill:not(#gFly):not(#gMore) { display: none; }
265
- body.g-more .g-btns { background: rgba(10,12,18,.92); padding: 10px; border-radius: 18px; border: 1px solid rgba(255,255,255,.15); z-index: 25; }
266
- body.g-more .g-btns .pill:not(#gFly):not(#gMore) { display: inline-flex; width: 150px; justify-content: center; }
267
- body.g-more .g-map { visibility: hidden; }
268
- .g-stars { top: calc(58px + var(--top)); font-size: 18px; letter-spacing: 2px; }
269
- .g-race { top: calc(84px + var(--top)); left: 12px; right: 12px; transform: none; justify-content: space-between; gap: 6px; padding: 6px 6px 6px 12px; font-size: 11px; }
270
- .g-race b { font-size: 10px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
271
- .g-gps { top: auto; bottom: calc(300px + var(--bot)); max-width: calc(100% - 24px); white-space: normal; text-align: center; font-size: 12px; }
272
- .g-players { top: calc(290px + var(--top)); }
273
- .g-count { font-size: 84px; }
274
- }
275
- @media (pointer: coarse) and (max-width: 560px) {
276
- .pad-r { display: grid; grid-template-columns: repeat(2, auto); gap: 8px; justify-items: center; align-items: end; }
277
- .pads button { width: 58px; height: 58px; }
278
- .pads .big { width: 70px; height: 70px; }
279
- body.g-air .pad-r .ground { display: none; }
280
- }
281
- @media (max-width: 820px) {
282
- .g-race { top: calc(58px + var(--top)); }
283
- .g-score { top: calc(104px + var(--top)); }
284
- .g-bars { top: calc(160px + var(--top)); }
285
- .g-stars { left: var(--pad); transform: none; top: calc(206px + var(--top)); }
286
- .g-gps { top: calc(300px + var(--top)); bottom: auto; left: 50%; transform: translateX(-50%); }
287
- }
288
- @media (max-width: 820px) { .g-bars { top: calc(172px + var(--top)); } .g-stars { top: calc(218px + var(--top)); } .g-map { top: calc(196px + var(--top)); } .g-players { top: calc(326px + var(--top)); } .g-gps { top: calc(330px + var(--top)); } }
289
-
290
- /* ===== HUD v3: four tidy corners and one menu ===== */
291
- #playUI .hud-tl { position: absolute; left: var(--pad); top: calc(66px + var(--top)); display: grid; gap: 8px; width: 190px; padding: 12px 14px; border-radius: 16px; background: rgba(8,10,16,.55); border: 1px solid rgba(255,255,255,.1); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); pointer-events: none; }
292
- #playUI .hud-tl .g-score, #playUI .hud-tl .g-bars, #playUI .hud-tl .g-stars { position: static; transform: none; left: auto; top: auto; width: auto; }
293
- #playUI .hud-tl .g-score { display: flex; align-items: baseline; gap: 10px; } #playUI .hud-tl .g-score b { font-size: 24px; }
294
- #playUI .hud-tl .g-stars { font-size: 17px; letter-spacing: 2px; text-align: left; min-height: 0; } #playUI .hud-tl .g-stars:empty { display: none; }
295
- .g-bars .fuel i { background: linear-gradient(90deg, #ff8a3d, #ffd23d); } .g-bars .fuel.low i { background: #ff8a3d; animation: hpPulse .6s infinite alternate; }
296
- #playUI .hud-tr { position: absolute; right: var(--pad); top: calc(66px + var(--top)); display: grid; justify-items: end; gap: 10px; }
297
- #playUI .hud-tr .g-map { position: static; width: 170px; height: 170px; cursor: pointer; }
298
- #playUI .hud-tr .g-btns { position: static; display: flex; gap: 8px; max-width: none; flex-direction: row; background: none; padding: 0; border: 0; }
299
- #playUI .hud-tr .g-players { position: static; text-align: right; }
300
- #playUI .hud-top { position: absolute; left: 50%; top: calc(64px + var(--top)); transform: translateX(-50%); display: grid; justify-items: center; gap: 8px; width: min(560px, calc(100% - 460px)); pointer-events: none; }
301
- #playUI .hud-top > * { position: static; transform: none; left: auto; top: auto; }
302
- #playUI .hud-top .g-race { pointer-events: auto; }
303
- #playUI .hud-gauge { position: absolute; left: 50%; bottom: calc(10px + var(--bot)); transform: translateX(-50%); width: 230px; height: 230px; pointer-events: none; }
304
- #playUI .hud-gauge canvas { width: 100%; height: 100%; }
305
- #playUI .g-feed { bottom: calc(24px + var(--bot)); }
306
- /* the menu */
307
- .g-menu { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(4,6,10,.62); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); padding: calc(20px + var(--top)) 16px calc(20px + var(--bot)); overflow: auto; }
308
- .g-menu[hidden] { display: none; }
309
- .g-menu > * { width: min(860px, 100%); }
310
- .menu-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; } .menu-head h2 { margin: 0; font: 900 28px var(--wide); letter-spacing: .04em; }
311
- .menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
312
- .menu-grid section { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); border-radius: 18px; padding: 14px; } .menu-grid section.wide { grid-column: 1 / -1; }
313
- .menu-grid h4 { margin: 0 0 10px; font: 800 11px var(--wide); letter-spacing: .2em; text-transform: uppercase; color: var(--mute); }
314
- .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
315
- .tile { display: grid; justify-items: center; gap: 4px; padding: 12px 6px; border-radius: 14px; border: 1px solid rgba(255,255,255,.14); background: rgba(0,0,0,.3); color: #fff; font: 600 12px var(--body); cursor: pointer; transition: background .15s, transform .1s, border-color .15s; }
316
- .tile b { font-size: 24px; line-height: 1; } .tile:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.35); } .tile:active { transform: scale(.96); }
317
- .tile.on, .tile[aria-pressed="true"] { background: #fff; color: #000; }
318
- .set { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; font: 600 13px var(--body); }
319
- .set .seg { display: inline-flex; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; overflow: hidden; }
320
- .set .seg button { padding: 6px 11px; background: none; border: 0; color: #fff; font: 600 12px var(--body); cursor: pointer; } .set .seg button.on { background: #fff; color: #000; }
321
- .set input[type=range] { width: 150px; accent-color: #fff; }
322
- .menu-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
323
- /* touch: a joystick on the left (or the old arrow buttons), pedals on the right */
324
- .stick { display: none; }
325
- @media (pointer: coarse) {
326
- .stick { display: block; position: relative; width: 132px; height: 132px; border-radius: 50%; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.3); pointer-events: auto; touch-action: none; backdrop-filter: blur(8px); }
327
- .stick i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 4px 14px rgba(0,0,0,.4); transition: transform .05s; }
328
- body:not(.steer-buttons) .pads .pad-l { display: none; }
329
- body.steer-buttons .pads .stick { display: none; }
330
- .pads button { width: 70px !important; height: 70px !important; font-size: 12px !important; }
331
- .pads .big { width: 84px !important; height: 84px !important; }
332
- #playUI .g-lookhint { display: none; }
333
- }
334
- @media (max-width: 820px) {
335
- #playUI .hud-tl { left: 10px; top: calc(56px + var(--top)); width: 140px; padding: 8px 10px; gap: 5px; }
336
- #playUI .hud-tl .g-score b { font-size: 18px; }
337
- #playUI .hud-tr { right: 10px; top: calc(56px + var(--top)); gap: 6px; }
338
- #playUI .hud-tr .g-map { width: 108px; height: 108px; }
339
- #playUI .hud-tr .g-btns .pill { padding: 7px 10px; font-size: 11px; }
340
- #playUI .hud-top { top: calc(176px + var(--top)); width: calc(100% - 24px); }
341
- #playUI .hud-top .g-race { width: 100%; justify-content: space-between; }
342
- #playUI .hud-gauge { width: 112px; height: 112px; bottom: auto; top: calc(56px + var(--top)); }
343
- .menu-grid { grid-template-columns: minmax(0, 1fr); }
344
- .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
345
- .pads { bottom: calc(18px + var(--bot)) !important; }
346
- }
347
- #gMore { display: none !important; }
348
- /* the account button from hub.js: tucked under the top bar so it doesn't sit on the game controls */
349
- .hub-chip { left: auto !important; right: 14px !important; bottom: auto !important; top: calc(64px + var(--top)) !important; }
350
- body[data-mode="play"] .hub-chip { display: none !important; }
351
- .hub-box { left: auto !important; right: 12px !important; bottom: auto !important; top: calc(104px + var(--top)) !important; }
352
- #playUI .g-bars .bar { height: 18px; } #playUI .g-bars .bar span { line-height: 18px; font-size: 9px; }
353
- @media (min-width: 821px) { #playUI .hud-gauge { left: auto; right: var(--pad); transform: none; bottom: calc(14px + var(--bot)); width: 210px; height: 210px; } }
354
- .g-menu { padding-top: calc(70px + var(--top)) !important; place-items: start center !important; }
355
- #playUI .hud-tr .g-btns #gMenuBtn { display: inline-flex !important; }
356
- @media (max-width: 820px) {
357
- #playUI .hud-tr .g-btns { flex-direction: column; align-items: flex-end; }
358
- #playUI .hud-gauge { left: auto; right: 10px; transform: none; top: calc(258px + var(--top)); width: 100px; height: 100px; }
359
- #playUI .hud-tl { width: 132px; }
360
- }
361
- @media (max-width: 820px) { #playUI .hud-top { left: 10px; transform: none; width: calc(100% - 124px); top: calc(176px + var(--top)); justify-items: start; } }
362
- #playUI .g-bars .bar span { position: absolute; inset: 0; display: flex; align-items: center; line-height: 1; }
363
-
364
- /* status chips, trophies, stats, challenges */
365
- #playUI .hud-tr .chips { display: flex; gap: 6px; } #playUI .hud-tr .chips span { padding: 4px 9px; border-radius: 999px; background: rgba(8,10,16,.55); border: 1px solid rgba(255,255,255,.12); font: 600 11px var(--body); text-transform: capitalize; backdrop-filter: blur(8px); }
366
- .g-trophy { position: absolute; left: 50%; top: calc(14px + var(--top)); z-index: 45; display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 12px; border-radius: 18px; background: linear-gradient(135deg, rgba(40,32,8,.92), rgba(12,12,16,.92)); border: 1px solid rgba(255,210,61,.6); box-shadow: 0 10px 40px rgba(255,190,40,.25); transform: translate(-50%, -140%); opacity: 0; pointer-events: none; }
367
- .g-trophy.on { animation: trophy 4.2s cubic-bezier(.2,.8,.2,1) forwards; }
368
- .g-trophy b { font-size: 30px; } .g-trophy span { display: block; font: 800 10px var(--wide); letter-spacing: .18em; text-transform: uppercase; color: #ffd23d; } .g-trophy div { font: 700 15px var(--body); } .g-trophy em { font-style: normal; color: #ffd23d; margin-left: 8px; }
369
- @keyframes trophy { 0% { transform: translate(-50%, -140%); opacity: 0; } 10%, 85% { transform: translate(-50%, 0); opacity: 1; } 100% { transform: translate(-50%, -140%); opacity: 0; } }
370
- .stats-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
371
- .stats-row div { padding: 12px; border-radius: 16px; background: linear-gradient(160deg, rgba(255,255,255,.08), rgba(255,255,255,.02)); border: 1px solid rgba(255,255,255,.1); }
372
- .stats-row b { display: block; font: 900 22px var(--wide); } .stats-row span { font: 600 11px var(--body); color: var(--mute); text-transform: uppercase; letter-spacing: .1em; }
373
- .goals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
374
- .goal { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 14px; background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.08); }
375
- .goal b { font-size: 22px; } .goal span { display: block; font: 700 13px var(--body); } .goal small { color: var(--mute); font-size: 11.5px; }
376
- .goal i { display: block; height: 5px; border-radius: 3px; margin-top: 5px; background: linear-gradient(90deg, #ffd23d calc(var(--v) * 100%), rgba(255,255,255,.12) 0); }
377
- .goal em { font: 700 12px var(--body); font-style: normal; color: var(--mute); } .goal.ok { border-color: rgba(255,210,61,.45); background: rgba(255,210,61,.08); }
378
- .g-menu .menu-grid section { transition: border-color .2s; } .g-menu .menu-grid section:hover { border-color: rgba(255,255,255,.2); }
379
- .g-menu[hidden] + * {} .g-menu:not([hidden]) > * { animation: menuIn .28s cubic-bezier(.2,.8,.2,1) both; }
380
- @keyframes menuIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
381
- @media (max-width: 820px) { .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .goals { grid-template-columns: minmax(0, 1fr); } #playUI .hud-tr .chips { display: none; } }
382
- .g-welcome { max-width: 460px !important; text-align: left; }
383
- .g-welcome h2 { font: 900 30px var(--wide); margin: 0 0 4px; } .g-welcome .sub { color: var(--mute); margin: 0 0 14px; }
384
- .g-welcome .tips { display: grid; gap: 8px; margin-bottom: 14px; }
385
- .g-welcome .tips div { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); font-size: 13.5px; }
386
- .g-welcome .tips b { font-size: 24px; } .g-welcome kbd { padding: 1px 6px; font-size: 11px; }
387
- .g-welcome .big-go { width: 100%; padding: 14px; font-size: 14px; }
388
- .touch-only { display: none; } @media (pointer: coarse) { .touch-only { display: block; } }
389
- .g-job { padding: 7px 16px; border-radius: 12px; background: rgba(60,46,0,.8); border: 1px solid rgba(255,210,61,.6); color: #ffe48a; font: 700 14px var(--body); white-space: nowrap; }
390
- .g-job[hidden] { display: none; }
391
- @media (max-width: 820px) { .g-job { font-size: 12px; white-space: normal; } }
392
- /* the menu takes its own scrolling (it sits inside the click-through play layer) */
393
- .g-menu { pointer-events: auto !important; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
394
- .g-panel { overscroll-behavior: contain; }
395
 
396
  .gpu { margin: 4px 0 8px; } .gpu .warn { color: #ffb347; }
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* VOID: matte black, white type, one clear thing per screen */
2
+ :root {
3
+ --bg: #10131b; --ink: #f6f7fa; --mute: #a3a8b6; --dim: #5a6070; --line: rgba(255,255,255,.18);
4
+ --panel: rgba(40,46,62,.55); --ok: #3dff8a; --bad: #ff4455;
5
+ --wide: "Unbounded", "Inter", system-ui, sans-serif; --body: "Inter", system-ui, sans-serif;
6
+ --pad: clamp(16px, 4vw, 40px); --top: env(safe-area-inset-top); --bot: env(safe-area-inset-bottom);
7
+ }
8
+ * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
9
+ html { background: var(--bg); }
10
+ body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
11
+ button { font: inherit; color: inherit; cursor: pointer; }
12
+ a { color: inherit; text-decoration: none; }
13
+ kbd { font: 600 12px var(--body); border: 1px solid rgba(255,255,255,.3); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }
14
+ [hidden] { display: none !important; }
15
+
16
+ #gl { position: fixed; left: 0; top: 0; width: 100%; height: 100vh; height: 100lvh; display: block; z-index: 0; touch-action: pan-y; }
17
+ body:not([data-mode="home"]) #gl { touch-action: none; }
18
+ #grain { position: fixed; inset: -50%; z-index: 1; pointer-events: none; opacity: .05;
19
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
20
+ animation: grain 1.2s steps(6) infinite; }
21
+ @keyframes grain { 0% { transform: translate(0,0) } 33% { transform: translate(-3%,2%) } 66% { transform: translate(2%,-3%) } 100% { transform: translate(0,0) } }
22
+ #fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 6; transition: opacity .35s; }
23
+ #fade.on { opacity: 1; }
24
+
25
+ /* loader */
26
+ #loader { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 22px; transition: opacity .8s ease, visibility .8s; }
27
+ #loader.done { opacity: 0; visibility: hidden; }
28
+ .ld-word { font: 900 clamp(64px, 16vw, 180px)/1 var(--wide); letter-spacing: .04em; display: flex; }
29
+ .ld-word span { display: inline-block; color: transparent; -webkit-text-stroke: 1.5px rgba(255,255,255,.55); animation: ldIn .9s cubic-bezier(.2,.8,.2,1) both; }
30
+ .ld-word span:nth-child(2) { animation-delay: .08s } .ld-word span:nth-child(3) { animation-delay: .16s } .ld-word span:nth-child(4) { animation-delay: .24s }
31
+ @keyframes ldIn { from { opacity: 0; transform: translateY(40%); } }
32
+ .ld-bar { width: min(260px, 60vw); height: 2px; background: var(--line); overflow: hidden; }
33
+ .ld-bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .25s ease; }
34
+ .ld-pct { font: 500 12px var(--wide); color: var(--mute); letter-spacing: .2em; }
35
+
36
+ /* nav: the same three things everywhere */
37
+ #nav { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: calc(14px + var(--top)) var(--pad) 14px; }
38
+ .logo { font: 900 20px var(--wide); letter-spacing: .12em; background: none; border: 0; padding: 0; }
39
+ .credit { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600; color: #d6d6dc; }
40
+ .right { margin-left: auto; display: flex; gap: 10px; }
41
+ #exit { display: none; padding: 8px 14px; }
42
+ body:not([data-mode="home"]) #exit { display: inline-block; }
43
+ .pill { border: 1px solid rgba(255,255,255,.28); background: rgba(0,0,0,.35); border-radius: 999px; padding: 9px 16px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; transition: background .2s, color .2s, border-color .2s; white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
44
+ .pill:hover { border-color: #fff; }
45
+ .pill.solid, .pill[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
46
+
47
+ /* home */
48
+ #page { position: relative; z-index: 2; }
49
+ body:not([data-mode="home"]) #page { display: none; }
50
+ body:not([data-mode="home"]) { overflow: hidden; }
51
+ #home { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: space-between; padding: calc(84px + var(--top)) var(--pad) calc(28px + var(--bot)); }
52
+ .home-copy { text-align: center; }
53
+ .kicker { font: 500 11px var(--wide); letter-spacing: .36em; color: var(--mute); text-transform: uppercase; }
54
+ .mega { font: 900 clamp(84px, 20vw, 280px)/.86 var(--wide); letter-spacing: -.02em; margin: 12px 0 8px;
55
+ background: linear-gradient(180deg, #fff 0%, #c9c9cf 55%, rgba(255,255,255,.08) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
56
+ .lede { color: #b9b9c1; font-size: clamp(15px, 1.6vw, 19px); margin: 0; }
57
+ .choices { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; width: min(860px, 100%); margin: 0 auto; }
58
+ .choice { text-align: left; padding: 18px 20px; border-radius: 18px; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: border-color .2s, transform .15s; }
59
+ .choice:hover { border-color: rgba(255,255,255,.5); transform: translateY(-2px); }
60
+ .choice b { display: block; font: 800 clamp(18px, 2.2vw, 24px) var(--wide); }
61
+ .choice span { display: block; font-size: 13px; color: var(--mute); margin-top: 4px; }
62
+ .choice.main { background: #fff; color: #000; border-color: #fff; }
63
+ .choice.main span { color: #444; }
64
+ .more { align-self: center; margin-top: 16px; font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--mute); }
65
+ .more::after { content: " \2193"; }
66
+
67
+ #specs { background: linear-gradient(180deg, transparent, rgba(5,5,6,.8) 18%, var(--bg) 45%); }
68
+ .specs-wrap { padding: 18vh var(--pad) 8vh; max-width: 1200px; margin: 0 auto; }
69
+ .sec-label { font: 500 11px var(--wide); letter-spacing: .28em; text-transform: uppercase; color: var(--mute); margin-bottom: 16px; }
70
+ h2 { font: 800 clamp(28px, 4.6vw, 60px)/1.04 var(--wide); letter-spacing: -.01em; margin: 0 0 14px; }
71
+ .specs-title { margin-bottom: 40px; }
72
+ .specs { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
73
+ .specs div { padding: 26px 16px 26px 0; border-bottom: 1px solid var(--line); }
74
+ .specs b { display: block; font: 800 clamp(32px, 4.2vw, 56px)/1 var(--wide); letter-spacing: -.02em; }
75
+ .specs small { font-size: .42em; color: var(--mute); margin-left: 4px; }
76
+ .specs span { display: block; margin-top: 10px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); }
77
+ footer { padding: 36px var(--pad) calc(36px + var(--bot)); max-width: 1200px; margin: 0 auto; border-top: 1px solid var(--line); display: flex; gap: 32px; align-items: flex-start; }
78
+ .foot-logo { font: 900 44px/1 var(--wide); letter-spacing: .06em; color: transparent; -webkit-text-stroke: 1px rgba(255,255,255,.5); }
79
+ footer p { margin: 0; color: var(--mute); font-size: 13px; max-width: 70ch; }
80
+ footer b, footer a { color: var(--ink); }
81
+
82
+ /* modes */
83
+ .mode { position: fixed; inset: 0; z-index: 10; pointer-events: none; display: none; }
84
+ body[data-mode="watch"] #watchUI, body[data-mode="play"] #playUI, body[data-mode="build"] #buildUI { display: block; }
85
+ .mode button, .mode input, .mode aside, .mode .g-card { pointer-events: auto; }
86
+
87
+ /* watch */
88
+ .cap { position: absolute; left: var(--pad); bottom: calc(96px + var(--bot)); width: min(440px, calc(100% - 2 * var(--pad))); transition: opacity .4s ease, transform .4s ease; }
89
+ .cap.hide { opacity: 0; transform: translateY(12px); }
90
+ .cap .num { font: 500 11px var(--wide); letter-spacing: .3em; color: var(--mute); margin-bottom: 6px; }
91
+ .cap h2 { font-size: clamp(28px, 4vw, 52px); margin: 0 0 6px; }
92
+ .cap p { margin: 0; color: #b6b6bf; text-shadow: 0 1px 12px #000; }
93
+ .telem { position: absolute; right: var(--pad); bottom: calc(96px + var(--bot)); display: flex; gap: 22px; transition: opacity .4s; }
94
+ .telem div { display: grid; justify-items: end; }
95
+ .telem span, .g-stats span { font: 500 10px var(--wide); letter-spacing: .22em; text-transform: uppercase; color: var(--mute); }
96
+ .telem b { font: 800 clamp(24px, 3.4vw, 42px)/1.05 var(--wide); font-variant-numeric: tabular-nums; }
97
+ .telem i, .g-stats i { font-style: normal; font-size: 11px; color: var(--mute); }
98
+ .dream { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 0 20px; opacity: 0; background: radial-gradient(closest-side, rgba(0,0,0,.55), rgba(0,0,0,.85)); }
99
+ .dream .d0 { font: 600 12px var(--wide); letter-spacing: .4em; color: var(--mute); margin-bottom: 18px; }
100
+ .dream .d1 { font: 800 clamp(26px, 4.4vw, 62px)/1.08 var(--wide); }
101
+ .dream .d2 { font: 500 clamp(18px, 2.4vw, 28px) var(--wide); color: #b9b9c2; margin-top: 14px; letter-spacing: .06em; }
102
+ .dream .d3 { margin-top: 24px; font: 600 12px var(--wide); letter-spacing: .3em; text-transform: uppercase; color: var(--mute); }
103
+ .end { position: absolute; inset: 0; display: none; place-content: center; justify-items: center; text-align: center; gap: 22px; background: rgba(0,0,0,.75); padding: 0 20px; }
104
+ .end.on { display: grid; }
105
+ .end-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
106
+ .player { position: absolute; left: var(--pad); right: var(--pad); bottom: calc(22px + var(--bot)); display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); pointer-events: auto; }
107
+ .pbtn { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: #fff; color: #000; font-size: 13px; letter-spacing: -2px; }
108
+ .scrub { position: relative; flex: 1; height: 28px; display: flex; align-items: center; }
109
+ .scrub input { width: 100%; margin: 0; -webkit-appearance: none; appearance: none; background: transparent; height: 28px; position: relative; z-index: 1; }
110
+ .scrub input::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(90deg, #fff var(--p, 0%), rgba(255,255,255,.18) var(--p, 0%)); border-radius: 2px; }
111
+ .scrub input::-moz-range-track { height: 3px; background: rgba(255,255,255,.18); border-radius: 2px; }
112
+ .scrub input::-moz-range-progress { height: 3px; background: #fff; }
113
+ .scrub input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; margin-top: -6.5px; }
114
+ .scrub input::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; }
115
+ .ticks { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; }
116
+ .ticks button { position: absolute; top: -20px; transform: translateX(-50%); background: none; border: 0; padding: 0 2px; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); pointer-events: auto; white-space: nowrap; }
117
+ .ticks button::after { content: ""; position: absolute; left: 50%; top: 17px; width: 1px; height: 8px; background: rgba(255,255,255,.35); }
118
+ .wtime { font: 600 12px var(--body); color: var(--mute); font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
119
+
120
+ /* play */
121
+ .g-hint { position: absolute; top: calc(70px + var(--top)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); text-align: center; font: 600 14px var(--body); letter-spacing: .02em; padding: 8px 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
122
+ .g-hint:empty { display: none; }
123
+ .g-target { position: absolute; top: calc(118px + var(--top)); left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 4px; }
124
+ .g-target i { font-style: normal; font-size: 30px; color: var(--ok); transition: opacity .3s; display: inline-block; text-shadow: 0 0 14px rgba(61,255,138,.6); }
125
+ .g-target span { font: 700 12px var(--wide); letter-spacing: .1em; color: var(--ok); }
126
+ .g-stats { position: absolute; left: var(--pad); bottom: calc(22px + var(--bot)); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(480px, calc(100% - 2 * var(--pad))); }
127
+ .g-stats em { font-style: normal; }
128
+ .g-stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(340px, calc(100% - 2 * var(--pad))); }
129
+ .g-stats > div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
130
+ .g-stats b { display: block; font: 800 clamp(18px, 2.4vw, 26px)/1.2 var(--wide); font-variant-numeric: tabular-nums; }
131
+ .fbar { height: 3px; background: rgba(255,255,255,.12); border-radius: 2px; margin-top: 4px; overflow: hidden; }
132
+ .fbar i { display: block; height: 100%; width: 100%; background: var(--ok); }
133
+ .g-btns { position: absolute; right: var(--pad); top: calc(64px + var(--top)); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
134
+ .g-score { position: absolute; left: var(--pad); top: calc(64px + var(--top)); display: grid; }
135
+ .g-score span { font: 500 10px var(--wide); letter-spacing: .22em; text-transform: uppercase; color: var(--mute); }
136
+ .g-score b { font: 800 26px var(--wide); }
137
+ .g-map { position: absolute; right: var(--pad); bottom: calc(22px + var(--bot)); width: 180px; height: 180px; border-radius: 50%; box-shadow: 0 6px 30px rgba(0,0,0,.5); }
138
+ #gGarageClose { display: none; }
139
+ body.garage[data-mode="play"] #buildUI { display: block; z-index: 15; }
140
+ body.garage[data-mode="play"] #gGarageClose { display: inline-block; }
141
+ body.garage[data-mode="play"] #playUI > *:not(.g-card) { opacity: .25; pointer-events: none; }
142
+ .pads { display: none; }
143
+ .g-card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100% - 32px)); max-height: calc(100% - 140px); overflow: auto; padding: 26px; border-radius: 22px; background: rgba(10,10,13,.88); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
144
+ .g-card h2 { font-size: clamp(24px, 3.6vw, 34px); }
145
+ .g-card h2.win { color: var(--ok); } .g-card h2.crash, .g-card h2.lose { color: var(--bad); }
146
+ .g-card ol { margin: 0 0 12px; padding-left: 20px; color: #c4c4cc; font-size: 14px; display: grid; gap: 8px; }
147
+ .g-card .small { font-size: 12px; color: var(--mute); margin: 10px 0; }
148
+ .g-card .ok { color: var(--ok); font-weight: 700; }
149
+ .g-card p { color: #c4c4cc; }
150
+ .g-res { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 14px 0; }
151
+ .g-res div { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
152
+ .g-res b { display: block; font: 800 22px var(--wide); }
153
+ .g-res span { font-size: 11px; color: var(--mute); letter-spacing: .1em; text-transform: uppercase; }
154
+
155
+ /* build */
156
+ .drag-hint { position: absolute; left: var(--pad); bottom: calc(26px + var(--bot)); font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--mute); }
157
+ .cfg { position: absolute; right: clamp(16px, 3vw, 32px); top: calc(72px + var(--top)); bottom: 24px; width: min(360px, calc(100% - 32px)); display: flex; flex-direction: column;
158
+ background: var(--panel); border: 1px solid var(--line); border-radius: 20px; backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px); overflow: hidden; }
159
+ .cfg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
160
+ .cfg-head h2 { font-size: 20px; margin: 0; }
161
+ #cfgBody { flex: 1; overflow-y: auto; padding: 4px 20px 10px; scrollbar-width: thin; }
162
+ .grp { padding: 13px 0; border-bottom: 1px solid var(--line); }
163
+ .grp:last-child { border-bottom: 0; }
164
+ .grp-h { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--mute); margin-bottom: 10px; }
165
+ .grp-h b { color: var(--ink); font-weight: 600; letter-spacing: .08em; text-transform: none; font-size: 13px; }
166
+ .sw { display: flex; flex-wrap: wrap; gap: 10px; }
167
+ .sw button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18); position: relative; padding: 0; transition: transform .15s; }
168
+ .sw button:hover { transform: scale(1.08); }
169
+ .sw button[aria-pressed="true"]::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 1.5px solid #fff; }
170
+ .seg { display: flex; gap: 6px; }
171
+ .seg button { flex: 1; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-size: 12px; letter-spacing: .06em; }
172
+ .seg button[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
173
+ .cfg-foot { border-top: 1px solid var(--line); padding: 14px 20px 18px; display: grid; gap: 12px; }
174
+ .sum { font-size: 12px; color: var(--mute); }
175
+ .sum b { color: var(--ink); font: 800 13px var(--wide); letter-spacing: .08em; display: block; margin-bottom: 2px; }
176
+ .cfg-btns { display: flex; gap: 8px; }
177
+ .cfg-btns .pill { flex: 1; }
178
+
179
+ #toast { position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); z-index: 30; background: #fff; color: #000; padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
180
+ #toast.on { opacity: 1; transform: translate(-50%, 0); }
181
+
182
+ /* touch controls (phones, tablets, anything without a mouse) */
183
+ @media (pointer: coarse) {
184
+ .pads { display: flex; justify-content: space-between; align-items: flex-end; position: absolute; left: 12px; right: 12px; bottom: calc(92px + var(--bot)); pointer-events: none; }
185
+ .pads button { pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; width: 64px; height: 64px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.45); font: 700 11px var(--body); letter-spacing: .08em; text-transform: uppercase; backdrop-filter: blur(8px); }
186
+ .pads button.on { background: #fff; color: #000; }
187
+ .pads .big { width: 78px; height: 78px; }
188
+ .pad-l, .pad-r { display: flex; gap: 10px; align-items: flex-end; }
189
+ .pad-l button { font-size: 20px; }
190
+ body:not(.g-air) .pads .air { display: none; }
191
+ }
192
+ @media (max-width: 820px) {
193
+ .credit { font-size: 9px; letter-spacing: .1em; }
194
+ .choices { grid-template-columns: 1fr 1fr; }
195
+ .choice.main { grid-column: 1 / -1; }
196
+ .choice { padding: 14px 16px; }
197
+ .specs { grid-template-columns: repeat(2, 1fr); }
198
+ footer { flex-direction: column; gap: 16px; }
199
+ .cap { bottom: auto; top: calc(70px + var(--top)); }
200
+ .telem { bottom: calc(92px + var(--bot)); gap: 14px; }
201
+ .g-stats > div { padding: 6px 9px; }
202
+ .g-btns { top: calc(112px + var(--top)); right: 12px; }
203
+ .g-map { width: 120px; height: 120px; bottom: auto; top: calc(160px + var(--top)); right: 12px; }
204
+ .pads { bottom: calc(150px + var(--bot)); }
205
+ .cfg { top: auto; bottom: calc(12px + var(--bot)); left: 12px; right: 12px; width: auto; height: 50vh; }
206
+ .drag-hint { bottom: auto; top: calc(70px + var(--top)); }
207
+ .ticks button { font-size: 0; } .ticks button::after { top: 17px; }
208
+ }
209
+ @media (max-height: 520px) and (orientation: landscape) {
210
+ .cap p { display: none; }
211
+ .mega { font-size: 64px; }
212
+ #home { padding-top: calc(64px + var(--top)); }
213
+ .pads { bottom: calc(84px + var(--bot)); }
214
+ }
215
+ @media (prefers-reduced-motion: reduce) { #grain, .ld-word span { animation: none; } }
216
+
217
+ /* VOID City HUD: health and nitro, combo, hurt flash, photo mode */
218
+ .g-score em { font: 800 15px var(--wide); color: #ffd23d; font-style: normal; min-height: 18px; }
219
+ .g-bars { position: absolute; left: var(--pad); top: calc(128px + var(--top)); display: grid; gap: 6px; width: 160px; }
220
+ .g-btns { max-width: min(560px, 58vw); }
221
+ .g-bars .bar { position: relative; height: 16px; border-radius: 8px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.18); overflow: hidden; backdrop-filter: blur(6px); }
222
+ .g-bars .bar i { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--v, 1)); transition: transform .2s; }
223
+ .g-bars .hp i { background: linear-gradient(90deg, #ff2a3a, #3dff8a); } .g-bars .hp.low i { background: #ff2a3a; animation: hpPulse .6s infinite alternate; }
224
+ .g-bars .nos i { background: linear-gradient(90deg, #3d7bff, #3df5ff); }
225
+ .g-bars .bar span { position: relative; font: 700 9px var(--wide); letter-spacing: .18em; text-transform: uppercase; padding-left: 8px; line-height: 16px; text-shadow: 0 1px 3px #000; }
226
+ @keyframes hpPulse { to { opacity: .45; } }
227
+ body.g-hurt #gl { filter: saturate(1.6) brightness(1.15) sepia(.35) hue-rotate(-25deg); }
228
+ body.g-photo #playUI > *:not(.g-hint) { opacity: 0; pointer-events: none; }
229
+ .pads .nos { background: rgba(40,90,255,.45) !important; } .pads .nos.on { background: #3df5ff !important; }
230
+ body.g-air .pads .ground { display: none; }
231
+ @media (max-width: 560px) { .g-bars { top: calc(112px + var(--top)); width: 130px; } .g-btns .pill { padding: 7px 11px; font-size: 11px; } }
232
+
233
+ /* police, races, GPS, online */
234
+ .g-stars { position: absolute; left: 50%; top: calc(14px + var(--top)); transform: translateX(-50%); font-size: 26px; letter-spacing: 4px; color: #ffd23d; text-shadow: 0 0 12px rgba(255,60,60,.8), 0 2px 4px #000; pointer-events: none; }
235
+ .g-stars.bust { color: #ff3040; animation: hpPulse .3s infinite alternate; }
236
+ .g-race { position: absolute; left: 50%; top: calc(52px + var(--top)); transform: translateX(-50%); display: flex; gap: 14px; align-items: center; padding: 8px 10px 8px 18px; border-radius: 999px; background: rgba(0,0,0,.6); border: 1px solid rgba(255,210,61,.5); font: 700 13px var(--body); white-space: nowrap; backdrop-filter: blur(8px); }
237
+ .g-race b { font: 800 13px var(--wide); color: #ffd23d; } .g-race .pill { padding: 5px 12px; font-size: 11px; }
238
+ .g-count { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); font: 900 120px var(--wide); color: #fff; text-shadow: 0 0 40px rgba(255,210,61,.9); pointer-events: none; }
239
+ .g-raceres { max-width: 380px; } .g-raceres ol { padding-left: 20px; margin: 10px 0 14px; } .g-raceres li { display: flex; justify-content: space-between; padding: 4px 0; } .g-raceres li.me { color: #ffd23d; font-weight: 800; }
240
+ .g-racego { position: absolute; left: 50%; bottom: calc(110px + var(--bot)); transform: translateX(-50%); }
241
+ .g-gps { position: absolute; left: 50%; top: calc(96px + var(--top)); transform: translateX(-50%); padding: 7px 16px; border-radius: 12px; background: rgba(8,40,52,.75); border: 1px solid rgba(61,252,255,.45); color: #bff9ff; font: 700 14px var(--body); white-space: nowrap; pointer-events: none; }
242
+ .g-gps:empty { display: none; }
243
+ .g-panel { max-width: 460px; width: calc(100% - 32px); max-height: 80vh; overflow: auto; z-index: 30; }
244
+ .g-panel h3 { margin: 0 0 8px; font: 800 18px var(--wide); } .g-panel .row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
245
+ .g-panel input { flex: 1; min-width: 120px; padding: 10px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.35); color: #fff; font: inherit; }
246
+ .g-panel label { display: flex; gap: 10px; align-items: center; font-size: 13px; }
247
+ .g-panel .places { display: flex; flex-wrap: wrap; gap: 8px; } .g-panel .emotes { display: flex; flex-wrap: wrap; gap: 6px; }
248
+ .g-panel .emotes .pill { padding: 6px 10px; font-size: 12px; }
249
+ .pill.on { background: #3dfcff !important; color: #001 !important; }
250
+ .g-feed { position: absolute; left: var(--pad); bottom: calc(130px + var(--bot)); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
251
+ .g-feed div { padding: 5px 10px; border-radius: 8px; background: rgba(0,0,0,.55); font-size: 13px; animation: rise .3s ease; }
252
+ .g-players { position: absolute; right: var(--pad); top: calc(300px + var(--top)); display: grid; gap: 3px; text-align: right; font-size: 12px; pointer-events: none; text-shadow: 0 1px 3px #000; }
253
+ .g-lookhint { position: absolute; left: 50%; bottom: calc(14px + var(--bot)); transform: translateX(-50%); font-size: 11px; color: rgba(255,255,255,.55); pointer-events: none; }
254
+ body.g-locked .g-lookhint, .pads ~ .g-lookhint { display: none; }
255
+ @media (pointer: coarse) { .g-lookhint { display: none; } }
256
+ @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
257
+ @media (max-width: 560px) { .g-race { gap: 8px; font-size: 11px; padding-left: 12px; } .g-gps { font-size: 12px; top: calc(150px + var(--top)); } .g-players { top: calc(250px + var(--top)); } }
258
+
259
+ /* phones: one Fly button and a More menu instead of nine buttons, a 2x2 pedal block, and the banners stacked under the top bar */
260
+ #gMore { display: none; }
261
+ @media (max-width: 820px) {
262
+ #gMore { display: inline-flex; }
263
+ .g-btns { flex-direction: column; align-items: flex-end; max-width: none; }
264
+ .g-btns .pill:not(#gFly):not(#gMore) { display: none; }
265
+ body.g-more .g-btns { background: rgba(10,12,18,.92); padding: 10px; border-radius: 18px; border: 1px solid rgba(255,255,255,.15); z-index: 25; }
266
+ body.g-more .g-btns .pill:not(#gFly):not(#gMore) { display: inline-flex; width: 150px; justify-content: center; }
267
+ body.g-more .g-map { visibility: hidden; }
268
+ .g-stars { top: calc(58px + var(--top)); font-size: 18px; letter-spacing: 2px; }
269
+ .g-race { top: calc(84px + var(--top)); left: 12px; right: 12px; transform: none; justify-content: space-between; gap: 6px; padding: 6px 6px 6px 12px; font-size: 11px; }
270
+ .g-race b { font-size: 10px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
271
+ .g-gps { top: auto; bottom: calc(300px + var(--bot)); max-width: calc(100% - 24px); white-space: normal; text-align: center; font-size: 12px; }
272
+ .g-players { top: calc(290px + var(--top)); }
273
+ .g-count { font-size: 84px; }
274
+ }
275
+ @media (pointer: coarse) and (max-width: 560px) {
276
+ .pad-r { display: grid; grid-template-columns: repeat(2, auto); gap: 8px; justify-items: center; align-items: end; }
277
+ .pads button { width: 58px; height: 58px; }
278
+ .pads .big { width: 70px; height: 70px; }
279
+ body.g-air .pad-r .ground { display: none; }
280
+ }
281
+ @media (max-width: 820px) {
282
+ .g-race { top: calc(58px + var(--top)); }
283
+ .g-score { top: calc(104px + var(--top)); }
284
+ .g-bars { top: calc(160px + var(--top)); }
285
+ .g-stars { left: var(--pad); transform: none; top: calc(206px + var(--top)); }
286
+ .g-gps { top: calc(300px + var(--top)); bottom: auto; left: 50%; transform: translateX(-50%); }
287
+ }
288
+ @media (max-width: 820px) { .g-bars { top: calc(172px + var(--top)); } .g-stars { top: calc(218px + var(--top)); } .g-map { top: calc(196px + var(--top)); } .g-players { top: calc(326px + var(--top)); } .g-gps { top: calc(330px + var(--top)); } }
289
+
290
+ /* ===== HUD v3: four tidy corners and one menu ===== */
291
+ #playUI .hud-tl { position: absolute; left: var(--pad); top: calc(66px + var(--top)); display: grid; gap: 8px; width: 190px; padding: 12px 14px; border-radius: 16px; background: rgba(8,10,16,.55); border: 1px solid rgba(255,255,255,.1); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); pointer-events: none; }
292
+ #playUI .hud-tl .g-score, #playUI .hud-tl .g-bars, #playUI .hud-tl .g-stars { position: static; transform: none; left: auto; top: auto; width: auto; }
293
+ #playUI .hud-tl .g-score { display: flex; align-items: baseline; gap: 10px; } #playUI .hud-tl .g-score b { font-size: 24px; }
294
+ #playUI .hud-tl .g-stars { font-size: 17px; letter-spacing: 2px; text-align: left; min-height: 0; } #playUI .hud-tl .g-stars:empty { display: none; }
295
+ .g-bars .fuel i { background: linear-gradient(90deg, #ff8a3d, #ffd23d); } .g-bars .fuel.low i { background: #ff8a3d; animation: hpPulse .6s infinite alternate; }
296
+ #playUI .hud-tr { position: absolute; right: var(--pad); top: calc(66px + var(--top)); display: grid; justify-items: end; gap: 10px; }
297
+ #playUI .hud-tr .g-map { position: static; width: 170px; height: 170px; cursor: pointer; }
298
+ #playUI .hud-tr .g-btns { position: static; display: flex; gap: 8px; max-width: none; flex-direction: row; background: none; padding: 0; border: 0; }
299
+ #playUI .hud-tr .g-players { position: static; text-align: right; }
300
+ #playUI .hud-top { position: absolute; left: 50%; top: calc(64px + var(--top)); transform: translateX(-50%); display: grid; justify-items: center; gap: 8px; width: min(560px, calc(100% - 460px)); pointer-events: none; }
301
+ #playUI .hud-top > * { position: static; transform: none; left: auto; top: auto; }
302
+ #playUI .hud-top .g-race { pointer-events: auto; }
303
+ #playUI .hud-gauge { position: absolute; left: 50%; bottom: calc(10px + var(--bot)); transform: translateX(-50%); width: 230px; height: 230px; pointer-events: none; }
304
+ #playUI .hud-gauge canvas { width: 100%; height: 100%; }
305
+ #playUI .g-feed { bottom: calc(24px + var(--bot)); }
306
+ /* the menu */
307
+ .g-menu { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(4,6,10,.62); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); padding: calc(20px + var(--top)) 16px calc(20px + var(--bot)); overflow: auto; }
308
+ .g-menu[hidden] { display: none; }
309
+ .g-menu > * { width: min(860px, 100%); }
310
+ .menu-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; } .menu-head h2 { margin: 0; font: 900 28px var(--wide); letter-spacing: .04em; }
311
+ .menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
312
+ .menu-grid section { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); border-radius: 18px; padding: 14px; } .menu-grid section.wide { grid-column: 1 / -1; }
313
+ .menu-grid h4 { margin: 0 0 10px; font: 800 11px var(--wide); letter-spacing: .2em; text-transform: uppercase; color: var(--mute); }
314
+ .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
315
+ .tile { display: grid; justify-items: center; gap: 4px; padding: 12px 6px; border-radius: 14px; border: 1px solid rgba(255,255,255,.14); background: rgba(0,0,0,.3); color: #fff; font: 600 12px var(--body); cursor: pointer; transition: background .15s, transform .1s, border-color .15s; }
316
+ .tile b { font-size: 24px; line-height: 1; } .tile:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.35); } .tile:active { transform: scale(.96); }
317
+ .tile.on, .tile[aria-pressed="true"] { background: #fff; color: #000; }
318
+ .set { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; font: 600 13px var(--body); }
319
+ .set .seg { display: inline-flex; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; overflow: hidden; }
320
+ .set .seg button { padding: 6px 11px; background: none; border: 0; color: #fff; font: 600 12px var(--body); cursor: pointer; } .set .seg button.on { background: #fff; color: #000; }
321
+ .set input[type=range] { width: 150px; accent-color: #fff; }
322
+ .menu-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
323
+ /* touch: a joystick on the left (or the old arrow buttons), pedals on the right */
324
+ .stick { display: none; }
325
+ @media (pointer: coarse) {
326
+ .stick { display: block; position: relative; width: 132px; height: 132px; border-radius: 50%; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.3); pointer-events: auto; touch-action: none; backdrop-filter: blur(8px); }
327
+ .stick i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 4px 14px rgba(0,0,0,.4); transition: transform .05s; }
328
+ body:not(.steer-buttons) .pads .pad-l { display: none; }
329
+ body.steer-buttons .pads .stick { display: none; }
330
+ .pads button { width: 70px !important; height: 70px !important; font-size: 12px !important; }
331
+ .pads .big { width: 84px !important; height: 84px !important; }
332
+ #playUI .g-lookhint { display: none; }
333
+ }
334
+ @media (max-width: 820px) {
335
+ #playUI .hud-tl { left: 10px; top: calc(56px + var(--top)); width: 140px; padding: 8px 10px; gap: 5px; }
336
+ #playUI .hud-tl .g-score b { font-size: 18px; }
337
+ #playUI .hud-tr { right: 10px; top: calc(56px + var(--top)); gap: 6px; }
338
+ #playUI .hud-tr .g-map { width: 108px; height: 108px; }
339
+ #playUI .hud-tr .g-btns .pill { padding: 7px 10px; font-size: 11px; }
340
+ #playUI .hud-top { top: calc(176px + var(--top)); width: calc(100% - 24px); }
341
+ #playUI .hud-top .g-race { width: 100%; justify-content: space-between; }
342
+ #playUI .hud-gauge { width: 112px; height: 112px; bottom: auto; top: calc(56px + var(--top)); }
343
+ .menu-grid { grid-template-columns: minmax(0, 1fr); }
344
+ .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
345
+ .pads { bottom: calc(18px + var(--bot)) !important; }
346
+ }
347
+ #gMore { display: none !important; }
348
+ /* the account button from hub.js: tucked under the top bar so it doesn't sit on the game controls */
349
+ .hub-chip { left: auto !important; right: 14px !important; bottom: auto !important; top: calc(64px + var(--top)) !important; }
350
+ body[data-mode="play"] .hub-chip { display: none !important; }
351
+ .hub-box { left: auto !important; right: 12px !important; bottom: auto !important; top: calc(104px + var(--top)) !important; }
352
+ #playUI .g-bars .bar { height: 18px; } #playUI .g-bars .bar span { line-height: 18px; font-size: 9px; }
353
+ @media (min-width: 821px) { #playUI .hud-gauge { left: auto; right: var(--pad); transform: none; bottom: calc(14px + var(--bot)); width: 210px; height: 210px; } }
354
+ .g-menu { padding-top: calc(70px + var(--top)) !important; place-items: start center !important; }
355
+ #playUI .hud-tr .g-btns #gMenuBtn { display: inline-flex !important; }
356
+ @media (max-width: 820px) {
357
+ #playUI .hud-tr .g-btns { flex-direction: column; align-items: flex-end; }
358
+ #playUI .hud-gauge { left: auto; right: 10px; transform: none; top: calc(258px + var(--top)); width: 100px; height: 100px; }
359
+ #playUI .hud-tl { width: 132px; }
360
+ }
361
+ @media (max-width: 820px) { #playUI .hud-top { left: 10px; transform: none; width: calc(100% - 124px); top: calc(176px + var(--top)); justify-items: start; } }
362
+ #playUI .g-bars .bar span { position: absolute; inset: 0; display: flex; align-items: center; line-height: 1; }
363
+
364
+ /* status chips, trophies, stats, challenges */
365
+ #playUI .hud-tr .chips { display: flex; gap: 6px; } #playUI .hud-tr .chips span { padding: 4px 9px; border-radius: 999px; background: rgba(8,10,16,.55); border: 1px solid rgba(255,255,255,.12); font: 600 11px var(--body); text-transform: capitalize; backdrop-filter: blur(8px); }
366
+ .g-trophy { position: absolute; left: 50%; top: calc(14px + var(--top)); z-index: 45; display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 12px; border-radius: 18px; background: linear-gradient(135deg, rgba(40,32,8,.92), rgba(12,12,16,.92)); border: 1px solid rgba(255,210,61,.6); box-shadow: 0 10px 40px rgba(255,190,40,.25); transform: translate(-50%, -140%); opacity: 0; pointer-events: none; }
367
+ .g-trophy.on { animation: trophy 4.2s cubic-bezier(.2,.8,.2,1) forwards; }
368
+ .g-trophy b { font-size: 30px; } .g-trophy span { display: block; font: 800 10px var(--wide); letter-spacing: .18em; text-transform: uppercase; color: #ffd23d; } .g-trophy div { font: 700 15px var(--body); } .g-trophy em { font-style: normal; color: #ffd23d; margin-left: 8px; }
369
+ @keyframes trophy { 0% { transform: translate(-50%, -140%); opacity: 0; } 10%, 85% { transform: translate(-50%, 0); opacity: 1; } 100% { transform: translate(-50%, -140%); opacity: 0; } }
370
+ .stats-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
371
+ .stats-row div { padding: 12px; border-radius: 16px; background: linear-gradient(160deg, rgba(255,255,255,.08), rgba(255,255,255,.02)); border: 1px solid rgba(255,255,255,.1); }
372
+ .stats-row b { display: block; font: 900 22px var(--wide); } .stats-row span { font: 600 11px var(--body); color: var(--mute); text-transform: uppercase; letter-spacing: .1em; }
373
+ .goals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
374
+ .goal { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 14px; background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.08); }
375
+ .goal b { font-size: 22px; } .goal span { display: block; font: 700 13px var(--body); } .goal small { color: var(--mute); font-size: 11.5px; }
376
+ .goal i { display: block; height: 5px; border-radius: 3px; margin-top: 5px; background: linear-gradient(90deg, #ffd23d calc(var(--v) * 100%), rgba(255,255,255,.12) 0); }
377
+ .goal em { font: 700 12px var(--body); font-style: normal; color: var(--mute); } .goal.ok { border-color: rgba(255,210,61,.45); background: rgba(255,210,61,.08); }
378
+ .g-menu .menu-grid section { transition: border-color .2s; } .g-menu .menu-grid section:hover { border-color: rgba(255,255,255,.2); }
379
+ .g-menu[hidden] + * {} .g-menu:not([hidden]) > * { animation: menuIn .28s cubic-bezier(.2,.8,.2,1) both; }
380
+ @keyframes menuIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
381
+ @media (max-width: 820px) { .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .goals { grid-template-columns: minmax(0, 1fr); } #playUI .hud-tr .chips { display: none; } }
382
+ .g-welcome { max-width: 460px !important; text-align: left; }
383
+ .g-welcome h2 { font: 900 30px var(--wide); margin: 0 0 4px; } .g-welcome .sub { color: var(--mute); margin: 0 0 14px; }
384
+ .g-welcome .tips { display: grid; gap: 8px; margin-bottom: 14px; }
385
+ .g-welcome .tips div { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); font-size: 13.5px; }
386
+ .g-welcome .tips b { font-size: 24px; } .g-welcome kbd { padding: 1px 6px; font-size: 11px; }
387
+ .g-welcome .big-go { width: 100%; padding: 14px; font-size: 14px; }
388
+ .touch-only { display: none; } @media (pointer: coarse) { .touch-only { display: block; } }
389
+ .g-job { padding: 7px 16px; border-radius: 12px; background: rgba(60,46,0,.8); border: 1px solid rgba(255,210,61,.6); color: #ffe48a; font: 700 14px var(--body); white-space: nowrap; }
390
+ .g-job[hidden] { display: none; }
391
+ @media (max-width: 820px) { .g-job { font-size: 12px; white-space: normal; } }
392
+ /* the menu takes its own scrolling (it sits inside the click-through play layer) */
393
+ .g-menu { pointer-events: auto !important; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
394
+ .g-panel { overscroll-behavior: contain; }
395
 
396
  .gpu { margin: 4px 0 8px; } .gpu .warn { color: #ffb347; }
397
+
398
+ /* garage performance upgrades */
399
+ #upgBody .grp { border-bottom: 1px solid var(--line); }
400
+ .upg { display: grid; gap: 8px; }
401
+ .up-row { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }
402
+ .up-row > b { font-size: 20px; } .up-row span { display: block; font: 700 13px var(--body); } .up-row small { color: var(--mute); font-size: 11px; }
403
+ .up-row i { display: flex; gap: 4px; margin-top: 5px; } .up-row u { width: 22px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.14); } .up-row u.on { background: #ffd23d; }
404
+ .up-row button { padding: 7px 11px; border-radius: 999px; border: 0; background: #ffd23d; color: #111; font: 800 12px var(--body); cursor: pointer; }
405
+ .up-row button:disabled { background: rgba(255,255,255,.1); color: var(--mute); cursor: not-allowed; }
406
+ .up-row em { font: 800 11px var(--body); font-style: normal; color: #ffd23d; }
407
+ #gCash { color: #9dffb0; }
408
+ .up-note { margin: 10px 0 0; color: var(--mute); font-size: 11.5px; line-height: 1.4; }