<!-- SAGA-STAGING · part 40 -->
urn p;
    }

    /* People in the city */
    for(var i = 0; i < 15; i++){
      person(100 + (Math.random()-0.5)*80, -100 + (Math.random()-0.5)*80,
        clothColors[i % clothColors.length]);
    }
    /* People in the village */
    for(var j = 0; j < 10; j++){
      person(-80 + (Math.random()-0.5)*50, 180 + (Math.random()-0.5)*50,
        clothColors[(j+3) % clothColors.length]);
    }

  }catch(e){ console.error(e); }
}
if(typeof buildPeople === 'function'){ try{ buildPeople(); }catch(e){ console.error(e); } }















/* WORLD HEART — the crystal at the center of everything. 2026-10-04. */
function buildWorldHeart(){
  if(window.STAGING_CLEAN_MAP) return; // Clean map: old builder disabled
  try{
    window._dynamics = window._dynamics || [];
    /* Massive crystal */
    var heart = new THREE.Mesh(new THREE.OctahedronGeometry(15, 0),
      new THREE.MeshStandardMaterial({
        color: 0xffd700, emissive: 0xaa7700, emissiveIntensity: 1,
        transparent: true, opacity: 0.9, roughness: 0.1, metalness: 0.3
      }));
    heart.position.set(0, 40, 0);
    scene.add(heart);
    /* Inner glow */
    var glow = new THREE.Mesh(new THREE.OctahedronGeometry(10, 0),
      new THREE.MeshBasicMaterial({color: 0xfff8dc, transparent: true, opacity: 0.6}));
    glow.position.set(0, 40, 0);
    scene.add(glow);
    /* Floating rings */
    for(var r = 0; r < 3; r++){
      (function(){
        var ring = new THREE.Mesh(new THREE.TorusGeometry(25 + r*10, 1, 8, 32),
          new THREE.MeshBasicMaterial({color: 0xd4a017, transparent: true, opacity: 0.5}));
        ring.position.set(0, 40, 0);
        ring.rotation.x = Math.PI/2 + r*0.3;
        scene.add(ring);
        window._dynamics.push(function(t){
          ring.rotation.z += 0.005 * (r+1);
        });
      })();
    }
    /* Pedestal */
    var ped = new THREE.Mesh(new THREE.CylinderGeometry(20, 25, 10, 8),
      new THREE.MeshStandardMaterial({color: 0x1a1a1a, roughness: 0.8}));
    ped.position.set(0, 5, 0);
    scene.add(ped);
    /* Pulse */
    window._dynamics.push(function(t){
      var pulse = 1 + Math.sin(t*2) * 0.1;
      heart.scale.set(pulse, pulse*1.2, pulse);
      heart.rotation.y += 0.01;
      heart.material.emissiveIntensity = 0.8 + Math.sin(t*2) * 0.4;
      glow.material.opacity = 0.4 + Math.sin(t*2) * 0.2;
    });
    /* World Heart sky beam disabled v195.
       Crystal, glow, rings and pedestal remain intact. */
  }catch(e){ console.error(e); }
}
if(typeof buildWorldHeart === 'function'){ try{ buildWorldHeart(); }catch(e){ console.error(e); } }

/* DYNAMIC RESOLUTION — adaptive pixel ratio for performance. 2026-10-04. */
(function(){
  var frameTimes = [];
  var lastT = performance.now();
  window._dynamics = window._dynamics || [];
  window._dynamics.push(function(){
    try{
      var now = performance.now();
      var dt = now - lastT;
      lastT = now;
      frameTimes.push(dt);
      if(frameTimes.length > 60) frameTimes.shift();
      if(frameTimes.length === 60){
        var avg = frameTimes.reduce(function(a,b){return a+b;}, 0) / 60;
        var fps = 1000 / avg;
        var pr = renderer.getPixelRatio();
        if(fps < 25 && pr > 0.6){
          renderer.setPixelRatio(Math.max(0.6, pr - 0.1));
        } else if(fps > 50 && pr < 1.25){
          renderer.setPixelRatio(Math.min(1.25, pr + 0.05));
        }
        frameTimes = [];
      }
    }catch(e){ console.error(e); }
  });
})();

/* BRIDGE-TUNNEL HYBRID — Aqua-Line model. Bridge dives into tunnel. 2026-10-04. */
function buildAquaLine(){
  if(window.STAGING_CLEAN_MAP) return; // Clean map: old builder disabled
  try{
    var concreteMat = new THREE.MeshStandardMaterial({color: 0x888888, roughness: 0.8});
    /* Bridge section: from shore */
    var bridge = new THREE.Mesh(new THREE.BoxGeometry(12, 3, 400), concreteMat);
    bridge.position.set(2900, 8, 500);
    scene.add(bridge);
    /* Pillars */
    for(var p = 0; p < 8; p++){
      var pillar = new THREE.Mesh(new THREE.CylinderGeometry(3, 4, 16, 8), concreteMat);
      pillar.position.set(2900, 0, 320 + p*50);
      scene.add(pillar);
    }
    /* Artificial island (Umihotaru) */
    var island = new THREE.Mesh(new THREE.CylinderGeometry(40, 45, 6, 16), concreteMat);
    island.position.set(2900, 2, 720);
    scene.add(island);
    var tower = new THREE.Mesh(new THREE.CylinderGeometry(8, 10, 30, 8), concreteMat);
    tower.position.set(2900, 18, 720);
    scene.add(tower);
    /* Tunnel portal — dives underwater */
    var portal = new THREE.Mesh(new THREE.BoxGeometry(16, 12, 4), concreteMat);
    portal.position.set(2900, 2, 745);
    scene.add(portal);
    var dark = new THREE.Mesh(new THREE.PlaneGeometry(12, 8),
      new THREE.MeshBasicMaterial({color: 0x000000}));
    dark.position.set(2900, 2, 747.1);
    dark.rotation.y = Math.PI;
    scene.add(dark);
  }catch(e){ console.error(e); }
}
if(typeof buildAquaLine === 'function'){ try{ buildAquaLine(); }catch(e){ conso