<!-- SAGA-STAGING · part 42 -->
dark opening */
      var entrance = new THREE.Mesh(new THREE.CircleGeometry(8, 12), tubeMat);
      entrance.position.set(x, 4, z);
      entrance.rotation.y = angle;
      scene.add(entrance);
      /* Glow from inside */
      var glow = new THREE.Mesh(new THREE.CircleGeometry(6, 12), glowMat);
      glow.position.set(x + Math.sin(angle)*0.5, 3, z + Math.cos(angle)*0.5);
      glow.rotation.y = angle;
      scene.add(glow);
      /* Tube going in */
      var tube = new THREE.Mesh(new THREE.CylinderGeometry(8, 8, len, 12, 1, true), tubeMat);
      tube.rotation.x = Math.PI/2;
      tube.rotation.z = angle;
      tube.position.set(x + Math.sin(angle)*len/2, 4, z + Math.cos(angle)*len/2);
      scene.add(tube);
    }
    lavaTube(2000, 1850, 60, 0);
    lavaTube(-2000, 1850, 70, Math.PI/4);
    lavaTube(0, -2510, 65, Math.PI);
  }catch(e){ console.error(e); }
}
if(typeof buildLavaTubes === 'function'){ try{ buildLavaTubes(); }catch(e){ console.error(e); } }

/* ALLUVIAL FANS — sediment at canyon mouths. 2026-10-04. */
function buildFans(){
  if(window.STAGING_CLEAN_MAP) return; // Clean map: old builder disabled
  try{
    var sedimentMat = new THREE.MeshStandardMaterial({color: 0xb09468, roughness: 1});
    function fan(x, z, r){
      /* Fan shape: half-cone spreading from canyon mouth */
      var fanMesh = new THREE.Mesh(new THREE.CylinderGeometry(r, r*0.3, 8, 16, 1, false, 0, Math.PI), sedimentMat);
      fanMesh.position.set(x, 2, z);
      fanMesh.scale.y = 0.5;
      scene.add(fanMesh);
      /* Braided channels */
      for(var c = 0; c < 5; c++){
        var ch = new THREE.Mesh(new THREE.PlaneGeometry(3, r*0.8),
          new THREE.MeshStandardMaterial({color: 0x8a7050, roughness: 1}));
        ch.rotation.x = -Math.PI/2;
        var ca = (c / 5) * Math.PI;
        ch.position.set(x + Math.cos(ca)*r*0.4, 4.2, z + Math.sin(ca)*r*0.4);
        ch.rotation.z = ca;
        scene.add(ch);
      }
    }
    fan(-1800, -3450, 80);  /* Canyon 1 mouth */
    fan(2200, 3450, 90);    /* Canyon 2 mouth */
    fan(-2800, -2700, 70);  /* Valley mouth */
  }catch(e){ console.error(e); }
}
if(typeof buildFans === 'function'){ try{ buildFans(); }catch(e){ console.error(e); } }

/* TRANSIT STATIONS — integrated into districts (Singapore model). 2026-10-04. */
function buildStations(){
  if(window.STAGING_CLEAN_MAP) return; // Clean map: old builder disabled
  try{
    var steelMat = new THREE.MeshStandardMaterial({color: 0x888888, metalness: 0.7, roughness: 0.4});
    var glassMat = new THREE.MeshStandardMaterial({color: 0xaaddff, transparent: true, opacity: 0.4});

    function station(x, z, name){
      var st = new THREE.Group();
      /* Platform */
      var plat = new THREE.Mesh(new THREE.BoxGeometry(30, 2, 12), steelMat);
      plat.position.y = 1;
      st.add(plat);
      /* Canopy */
      var canopy = new THREE.Mesh(new THREE.BoxGeometry(32, 0.5, 14), glassMat);
      canopy.position.y = 8;
      st.add(canopy);
      /* Pillars */
      for(var p = -1; p <= 1; p++){
        for(var q = -1; q <= 1; q += 2){
          var pillar = new THREE.Mesh(new THREE.CylinderGeometry(0.5, 0.5, 7, 8), steelMat);
          pillar.position.set(p*12, 4.5, q*6);
          st.add(pillar);
        }
      }
      /* Sign */
      var sign = new THREE.Mesh(new THREE.BoxGeometry(10, 2, 0.5),
        new THREE.MeshBasicMaterial({color: 0x00ffff}));
      sign.position.set(0, 10, 0);
      st.add(sign);
      st.position.set(x, 0.13, z);
      scene.add(st);
    }

    station(100, -80);    /* City Central */
    station(-80, 160);    /* Village */
    station(2000, 1980);  /* Ahupua'a */
    station(3000, 480);   /* Shoreline */

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

/* SCHOOLS — places of learning, for the children. 2026-10-04. */
function buildSchools(){
  if(window.STAGING_CLEAN_MAP) return; // Clean map: old builder disabled
  try{
    var wallMat = new THREE.MeshStandardMaterial({color: 0xf0e0c0, roughness: 0.9});
    var roofMat = new THREE.MeshStandardMaterial({color: 0x2a5aaa, roughness: 0.8});

    function school(x, z){
      var sc = new THREE.Group();
      /* Main building */
      var main = new THREE.Mesh(new THREE.BoxGeometry(20, 8, 12), wallMat);
      main.position.y = 4;
      sc.add(main);
      /* Roof */
      var roof = new THREE.Mesh(new THREE.BoxGeometry(22, 1, 14), roofMat);
      roof.position.y = 8.5;
      sc.add(roof);
      /* Door */
      var door = new THREE.Mesh(new THREE.PlaneGeometry(3, 5),
        new THREE.MeshBasicMaterial({color: 0x8a5a2a}));
      door.position.set(0, 2.5, 6.01);
      sc.add(door);
      /* Windows — bright, welcoming */
      for(var w = -2; w <= 2; w++){
        if(w === 0) continue;
        var win = new THREE.Mesh(new THREE.PlaneGeometry(2, 2),
          new THREE.MeshBasicMaterial({color: 0xaaddff}));
        win.position.set(w*4, 5, 6