<!-- LIVE · part 32 -->
es */
    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){ console.error(e); }
}
if(typeof buildCosmic === 'function'){ try{ buildCosmic(); }catch(e){ console.error(e); } }

/* 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 + Math.random()*10, 12, 8), sandMat);
      dune.scale.y = 0.3;
      dune.position.set(sx, 0.5, sz);
      scene.add(dune);
    }

    /* 6. SHADOW GROVE (-800, 1200) — dark trees */
    var shadowMat = new THREE.MeshStandardMaterial({color: 0x0a0a1a, roughness: 0.95});
    for(var sg = 0; sg < 25; sg++){
      var gx = -800 + (Math.random()-0.5)*80;
      var gz = 1200 + (Math.random()-0.5)*80;
      var gtree = new THREE.Mesh(new THREE.ConeGeometry(4, 12, 7), shadowMat);
      gtree.position.set(gx, 6, gz);
      scene.add(gtree);
    }

    /* 7. TIDE POOLS (1200, 300) — water gardens */
    var tideMat = new THREE.MeshStandardMaterial({color: 0x00aaff, transparent: true, opacity: 0.6});
    for(var tp = 0; tp < 8; tp++){
      var px = 1200 + (Math.random()-0.5)*60;
      var pz = 300 + (Math.random()-0.5)*60;
      var pool = new THREE.Mesh(new THREE.CircleGeometry(8, 16), tideMat);
      pool.rotation.x = -Math.PI/2;
      pool.position.set(px, 0.3, pz);
      scene.add(pool);
    }

    /* 8. STORM SPIRE (-1500, 0) — lightning tower */
    var spire = new THREE.Mesh(new THREE.CylinderGeometry(3, 6, 80, 8), darkMat);
    spire.position.set(-1500, 40, 0);
    scene.add(spire);
    var orb = new THREE.Mesh(new THREE.SphereGeometry(6, 16, 12),
      new THREE.MeshBasicMaterial({color: 0x8888ff}));
    orb.position.set(-1500, 85, 0);
    scene.add(orb);
    window._dynamics.push(function(t){
      orb.material.color.setHSL(0.6, 1, 0.5 + Math.sin(t*5)*0.3);
 