<!-- SOLID CITY · part 1925 -->
t.mode==='formation'&&ships[0].alive&&ships[1].alive){var saved=n*.18;n*=.82;metrics.defenseSaved+=saved;notify(i,'FORMATION DEFENSE',420)}s.hull-=n;notify(i,flight.mode==='formation'?'FORMATION DEFENSE':'HULL HIT',350);if(s.hull<=0){s.hull=0;s.alive=false;s.respawn=2.4;s.vx=0;s.vy=0;burst(s.x,s.y,s.color,28);notify(i,'RESPAWNING',1600);if(!runEnding&&ships.every(function(q){return !q.alive})){runEnding=true;setTimeout(function(){endRun('defeat')},240)}}}
  function burst(x,y,color,n){for(var i=0;i<n;i++){var a=Math.random()*6.28,sp=40+Math.random()*180;sparks.push({x:x,y:y,vx:Math.cos(a)*sp,vy:Math.sin(a)*sp,life:.3+Math.random()*.55,color:color})}}
  function updateHUD(){
    var now=performance.now();ships.forEach(function(s,i){document.querySelector('#hull'+i).style.width=Math.max(0,s.hull/s.maxHull*100)+'%';document.querySelector('#score'+i).textContent=String(s.score).padStart(4,'0');document.querySelector('#build'+i).innerHTML='<b>H'+s.build.hull+'</b> C'+s.build.cannon+' T'+s.build.thruster+' B'+s.build.bio;var items=[];if(s.shieldCharges>0&&s.shieldUntil>now)items.push('<span class="power shield on">SH '+Math.max(0,(s.shieldUntil-now)/1000).toFixed(1)+'</span>');if(s.spreadUntil>now)items.push('<span class="power spread on">SP '+((s.spreadUntil-now)/1000).toFixed(1)+'</span>');if(s.rapidUntil>now)items.push('<span class="power rapid on">RP '+((s.rapidUntil-now)/1000).toFixed(1)+'</span>');if(s.repairUntil>now)items.push('<span class="power repair on">R+</span>');document.querySelector('#powers'+i).innerHTML=items.join('');var band=altitudeBand(s.altitude);document.querySelectorAll('#alt'+i+' span').forEach(function(el){el.classList.toggle('active',Number(el.dataset.band)===band)})});
    var speed=level===5?Math.min(599,390+Math.round(levelElapsed*4)):Math.round((Math.hypot(ships[0].vx,ships[0].vy)+Math.hypot(ships[1].vx,ships[1].vy))/2);speedValueEl.textContent=String(speed).padStart(3,'0');speedBarEl.style.setProperty('--speed',Math.min(100,speed/SPEED_TARGET*100)+'%');clockEl.textContent=String(Math.floor(levelElapsed/60)).padStart(2,'0')+':'+String(Math.floor(levelElapsed%60)).padStart(2,'0');
  }
  function render(){ctxs.forEach(function(ctx,i){drawView(ctx,canvases[i],ships[i],i)});var now=performance.now();indicators.forEach(function(o,i){if(o.until&&now>o.until){document.querySelector('#ind'+i).classList.remove('show');o.until=0}})}
  function worldToScreen(o,cam,w,h,scale){return{x:w/2+delta(o.x,cam.x,WORLD.w)*scale,y:h/2+delta(o.y,cam.y,WORLD.h)*scale}}
  function drawView(ctx,c,cam,index){var d=c._d||1,w=c._w||1,h=c._h||1;ctx.setTransform(d,0,0,d,0,0);ctx.clearRect(0,0,w,h);if(level===5){drawCorridorView(ctx,w,h,index);return}var g=ctx.createRadialGradient(w*.5,h*.45,10,w*.5,h*.5,Math.max(w,h));g.addColorStop(0,'#111b2b');g.addColorStop(1,'#02040a');ctx.fillStyle=g;ctx.fillRect(0,0,w,h);var baseScale=Math.max(.68,Math.min(1.05,Math.min(w/700,h/500))),scale=level===3?baseScale/(1+(progression.expansionStage-1)*.22):baseScale;
    nebula.forEach(function(n){var p=worldToScreen(n,cam,w,h,scale);ctx.beginPath();ctx.fillStyle=n.c;ctx.arc(p.x,p.y,n.r*scale,0,6.28);ctx.fill()});
    stars.forEach(function(s){var p=worldToScreen(s,cam,w,h,scale);if(p.x>-3&&p.x<w+3&&p.y>-3&&p.y<h+3){ctx.globalAlpha=s.a;ctx.fillStyle='#d8e9ff';ctx.fillRect(p.x,p.y,s.r,s.r)}});ctx.globalAlpha=1;
    hazards.forEach(function(q){if(progression.expansionStage<q.stage)return;var p=worldToScreen(q,cam,w,h,scale);if(onScreen(p,w,h,q.r*scale)){ctx.save();ctx.globalAlpha=.13+.04*Math.sin(elapsed*3);ctx.fillStyle=q.color;ctx.strokeStyle=q.color;ctx.lineWidth=2;ctx.beginPath();ctx.arc(p.x,p.y,q.r*scale,0,6.28);ctx.fill();ctx.setLineDash([7,9]);ctx.stroke();ctx.restore()}});
    rings.forEach(function(q){var p=worldToScreen(q,cam,w,h,scale);if(onScreen(p,w,h,45))drawSpeedRing(ctx,p,q,scale)});
    if(progression.pursuer){var p=worldToScreen(progression.pursuer,cam,w,h,scale);if(onScreen(p,w,h,70))drawPursuer(ctx,p,progression.pursuer,scale)}
    meteors.forEach(function(m){var p=worldToScreen(m,cam,w,h,scale);if(onScreen(p,w,h,50))drawMeteor(ctx,p,m,scale)});
    pickups.forEach(function(q){var p=worldToScreen(q,cam,w,h,scale);if(onScreen(p,w,h,30))drawPickup(ctx,p,q,scale)});
    enemies.forEach(function(e){var p=worldToScreen(e,cam,w,h,scale);if(onScreen(p,w,h,e===progression.boss?80:30)){if(e===progression.boss)drawBoss(ctx,p,e,scale);else drawDrone(ctx,p,e,scale)}});
    shots.forEach(function(s){var p=worldToScreen(s,cam,w,h,scale);if(onScreen(p,w,h,10)){ctx.strokeStyle=s.color;ctx.lineWidth=2;ctx.beginPath();ctx.moveTo(p.x,p.y);ctx.lineTo(p.x-s.vx*.025,p.y-s.vy*.025);ctx.stroke()}});
    bolts.forEach(function(b){var p=worldToScreen(b,cam,w,h,scale);if(onScreen(p,w,h,10)){ctx.fillStyle='#ff4864';ctx.shadowColor='#ff264d';ctx.shadowBlur=8;ctx.beginPath();ctx.arc(p.x,p.y,4,0,6.28);ctx.fill();ctx.shadowBlur=0}});
    sparks.forEach(function(s){var p=worldToScreen(s,cam,w,h,scale);if(onScree