<!-- SAGA · part 32 -->
n.z = Math.PI/2;
      beam.rotation.y = Math.atan2(x2-x1, z2-z1);
      scene.add(beam);
    }
    window._dynamics.push(function(t){
      beamMat.opacity = 0.3 + Math.sin(t * 2) * 0.15;
    });

    /* FLOATING ISLANDS */
    for(var fi = 0; fi < 8; fi++){
      (function(){
        var fx = (Math.random() - 0.5) * 400;
        var fz = (Math.random() - 0.5) * 400;
        var fy = 60 + Math.random() * 40;
        var island = new THREE.Group();
        var top = new THREE.Mesh(new THREE.CylinderGeometry(12, 8, 4, 8),
          new THREE.MeshStandardMaterial({color: 0x2a4a2a, roughness: 0.9}));
        island.add(top);
        var bottom = new THREE.Mesh(new THREE.ConeGeometry(8, 12, 8),
          new THREE.MeshStandardMaterial({color: 0x555555, roughness: 0.9}));
        bottom.position.y = -8;
        bottom.rotation.x = Math.PI;
        island.add(bottom);
        /* Mini trees */
        for(var mt = 0; mt < 5; mt++){
          var mtree = new THREE.Mesh(new THREE.ConeGeometry(1.5, 4, 6),
            new THREE.MeshStandardMaterial({color: 0x0a4a0a}));
          mtree.position.set((Math.random()-0.5)*15, 4, (Math.random()-0.5)*15);
          island.add(mtree);
        }
        island.position.set(fx, fy, fz);
        scene.add(island);
        var ph3 = Math.random() * 10;
        window._dynamics.push(function(t){
          island.position.y = fy + Math.sin(t * 0.6 + ph3) * 4;
          island.rotation.y += 0.001;
        });
      })();
    }

    /* COSMIC DUST — maximum particles */
    var cosmicGeo = new THREE.BufferGeometry();
    var cosmicCount = 2000;
    var cosmicPos = new Float32Array(cosmicCount * 3);
    for(var cd = 0; cd < cosmicCount; cd++){
      cosmicPos[cd*3] = (Math.random() - 0.5) * 1200;
      cosmicPos[cd*3+1] = Math.random() * 500;
      cosmicPos[cd*3+2] = (Math.random() - 0.5) * 1200;
    }
    cosmicGeo.setAttribute('position', new THREE.BufferAttribute(cosmicPos, 3));
    var cosmicMat = new THREE.PointsMaterial({color: 0xaaaaff, size: 1, transparent: true, opacity: 0.5, fog: false});
    var cosmic = new THREE.Points(cosmicGeo, cosmicMat);
    scene.add(cosmic);
    window._dynamics.push(function(t){
      cosmic.rotation.y = t * 0.005;
    });

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

/* 10 MORE DISTRICTS — filling the 20000 world. 2026-10-04. */
function buildTenDistricts(){
  try{
    window._dynamics = window._dynamics || [];
    var goldMat = new THREE.MeshStandardMaterial({color: 0xd4a017, roughness: 0.4, metalness: 0.6});
    var darkMat = new THREE.MeshStandardMaterial({color: 0x1a1a1a, roughness: 0.8});

    /* 1. CRYSTAL CAVERNS (1000, 1000) */
    for(var c = 0; c < 20; c++){
      (function(){
        var cx = 1000 + (Math.random()-0.5)*80;
        var cz = 1000 + (Math.random()-0.5)*80;
        var crys = new THREE.Mesh(new THREE.OctahedronGeometry(2 + Math.random()*3, 0),
          new THREE.MeshStandardMaterial({color: 0x8844ff, emissive: 0x442288, emissiveIntensity: 0.8, transparent: true, opacity: 0.9}));
        crys.position.set(cx, 2, cz);
        scene.add(crys);
        var ph = Math.random()*10;
        window._dynamics.push(function(t){ crys.rotation.y += 0.01; crys.material.emissiveIntensity = 0.6 + Math.sin(t*2+ph)*0.3; });
      })();
    }

    /* 2. SKY PORT (-1000, 500) — docks in the sky */
    var spx = -1000, spz = 500;
    var platform = new THREE.Mesh(new THREE.BoxGeometry(60, 4, 40), darkMat);
    platform.position.set(spx, 80, spz);
    scene.add(platform);
    for(var d = 0; d < 4; d++){
      var dockArm = new THREE.Mesh(new THREE.BoxGeometry(20, 2, 4), goldMat);
      dockArm.position.set(spx - 30 + d*20, 82, spz + 25);
      scene.add(dockArm);
    }

    /* 3. EMBER FIELDS (1500, -800) — volcanic */
    for(var e = 0; e < 15; e++){
      var ex = 1500 + (Math.random()-0.5)*100;
      var ez = -800 + (Math.random()-0.5)*100;
      var lava = new THREE.Mesh(new THREE.CircleGeometry(5 + Math.random()*5, 12),
        new THREE.MeshBasicMaterial({color: 0xff4400}));
      lava.rotation.x = -Math.PI/2;
      lava.position.set(ex, 0.25, ez);
      scene.add(lava);
    }

    /* 4. FROST PEAKS (-1200, -1000) — ice */
    var iceMat = new THREE.MeshStandardMaterial({color: 0xaaddff, transparent: true, opacity: 0.8, roughness: 0.2});
    for(var f = 0; f < 10; f++){
      var fx = -1200 + (Math.random()-0.5)*120;
      var fz = -1000 + (Math.random()-0.5)*120;
      var fh = 25 + Math.random()*25;
      var peak = new THREE.Mesh(new THREE.ConeGeometry(12, fh, 6), iceMat);
      peak.position.set(fx, fh/2, fz);
      scene.add(peak);
    }

    /* 5. GOLDEN DESERT (800, 1500) — dunes */
    var sandMat = new THREE.MeshStandardMaterial({color: 0xd4a017, roughness: 1});
    for(var sd = 0; sd < 12; sd++){
      var sx = 800 + (Math.random()-0.5)*150;
      var sz = 1500 + (Math.random()-0.5)*150;
      var dune = new THREE.Mesh(new THREE.SphereGeometry(15 + Ma