<!-- SOLID CITY · part 2902 -->
 fracture from Human Command.';
    else if(a.phase==='anchor')obj='Hold the vessel anchored while the survivors cross.';
    else if(a.phase==='choice')obj='Fourth heartbeat found. Decide whether we go back for Iona.';
    else if(a.phase==='retrieve')obj='Hold the retrieval collar steady until Iona is aboard.';
    else if(a.phase==='escape')obj='Lantern Anchor is falling. Reach the blue gate.';
    else if(a.phase==='done')obj='Mission accounted for.';
    else if(p)obj='Protect '+p.id+' on the run to the blue rescue gate.';
    else{const n=nearestPod();obj=n?'Approach '+n.id+', stabilize, recover, protect.':'Choose the next life at Human Command.'}
    $('#objective').textContent=obj;
  }
  function derived(){
    const of=t=>events.filter(e=>e.type===t), lat=of('handoff').map(e=>e.data.latency).sort((a,b)=>a-b);return{rescued:of('rescue').length,lost:of('lost').length,human:of('extraction').filter(e=>e.data.owner==='human').length,ai:of('extraction').filter(e=>e.data.owner==='ai').length,intercepts:of('interception').length,handoffs:of('handoff').length,rejected:of('rejected').length,repairs:of('repair').length,events:events.filter(e=>['handoff','rejected','interception','extraction','repair'].includes(e.type)).length,latency:lat.length?lat[Math.floor(lat.length/2)]:null};
  }
  function updateStats(){const d=derived();$('#statRescued').textContent=d.rescued;$('#statLost').textContent=d.lost;$('#statHuman').textContent=d.human;$('#statAI').textContent=d.ai;$('#statIntercept').textContent=d.intercepts;$('#statHandoffs').textContent=d.handoffs;$('#statRejected').textContent=d.rejected;$('#statRepairs').textContent=d.repairs;$('#statEvents').textContent=d.events;$('#statLatency').textContent=d.latency===null?'—':d.latency.toFixed(2)}
  function renderLog(){
    const labels={handoff:'Handoff',rejected:'Rejected',interception:'Defense',extraction:'Extracted',repair:'Repair',rescue:'Rescued',lost:'Lost',triage:'Triage',anchorPhase:'Anchor',choice:'Decision',lights:'Signal',mission:'Mission'};
    const relevant=events.filter(e=>labels[e.type]).slice(-30).reverse();$('#eventLog').innerHTML=relevant.length?relevant.map(e=>{
      const d=e.data;let txt='';if(e.type==='handoff')txt=pretty(d.task)+': '+d.from+' → '+d.to+' · epoch '+d.epoch+' · '+d.latency.toFixed(2)+' ms';if(e.type==='rejected')txt=pretty(d.task)+' '+d.reason;if(e.type==='interception')txt='Interceptor stopped by '+d.owner;if(e.type==='extraction')txt=d.pod+' recovered by '+d.owner;if(e.type==='repair')txt='Vessel systems restored by '+d.owner;if(e.type==='rescue')txt=d.pod+' delivered alive';if(e.type==='lost')txt=d.pod+' life signal ended';if(e.type==='triage')txt=d.pod+' given rescue priority by human command';if(e.type==='anchorPhase')txt=d.message;if(e.type==='choice')txt=d.choice==='retrieve'?'Command went back for Iona':'Command ordered breakaway';if(e.type==='lights')txt=d.by+' lit the station chain';if(e.type==='mission')txt=d.rescued+' rescued · '+d.lost+' lost';const cls=e.type==='rejected'||e.type==='lost'?'interference':(e.type==='rescue'||e.type==='lights'?'rescue':'');return '<div class="event '+cls+'"><time>T+'+e.t.toFixed(1)+'s</time><div><b>'+labels[e.type]+'</b>'+txt+'</div></div>'}).join(''):'<div class="event"><time>Ready</time><div>Coordination events will appear when the mission begins.</div></div>';updateStats();
  }

  function loop(ts){const dt=Math.min(.033,(ts-last)/1000||0);last=ts;update(dt);draw();requestAnimationFrame(loop)}
  function setMissionInterfaceInert(value){['.mission-strip','.station-panel','.lower'].forEach(sel=>{const el=$(sel);if(el)el.inert=value})}
  function setPaused(next){
    if(!running||state.missionEnd)return;
    paused=next;setMissionInterfaceInert(paused);$('#pauseScreen').classList.toggle('show',paused);$('#pauseScreen').setAttribute('aria-hidden',String(!paused));$('#pauseBtn').classList.toggle('hidden',paused);
    if(paused){Object.keys(state.keys).forEach(k=>state.keys[k]=false);state.stabilizeHeld=false;state.extractHeld=false;state.anchorHeld=false;state.retrievalHeld=false;$$('.control-btn.pressed,.command-btn.active').forEach(b=>b.classList.remove('pressed','active'));$('#resumeBtn').focus();}
    else{last=performance.now();$('#pauseBtn').focus();}
  }
  function launch(){resetState();running=true;paused=false;setMissionInterfaceInert(false);last=performance.now();$('#startScreen').classList.add('hidden');$('#result').classList.remove('show');$('#pauseScreen').classList.remove('show');$('#pauseScreen').setAttribute('aria-hidden','true');$('#pauseBtn').classList.remove('hidden');$('#anchorMeter').classList.add('hidden');recordEvent('missionStart',{});setAdvice('Launching now. Three clear signals — and a ghost echo under the noise. Human command, set triage.');updateCommand();}
  $('#launchBtn').addEventListener('click',launch);$('#againBtn').addEventListener('click',launch);$('#pauseBtn').addEventListener('click',()=>setPaused(true));$('#resumeB