<!-- SOLID CITY · part 3616 -->
iant trees — ancients 25 to 40 meters tall. The lookout faces the city lights, far below.' });
  if (H.regrid) H.regrid();
}
function watchStop() {
  var W = window.CityWatch, r = W && W.routes && W.routes.grand; if (!r || r._villageMauna) return;
  var orig = r.build; r._villageMauna = true;
  r.build = function () {
    var w = orig.apply(this, arguments);
    w.push({ x: POS.x - 500, z: POS.z + 300, y: M.gy + 260, v: 240, cap: { cap: 'KAUHALE MAUNA', sub: 'Mountain village \u00b7 giant trees \u00b7 terraces', say: 'Kauhale Mauna, the mountain village: terraces, warm windows, and giant trees rising into the mist.' }, agl: false });
    return w;
  };
}
function standY(x, z) {
  if (!M.tops) return -1000;
  for (var i = 0; i < M.tops.length; i++) {
    var t = M.tops[i];
    if (Math.hypot(x - (POS.x + t.x), z - (POS.z + t.z)) < t.r) return M.gy + t.topY;
  }
  return -1000;
}
function load() {
  M.state = 'loading';
  M.gy = sampleGround() + 3;
  var p; try { p = import('/city/village-mauna.js?v=20261011a'); } catch (e) { p = Promise.reject(e); }
  p.then(function (mod) {
    var make = mod.createMaunaVillage || mod.default;
    var g = make({ THREE: A.T, position: { x: POS.x, y: M.gy, z: POS.z } });
    A.world.add(g); M.group = g; M.state = 'ready';
    M.tops = (g.userData && g.userData.terraceTops) || null;
    collide(g.userData || {}); hyperStop(); watchStop();
  }).catch(function (e) { M.state = 'failed'; try { console.warn('[city] Village Mauna skipped:', e && e.message); } catch (x) {} });
}
function update(dt) {
  if (M.state === 'idle') { if (A.isBuilt && !A.isBuilt()) return; M.wait -= dt; if (M.wait <= 0) load(); return; }
  if (M.state !== 'ready' || document.hidden) return;
  var c = A.camera.position, d = Math.hypot(c.x + A.origin.x - POS.x, c.z + A.origin.z - POS.z);
  M.group.visible = d < 9000;
  if (d < 2600 && M.group.userData.update) try { M.group.userData.update(S.t); } catch (e) {}
  if (S.mode === 'walk') {
    var pd = Math.hypot(S.p.x - POS.x, S.p.z - POS.z);
    if (pd < 320 && !M.said) { M.said = true; if (window.CityHyper && CityHyper.narrate) CityHyper.narrate('<b>Kauhale Mauna</b>: the mountain village. Warm windows among the giant trees.', 7); }
    else if (pd > 600) M.said = false;
  }
}
function radar(g, blip, fl) { if (M.state === 'ready') blip(POS.x, POS.z, '#4a8a3a', fl ? 3 : 6, fl ? '' : 'VILLAGE'); }
window.CityVillageMauna = { update: update, radar: radar, pos: POS, standY: standY, state: function () { return M.state; }, group: function () { return M.group; } };
})();


===== FILE: public/city/village-mauna-place.js.bak-oneroad-20261012 =====
/* Solid City — places KAUHALE MAUNA, THE MOUNTAIN VILLAGE (public/city/village-mauna.js)
   on a mountainside ~2.8 km southeast of the capital.
   Lazy: imported after the city is built; any import/build error is caught and the city carries on.
   The village height adapts to the terrain at runtime: samples groundAt over the
   district, takes the max, and sets the terraces above it. Permanent at load.
   Adds: collision (userData.footprint), a radar marker 'VILLAGE', a Hyper
   Controller stop, and a Watch (GRAND TOUR) caption. One quiet line on first approach. */
(function () {
'use strict';
if (!window.SC || !SC.api) return;
var A = SC.api, S = A.S;
var POS = { x: 2000, z: 2000 }, NAME = 'Kauhale Mauna';
var M = { state: 'idle', group: null, wait: 4.0, said: false, gy: 22, tops: null };
function sampleGround() {
  var g = (typeof groundAt === 'function') ? groundAt : null;
  if (!g) return 22;
  var max = -1000, x, z, h;
  for (var i = -2; i <= 2; i++) for (var j = -2; j <= 2; j++) {
    x = POS.x + i * 130; z = POS.z + j * 130;
    try { h = g(x, z); } catch (e) { h = 22; }
    if (h > max) max = h;
  }
  return max;
}
function addBox(cx, cz, w, d, rot, y0, y1) {
  var nx = Math.max(1, Math.ceil(w / 2.5)), nz = Math.max(1, Math.ceil(d / 2.5)), cw = w / nx, cd = d / nz, c = Math.cos(rot), s = Math.sin(rot);
  var hx = cw / 2 * Math.abs(c) + cd / 2 * Math.abs(s), hz = cw / 2 * Math.abs(s) + cd / 2 * Math.abs(c);
  for (var i = 0; i < nx; i++) for (var j = 0; j < nz; j++) {
    var ox = -w / 2 + cw * (i + 0.5), oz = -d / 2 + cd * (j + 0.5), lx = cx + ox * c + oz * s, lz = cz - ox * s + oz * c;
    A.solids.push({ x0: POS.x + lx - hx, x1: POS.x + lx + hx, z0: POS.z + lz - hz, z1: POS.z + lz + hz, y0: M.gy + y0, y1: M.gy + y1, villageMauna: true });
  }
}
function collide(ud) { (ud.footprint || []).forEach(function (b) { addBox(b[0], b[1], b[2], b[3], b[6] || 0, b[4], b[5]); }); }
function hyperStop() {
  var H = window.CityHyper; if (!H || !H.pois || H.pois.some(function (p) { return p.id === 'village-mauna'; })) return;
  H.pois.push({ id: 'village-mauna', name: 'Kauhale Mauna — Mountain Village', short: 'VILLAGE', x: POS.x, z: POS.z, stand: { x: POS.x, z: POS.z + 200 },
    alias: 'mountain village kauhale trees huts',
    text: 'Kauhale Mauna, the mountain village: three terraces climbing 