<!-- SOLID CITY · part 3451 -->
);
    document.getElementById('finalClear').textContent=count('CLEARED');
    document.getElementById('finalLost').textContent=count('LOST');
    debrief.hidden=false;
    addEvent(won?'COMPLETE':'FAILED','SUMMIT',(won?'Summit resolved: ':'Summit failed: ')+kind);
    updateAllUI();
  }
  function drawSummitLattice(w,h){
    var s=summit,R=summitLatticeR();
    var cx=s.core.x*w,cy=s.core.y*h;
    var sc=R/s.apothem,i,k,e;
    function P(v,scale){var p=summitProject(v[0],v[1],v[2],s.rot);return [cx+p[0]*scale*w,cy+p[1]*scale*w]}
    for(i=0;i<12;i++){
      var lit=s.faceLit[i],f=s.faces[i];
      ctx.save();ctx.beginPath();
      for(k=0;k<5;k++){var q=P(s.dodN[f[k]],sc);if(k)ctx.lineTo(q[0],q[1]);else ctx.moveTo(q[0],q[1])}
      ctx.closePath();
      ctx.fillStyle='rgba(255,195,77,'+(0.03+0.30*lit).toFixed(3)+')';ctx.fill();
      ctx.strokeStyle='rgba(255,195,77,'+(0.10+0.55*lit).toFixed(3)+')';ctx.lineWidth=lit>0.5?1.6:1;ctx.stroke();
      ctx.restore();
    }
    ctx.save();ctx.lineWidth=1;
    for(e=0;e<s.edges.length;e++){
      var a=s.edges[e][0],b=s.edges[e][1],m=Math.min(s.faceLit[a],s.faceLit[b]);
      if(m>0.03){var pa=P(s.icoN[a],R),pb=P(s.icoN[b],R);ctx.strokeStyle='rgba(255,210,120,'+(0.5*m).toFixed(3)+')';ctx.beginPath();ctx.moveTo(pa[0],pa[1]);ctx.lineTo(pb[0],pb[1]);ctx.stroke()}
    }
    ctx.restore();
    var sp=summitStationField();
    for(i=0;i<12;i++){
      var held=s.heldBy[i],pulse=held?0:(0.5+0.5*Math.sin(elapsed*5+i));
      ctx.save();ctx.translate(sp[i].x*w,sp[i].y*h);ctx.rotate(Math.PI/4);
      ctx.fillStyle=held?'#ffc34d':'rgba(255,195,77,'+(0.25+0.35*pulse).toFixed(3)+')';
      var sz=held?5:4+2*pulse;
      ctx.fillRect(-sz/2,-sz/2,sz,sz);
      ctx.restore();
    }
  }
  function drawSummit(w,h){
    var s=summit,ph=s.phase;
    if(!s.core.dead){
      var cx=s.core.x*w,cy=s.core.y*h,cr=Math.max(2,s.core.r*w);
      var strainA=0.25+0.55*Math.min(1,s.core.strain)+(s.core.surgeWarn>0?(0.3+0.3*Math.sin(elapsed*20)):0)+(s.core.flash*0.8);
      ctx.save();ctx.translate(cx,cy);
      var g=ctx.createRadialGradient(0,0,cr*0.3,0,0,cr*2.2);
      g.addColorStop(0,'rgba(255,120,60,'+Math.min(0.9,0.15+0.35*strainA).toFixed(3)+')');
      g.addColorStop(1,'rgba(255,80,40,0)');
      ctx.fillStyle=g;ctx.beginPath();ctx.arc(0,0,cr*2.2,0,Math.PI*2);ctx.fill();
      ctx.rotate(s.rot*0.7);
      ctx.fillStyle='#2b1d18';ctx.strokeStyle=s.core.surgeWarn>0?'#ff5040':'#c96a3e';ctx.lineWidth=2;
      ctx.beginPath();
      for(var k=0;k<11;k++){var a=k/11*Math.PI*2,rr=cr*(0.78+((k*7)%5)/14);var px=Math.cos(a)*rr,py=Math.sin(a)*rr;if(k)ctx.lineTo(px,py);else ctx.moveTo(px,py)}
      ctx.closePath();ctx.fill();ctx.stroke();
      ctx.fillStyle='rgba(255,'+Math.floor(90+80*Math.min(1,s.core.strain))+',50,'+(0.25+0.3*Math.min(1,s.core.strain)).toFixed(3)+')';
      ctx.beginPath();ctx.arc(0,0,cr*0.45,0,Math.PI*2);ctx.fill();
      ctx.restore();
      if(s.core.surgeWarn>0){
        ctx.save();ctx.strokeStyle='rgba(255,70,50,'+(0.35+0.4*Math.abs(Math.sin(elapsed*14))).toFixed(3)+')';ctx.setLineDash([10,8]);ctx.lineWidth=2;
        ctx.beginPath();ctx.arc(cx,cy,cr+(1.2-s.core.surgeWarn)*40,0,Math.PI*2);ctx.stroke();ctx.setLineDash([]);ctx.restore();
      }
      if(s.core.surge>0){
        var sr=(0.9-s.core.surge)/0.9;
        ctx.save();ctx.globalAlpha=Math.max(0,s.core.surge);ctx.strokeStyle='#ff7a50';ctx.lineWidth=3;
        ctx.beginPath();ctx.arc(cx,cy,cr+sr*0.30*w,0,Math.PI*2);ctx.stroke();ctx.restore();
      }
    }
    if(ph==='coalesce'&&s.motes){
      ctx.save();ctx.fillStyle='#8a6a55';
      s.motes.forEach(function(m){ctx.beginPath();ctx.arc(m.x*w,m.y*h,Math.max(1.5,m.r*w),0,Math.PI*2);ctx.fill()});
      ctx.restore();
    }
    if(ph!=='coalesce')drawSummitLattice(w,h);
    if(s.collapseFlash>0){ctx.save();ctx.globalAlpha=Math.min(1,s.collapseFlash);ctx.fillStyle='#fff6e0';ctx.fillRect(0,0,w,h);ctx.restore()}
  }
  /* =============== END SUMMIT: THE COALESCENCE =============== */

  function loop(t){if(!running)return;if(paused){last=t;draw();requestAnimationFrame(loop);return}var dt=Math.min(.035,(t-last)/1000||.016);last=t;update(dt);draw();if(running)requestAnimationFrame(loop)}

  function draw(){
    var w=canvasW,h=canvasH;if(!w||!h)return;ctx.clearRect(0,0,w,h);ctx.fillStyle='#03090b';ctx.fillRect(0,0,w,h);
    ctx.strokeStyle='rgba(82,224,208,.055)';ctx.lineWidth=1;for(var x=0;x<w;x+=44){ctx.beginPath();ctx.moveTo(x,0);ctx.lineTo(x,h);ctx.stroke()}for(var y=0;y<h;y+=44){ctx.beginPath();ctx.moveTo(0,y);ctx.lineTo(w,y);ctx.stroke()}
    for(var s=0;s<38;s++){var sx=(s*97%997)/997*w,sy=(s*61%557)/557*h;ctx.fillStyle='rgba(220,246,242,'+(s%5===0?.55:.22)+')';ctx.fillRect(sx,sy,s%5===0?1.6:1,s%5===0?1.6:1)}
    var top=.18*h,bottom=.86*h;ctx.fillStyle='rgba(82,224,208,.035)';ctx.fillRect(0,top,w,bottom-top);ctx.strokeStyle='rgba(82,224,208,.18)';ctx.setLineDash([8,10]);ctx.beginPath();ctx.moveTo(0,top);ctx.lineTo(w,top);ctx.moveTo(0,