<!-- RUBY-BACKUP · part 469 -->
;
  scene.add(m2); TERRAIN_GROUP.push(m2);
  /* rough terrain */
  var r1 = buildRoughTerrain(px+40, pz-100, 20);
  scene.add(r1); TERRAIN_GROUP.push(r1);
  var r2 = buildRoughTerrain(px-40, pz+100, 20);
  scene.add(r2); TERRAIN_GROUP.push(r2);
  /* cliffs with trails */
  var c1 = buildCliffTrail(px-120, pz, 8);
  scene.add(c1); TERRAIN_GROUP.push(c1);
  var c2 = buildCliffTrail(px+120, pz, 10);
  scene.add(c2); TERRAIN_GROUP.push(c2);
  codeStatus('wild terrain — 4 islands (2 volcanoes), mountains, rough terrain, cliff trails.');
}
function clearWildTerrain(){
  if(TERRAIN_GROUP){
    TERRAIN_GROUP.forEach(function(o){ try{ scene.remove(o); }catch(e){} });
    TERRAIN_GROUP = null;
  }
  codeStatus('wild terrain cleared');
}

/* THREE ZONES — city separate from rural counties and tribal villages */
var RURAL_GROUP = null;
var TRIBAL_GROUP = null;
function buildFarm(x, z){
  var g = new THREE.Group();
  /* barn */
  var barn = new THREE.Mesh(new THREE.BoxGeometry(2, 1.5, 1.5),
    new THREE.MeshStandardMaterial({color: 0xaa3322, roughness: 0.8}));
  barn.position.y = 0.75; g.add(barn);
  var roof = new THREE.Mesh(new THREE.ConeGeometry(1.4, 0.8, 4),
    new THREE.MeshStandardMaterial({color: 0x664422, roughness: 0.8}));
  roof.position.y = 1.9; roof.rotation.y = Math.PI/4; g.add(roof);
  /* fields — rows */
  for(var r=0; r<4; r++){
    var row = new THREE.Mesh(new THREE.BoxGeometry(4, 0.1, 0.5),
      new THREE.MeshStandardMaterial({color: 0x4a6a2a, roughness: 1}));
    row.position.set(0, 0.05, -2 - r*0.8);
    g.add(row);
    /* crops */
    for(var ci=0; ci<8; ci++){
      var crop = new THREE.Mesh(new THREE.ConeGeometry(0.08, 0.3, 6),
        new THREE.MeshStandardMaterial({color: 0x66aa33, roughness: 0.9}));
      crop.position.set(-1.75+ci*0.5, 0.25, -2 - r*0.8);
      g.add(crop);
    }
  }
  /* fence */
  for(var f=0; f<6; f++){
    var post = new THREE.Mesh(new THREE.CylinderGeometry(0.04, 0.04, 0.8, 6),
      new THREE.MeshStandardMaterial({color: 0x6a4a2a, roughness: 0.9}));
    post.position.set(-2.5+f, 0.4, 2);
    g.add(post);
  }
  g.position.set(x*0.13, 0, z*0.13);
  return g;
}
function buildRuralCounties(){
  if(typeof scene==='undefined' || typeof mePos==='undefined') return;
  if(RURAL_GROUP){
    RURAL_GROUP.forEach(function(o){ try{ scene.remove(o); }catch(e){} });
  }
  RURAL_GROUP = [];
  var px = mePos.x, pz = mePos.z;
  /* rural — far from the city, to the west */
  for(var i=0; i<6; i++){
    var x = px - 200 - (i%3)*25;
    var z = pz - 50 + Math.floor(i/3)*40;
    var farm = buildFarm(x, z);
    scene.add(farm);
    RURAL_GROUP.push(farm);
  }
  codeStatus('rural counties — 6 farms, far from the city. Separate.');
}
function buildTribalHut(x, z, cyborgLevel){
  var g = new THREE.Group();
  var thatch = new THREE.MeshStandardMaterial({color: 0x8a6a3a, roughness: 1});
  var wood = new THREE.MeshStandardMaterial({color: 0x5a3a1a, roughness: 0.9});
  /* traditional hut — round */
  var hut = new THREE.Mesh(new THREE.CylinderGeometry(1.2, 1.4, 1.2, 10), wood);
  hut.position.y = 0.6; g.add(hut);
  var roof = new THREE.Mesh(new THREE.ConeGeometry(1.6, 1.0, 10), thatch);
  roof.position.y = 1.7; g.add(roof);
  /* CYBORG FEATURES — tribal meets future */
  if(cyborgLevel > 0){
    var techMat = new THREE.MeshStandardMaterial({
      color: 0x00ffff, emissive: 0x00ffff, emissiveIntensity: 1.2,
      metalness: 0.8, roughness: 0.3
    });
    /* glowing tribal patterns — circuit-like */
    for(var i=0; i<8; i++){
      var ang = i*(Math.PI*2/8);
      var circuit = new THREE.Mesh(new THREE.BoxGeometry(0.05, 0.8, 0.02), techMat);
      circuit.position.set(Math.cos(ang)*1.31, 0.6, Math.sin(ang)*1.31);
      circuit.rotation.y = -ang;
      g.add(circuit);
    }
    /* antenna — traditional meets tech */
    var ant = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.03, 1.5, 6),
      new THREE.MeshStandardMaterial({color: 0x888888, metalness: 0.9, roughness: 0.3}));
    ant.position.y = 2.8; g.add(ant);
    var tip = new THREE.Mesh(new THREE.SphereGeometry(0.08, 10, 10), techMat);
    tip.position.y = 3.6; g.add(tip);
    /* holographic fire — instead of wood fire */
    if(cyborgLevel > 1){
      var holo = new THREE.Mesh(new THREE.ConeGeometry(0.3, 0.6, 8),
        new THREE.MeshStandardMaterial({
          color: 0x00aaff, emissive: 0x00aaff, emissiveIntensity: 1.5,
          transparent: true, opacity: 0.7
        }));
      holo.position.set(1.8, 0.3, 0);
      g.add(holo);
    }
  }
  /* totem */
  var totem = new THREE.Mesh(new THREE.CylinderGeometry(0.15, 0.2, 2, 8), wood);
  totem.position.set(-1.8, 1.0, 0); g.add(totem);
  g.position.set(x*0.13, 0, z*0.13);
  return g;
}
function buildTribalVillages(){
  if(typeof scene==='undefined' || typeof mePos==='undefined') return;
  if(TRIBAL_GROUP){
    TRIBAL_GROUP.forEach(function(o){ try{ scene.remove(o); }catch(e){} });
  }
  TRIBAL_GROUP = [];
  var px = mePos.x, pz = mePos.z;
  /* tribal — to t