<!-- SOLID CITY · part 1953 -->
CONVERGENCE'},{name:'DEPTH FLIGHT',copy:'The corridor carries both ships forward. Rise ABOVE or dive BELOW incoming attack runs; lateral movement is now fine positioning. Thread the three bands together.',button:'ENTER THE CORRIDOR'}];
  var flight={mode:'formation',wasSeparated:false,reunionUntil:0,lastDistance:0};
  var indicators=[{until:0},{until:0}], keys={}, controls=[makeControl(),makeControl()],friendlyHitGuard={};
  var fireControl={active:false,pointer:null},fireEl=document.querySelector('#fire'),metrics;
  var sessionBest={score:0,kills:0,level:1,time:0,formation:0,reunions:0,rescues:0,shield:0,friendly:0};
  function makeControl(){return {active:false,x:0,y:0,startX:0,startY:0,pointer:null,lastRelease:0,resumePending:false,keyActive:false}}
  function resetMetrics(){metrics={avoided:0,meteorHits:0,shieldHits:0,friendlyFire:0,kills:0,formationTime:0,separations:0,reunions:0,rescues:0,coordinated:0,reunionBonus:0,defenseSaved:0,latencies:[],handoffs:[],assists:[],assistChecks:0,assistContinuity:0,threats:{}};flight={mode:'formation',wasSeparated:false,reunionUntil:0,lastDistance:0}}
  function stamp(){var s=Math.max(0,elapsed);return String(Math.floor(s/60)).padStart(2,'0')+':'+String(Math.floor(s%60)).padStart(2,'0')}
  function logH(text){metrics.handoffs.push(stamp()+'  '+text)}
  function logA(text){metrics.assists.push(stamp()+'  '+text)}
  function notify(i,text,ms){var el=document.querySelector('#ind'+i);el.textContent=text;el.classList.add('show');indicators[i].until=performance.now()+(ms||900)}
  function resize(){canvases.forEach(function(c){var r=c.getBoundingClientRect(),d=Math.min(devicePixelRatio||1,2);c.width=Math.max(1,Math.floor(r.width*d));c.height=Math.max(1,Math.floor(r.height*d));c._w=r.width;c._h=r.height;c._d=d})}
  function syncOrientation(){var viewport=window.visualViewport;var height=viewport?viewport.height:window.innerHeight;var width=viewport?viewport.width:window.innerWidth;document.body.setAttribute('data-orient',height>=width?'portrait':'landscape');resize()}
  addEventListener('load',syncOrientation);addEventListener('resize',syncOrientation);addEventListener('orientationchange',syncOrientation);if(window.visualViewport)visualViewport.addEventListener('resize',syncOrientation);syncOrientation();
  function makeShip(x,y,color,label){return {x:x,y:y,vx:0,vy:0,a:0,color:color,label:label,hull:100,maxHull:100,alive:true,respawn:0,fire:0,manualFire:0,score:0,actionTick:0,assistVX:0,assistVY:0,assistUntil:0,coveringTarget:null,coverBroke:false,coverNotice:0,shieldCharges:0,shieldUntil:0,shieldHitUntil:0,shieldRingUntil:0,shieldShatterUntil:0,spreadUntil:0,rapidUntil:0,repairUntil:0,build:{hull:0,cannon:0,thruster:0,bio:0},ringScore:0,speedBank:0,altitude:0,corridorX:0}}
  function init(){
    paused=false;pauseMenu.hidden=true;pauseToggle.hidden=true;
    ships=[makeShip(1100,800,'#ffc84a','YOU'),makeShip(1280,840,'#44e1d0','AI')];
    enemies=[];shots=[];bolts=[];meteors=[];sparks=[];pickups=[];muzzles=[];rings=[];hazards=[];corridorThreats=[];corridorShots=[];corridorPickups=[];corridorStars=[];elapsed=0;levelElapsed=0;wave=1;level=1;spawnT=0;meteorT=2;enemyShotT=1;nextId=1;transitioning=false;runEnding=false;progression={componentIndex:0,speedHold:0,expansionStage:1,levelKills:0,boss:null,pursuer:null,corridorCleared:0,corridorRunT:0,corridorSequence:0};resetMetrics();
    controls=[makeControl(),makeControl()];friendlyHitGuard={};fireControl={active:false,pointer:null};fireEl.classList.remove('firing');keys={};armEl.checked=false;flightStateEl.textContent='FORMATION';flightStateEl.className='flight-state formation';
    stars=[];for(var i=0;i<260;i++)stars.push({x:Math.random()*WORLD.w,y:Math.random()*WORLD.h,r:.4+Math.random()*1.7,a:.25+Math.random()*.65});
    nebula=[{x:500,y:410,r:460,c:'rgba(64,32,90,.12)'},{x:1900,y:1180,r:560,c:'rgba(10,110,120,.10)'},{x:1480,y:260,r:360,c:'rgba(118,46,22,.09)'}];
    for(i=0;i<6;i++)spawnEnemy();setLevelHUD();resize();updateHUD();
  }
  function spawnEnemy(){var side=Math.floor(Math.random()*4),x,y;if(side<2){x=Math.random()*WORLD.w;y=side?WORLD.h-80:80}else{x=side===2?80:WORLD.w-80;y=Math.random()*WORLD.h}enemies.push({id:nextId++,x:x,y:y,vx:0,vy:0,a:0,hull:24+wave*4,fire:1+Math.random()*2,phase:Math.random()*6.2,targetIndex:-1,threatTargetIndex:-1,rescuePilot:-1,rescueBroke:false,lastHitBy:-1,lastHitAt:0,coordAt:0,splitter:level===4&&Math.random()<.45})}
  function setLevelHUD(){
    waveEl.textContent='LEVEL '+level+' · '+levelInfo[level].name;
    speedometerEl.classList.toggle('show',level===2||level===4||level===5);
    document.querySelectorAll('.buildbar').forEach(function(el){el.style.display=(level===1||level===4)?'block':'none'});
    document.querySelectorAll('.altitude-meter').forEach(function(el){el.classList.toggle('show',level===5)});
    if(level===1)objectiveEl.textContent='SOLIDIVISM · 0 / 16';
    if(level===2)objectiveEl.textContent='BANK 3 RINGS EACH · HOLD TARGET';
    