<!-- SOLID CITY · part 3398 -->
xed(0)}px)`;i.hidden=!1}function fy(i){let e=y.phase,t=vs(y.pos.y);cr(Ne["h-spd"],"spd",String(Math.round(y.speed*xs))),cr(Ne["h-alt"],"alt","ALT "+(t>1e3?(t/1e3).toFixed(1)+" km":Math.round(t)+" m")),cr(Ne["h-kills"],"kills",y.kills+"/"+hu),cr(Ne["h-time"],"time",ou(y.runT));let n=Math.round(y.shields);fr.sh!==n&&(fr.sh=n,Ne["h-shield"].style.width=n+"%",Ne["h-shield"].parentNode.classList.toggle("low",n<30));let s=Math.round(y.boostMeter*100);fr.bo!==s&&(fr.bo=s,Ne["h-boost"].style.width=s+"%",Ne["b-boost"].style.setProperty("--m",s+"%")),Ne["b-boost"].classList.toggle("hot",y.boosting),Ne["h-speedo"].classList.toggle("boost",y.boosting),cr(Ne["h-arc"],"arc",""),Ne["h-arc"].style.strokeDashoffset=String(Math.round(100-ht(y.speed*xs/2400,0,1)*100));let r="";e==="pad"?r="ON THE HANGAR PAD \xB7 READY":e==="count"?r="COUNTDOWN":e==="climb"?r="CLIMB TO SPACE \xB7 "+(t/1e3).toFixed(1)+" / "+Xf/1e3+" km":e==="battle"?r=y.wave?"HIT THEM DOWN \xB7 WAVE "+y.wave+"/3":"ALIEN FLEET INBOUND":e==="respawn"?r="RESPAWNING\u2026":e==="return"?r=(y.heat>.3?"RE-ENTRY \xB7 ":"RETURN HOME \xB7 ")+(Math.hypot(Math.hypot(y.pos.x,y.pos.z),t)/1e3).toFixed(1)+" km":e==="landing"?r="PARK ON THE GLOWING CIRCLE \xB7 "+Math.round(Math.hypot(y.pos.x,y.pos.z))+" m":(e==="parked"||e==="result")&&(r="PARKED \xB7 MISSION COMPLETE"),cr(Ne["h-obj"],"obj",r),sc>0&&(sc-=i,sc<=0&&(Ne["h-banner"].hidden=!0)),y.hurt=Math.max(0,y.hurt-i*1.8),Ne["h-hurt"].style.opacity=(y.hurt*.9+(y.shields<30&&e==="battle"?.25+.15*Math.sin(y.t*8):0)).toFixed(3),Ne["h-heat"].style.opacity=(y.heat*.85).toFixed(3);let a=e==="battle"||e==="return"||e==="climb";if(a&&gn.visible?(cu(Je.copy(y.pos).addScaledVector(_n(Ot),700),Cn),Ne["h-reticle"].hidden=Cn.behind,Ne["h-reticle"].style.transform=`translate(${Cn.x.toFixed(1)}px,${Cn.y.toFixed(1)}px)`):Ne["h-reticle"].hidden=!0,y.lock&&a){cu(y.lock.pos,Cn);let h=ht(y.lock.r*2*900/Math.max(1,y.lock.pos.distanceTo(Mt.position)),30,120);Ne["h-lock"].hidden=Cn.behind,Ne["h-lock"].style.transform=`translate(${Cn.x.toFixed(1)}px,${Cn.y.toFixed(1)}px)`,Ne["h-lock"].style.width=Ne["h-lock"].style.height=h.toFixed(0)+"px"}else Ne["h-lock"].hidden=!0;let o=0;if(e==="battle"){let h=Hn.filter(f=>f.alive&&f!==y.lock).sort((f,u)=>f.pos.distanceToSquared(y.pos)-u.pos.distanceToSquared(y.pos));for(let f of h){if(o>=ur.length-1)break;Vf(ur[o++],f.pos,f.type==="mother"?"boss":"")}}for((e==="return"||e==="landing")&&Vf(ur[o++],lp,"home");o<ur.length;o++)ur[o].hidden=!0;let l=Hn.find(h=>h.type==="mother");l&&l.alive&&e==="battle"?(Ne["h-mother"].hidden=!1,Ne["h-mbar"].style.width=(l.hp/l.maxHp*100).toFixed(0)+"%"):Ne["h-mother"].hidden=!0;let c=!(e==="battle"||e==="return"||e==="climb");Ne["b-fire"].hidden=c,Ne["b-boost"].hidden=c,Ne.stick.hidden=!Qn||!(e==="battle"||e==="return"||e==="climb"||e==="landing"),bt.show&&(Ne["h-perf"].textContent=bt.fps.toFixed(0)+" FPS \xB7 "+Rn.toFixed(2)+"x \xB7 "+zn.info.render.calls+" calls")}function py(){try{return(localStorage.getItem("space-callsign")||"").slice(0,16)}catch{return""}}function my(i){let e=i.timeMs/1e3;return i.kills<hu?"CADET":e<150?"ACE OF SOLID CITY":e<210?"SKY KNIGHT":e<300?"WING COMMANDER":"PILOT"}var gy=i=>String(i).replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]);async function _y(i){if(y.phase!=="parked")return;jn("result"),Lt("hud").hidden=!0,Lt("result").hidden=!1,Lt("r-time").textContent=ou(i.timeMs/1e3),Lt("r-kills").textContent=i.kills+" / "+hu,Lt("r-hits").textContent=String(i.hits),Lt("r-top").textContent=i.top+" km/h",Lt("r-title").textContent=my(i),Lt("r-board").innerHTML='<li class="dim">Saving your result\u2026</li>',Lt("r-save").textContent="";let e=null;try{let t=await fetch("/api/city/space/score",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:py()||"PILOT",timeMs:i.timeMs,kills:i.kills,hits:i.hits})}),n=await t.json();y.saved=n,n.ok?(e=n.row,Lt("r-save").textContent="Saved \xB7 rank #"+n.rank+" of "+n.total):Lt("r-save").textContent="Not saved: "+(n.error||t.status)}catch{Lt("r-save").textContent="Not saved (offline?)",y.saved={ok:!1}}try{let t=await(await fetch("/api/city/space/board",{cache:"no-store"})).json();y.board=t,Lt("r-board").innerHTML=(t.top||[]).map((n,s)=>`<li class="${e&&n.at===e.at&&n.name===e.name?"me":""}"><b>${s+1}</b><span>${gy(n.name)}</span><i>${ou(n.timeMs/1e3)}</i><em>${n.kills}</em></li>`).join("")||'<li class="dim">No results yet.</li>'}catch{Lt("r-board").innerHTML='<li class="dim">Leaderboard unavailable.</li>'}}Lt("r-again").addEventListener("click",()=>{_c(),_u()});Lt("h-mute").addEventListener("click",()=>{_c(),sp(!ct.muted)});Ne["b-launch"].addEventListener("click",xc);function xy(){let i={x:0,y:0,fire:!1,boost:!1},e=y.phase;if(e==="pad")return xc(),i;let t=n=>{Je.copy(n).sub(y.pos);let s=Je.length(),r=Math.atan2(-Je.x,-Je.z),a=Math.asin(ht(Je.y/s,-1,1));return i.x=ht(-rc(r-y.yaw)*2.5,-1,1),i.y=ht((a-y.pitch)*2.5,-1,1),{d:s,err: