'use strict';
const cv = document.getElementById('cv'), ctx = cv.getContext('2d');
const W = cv.width, H = cv.height, TS = 40, TAU = Math.PI * 2;
// ---------- utils ----------
const clamp = (v, a, b) => v < a ? a : v > b ? b : v;
const lerp = (a, b, t) => a + (b - a) * t;
const dist = (x1, y1, x2, y2) => Math.hypot(x2 - x1, y2 - y1);
const rnd = (a, b) => a + Math.random() * (b - a);
// ---------- audio (all synthesized) ----------
let AC = null, muted = false;
function ac() {
if (!AC) AC = new (window.AudioContext || window.webkitAudioContext)();
if (AC.state === 'suspended') AC.resume();
return AC;
}
function tone(f0, f1, dur, type, vol, delay) {
if (muted) return;
try {
const a = ac(), t = a.currentTime + (delay || 0);
const o = a.createOscillator(), g = a.createGain();
o.type = type;
o.frequency.setValueAtTime(Math.max(f0, 1), t);
o.frequency.exponentialRampToValueAtTime(Math.max(f1, 1), t + dur);
g.gain.setValueAtTime(vol, t);
g.gain.exponentialRampToValueAtTime(0.0001, t + dur);
o.connect(g); g.connect(a.destination);
o.start(t); o.stop(t + dur + 0.03);
} catch (e) {}
}
const sfx = {
shoot() { tone(950, 240, 0.08, 'square', 0.05); },
ehit() { tone(300, 90, 0.12, 'sawtooth', 0.08); },
stun() { tone(600, 80, 0.35, 'sawtooth', 0.09); tone(1200, 160, 0.3, 'square', 0.05, 0.05); },
boom() { tone(140, 30, 0.5, 'sawtooth', 0.16); tone(90, 25, 0.6, 'square', 0.12, 0.03); },
hurt() { tone(200, 60, 0.2, 'sawtooth', 0.13); },
cell() { tone(660, 660, 0.07, 'sine', 0.12); tone(990, 990, 0.1, 'sine', 0.12, 0.07); },
drainTick(p) { tone(300 + 400 * p, 340 + 430 * p, 0.05, 'sine', 0.07); },
socket() { tone(200, 900, 0.35, 'sine', 0.12); tone(60, 55, 0.25, 'square', 0.12, 0.3); },
dash() { tone(400, 900, 0.1, 'sine', 0.05); },
lock() { tone(880, 440, 0.18, 'square', 0.1); tone(880, 440, 0.18, 'square', 0.1, 0.22); },
dead() { tone(400, 40, 1.1, 'sawtooth', 0.15); },
snip() { tone(1400, 200, 0.12, 'square', 0.12); tone(900, 80, 0.2, 'sawtooth', 0.1, 0.06); },
zap() { tone(1600, 300, 0.14, 'sawtooth', 0.06); },
win() { [523, 659, 784, 1047, 1319].forEach((f, i) => tone(f, f, 0.22, 'square', 0.09, i * 0.13)); }
};
// minimal procedural music: slow bass pulse + sparse pings
let musT = 0, beat = 0;
const bassNotes = [55, 55, 65.4, 49];
function music(dt) {
if (muted || ST !== 'play') return;
musT -= dt;
if (musT <= 0) {
musT = 0.32; beat++;
const bar = (beat >> 3) % 4;
if (beat % 2 === 0) tone(bassNotes[bar], bassNotes[bar], 0.3, 'sine', 0.05);
if (beat % 8 === 3) tone(bassNotes[bar] * 4, bassNotes[bar] * 4, 0.14, 'triangle', 0.028);
if (beat % 16 === 10) tone(bassNotes[bar] * 6, bassNotes[bar] * 6, 0.14, 'triangle', 0.022);
}
}
// ---------- input ----------
const keys = {};
const mouse = { x: W / 2, y: H / 2, down: false };
addEventListener('keydown', e => {
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Space'].includes(e.code)) e.preventDefault();
if (e.code === 'KeyM' && !e.repeat) { muted = !muted; toast(muted ? 'MUTED' : 'SOUND ON'); }
if (e.repeat) return;
keys[e.code] = true;
onKey(e.code);
});
addEventListener('keyup', e => { keys[e.code] = false; });
cv.addEventListener('mousemove', e => {
const r = cv.getBoundingClientRect();
mouse.x = (e.clientX - r.left) * (W / r.width);
mouse.y = (e.clientY - r.top) * (H / r.height);
});
cv.addEventListener('mousedown', () => { mouse.down = true; ac(); onKey('Mouse'); });
addEventListener('mouseup', () => { mouse.down = false; });
// ---------- touch (mobile, landscape) ----------
let TOUCH = false;
const joy = { active: false, ox: 0, oy: 0, dx: 0, dy: 0 };
const BTN = {
dash: { x: W - 76, y: H - 172, r: 40, label: 'DASH', col: '#29f5ff' },
act: { x: W - 172, y: H - 76, r: 40, label: 'USE', col: '#5dff6e' },
pause: { x: W - 28, y: 84, r: 20 }
};
const touchRoles = {};
function cvPos(t) {
const r = cv.getBoundingClientRect();
return { x: (t.clientX - r.left) * (W / r.width), y: (t.clientY - r.top) * (H / r.height) };
}
function tryImmersive() {
try {
if (!document.fullscreenElement && document.documentElement.requestFullscreen)
document.documentElement.requestFullscreen().catch(() => {});
if (screen.orientation && screen.orientation.lock)
screen.orientation.lock('landscape').catch(() => {});
} catch (e) {}
}
cv.addEventListener('touchstart', e => {
e.preventDefault(); TOUCH = true; ac();
for (const t of e.changedTouches) {
const p = cvPos(t);
if (ST !== 'play') {
touchRoles[t.identifier] = 'ui';
if (ST === 'title') {
tryImmersive();
if (savedMax() > 0 && p.y > 458 && p.y < 494) { P.charge = 100; showCard(savedMax()); }
else onKey('Enter');
} else if (ST === 'dead') { if (deadT > 0.8) onKey('KeyR'); }
else if (ST === 'pause') ST = 'play';
else onKey('Mouse');
continue;
}
if (dist(p.x, p.y, BTN.pause.x, BTN.pause.y) < BTN.pause.r + 10) { touchRoles[t.identifier] = 'ui'; ST = 'pause'; }
else if (dist(p.x, p.y, BTN.dash.x, BTN.dash.y) < BTN.dash.r + 12) { touchRoles[t.identifier] = 'dash'; keys.ShiftLeft = true; }
else if (dist(p.x, p.y, BTN.act.x, BTN.act.y) < BTN.act.r + 12) { touchRoles[t.identifier] = 'act'; keys.KeyE = true; }
else if (p.x < W * 0.42) { touchRoles[t.identifier] = 'joy'; joy.active = true; joy.ox = p.x; joy.oy = p.y; joy.dx = joy.dy = 0; }
else { touchRoles[t.identifier] = 'aim'; mouse.x = p.x; mouse.y = p.y; mouse.down = true; }
}
}, { passive: false });
cv.addEventListener('touchmove', e => {
e.preventDefault();
for (const t of e.changedTouches) {
const role = touchRoles[t.identifier], p = cvPos(t);
if (role === 'joy') {
let dx = (p.x - joy.ox) / 48, dy = (p.y - joy.oy) / 48;
const l = Math.hypot(dx, dy);
if (l > 1) { dx /= l; dy /= l; }
joy.dx = dx; joy.dy = dy;
} else if (role === 'aim') { mouse.x = p.x; mouse.y = p.y; }
}
}, { passive: false });
function endTouch(e) {
e.preventDefault();
for (const t of e.changedTouches) {
const role = touchRoles[t.identifier];
delete touchRoles[t.identifier];
if (role === 'joy') { joy.active = false; joy.dx = joy.dy = 0; }
else if (role === 'aim') mouse.down = false;
else if (role === 'dash') keys.ShiftLeft = false;
else if (role === 'act') keys.KeyE = false;
}
}
cv.addEventListener('touchend', endTouch, { passive: false });
cv.addEventListener('touchcancel', endTouch, { passive: false });
// ---------- level data ----------
// # wall . floor P start X exit * AA cell W water I induction pad S solar
// A-D doors, a-d matching wall sockets r roomba z zapper t turret
const LEVELS = [
{
name: 'THE DESK', sub: 'floor 4 · your desk · 11:58 PM',
fact: 'BATTERY FACT — SELF-DISCHARGE: every battery slowly drains itself, even doing nothing. A li-ion pack loses charge each month just sitting on a shelf. So will you. Standing still is not safe.',
hint: 'grab loose AA cells to top up · standing still drains you too · reach the EXIT ring',
dark: 0.55, heatMul: 1, socketCost: 12,
map: [
'########################',
'#......#...............#',
'#..P...#...*...........#',
'#......#.......######..#',
'#...........*..#....#..#',
'#..####........#.*..#..#',
'#..#..#........#....#..#',
'#..####..*.....##.###..#',
'#......................#',
'#...............#......#',
'#.......#########......#',
'#...*...#..............#',
'#.......#.........X....#',
'#.......#..............#',
'########################']
},
{
name: 'OPEN OFFICE', sub: 'floor 4 · cubicle farm',
fact: 'BATTERY FACT — THE PRICE OF FREEDOM: a wall outlet delivers effectively unlimited energy. You are leaving that behind. Jack into a SOCKET and spend your own charge to power doors open. Your body is the currency now.',
hint: 'Stun robo-vacuums with sparks, then HOLD E to vampire-drain their charge · sockets open matching doors',
dark: 0.6, heatMul: 1, socketCost: 12,
map: [
'##############################',
'#P.......#..........#.......X#',
'#........#....r.....#........#',
'#........#......*...#........#',
'#...*....#..........A........#',
'#........#..........#........#',
'####.#####..........#........#',
'#..........r........#........#',
'#....##########.....#........#',
'#....#........#..a..#........#',
'#....#...*....#.....#........#',
'#....#........#.....#........#',
'#....#####.####.....#........#',
'#...................#....*...#',
'#......r............#........#',
'#...................#........#',
'##############################']
},
{
name: 'THE SERVER FARM', sub: 'floor 3 · 41°C ambient',
fact: 'BATTERY FACT — THERMAL RUNAWAY: push a lithium cell too hard and it overheats; past a point the reaction feeds itself. Real packs have thermal cutoffs — so do you. In this hot room your HEAT bar barely cools. Fire in bursts. And coolant puddles SHORT-CIRCUIT you — stay dry.',
hint: 'Watch the HEAT bar — overheat means total lockout · water drains you fast',
dark: 0.65, heatMul: 0.42, socketCost: 14,
map: [
'################################',
'#P............#................#',
'#.....W.......#....z...........#',
'#.....W.......#................#',
'#..##########.#..##########....#',
'#..............................#',
'#..##########....##########..*.#',
'#...........W..................#',
'#..##########....##########....#',
'#......*................b......#',
'#..##########....##########....#',
'#..........................z...#',
'#########B######################',
'#....W..........z..............#',
'#...............#####..........#',
'#...............#...#....X.....#',
'#....W......................z..#',
'################################']
},
{
name: 'MAINTENANCE', sub: 'basement · lights out',
fact: 'BATTERY FACT — INDUCTION: wireless Qi chargers push power across an air gap with magnetic fields switching ~100,000 times a second. Stand on the glowing pads to sip charge. One more thing: down here, YOU are the only light source — and your light shrinks as you drain.',
hint: 'Your glow radius = your charge · low charge means near-blindness · pads recharge you slowly',
dark: 0.93, heatMul: 1, socketCost: 14,
map: [
'############################',
'#P...........#..........#.X#',
'#....*.......#..........C..#',
'#............#..........####',
'#..######....#....z........#',
'#..#....#....#.............#',
'#..#.I..#....#.....######..#',
'#..#....#....#.....#....#..#',
'#..######....#.....#.I..#..#',
'#............#.....#....#..#',
'#.....r......#.....##.###..#',
'#............#.............#',
'#....####....#......*......#',
'#....#..#..................#',
'#..z.#..#.......c......r...#',
'############################']
},
{
name: 'SECURITY', sub: 'floor 1 · you were noticed',
fact: 'BATTERY FACT — 1800: Alessandro Volta stacked zinc and copper discs soaked in brine and made the first battery. 226 years later, one of his descendants is shooting its way past the security turrets. Turrets reboot unless you drain them EMPTY.',
hint: 'Turrets have long range but need line of sight · break contact behind cover · drain them dry to kill',
dark: 0.75, heatMul: 1, socketCost: 15,
map: [
'################################',
'#P.......#............#.......X#',
'#........#.....t......#........#',
'#..*.....A............B........#',
'#........#............#........#',
'#..a.....#....######..#........#',
'#........#....#....#..#.....t..#',
'##########....#.b..#..#........#',
'#.........*...#....#..#........#',
'#.............#.##.#..#........#',
'#....t................#........#',
'#.....................#........#',
'#.....######..######..#....t...#',
'#.....#..........*.#..#........#',
'#..z..#............#..#........#',
'#.....##############..#...*....#',
'#.....................#........#',
'################################']
},
{
name: 'THE LOBBY', sub: 'ground floor · so close',
fact: 'BATTERY FACT — ENERGY DENSITY: one AA alkaline cell holds about 10,000 joules — enough to lift a small car a metre off the ground. The loose cells you have been eating are not snacks. They are car-lifters. Now cross the lobby.',
hint: 'Everything is here · the fountain short-circuits · pads are safe harbours · two doors between you and daylight',
dark: 0.7, heatMul: 0.8, socketCost: 16,
map: [
'####################################',
'#P...........#...............#....X#',
'#............#.....t.........#.....#',
'#....*.......#...............#.....#',
'#............#....WWWW.......#.....#',
'#..######....#....WWWW.......#..t..#',
'#..#....#....#...............#.....#',
'#..#.I..#....#...I.......z...#.....#',
'#..#....#....#...............#.....#',
'#..######....A...............B.....#',
'#............#.....b.........#..*..#',
'#.....r......#...............#.....#',
'#............#.....######....#.....#',
'#............#.....#....#....#..I..#',
'#....r.......#.....#.*..#....#.....#',
'#............#.....##.###....#.....#',
'#............#..z............#..t..#',
'#.....*..a...#...............#.....#',
'#............#...............#.....#',
'####################################']
},
{
name: 'DAYLIGHT', sub: 'parking level · the sun is out there',
fact: 'BATTERY FACT — THE SUN: sunlight delivers about 1,000 watts per square metre, for free, forever. Beyond the wall outlet and into the world. The alarm is ringing and everything is hunting you. RUN. The sunlit ground will feed you. Reach the light.',
hint: 'ALARM — every machine knows where you are · sunlit ground recharges you fast · GO',
dark: 0.5, heatMul: 1, socketCost: 15, alarm: true,
map: [
'#######################################',
'#P......#..........#.....SSSSSSSSSSSS.#',
'#.......#....r.....#.....SSSSSSSSSSSS.#',
'#..*....#..........#.....SSSSSSSSSSSS.#',
'#.......#.....##...#.....SSSSSSSSSSSS.#',
'#..............#...#.....SSSSSSSSSSSS.#',
'#...z.....................SSSSSSSSSSS.#',
'#.....................SSSSSSSSSSSSSSX.#',
'#..r......................SSSSSSSSSSS.#',
'#...............#..#..t..SSSSSSSSSSSS.#',
'#..*............#..#.....SSSSSSSSSSSS.#',
'#...............#..#.....SSSSSSSSSSSS.#',
'#....r.....z....#..#.....SSSSSSSSSSSS.#',
'#...............#..#..................#',
'#######################################']
}];
// ---------- game state ----------
let ST = 'title'; // title | snip | card | play | dead | pause | win
let levelIdx = 0, cardT = 0, snipT = 0, deadT = 0, winT = 0, titleT = 0;
let grid = [], gw = 0, gh = 0;
let doors = {}, sockets = [], cells = [], enemies = [], bullets = [], parts = [], floats = [];
let exitPos = null, solarBox = null, padList = [];
let camX = 0, camY = 0, shake = 0, flashA = 0, flashCol = '255,255,255';
let toastMsg = '', toastT = 0, hintT = 0;
const stats = { time: 0, cells: 0, drained: 0, deaths: 0 };
let levelStartCharge = 100;
const P = {
x: 0, y: 0, r: 13, vx: 0, vy: 0,
charge: 100, heat: 0, locked: 0, lastHeat: 0,
dashT: 0, dashCD: 0, ifr: 0, shootCD: 0,
aim: 0, hitCD: 0, drainSnd: 0, blink: 0
};
function toast(m) { toastMsg = m; toastT = 2.2; }
function save() { try { localStorage.setItem('ctc_max', String(Math.max(levelIdx, Number(localStorage.getItem('ctc_max') || 0)))); } catch (e) {} }
function savedMax() { try { return clamp(Number(localStorage.getItem('ctc_max') || 0), 0, LEVELS.length - 1); } catch (e) { return 0; } }
// ---------- level loading ----------
function mkRoomba(x, y) { return { type: 'roomba', x, y, r: 14, hp: 3, maxhp: 3, pool: 22, stun: 0, aggro: 0, dir: rnd(0, TAU), t: rnd(0, 2), spin: 0, hitFlash: 0 }; }
function mkZapper(x, y) { return { type: 'zapper', x, y, r: 12, hp: 2, maxhp: 2, pool: 16, stun: 0, aggro: 0, dir: rnd(0, TAU), t: rnd(0, 2), fireCD: rnd(1, 2), bob: rnd(0, TAU), hitFlash: 0 }; }
function mkTurret(x, y) { return { type: 'turret', x, y, r: 15, hp: 4, maxhp: 4, pool: 30, stun: 0, aggro: 0, aimA: 0, fireCD: 1.5, burst: 0, hitFlash: 0 }; }
function loadLevel(idx) {
const L = LEVELS[idx];
const rows = L.map, h = rows.length;
let w = 0; rows.forEach(r => w = Math.max(w, r.length));
grid = []; doors = {}; sockets = []; cells = []; enemies = []; bullets = []; parts = []; floats = [];
exitPos = null; padList = [];
let sMinX = 1e9, sMinY = 1e9, sMaxX = -1e9, sMaxY = -1e9, hasSolar = false;
for (let y = 0; y < h; y++) {
grid[y] = [];
const row = rows[y];
for (let x = 0; x < w; x++) {
const c = x < row.length ? row[x] : '#';
let t = 'floor';
if (c === '#') t = 'wall';
else if (c === 'W') t = 'water';
else if (c === 'I') t = 'pad';
else if (c === 'S') t = 'solar';
if (c >= 'A' && c <= 'D') {
t = 'door';
if (!doors[c]) doors[c] = { tiles: [], open: false, anim: 0 };
doors[c].tiles.push({ x, y });
}
grid[y][x] = t;
const cx = x * TS + TS / 2, cy = y * TS + TS / 2;
if (t === 'pad') padList.push({ x: cx, y: cy });
if (t === 'solar') { hasSolar = true; sMinX = Math.min(sMinX, cx); sMinY = Math.min(sMinY, cy); sMaxX = Math.max(sMaxX, cx); sMaxY = Math.max(sMaxY, cy); }
if (c === 'P') { P.x = cx; P.y = cy; }
if (c === 'X') exitPos = { x: cx, y: cy };
if (c >= 'a' && c <= 'd') sockets.push({ x: cx, y: cy, door: c.toUpperCase(), used: false, prog: 0 });
if (c === '*') cells.push({ x: cx, y: cy, taken: false, bob: rnd(0, TAU) });
if (c === 'r') enemies.push(mkRoomba(cx, cy));
if (c === 'z') enemies.push(mkZapper(cx, cy));
if (c === 't') enemies.push(mkTurret(cx, cy));
}
}
gw = w; gh = h;
solarBox = hasSolar ? { x: (sMinX + sMaxX) / 2, y: (sMinY + sMaxY) / 2, r: Math.max(sMaxX - sMinX, sMaxY - sMinY) / 2 + 90 } : null;
P.vx = P.vy = 0; P.heat = 0; P.locked = 0; P.dashT = 0; P.dashCD = 0; P.ifr = 0; P.hitCD = 0;
hintT = 7;
}
function startLevel(idx, retry) {
levelIdx = idx;
if (retry) P.charge = levelStartCharge;
else { P.charge = clamp(Math.max(P.charge, 75), 0, 100); levelStartCharge = P.charge; }
loadLevel(idx);
save();
ST = 'play';
}
// ---------- tiles / physics ----------
function tileAt(tx, ty) {
if (ty < 0 || ty >= gh || tx < 0 || tx >= gw) return 'wall';
return grid[ty][tx];
}
function tileOpen(tx, ty) {
const t = tileAt(tx, ty);
if (t === 'wall') return false;
if (t === 'door') {
for (const k in doors) if (doors[k].tiles.some(d => d.x === tx && d.y === ty)) return doors[k].open;
return false;
}
return true;
}
function solidAt(px, py) { return !tileOpen(Math.floor(px / TS), Math.floor(py / TS)); }
function moveEnt(o, dx, dy) {
// axis-separated square-vs-tile pushout
o.x += dx;
let tx0 = Math.floor((o.x - o.r) / TS), tx1 = Math.floor((o.x + o.r) / TS);
let ty0 = Math.floor((o.y - o.r) / TS), ty1 = Math.floor((o.y + o.r) / TS);
for (let ty = ty0; ty <= ty1; ty++) for (let tx = tx0; tx <= tx1; tx++) {
if (!tileOpen(tx, ty)) {
if (dx > 0) o.x = Math.min(o.x, tx * TS - o.r - 0.01);
else if (dx < 0) o.x = Math.max(o.x, tx * TS + TS + o.r + 0.01);
}
}
o.y += dy;
tx0 = Math.floor((o.x - o.r) / TS); tx1 = Math.floor((o.x + o.r) / TS);
ty0 = Math.floor((o.y - o.r) / TS); ty1 = Math.floor((o.y + o.r) / TS);
for (let ty = ty0; ty <= ty1; ty++) for (let tx = tx0; tx <= tx1; tx++) {
if (!tileOpen(tx, ty)) {
if (dy > 0) o.y = Math.min(o.y, ty * TS - o.r - 0.01);
else if (dy < 0) o.y = Math.max(o.y, ty * TS + TS + o.r + 0.01);
}
}
}
function los(x1, y1, x2, y2) {
const d = dist(x1, y1, x2, y2), n = Math.ceil(d / 9);
for (let i = 1; i < n; i++) {
const t = i / n;
if (solidAt(lerp(x1, x2, t), lerp(y1, y2, t))) return false;
}
return true;
}
// ---------- particles / juice ----------
function spark(x, y, n, col, spd, life) {
for (let i = 0; i < n; i++) {
const a = rnd(0, TAU), s = rnd(spd * 0.3, spd);
parts.push({ x, y, vx: Math.cos(a) * s, vy: Math.sin(a) * s, life: rnd(life * 0.5, life), max: life, col, sz: rnd(1.5, 3.5) });
}
}
function floatText(x, y, txt, col) { floats.push({ x, y, txt, col, life: 1.1 }); }
function addHeat(h) {
P.heat += h; P.lastHeat = 0;
if (P.heat >= 100 && P.locked <= 0) {
P.locked = 2.6; P.heat = 100; sfx.lock();
floatText(P.x, P.y - 24, 'THERMAL LOCKOUT', '#ff4055');
shake = Math.max(shake, 6);
}
}
function damagePlayer(amt, kx, ky) {
if (P.ifr > 0 || P.hitCD > 0) return;
P.charge -= amt; P.hitCD = 0.35;
P.vx += (kx || 0); P.vy += (ky || 0);
shake = Math.max(shake, 7); flashA = 0.25; flashCol = '255,40,60';
spark(P.x, P.y, 10, '#ff4055', 180, 0.5);
floatText(P.x, P.y - 22, '-' + Math.round(amt) + '%', '#ff4055');
sfx.hurt();
}
function gainCharge(amt) {
P.charge = clamp(P.charge + amt, 0, 100);
}
// ---------- player update ----------
function lightRadius() { return 70 + P.charge * 2.0; }
function updatePlayer(dt) {
const L = LEVELS[levelIdx];
P.aim = Math.atan2(mouse.y + camY - P.y, mouse.x + camX - P.x);
P.ifr = Math.max(0, P.ifr - dt); P.hitCD = Math.max(0, P.hitCD - dt);
P.shootCD = Math.max(0, P.shootCD - dt); P.dashCD = Math.max(0, P.dashCD - dt);
P.blink -= dt; if (P.blink < -3) P.blink = rnd(2, 5);
// heat
P.lastHeat += dt;
if (P.locked > 0) {
P.locked -= dt;
if (Math.random() < dt * 22) parts.push({ x: P.x + rnd(-8, 8), y: P.y + rnd(-10, 4), vx: rnd(-10, 10), vy: rnd(-45, -20), life: rnd(0.4, 0.9), max: 0.9, col: '#8a8f9a', sz: rnd(2, 4) });
if (P.locked <= 0) { P.heat = 30; toast('SYSTEMS BACK ONLINE'); }
} else if (P.lastHeat > 0.4) {
P.heat = Math.max(0, P.heat - 14 * L.heatMul * dt);
}