<!-- RUBY-BACKUP · part 298 -->
tions: where highways meet high terrain
        var tunnels = [
          {x: 300, z: 100, dir: 0.5},
          {x: -250, z: -200, dir: 2.1},
          {x: 150, z: -350, dir: 1.2},
          {x: -400, z: 300, dir: 3.8}
        ];
        tunnels.forEach(function(t, ti){
          var td = Math.sqrt(t.x*t.x + t.z*t.z);
          var th = 10 + Math.sin(td*0.02)*4 + Math.sin(td*0.05+1.3)*2;
          // tunnel tube (through the hill)
          var tunLen = 40;
          var tunGeo = new THREE.CylinderGeometry(6, 6, tunLen, 16, 1, true, 0, Math.PI);
          var tun = new THREE.Mesh(tunGeo, tunMat);
          // orient along direction
          tun.rotation.z = Math.PI/2;
          tun.rotation.y = t.dir;
          tun.position.set(t.x, th+2, t.z);
          tun.name = 'tunnel-'+ti;
          g.add(tun);
          // entrance portals (both ends)
          [-1, 1].forEach(function(s){
            var px = t.x + Math.cos(t.dir)*s*tunLen/2;
            var pz = t.z + Math.sin(t.dir)*s*tunLen/2;
            // stone portal frame
            var portal = new THREE.Mesh(new THREE.TorusGeometry(7, 1.2, 8, 16, Math.PI), portMat);
            portal.position.set(px, th+2, pz);
            portal.rotation.y = t.dir + Math.PI/2;
            portal.name = 'tunnel-portal-'+ti+'-'+s;
            g.add(portal);
            // lights inside
            for(var li=1; li<=3; li++){
              var lx = t.x + Math.cos(t.dir)*s*(tunLen/2 - li*8);
              var lz = t.z + Math.sin(t.dir)*s*(tunLen/2 - li*8);
              var lamp = new THREE.Mesh(new THREE.SphereGeometry(0.5, 8, 8), tunLightMat);
              lamp.position.set(lx, th+7, lz);
              lamp.name = 'tunnel-light';
              g.add(lamp);
            }
          });
          // hill over the tunnel
          var hill = new THREE.Mesh(new THREE.SphereGeometry(20, 12, 8),
            new THREE.MeshStandardMaterial({color:0x2d5016, roughness:1}));
          hill.scale.set(1.5, 0.8, 1);
          hill.position.set(t.x, th-2, t.z);
          hill.name = 'tunnel-hill-'+ti;
          g.add(hill);
        });
      }catch(e){}
    })();
    /* SPACE AGE — the future rises along the highways */
    (function(){
      try{
        var bldMat = new THREE.MeshStandardMaterial({color:0x1a1a2e, metalness:0.8, roughness:0.3});
        var glassMat = new THREE.MeshStandardMaterial({color:0x00ffff, emissive:0x00ffff, emissiveIntensity:0.4, transparent:true, opacity:0.7});
        var glowMat = new THREE.MeshBasicMaterial({color:0xff00ff});
        // futuristic districts at highway intersections
        var districts = [
          {x: 200, z: 200, size: 1.5},
          {x: -300, z: 150, size: 1.2},
          {x: 150, z: -300, size: 1.3},
          {x: -200, z: -250, size: 1.0},
          {x: 400, z: -100, size: 1.4},
          {x: -400, z: -100, size: 1.1}
        ];
        districts.forEach(function(d, di){
          var gy = fortifiedGroundY(d.x, d.z);
          var n = Math.floor(8 * d.size);
          for(var i=0; i<n; i++){
            var bx = d.x + (Math.random()-0.5)*120*d.size;
            var bz = d.z + (Math.random()-0.5)*120*d.size;
            // skip if on highway
            if(typeof isOnHighway==='function' && isOnHighway(bx, bz)) continue;
            var by = fortifiedGroundY(bx, bz);
            var h = 20 + Math.random()*60*d.size;
            var w = 6 + Math.random()*8;
            // main tower
            var tower = new THREE.Mesh(new THREE.BoxGeometry(w, h, w), bldMat);
            tower.position.set(bx, by + h/2, bz);
            tower.name = 'space-tower-'+di+'-'+i;
            g.add(tower);
            // glowing top
            var top = new THREE.Mesh(new THREE.BoxGeometry(w*0.6, 2, w*0.6), glassMat);
            top.position.set(bx, by + h + 1, bz);
            top.name = 'space-top';
            g.add(top);
            // antenna
            if(Math.random() > 0.5){
              var ant = new THREE.Mesh(new THREE.CylinderGeometry(0.2, 0.2, 15, 6), bldMat);
              ant.position.set(bx, by + h + 8, bz);
              ant.name = 'space-antenna';
              g.add(ant);
              var beacon = new THREE.Mesh(new THREE.SphereGeometry(0.8, 8, 8), glowMat);
              beacon.position.set(bx, by + h + 16, bz);
              beacon.name = 'space-beacon';
              g.add(beacon);
            }
          }
          // central dome
          var dome = new THREE.Mesh(new THREE.SphereGeometry(25*d.size, 16, 12, 0, Math.PI*2, 0, Math.PI/2), glassMat);
          dome.position.set(d.x, gy, d.z);
          dome.name = 'space-dome-'+di;
          g.add(dome);
          // dome base ring
          var ring = new THREE.Mesh(new THREE.TorusGeometry(25*d.size, 2, 8, 32), bldMat);
          ring.rotation.x = Math.PI/2;
          ring.position.set(d.x, gy+1, d.z);
          ring.name = 'space-ring';
          g.add(ring);
        });
        // orbital ring station (high above)
        var station = new 