<!-- SOLID CITY · part 2897 -->
tton.setAttribute('aria-pressed',String(state[key]));button.querySelector('small').textContent=state[key]?'Hold engaged · tap to release':'Tap to engage · tap again to release'});
  }
  function updateCommand(){
    const title=$('#commandTitle'),copy=$('#commandCopy'),actions=$('#commandActions');if(!title||!state.anchor)return;
    actions.className='command-actions';actions.innerHTML='';
    const phase=state.anchor.phase;
    if(phase==='hidden'){
      title.textContent='Your station · Triage';
      const available=state.pods.filter(p=>p.status==='adrift');
      copy.textContent=available.length?'The AI can reach any signal. Only you decide which life takes priority.':'Corridor accounted for. The fourth echo is resolving at Lantern Anchor.';
      available.forEach(p=>{const b=document.createElement('button');b.className='command-btn'+(state.triageTarget===p.id?' active':'');b.innerHTML=p.id+'<small>'+({Aster:'oxygen stable',Morrow:'hull breach',Kite:"clock running out"}[p.id])+'</small>';b.addEventListener('click',()=>chooseTriage(p.id));actions.appendChild(b)});
    }else if(phase==='scan'){
      title.textContent='Your station · Structural call';
      copy.textContent=state.anchor.scan<100?'AI scan is tracing the station groan. Hold approach until the fracture resolves.':'Fracture found on the lower spine. Mark it so the pilot can set the vessel against the safe side.';
      const b=document.createElement('button');b.className='command-btn';b.textContent=state.anchor.scan<100?'SCANNING '+Math.floor(state.anchor.scan)+'%':'MARK THE FRACTURE';b.disabled=state.anchor.scan<100;b.addEventListener('click',markFracture);actions.appendChild(b);
    }else if(phase==='anchor'){
      title.textContent='Your station · Stabilize hold';copy.textContent='AI holds attitude. You keep the rescue vessel physically anchored while the survivors cross.';actions.classList.add('hold');
      const b=document.createElement('button');b.className='command-btn';b.innerHTML='ENGAGE ANCHOR HOLD<small>Tap to engage · tap again to release</small>';actions.appendChild(b);humanHoldButton(b,'anchorHeld');
    }else if(phase==='choice'){
      title.textContent='Your station · Final retrieval';copy.textContent='A fourth heartbeat: Iona, the Lantern keeper, below the fracture. The station will not hold for both caution and rescue.';actions.classList.add('decision');
      const risk=document.createElement('button');risk.className='command-btn danger';risk.innerHTML='GO BACK FOR IONA<small>risk vessel + recovered pilots</small>';risk.addEventListener('click',()=>makeFinalChoice('retrieve'));
      const leave=document.createElement('button');leave.className='command-btn';leave.innerHTML='BREAK AWAY<small>preserve everyone already aboard</small>';leave.addEventListener('click',()=>makeFinalChoice('leave'));actions.append(risk,leave);
    }else if(phase==='retrieve'){
      title.textContent='Your station · Iona';copy.textContent='The AI cannot complete this hold. Keep the rescue collar steady until Iona is across.';actions.classList.add('hold');
      const b=document.createElement('button');b.className='command-btn danger';b.innerHTML='ENGAGE RETRIEVAL HOLD<small>Tap to engage · the Anchor is collapsing</small>';actions.appendChild(b);humanHoldButton(b,'retrievalHeld');
    }else if(phase==='escape'){
      title.textContent='Your station · Account for every life';copy.textContent='Decision recorded. The AI is flying the damaged vessel clear; you carry the names.';
    }else{
      title.textContent='Your station · Debrief';copy.textContent='The rescue is over. The debt is not.';
    }
  }
  function markFracture(){
    if(state.anchor.phase!=='scan'||state.anchor.scan<100)return;
    state.anchor.phase='anchor';recordEvent('anchorPhase',{phase:'anchor',message:'Fracture marked. Hold the vessel to the safe side.'});setAdvice('Anchor lock ready. Human command must hold stabilization while survivors cross.');updateCommand();
  }
  function makeFinalChoice(choice){
    if(state.anchor.phase!=='choice')return;state.anchor.choice=choice;recordEvent('choice',{choice});
    if(choice==='leave'){
      state.anchor.heartbeat.status='lost';state.anchor.heartbeat.lostReason='left beneath Lantern Anchor when command ordered breakaway';state.lost++;state.anchor.phase='escape';
      setAdvice('Breakaway executed. Iona’s heartbeat vanished beneath the collapse.');recordEvent('lost',{pod:'Iona'});
    }else{
      state.anchor.phase='retrieve';setAdvice('Retrieval collar extended. Hold it steady — we have one chance.');recordEvent('anchorPhase',{phase:'retrieve',message:'One last retrieval. Hold for Iona.'});
    }
    updateCommand();
  }

  function updateStations(){
    if(!coordination)return;
    let humans=0;
    $$('.station').forEach(btn=>{
      const task=btn.dataset.task,t=coordination.tasks[task];btn.dataset.owner=t.owner;
      btn.querySelector('.epoch').textContent='E'+t.epoch;
      btn.querySele