<!-- SOLID CITY · part 1907 -->
.resolved&&distObj(s,m)<m.r+4){s.life=0;m.hull-=1+coordinatedHit(m,s.owner)/8;burst(s.x,s.y,'#ffc84a',5);if(m.hull<=0){m.resolved=true;ships[s.owner].score+=25;awardRescue(m,s.owner);burst(m.x,m.y,'#ffc84a',13);if(level===4){ships.forEach(function(ally,ai){if(ai!==s.owner&&ally.alive&&distObj(m,ally)<72){friendlyHit(m,s.owner,ai,15,'blast',ally.x,ally.y)}})}if(m.threat){metrics.avoided++;logA('outcome · meteor destroyed');checkContinuity(m)}}}})
    });
    bolts.forEach(function(b){ships.forEach(function(s,i){if(b.life>0&&s.alive&&distObj(b,s)<17){b.life=0;damage(s,i,15,'bolt')}})});
    meteors.forEach(function(m){ships.forEach(function(s,i){if(!m.resolved&&s.alive&&distObj(m,s)<m.r+19){m.resolved=true;damage(s,i,38,'meteor');burst(m.x,m.y,'#ff8c24',20);if(i===0){metrics.meteorHits++;if(m.threat){logA('outcome · human ship hit');checkContinuity(m)}}}})});
    enemies.forEach(function(e){ships.forEach(function(s,i){if(e.hull>0&&s.alive&&distObj(e,s)<32){e.hull=0;metrics.kills++;progression.levelKills++;if(level===1)dropComponent(e.x,e.y);dropPower(e.x,e.y);damage(s,i,30,'collision');burst(e.x,e.y,'#ff5b66',14)}})})
  }
  function breakShield(s){if(!s.shieldCharges)return;s.shieldCharges=0;s.shieldUntil=0;s.shieldShatterUntil=performance.now()+500;burst(s.x,s.y,'#6ef2ff',34)}
  function damage(s,i,n,why){if(!s||!s.alive||!Number.isFinite(n)||n<=0)return;var now=performance.now();if(s.shieldCharges>0&&now<s.shieldUntil){s.shieldCharges--;s.shieldHitUntil=now+260;metrics.shieldHits++;notify(i,'SHIELD ABSORBED',420);burst(s.x,s.y,'#d8fbff',12);if(s.shieldCharges<=0){s.shieldCharges=1;breakShield(s);notify(i,'SHIELD SHATTERED',700)}return}if(flight.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'