<!-- SOLID CITY · part 1967 -->
+ ox * c + oz * s, lz = cz - ox * s + oz * c;
    var e = { x0: POS.x + lx - hx, x1: POS.x + lx + hx, z0: POS.z + lz - hz, z1: POS.z + lz + hz, y0: y0, y1: y1, firstParking: true };
    A.solids.push(e); out.push(e);
  }
  return out;
}
function removeSolids(list) {
  if (!list) return;
  list.forEach(function (e) { var i = A.solids.indexOf(e); if (i >= 0) A.solids.splice(i, 1); });
}
function collide(ud) {
  (ud.footprint || []).forEach(function (b) {
    var entries = addBox(b[0], b[1], b[2], b[3], b[6] || 0, b[4], b[5]);
    if (b[7] && String(b[7]).indexOf('car:') === 0) {
      var id = String(b[7]).slice(4);
      (ud.cars || []).forEach(function (car) { if (car.id === id) car.solids = entries; });
    }
  });
  // the lot's retaining edges (below-deck walls; the ramp gap stays open)
  var ly = ud.lotY;
  addBox(-74.5, 73, 131, 2, 0, ly - 4, ly - 0.1);
  addBox(74.5, 73, 131, 2, 0, ly - 4, ly - 0.1);
  addBox(0, 171, 280, 2, 0, ly - 4, ly - 0.1);
  addBox(-139, 122, 2, 100, 0, ly - 4, ly - 0.1);
  addBox(139, 122, 2, 100, 0, ly - 4, ly - 0.1);
}
function hyperStop() {
  var H = window.CityHyper; if (!H || !H.pois || H.pois.some(function (p) { return p.id === 'south-lot'; })) return;
  H.pois.push({ id: 'south-lot', name: 'The South Lot', short: 'SOUTH LOT', x: POS.x, z: POS.z + 122, stand: { x: POS.x, z: POS.z + 100 },
    alias: 'south lot parking rides cars dart hauler long road first city parking',
    text: 'The South Lot, under the First City\u2019s southern edge: fourteen futuristic rides waiting in the stalls. Walk to one and roll \u2014 the Long Road runs east from the lot to the capital shelf.' });
  if (H.regrid) H.regrid();
}
function outButton() {
  if (M.outBtn) return M.outBtn;
  var b = document.createElement('button');
  b.textContent = 'STEP OUT \u2B07';
  b.style.cssText = 'position:fixed;left:50%;bottom:212px;transform:translateX(-50%);z-index:60;display:none;padding:12px 22px;border-radius:24px;border:2px solid #d8aa48;background:rgba(12,14,20,0.88);color:#ffd873;font:700 15px Georgia,serif;letter-spacing:1px;';
  b.addEventListener('pointerdown', function (ev) { ev.preventDefault(); act(); });
  document.body.appendChild(b);
  M.outBtn = b;
  return b;
}
function nearCar(wx, wz) {
  if (!M.group) return null;
  var cars = (M.group.userData || {}).cars || [], best = null, bd = 5.2;
  cars.forEach(function (car) {
    if (car.state !== 'parked') return;
    var d = Math.hypot(wx - (POS.x + car.x), wz - (POS.z + car.z));
    if (d < bd) { bd = d; best = car; }
  });
  return best;
}
function actHere(wx, wz) {
  if (window.CityDrive && CityDrive.active()) return { kind: 'firstparking', label: 'STEP OUT OF THE RIDE' };
  var car = nearCar(wx, wz);
  if (car) return { kind: 'firstparking', label: '\uD83D\uDE97 ROLL \u2014 ' + car.name };
  return null;
}
function act() {
  if (window.CityDrive && CityDrive.active()) {
    var st = CityDrive.state();
    if (CityDrive.end() !== true) return; // RUNG 2: NO_SAFE_EXIT — the driver stays seated, the car stays driven, nothing is re-parked
    if (st && st.carId && M.group) {
      (M.group.userData.cars || []).forEach(function (car) {
        if (car.id === st.carId) {
          car.state = 'parked';
          car.x = car.mesh.position.x; car.z = car.mesh.position.z; car.yaw = car.mesh.rotation.y;
          car.solids = addBox(car.x, car.z, 2.6, 5.6, car.yaw, car.y, car.y + 2.1);
        }
      });
    }
    return;
  }
  var car = nearCar(S.p.x, S.p.z);
  if (!car || !window.CityDrive) return;
  if (!CityDrive.begin(car.mesh, car.yaw, POS.x, POS.z, car.id)) return; // RUNG 2: admission first — a refused entry moves nothing (no solid lifted, no state flipped)
  removeSolids(car.solids); car.solids = null;
  car.state = 'driven';
}
function load() {
  M.state = 'loading';
  var p; try { p = import('/city/first-city-parking.js?v=20261013b'); } catch (e) { p = Promise.reject(e); }
  p.then(function (mod) {
    var make = mod.createFirstParking || mod.default;
    var g = make({ THREE: A.T, groundAt: (typeof groundAt === 'function') ? groundAt : function () { return 20; }, deckY: firstCityDeckY() });
    g.position.set(POS.x, 0, POS.z);
    A.world.add(g); M.group = g; M.state = 'ready';
    collide(g.userData || {}); hyperStop(); outButton();
    if (window.logBuild) logBuild('first-parking', 'The South Lot: apron + ramp + 14 rides + the Long Road, below the First City');
  }).catch(function (e) { M.state = 'failed'; try { console.warn('[city] South Lot skipped:', e && e.message); } catch (x) {} });
}
function standY(wx, wz, wy) {
  var deckY = firstCityDeckY(), best = -1;
  // the First City's own podium (lent by this placer until its own grows one)
  if (wx > FC.x - 212 && wx < FC.x + 212 && wz > FC.z - 380 && wz < FC.z + 380) {
    if (wy > deckY - 2.4 && deckY > best) best = deckY;
  }
  if (M.state !== 'ready' || !M.group) return best;
  var lx = wx - POS.x, lz = wz - POS.z, zones = M.group.userData.zones |