Run details
- Model
- qwen/qwen4-35b-a3b
- Route
- OpenRouter API
- Served by
- PrimeIntellect
- Effort
- high (OpenRouter default)
- Limits
- 60 min · 65,536 output tokens (model max)
- Date
- 4 Dec 2026
- Time
- 42 s
- Size
- 22 kB
- Tokens
- 99 in, 10,341 out (1,381 thinking)
- List price
- $0.004 at today's price ($0.06 in / $0.36 out per M)
- Paid
- $0.004
Prompt
Make a Breakout game I can play right now with the keyboard or the mouse. Give it several levels, a score and some juice. It must be one complete, self-contained HTML file: inline all CSS and JavaScript, and make no network requests of any kind (no CDNs, web fonts or remote images). Reply with the file in a single ```html code block.
Source
22 kB 679 lines Raw
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NEON BREAKOUT</title>
<style>
html,body{
margin:0;padding:0;height:100%;
background:radial-gradient(ellipse at 50% 20%, #1a1a3e 0%, #0a0a18 70%);
display:flex;align-items:center;justify-content:center;
font-family:'Segoe UI',Arial,sans-serif;
overflow:hidden;
user-select:none;-webkit-user-select:none;
}
#wrap{position:relative;}
canvas{
display:block;
border-radius:12px;
box-shadow:0 0 60px rgba(80,120,255,.35), 0 0 120px rgba(120,60,255,.15);
cursor:none;
max-width:96vw;max-height:96vh;
}
</style>
</head>
<body>
<div id="wrap"><canvas id="game" width="560" height="680"></canvas></div>
<script>
(() => {
"use strict";
// ---------- setup ----------
const cv = document.getElementById('game');
const ctx = cv.getContext('2d');
const W = cv.width, H = cv.height;
const COLS = 10;
const SIDE = 28;
const CELL_W = (W - SIDE*2) / COLS;
const ROW_H = 26;
const TOP_OFF = 86;
// ---------- audio ----------
let actx = null, muted = false;
function audioInit(){ if(!actx){ try{ actx = new (window.AudioContext||window.webkitAudioContext)(); }catch(e){} } if(actx && actx.state==='suspended') actx.resume(); }
function beep(freq, dur=0.08, type='square', vol=0.16, slide=0){
if(muted || !actx) return;
const t = actx.currentTime;
const o = actx.createOscillator(), g = actx.createGain();
o.type = type; o.frequency.setValueAtTime(freq, t);
if(slide) o.frequency.exponentialRampToValueAtTime(Math.max(30,freq+slide), t+dur);
g.gain.setValueAtTime(vol, t);
g.gain.exponentialRampToValueAtTime(0.0001, t+dur);
o.connect(g); g.connect(actx.destination);
o.start(t); o.stop(t+dur+0.02);
}
function chord(base){ beep(base,0.12,'triangle',0.14); setTimeout(()=>beep(base*1.5,0.14,'triangle',0.12),60); setTimeout(()=>beep(base*2,0.2,'triangle',0.1),120); }
// ---------- input ----------
const keys = {};
let mouseX = null, mouseActive = false;
addEventListener('keydown', e=>{
if(['ArrowLeft','ArrowRight',' ','Spacebar'].includes(e.key)||['ArrowLeft','ArrowRight',' '].includes(e.code)) e.preventDefault();
audioInit();
keys[e.code] = true;
if(e.code==='Space'||e.code==='Enter') primaryAction();
if(e.code==='KeyP' && state==='play') paused = !paused;
if(e.code==='KeyM'){ muted = !muted; }
});
addEventListener('keyup', e=> keys[e.code] = false);
cv.addEventListener('mousemove', e=>{
const r = cv.getBoundingClientRect();
mouseX = (e.clientX - r.left) * (W / r.width);
mouseActive = true;
});
cv.addEventListener('mousedown', ()=>{ audioInit(); primaryAction(); });
cv.addEventListener('touchmove', e=>{
e.preventDefault();
const r = cv.getBoundingClientRect();
mouseX = (e.touches[0].clientX - r.left) * (W / r.width);
mouseActive = true;
}, {passive:false});
cv.addEventListener('touchstart', e=>{ audioInit(); primaryAction(); }, {passive:true});
// ---------- levels ----------
// chars: '.' empty, '1'-'9' brick hp, 'F' reinforced(fixed, indestructible)
const LEVELS = [
[
"..........",
"1111111111",
".11111111.",
"..1.11.1..",
],
[
"1.1.1.1.1.",
"2222222222",
".2.2.2.2.2",
"1111111111",
"..111111..",
],
[
"F........F",
".22222222.",
".2.2222.2.",
".22222222.",
"F..21112.F",
"...1111...",
],
[
"...2222...",
"..233332..",
".23F..F32.",
"233.22.332",
"233.22.332",
".222..222.",
"F1111111F",
],
[
"3333333333",
"3F333333F3",
"3322222233",
"2F222222F2",
"2211111122",
"33.3333.33",
".F.3333.F.",
],
];
const BRICK_COLORS = {
1:['#3fd2ff','#7ee6ff'],
2:['#8f6bff','#b9a3ff'],
3:['#ff5fa8','#ff9cc8'],
4:['#ffb84d','#ffd699'],
5:['#5dff9d','#a9ffca'],
6:['#ff6b6b','#ffa3a3'],
7:['#ffe74d','#fff3a3'],
8:['#4de1ff','#b3f2ff'],
9:['#ffffff','#ffffff'],
};
const FIXED_COL = ['#5a6070','#8a92a6'];
// ---------- state ----------
let state = 'menu'; // menu | play | deadwait | levelmsg | gameover | victory
let paused = false;
let level = 0;
let score = 0, best = 0, lives = 3, combo = 0, maxCombo = 0;
let shake = 0, flash = 0, freezeT = 0;
let msgTimer = 0, msgText = '';
let timeScale = 1, slowTimer = 0;
let wideTimer = 0;
const paddle = { x: W/2, y: H-42, w: 96, h: 14, speed: 560 };
let bricks = [];
let balls = [];
let particles = [];
let floaters = [];
let powerups = [];
let stars = [];
for(let i=0;i<70;i++) stars.push({x:Math.random()*W, y:Math.random()*H, s:Math.random()*1.6+0.4, tw:Math.random()*6.28});
// ---------- helpers ----------
function resetBallOnPaddle(){
balls = [{ x:paddle.x, y:paddle.y-14, vx:0, vy:0, r:7, stuck:true, trail:[] }];
}
function launchBalls(){
let launched = false;
for(const b of balls){
if(b.stuck){
const ang = -Math.PI/2 + (Math.random()*0.6-0.3);
const sp = ballSpeed();
b.vx = Math.cos(ang)*sp; b.vy = Math.sin(ang)*sp;
b.stuck = false;
launched = true;
}
}
if(launched) beep(520,0.08,'triangle',0.15,300);
}
function ballSpeed(){ return 300 + level*26 + Math.min(score/1500,80)*(state==='play'?1:0)*0 ; }
function baseSpeed(){ return 296 + level*26; }
function buildLevel(n){
bricks = [];
const rows = LEVELS[n % LEVELS.length];
for(let r=0;r<rows.length;r++){
const row = rows[r];
for(let c=0;c<COLS;c++){
const ch = row[c] || '.';
if(ch === '.') continue;
const bx = SIDE + c*CELL_W, by = TOP_OFF + r*ROW_H;
if(ch === 'F'){
bricks.push({x:bx+2,y:by+2,w:CELL_W-4,h:ROW_H-5,hp:Infinity,max:Infinity,fixed:true});
} else {
const hp = parseInt(ch,10);
bricks.push({x:bx+2,y:by+2,w:CELL_W-4,h:ROW_H-5,hp:hp,max:hp,fixed:false});
}
}
}
powerups = [];
wideTimer = 0; slowTimer = 0; timeScale = 1;
paddle.w = 96;
combo = 0;
resetBallOnPaddle();
}
function spawnParticles(x,y,color,n,power=1){
for(let i=0;i<n;i++){
const a = Math.random()*Math.PI*2, s = (60+Math.random()*260)*power;
particles.push({x,y,vx:Math.cos(a)*s,vy:Math.sin(a)*s-60,life:0.5+Math.random()*0.5,max:1,color,size:2+Math.random()*3.5});
}
}
function addFloater(x,y,text,color='#fff',big=false){
floaters.push({x,y,text,life:1,color,big});
}
function addScore(pts,x,y,color){
const gain = pts * (1 + Math.floor(combo/4));
score += gain;
addFloater(x,y,'+'+gain,color || '#ffe74d', combo>=8);
if(score > best) best = score;
}
// powerups
const PU_TYPES = ['wide','multi','slow','life'];
const PU_COLORS = {wide:'#3fd2ff', multi:'#ff5fa8', slow:'#8f6bff', life:'#5dff9d'};
const PU_LABEL = {wide:'W', multi:'M', slow:'S', life:'♥'};
function maybeDropPowerup(x,y){
if(Math.random() < 0.13){
const t = PU_TYPES[Math.floor(Math.random()*PU_TYPES.length)];
powerups.push({x,y,t,vy:150});
}
}
function applyPowerup(t){
beep(700,0.1,'triangle',0.18,400);
chord(600);
addFloater(paddle.x, paddle.y-30, ({wide:'WIDE PADDLE!',multi:'MULTIBALL!',slow:'SLOW-MO!',life:'+1 LIFE!'})[t], PU_COLORS[t]);
if(t==='wide'){ wideTimer = 12; }
if(t==='slow'){ slowTimer = 7; }
if(t==='life'){ lives++; }
if(t==='multi'){
const src = balls.find(b=>!b.stuck) || balls[0];
if(src){
for(let i=0;i<2;i++){
const ang = Math.atan2(src.vy||-1, src.vx||0.3) + (i?0.5:-0.5);
const sp = baseSpeed();
balls.push({x:src.x,y:src.y,vx:Math.cos(ang)*sp,vy:Math.sin(ang)*sp,r:7,stuck:false,trail:[]});
}
if(src.stuck){ src.stuck=false; const sp=baseSpeed(); src.vx=Math.cos(-Math.PI/2+0.2)*sp; src.vy=Math.sin(-Math.PI/2+0.2)*sp; }
}
}
}
// ---------- flow ----------
function primaryAction(){
if(state==='menu'){ startGame(); return; }
if(state==='gameover'||state==='victory'){ state='menu'; return; }
if(state==='play'){ launchBalls(); }
}
function startGame(){
score = 0; lives = 3; level = 0; combo = 0; maxCombo = 0;
buildLevel(0);
state = 'play';
msgText = 'LEVEL ' + (level+1); msgTimer = 1.4;
beep(440,0.1,'triangle',0.15);
}
function nextLevel(){
level++;
if(level >= LEVELS.length){
state = 'victory';
chord(523);
return;
}
buildLevel(level);
state = 'play';
msgText = 'LEVEL ' + (level+1); msgTimer = 1.4;
chord(440);
}
// ---------- update ----------
function loseLife(){
lives--;
shake = 14; flash = 0.5; freezeT = 0.35;
beep(160,0.35,'sawtooth',0.2,-110);
combo = 0;
if(lives < 0){
state = 'gameover';
} else {
state = 'deadwait';
msgTimer = 1.0;
msgText = lives===0 ? 'LAST LIFE!' : '-1 LIFE';
setTimeout(()=>{ if(state==='deadwait'){ resetBallOnPaddle(); state='play'; } }, 700);
}
}
function update(dt){
// global timers
if(shake > 0) shake = Math.max(0, shake - dt*36);
if(flash > 0) flash = Math.max(0, flash - dt*2.2);
if(msgTimer > 0) msgTimer -= dt;
if(freezeT > 0){ freezeT -= dt; return; }
if(slowTimer > 0){ slowTimer -= dt; timeScale = 0.55; } else timeScale = 1;
if(wideTimer > 0){ wideTimer -= dt; if(wideTimer<=0) paddle.w = 96; }
const effDt = dt * timeScale;
// paddle
const targetW = wideTimer>0 ? 150 : 96;
paddle.w += (targetW - paddle.w) * Math.min(1, dt*10);
if(keys.ArrowLeft || keys.KeyA){ paddle.x -= paddle.speed*dt; mouseActive = false; }
if(keys.ArrowRight || keys.KeyD){ paddle.x += paddle.speed*dt; mouseActive = false; }
if(mouseActive && mouseX !== null && !keys.ArrowLeft && !keys.KeyA && !keys.KeyRight && !keys.KeyD){
paddle.x += (mouseX - paddle.x) * Math.min(1, dt*22);
}
paddle.x = Math.max(paddle.w/2+4, Math.min(W-paddle.w/2-4, paddle.x));
// balls
const sp = baseSpeed();
for(let bi = balls.length-1; bi>=0; bi--){
const b = balls[bi];
if(b.stuck){ b.x = paddle.x; b.y = paddle.y - b.r - 6; continue; }
// normalize speed toward current base (keeps pace with level)
const cur = Math.hypot(b.vx,b.vy);
if(cur>0){ const want = sp * (slowTimer>0?0.7:1); const f = 1 + (want-cur)/cur * Math.min(1,dt*0.6); b.vx*=f; b.vy*=f; }
b.x += b.vx*effDt; b.y += b.vy*effDt;
b.trail.push({x:b.x,y:b.y}); if(b.trail.length>9) b.trail.shift();
// walls
if(b.x < b.r){ b.x=b.r; b.vx=Math.abs(b.vx); beep(300,0.04,'square',0.08); spawnParticles(b.x,b.y,'#7ee6ff',4,0.5); }
if(b.x > W-b.r){ b.x=W-b.r; b.vx=-Math.abs(b.vx); beep(300,0.04,'square',0.08); spawnParticles(b.x,b.y,'#7ee6ff',4,0.5); }
if(b.y < b.r+52){ b.y=b.r+52; b.vy=Math.abs(b.vy); beep(300,0.04,'square',0.08); spawnParticles(b.x,b.y,'#7ee6ff',4,0.5); }
// paddle
if(b.vy>0 && b.y+b.r >= paddle.y-paddle.h/2 && b.y-b.r <= paddle.y+paddle.h/2 &&
b.x >= paddle.x-paddle.w/2-b.r && b.x <= paddle.x+paddle.w/2+b.r && b.y < paddle.y+paddle.h){
const rel = (b.x - paddle.x)/(paddle.w/2);
const ang = -Math.PI/2 + rel * 1.05;
b.vx = Math.cos(ang)*sp; b.vy = Math.sin(ang)*sp;
b.y = paddle.y - b.r - paddle.h/2 - 0.5;
combo = 0;
shake = Math.max(shake, 3);
beep(240,0.06,'square',0.14,60);
spawnParticles(b.x, paddle.y-paddle.h/2, '#3fd2ff', 6, 0.6);
}
// bricks
for(let k=0;k<bricks.length;k++){
const br = bricks[k];
if(br.hp<=0) continue;
const cx = Math.max(br.x, Math.min(b.x, br.x+br.w));
const cy = Math.max(br.y, Math.min(b.y, br.y+br.h));
const dx = b.x-cx, dy = b.y-cy;
if(dx*dx+dy*dy <= b.r*b.r){
// resolve axis
const ox = b.r - Math.abs(dx), oy = b.r - Math.abs(dy);
if(Math.abs(dx) > Math.abs(dy)){ b.vx = dx>0? Math.abs(b.vx):-Math.abs(b.vx); b.x += dx>0?ox:-ox; }
else { b.vy = dy>0? Math.abs(b.vy):-Math.abs(b.vy); b.y += dy>0?oy:-oy; }
if(br.fixed){
beep(140,0.05,'square',0.12);
spawnParticles(cx,cy,FIXED_COL[1],5,0.6);
shake = Math.max(shake,2);
} else {
br.hp--;
combo++; maxCombo = Math.max(maxCombo,combo);
const col = BRICK_COLORS[Math.min(br.max,9)][1];
if(br.hp<=0){
spawnParticles(cx,cy,BRICK_COLORS[Math.min(br.max,9)][0],16,1);
spawnParticles(cx,cy,'#ffffff',5,1.3);
shake = Math.max(shake, 4 + Math.min(combo,8));
flash = Math.max(flash, 0.12);
beep(360 + combo*45, 0.07, 'square', 0.15, 120);
addScore(50, cx, cy, combo>=6?'#ff9cc8':'#ffe74d');
maybeDropPowerup(cx,cy);
if(combo>0 && combo%4===0) addFloater(W/2, 300, 'COMBO x'+combo+'!', '#ff5fa8', true);
} else {
spawnParticles(cx,cy,BRICK_COLORS[Math.min(br.max,9)][0],7,0.7);
beep(220+br.hp*60,0.05,'square',0.11);
addScore(15, cx, cy, '#b9a3ff');
}
}
break;
}
}
// fell out
if(b.y > H + 30){
balls.splice(bi,1);
}
}
if(balls.length===0 && state==='play'){ loseLife(); }
// level clear?
if(state==='play' && !bricks.some(b=>b.hp>0 && !b.fixed)){
score += 500 + lives*100;
state = 'levelmsg';
msgText = 'LEVEL CLEAR!'; msgTimer = 1.6;
chord(523);
setTimeout(()=>{ if(state==='levelmsg') nextLevel(); }, 1300);
for(let i=0;i<40;i++) spawnParticles(Math.random()*W, Math.random()*H*0.5+80, ['#ffe74d','#ff5fa8','#3fd2ff'][i%3], 3, 1);
}
// powerups
for(let i=powerups.length-1;i>=0;i--){
const p = powerups[i];
p.y += p.vy*effDt;
if(p.y > H+20){ powerups.splice(i,1); continue; }
if(p.y > paddle.y-14 && p.y < paddle.y+14 && Math.abs(p.x-paddle.x) < paddle.w/2+12){
applyPowerup(p.t);
spawnParticles(p.x,p.y,PU_COLORS[p.t],14,1);
powerups.splice(i,1);
}
}
// particles
for(let i=particles.length-1;i>=0;i--){
const p = particles[i];
p.life -= dt; if(p.life<=0){ particles.splice(i,1); continue; }
p.vy += 620*dt; p.x += p.vx*dt; p.y += p.vy*dt;
}
// floaters
for(let i=floaters.length-1;i>=0;i--){
const f = floaters[i];
f.life -= dt*0.9; f.y -= 42*dt;
if(f.life<=0) floaters.splice(i,1);
}
}
// ---------- render ----------
function roundRect(x,y,w,h,r){
ctx.beginPath();
ctx.moveTo(x+r,y);
ctx.arcTo(x+w,y,x+w,y+h,r);
ctx.arcTo(x+w,y+h,x,y+h,r);
ctx.arcTo(x,y+h,x,y,r);
ctx.arcTo(x,y,x+w,y,r);
ctx.closePath();
}
let tGlobal = 0;
function render(){
tGlobal += 1/60;
ctx.save();
if(shake>0) ctx.translate((Math.random()-0.5)*shake, (Math.random()-0.5)*shake);
// bg
const g = ctx.createLinearGradient(0,0,0,H);
g.addColorStop(0,'#141433'); g.addColorStop(1,'#0a0a1c');
ctx.fillStyle = g;
ctx.fillRect(-20,-20,W+40,H+40);
// stars
for(const s of stars){
const a = 0.25 + 0.35*Math.sin(tGlobal*1.5+s.tw);
ctx.fillStyle = 'rgba(180,200,255,'+a.toFixed(2)+')';
ctx.fillRect(s.x, s.y, s.s, s.s);
}
// top bar separator glow line
ctx.fillStyle = 'rgba(100,140,255,0.25)';
ctx.fillRect(0,52,W,2);
// bricks
for(const br of bricks){
if(br.hp<=0) continue;
let c1,c2;
if(br.fixed){ c1=FIXED_COL[0]; c2=FIXED_COL[1]; }
else { const idx = Math.min(br.hp,9); c1=BRICK_COLORS[idx][0]; c2=BRICK_COLORS[idx][1]; }
ctx.fillStyle = 'rgba(0,0,0,0.35)';
roundRect(br.x+2, br.y+3, br.w, br.h, 4); ctx.fill();
const bg = ctx.createLinearGradient(br.x, br.y, br.x, br.y+br.h);
bg.addColorStop(0, c2); bg.addColorStop(1, c1);
ctx.fillStyle = bg;
roundRect(br.x, br.y, br.w, br.h, 4); ctx.fill();
// shine
ctx.fillStyle = 'rgba(255,255,255,0.22)';
roundRect(br.x+3, br.y+2.5, br.w-6, br.h*0.32, 3); ctx.fill();
if(br.fixed){
ctx.strokeStyle='rgba(255,255,255,0.15)'; ctx.lineWidth=1.5;
ctx.beginPath();
ctx.moveTo(br.x+6,br.y+br.h/2); ctx.lineTo(br.x+br.w-6,br.y+br.h/2);
ctx.stroke();
} else if(br.max>1){
ctx.fillStyle='rgba(255,255,255,0.75)';
ctx.font='bold 11px monospace'; ctx.textAlign='center';
ctx.fillText(br.hp, br.x+br.w/2, br.y+br.h/2+4);
}
}
// powerups
for(const p of powerups){
ctx.save();
ctx.translate(p.x, p.y);
ctx.rotate(Math.sin(tGlobal*6)*0.3);
ctx.shadowColor = PU_COLORS[p.t]; ctx.shadowBlur = 14;
ctx.fillStyle = PU_COLORS[p.t];
roundRect(-11,-11,22,22,6); ctx.fill();
ctx.shadowBlur = 0;
ctx.fillStyle = '#0a0a1c';
ctx.font = 'bold 14px monospace'; ctx.textAlign='center';
ctx.fillText(PU_LABEL[p.t], 0, 5);
ctx.restore();
}
// paddle
const pw = paddle.w, ph = paddle.h, px = paddle.x-pw/2, py = paddle.y-ph/2;
ctx.shadowColor = '#3fd2ff'; ctx.shadowBlur = 16;
const pg = ctx.createLinearGradient(px,py,px,py+ph);
pg.addColorStop(0, wideTimer>0?'#a9ffca':'#b3f2ff'); pg.addColorStop(1, wideTimer>0?'#5dff9d':'#2ba8e0');
ctx.fillStyle = pg;
roundRect(px, py, pw, ph, 7); ctx.fill();
ctx.shadowBlur = 0;
ctx.fillStyle='rgba(255,255,255,0.4)';
roundRect(px+4, py+2.5, pw-8, 4, 2); ctx.fill();
// balls + trails
for(const b of balls){
for(let i=0;i<b.trail.length;i++){
const t = b.trail[i], a = (i/b.trail.length)*0.35;
ctx.fillStyle = 'rgba(126,230,255,'+a.toFixed(2)+')';
ctx.beginPath(); ctx.arc(t.x,t.y, b.r*(i/b.trail.length), 0, 6.28); ctx.fill();
}
ctx.shadowColor='#7ee6ff'; ctx.shadowBlur=18;
const bg = ctx.createRadialGradient(b.x-2,b.y-2,1,b.x,b.y,b.r);
bg.addColorStop(0,'#ffffff'); bg.addColorStop(1,'#57c8ff');
ctx.fillStyle = bg;
ctx.beginPath(); ctx.arc(b.x,b.y,b.r,0,6.28); ctx.fill();
ctx.shadowBlur=0;
}
// particles
for(const p of particles){
ctx.globalAlpha = Math.max(0, p.life/(p.max||1));
ctx.fillStyle = p.color;
ctx.fillRect(p.x-p.size/2, p.y-p.size/2, p.size, p.size);
}
ctx.globalAlpha = 1;
// floaters
for(const f of floaters){
ctx.globalAlpha = Math.min(1, f.life*1.4);
ctx.fillStyle = f.color;
ctx.font = (f.big?'bold 30px':'bold 15px')+' monospace';
ctx.textAlign='center';
ctx.shadowColor=f.color; ctx.shadowBlur=10;
ctx.fillText(f.text, f.x, f.y);
ctx.shadowBlur=0;
}
ctx.globalAlpha = 1;
// HUD
ctx.textAlign='left';
ctx.fillStyle='#9fb4ff'; ctx.font='bold 12px monospace';
ctx.fillText('SCORE', 14, 22);
ctx.fillStyle='#ffffff'; ctx.font='bold 22px monospace';
ctx.fillText(String(score).padStart(6,'0'), 14, 44);
ctx.textAlign='center';
ctx.fillStyle='#9fb4ff'; ctx.font='bold 12px monospace';
ctx.fillText('LEVEL', W/2, 22);
ctx.fillStyle='#ffffff'; ctx.font='bold 22px monospace';
ctx.fillText(String(level+1)+'/'+LEVELS.length, W/2, 44);
ctx.textAlign='right';
ctx.fillStyle='#9fb4ff'; ctx.font='bold 12px monospace';
ctx.fillText('LIVES', W-14, 22);
for(let i=0;i<Math.max(0,lives);i++){
ctx.shadowColor='#7ee6ff'; ctx.shadowBlur=8;
ctx.fillStyle='#7ee6ff';
ctx.beginPath(); ctx.arc(W-20-i*20, 38, 6, 0, 6.28); ctx.fill();
ctx.shadowBlur=0;
}
if(combo>=2){
ctx.textAlign='center'; ctx.fillStyle='#ff5fa8'; ctx.font='bold 14px monospace';
ctx.fillText('COMBO x'+combo, W/2, 70);
}
// messages
if(msgTimer>0 && msgText){
const a = Math.min(1, msgTimer*2);
ctx.globalAlpha = a;
ctx.fillStyle='#fff'; ctx.textAlign='center';
ctx.font='bold 40px monospace';
ctx.shadowColor='#7ee6ff'; ctx.shadowBlur=24;
ctx.fillText(msgText, W/2, H/2-40);
ctx.shadowBlur=0;
ctx.globalAlpha = 1;
}
// overlays
if(state==='menu' || state==='gameover' || state==='victory'){
ctx.fillStyle='rgba(6,6,20,0.82)';
ctx.fillRect(0,0,W,H);
ctx.textAlign='center';
if(state==='menu'){
ctx.shadowColor='#ff5fa8'; ctx.shadowBlur=30;
ctx.fillStyle='#ff5fa8'; ctx.font='bold 46px monospace';
ctx.fillText('NEON', W/2, H/2-120);
ctx.shadowColor='#3fd2ff';
ctx.fillStyle='#3fd2ff';
ctx.fillText('BREAKOUT', W/2, H/2-70);
ctx.shadowBlur=0;
} else if(state==='gameover'){
ctx.shadowColor='#ff6b6b'; ctx.shadowBlur=30;
ctx.fillStyle='#ff6b6b'; ctx.font='bold 46px monospace';
ctx.fillText('GAME OVER', W/2, H/2-100);
ctx.shadowBlur=0;
} else {
ctx.shadowColor='#ffe74d'; ctx.shadowBlur=30;
ctx.fillStyle='#ffe74d'; ctx.font='bold 44px monospace';
ctx.fillText('VICTORY!', W/2, H/2-100);
ctx.shadowBlur=0;
ctx.fillStyle='#fff'; ctx.font='bold 16px monospace';
ctx.fillText('All '+LEVELS.length+' levels cleared. You are a legend.', W/2, H/2-64);
}
ctx.fillStyle='#fff'; ctx.font='bold 18px monospace';
ctx.fillText('SCORE '+score, W/2, H/2-16);
ctx.fillStyle='#9fb4ff'; ctx.font='14px monospace';
ctx.fillText('BEST '+best, W/2, H/2+10);
if(state==='menu'){
ctx.fillStyle='#9fb4ff'; ctx.font='13px monospace';
ctx.fillText('Move: mouse or ← → (A/D)', W/2, H/2+58);
ctx.fillText('Launch: click or SPACE', W/2, H/2+80);
ctx.fillText('P = pause · M = mute', W/2, H/2+102);
ctx.fillText('Catch drops: W wide · M multiball · S slow · ♥ life', W/2, H/2+124);
}
const pulse = 0.6+0.4*Math.sin(tGlobal*4);
ctx.globalAlpha = pulse;
ctx.fillStyle='#ffe74d'; ctx.font='bold 20px monospace';
ctx.fillText(state==='menu' ? 'CLICK OR PRESS SPACE TO START' : 'CLICK OR PRESS SPACE FOR MENU', W/2, H/2+ (state==='menu'?170:60));
ctx.globalAlpha = 1;
}
if(paused && state==='play'){
ctx.fillStyle='rgba(6,6,20,0.6)'; ctx.fillRect(0,0,W,H);
ctx.fillStyle='#fff'; ctx.font='bold 36px monospace'; ctx.textAlign='center';
ctx.fillText('PAUSED', W/2, H/2);
ctx.font='14px monospace'; ctx.fillStyle='#9fb4ff';
ctx.fillText('press P to resume', W/2, H/2+30);
}
// flash
if(flash>0){
ctx.fillStyle='rgba(255,255,255,'+(flash*0.5).toFixed(2)+')';
ctx.fillRect(0,0,W,H);
}
// slow-mo tint
if(slowTimer>0){
ctx.fillStyle='rgba(143,107,255,0.07)';
ctx.fillRect(0,0,W,H);
}
ctx.restore();
// custom cursor dot during play
if(state==='play' && mouseActive && mouseX!==null){
ctx.fillStyle='rgba(255,255,255,0.5)';
ctx.beginPath(); ctx.arc(mouseX, H-42, 2.5, 0, 6.28); ctx.fill();
}
}
// ---------- main loop ----------
let last = performance.now();
function loop(now){
let dt = (now-last)/1000; last = now;
if(dt>0.05) dt=0.05;
if(state==='play' || state==='deadwait' || state==='levelmsg') update(dt);
// particles/floaters still animate in menus
if(!(state==='play'||state==='deadwait'||state==='levelmsg')){
for(let i=particles.length-1;i>=0;i--){
const p=particles[i]; p.life-=dt; if(p.life<=0){particles.splice(i,1);continue;}
p.vy+=620*dt;p.x+=p.vx*dt;p.y+=p.vy*dt;
}
for(let i=floaters.length-1;i>=0;i--){ const f=floaters[i]; f.life-=dt*0.9; f.y-=42*dt; if(f.life<=0)floaters.splice(i,1);}
if(shake>0) shake=Math.max(0,shake-dt*36);
if(flash>0) flash=Math.max(0,flash-dt*2.2);
}
render();
requestAnimationFrame(loop);
}
requestAnimationFrame(loop);
})();
</script>
</body>
</html>

