<!-- SAGA · part 40 -->
kPhase < 0.5;
        var h;
        var w; /* Width expands at peaks, contracts at cols */
        if(isPeak){
          h = 120 + Math.sin(peakPhase * Math.PI * 2) * 40;
          w = 60 + Math.sin(peakPhase * Math.PI) * 30; /* Wide at peak */
        } else {
          h = 60 + Math.sin(peakPhase * Math.PI * 2) * 20;
          w = 15; /* Knife-edge at col */
        }
        /* Concave/convex: convex crest, concave base */
        var mtn = new THREE.Mesh(new THREE.ConeGeometry(w, h, 6), rockMat);
        mtn.position.set(px, h/2, pz);
        scene.add(mtn);
        if(h > 100){
          var cap = new THREE.Mesh(new THREE.ConeGeometry(w*0.4, h*0.25, 6), snowMat);
          cap.position.set(px, h - h*0.12, pz);
          scene.add(cap);
        }
      }
    }

    /* CIRQUE — concave bowl with tarn (lake) */
    function cirque(x, z, r){
      /* Bowl: concave */
      var bowl = new THREE.Mesh(new THREE.SphereGeometry(r, 16, 12, 0, Math.PI*2, 0, Math.PI/2), rockMat);
      bowl.rotation.x = Math.PI;
      bowl.position.set(x, 10, z);
      bowl.scale.y = 0.6;
      scene.add(bowl);
      /* Tarn */
      var tarn = new THREE.Mesh(new THREE.CircleGeometry(r*0.4, 20), waterMat);
      tarn.rotation.x = -Math.PI/2;
      tarn.position.set(x, 2, z);
      scene.add(tarn);
      /* Headwall: steep back */
      var wall = new THREE.Mesh(new THREE.CylinderGeometry(r, r*1.2, 60, 12, 1, true, 0, Math.PI), rockMat);
      wall.position.set(x, 30, z);
      wall.rotation.y = Math.PI;
      scene.add(wall);
    }

    /* PLATEAU BRIDGE — flat high ground connecting peaks (Tibetan model) */
    function plateauBridge(x1, z1, x2, z2, width, height){
      var dx = x2 - x1, dz = z2 - z1;
      var len = Math.sqrt(dx*dx + dz*dz);
      /* Flat top */
      var plat = new THREE.Mesh(new THREE.BoxGeometry(width, 20, len), grassMat);
      plat.position.set((x1+x2)/2, height, (z1+z2)/2);
      plat.rotation.y = Math.atan2(dx, dz);
      scene.add(plat);
      /* Cliffs at edges */
      var edge1 = new THREE.Mesh(new THREE.BoxGeometry(8, height, len), rockMat);
      edge1.position.set((x1+x2)/2 - width/2, height/2, (z1+z2)/2);
      edge1.rotation.y = Math.atan2(dx, dz);
      scene.add(edge1);
      var edge2 = new THREE.Mesh(new THREE.BoxGeometry(8, height, len), rockMat);
      edge2.position.set((x1+x2)/2 + width/2, height/2, (z1+z2)/2);
      edge2.rotation.y = Math.atan2(dx, dz);
      scene.add(edge2);
      /* Peaks on rim */
      for(var p = 0; p < 4; p++){
        var t = p / 3;
        var px = x1 + dx*t + (Math.random()-0.5)*width*0.8;
        var pz = z1 + dz*t + (Math.random()-0.5)*width*0.8;
        var peak = new THREE.Mesh(new THREE.ConeGeometry(40, 100, 7), rockMat);
        peak.position.set(px, height + 50, pz);
        scene.add(peak);
      }
    }

    /* Build */
    /* Arête ridges — expanding/contracting */
    areteRidge(-3500, -3000, -1500, -2500, 4);
    areteRidge(2500, 3500, 4000, 3000, 3);

    /* Cirques — concave bowls */
    cirque(-2800, -2800, 80);
    cirque(3200, 3300, 100);

    /* Plateau bridges — connecting mountain groups */
    plateauBridge(-3000, -2000, -2000, -2000, 300, 80);  /* Between peaks 1-3 */
    plateauBridge(2000, 2000, 2000, 1500, 250, 70);      /* Ahupua'a plateau */

  }catch(e){}
}
if(typeof buildRidgesPlateaus === 'function'){ window._buildQueue.push(buildRidgesPlateaus); }

/* CINEMATIC — art direction. Unified light, fog, tone mapping. 2026-10-04.
   From research: one sun rig, ACES, fog=sky, three-point light. */
function applyCinematic(){
  try{
    /* ACES tone mapping — cinematic color */
    renderer.toneMapping = THREE.ACESFilmicToneMapping;
    renderer.toneMappingExposure = 1.1;

    /* Fog — matched to sky horizon (gold) for seamless depth */
    scene.fog = new THREE.FogExp2(0xd4a017, 0.00012);

    /* THREE-POINT LIGHTING */
    /* Remove old lights */
    /* Warm key — golden hour sun */
    var key = new THREE.DirectionalLight(0xffd4a0, 2.2);
    key.position.set(400, 300, -600);
    key.castShadow = true;
    scene.add(key);
    /* Cool fill — 30% of key */
    var fill = new THREE.DirectionalLight(0x88aaff, 0.7);
    fill.position.set(-300, 200, 400);
    scene.add(fill);
    /* Rim light — behind, purple, separates from background */
    var rim = new THREE.DirectionalLight(0x8844ff, 0.5);
    rim.position.set(0, 400, 800);
    scene.add(rim);
    /* Low ambient — preserve drama */
    /* (Keep existing ambient but it should be low) */

    /* Hemisphere — sky/ground bounce */
    var hemi = new THREE.HemisphereLight(0x8a9acc, 0x2a1a0a, 0.4);
    scene.add(hemi);

  }catch(e){}
}
if(typeof applyCinematic === 'function'){ window._buildQueue.push(applyCinematic); }


/* GOD RAYS — volumetric light shafts. 2026-10-04. */
function buildGodRays(){
  try{
    window._dynamics = window._dynamics || [];
    var rayMat = new THREE.MeshBasicMaterial({
      color: 0xffd4a0, transparent: true, opacity: 0.08,
      blendi