<!-- SOLID CITY · part 3262 -->
 A.origin.x : 0), cz = A.camera.position.z + (A.origin ? A.origin.z : 0);
    var near = Math.hypot(cx - WH.x, cz - WH.z) < 4000 || Math.hypot(cx - PADP.x, cz - PADP.z) < 4000;
    if (near) {
      for (var i = 0; i < mats.length; i++) mats[i].uniforms.uT.value = t;
      ring.rotation.z = t * 0.3; orb1.rotation.x = t * 0.9; orb1.rotation.y = t * 0.5; orb2.rotation.y = -t * 0.7; orb2.rotation.x = t * 0.35;
      disk.rotation.z = -t * 0.25; spr.material.opacity = 0.55 + 0.15 * Math.sin(t * 2);
    }
    // trigger
    var inside = false, away = true;
    if (S.mode === 'walk') {
      var dx = S.p.x - WH.x, dz = S.p.z - WH.z;
      inside = Math.abs(dz) < 2.6 && Math.abs(dx) < WH_R - 1.5;
      away = Math.hypot(dx, dz) > 14;
    } else if (S.mode === 'fly' && S.ship) {
      var d3 = Math.hypot(S.ship.x - WH.x, S.ship.y - (wy + WH_H), S.ship.z - WH.z);
      inside = d3 < WH_R * 2.6; away = d3 > 90;
    }
    if (inside && !cool) { cool = true; showPrompt(); }
    if (away && cool && (!prompt || prompt.hidden)) cool = false;
  }
  requestAnimationFrame(loop);

  function showPrompt() {
    if (!prompt) {
      prompt = document.createElement('div'); prompt.id = 'wh-prompt'; prompt.setAttribute('role', 'dialog'); prompt.setAttribute('aria-label', 'Enter the wormhole?');
      prompt.innerHTML = '<span class="wh-sw">\uD83C\uDF00</span><h3>Enter the wormhole?</h3><p>It leads to the Space Mission: blast off, shoot down the alien fleet, then fly home and park.</p>' +
        '<div class="wh-b"><a id="wh-play" href="' + URL_SPACE + '?from=wormhole">PLAY</a><button type="button" id="wh-no">NOT NOW</button></div>';
      document.body.appendChild(prompt);
      $('wh-no').addEventListener('click', function () { prompt.hidden = true; });
      addEventListener('keydown', function (e) { if (!prompt || prompt.hidden) return; if (e.key === 'Escape') prompt.hidden = true; else if (e.key === 'Enter') location.href = $('wh-play').href; });
    }
    prompt.hidden = false;
  }

  /* radar blip + Hyper Controller stop */
  function hyper() {
    var H = window.CityHyper; if (!H) return false;
    if (!H.__spaceRadar) {
      var orig = H.radar; H.__spaceRadar = true;
      H.radar = function (g, blip, fl, sc, ax, az) { var r = orig.apply(this, arguments); try { blip(WH.x, WH.z, '#b46bff', fl ? 4 : 6, fl ? 'WORMHOLE' : 'WH'); } catch (e) {} return r; };
    }
    var stop = { id: 'wormhole', name: 'Wormhole', short: 'WORMHOLE', x: WH.x, z: WH.z, stand: { x: WH.x, z: WH.z - 20 }, url: URL_SPACE + '?from=wormhole', go: 'PLAY SPACE MISSION',
      alias: 'wormhole worm hole portal space mission spaceship space ship aliens alien fleet', text: 'A swirling wormhole south of the Hangar. Step through it to play the Space Mission: fly, shoot down the aliens, come home and park.' };
    if (H.pois && !H.pois.some(function (p) { return p.id === 'wormhole'; })) H.pois.push(stop);
    if (H.landmarks && !H.landmarks.some(function (p) { return p.id === 'wormhole'; })) H.landmarks.push({ id: 'wormhole', name: 'Wormhole', short: 'WORMHOLE', x: WH.x, z: WH.z, alt: wy + 120, alias: stop.alias, text: stop.text, url: stop.url, go: stop.go });
    if (H.regrid) H.regrid();
    return true;
  }
  if (!hyper()) { var n = 0, iv = setInterval(function () { if (hyper() || ++n > 60) clearInterval(iv); }, 500); }
  window.CitySpace = { pad: PADP, wormhole: WH, prompt: showPrompt, groups: { pad: pad, wormhole: wh } };
}

/* ---------- 5. arrival from the level: ?at=hangar | ?at=wormhole ---------- */
function arrive(A) {
  var at = (location.search.match(/[?&]at=(hangar|wormhole)\b/) || [])[1]; if (!at) return;
  var to = at === 'wormhole' ? { x: WH.x, z: WH.z - 30, tx: WH.x, tz: WH.z } : { x: PADP.x, z: PADP.z + 26, tx: PADP.x, tz: PADP.z - 40 };
  var n = 0, iv = setInterval(function () {
    var boot = $('sc-boot'), S = A.S;
    if (++n > 600) return clearInterval(iv);
    if (boot && !boot.hidden && getComputedStyle(boot).display !== 'none') return;
    if (S.mode !== 'walk' || !window.SC.walk) return;
    clearInterval(iv);
    window.SC.walk(to.x, to.z, Math.atan2(-(to.tx - to.x), -(to.tz - to.z)));
    try { A.help(at === 'wormhole' ? 'Welcome back through the wormhole! Step into it again to fly another mission.' : 'Welcome back to the Hangar! The glowing pad launches another Space Mission.'); } catch (e) {}
  }, 200);
}

function start() {
  var A = window.SC && window.SC.api; if (!A || !A.isBuilt || !A.isBuilt()) return false;
  try { addButton(); } catch (e) { console.warn('space btn', e); }
  try { watchChips(); } catch (e) { console.warn('space chips', e); }
  try { build(A); } catch (e) { console.warn('space build', e); }
  try { arrive(A); } catch (e) { console.warn('space arrive', e); }
  return true;
}
// the dock/button and chips do not need the 3D city; add them right away
function early() { try { addButton(); watchChips(); } catch (e) {} }
if (document.readyState === 'loading') document.addEventListe