<!-- RUBY-BACKUP · part 516 -->
* (width/2 - 0.8);
            /* match the road's height */
            var _h = pt.y;
            edgePts.push(new THREE.Vector3(pt.x + nx/nlen*off, _h + 0.3, pt.z + nz/nlen*off));
          }
          var edgeCurve = new THREE.CatmullRomCurve3(edgePts);
          var edgeGeo = new THREE.TubeGeometry(edgeCurve, 64, 0.18, 6, false);
          var edgeLine = new THREE.Mesh(edgeGeo, new THREE.MeshBasicMaterial({color:0xffffff}));
          edgeLine.name = 'road-edge-design';
          g.add(edgeLine);
        });
      }catch(e){}
    }
    // central plaza — roundabout
    var plaza = new THREE.Mesh(new THREE.CylinderGeometry(4, 4, 0.15, 24), plazaMat); /* small — not blocking */
    plaza.position.set(0, 10, 0); /* 5 blocks high */
    plaza.name = 'plaza';
    g.add(plaza);
    var plazaRing = new THREE.Mesh(new THREE.TorusGeometry(3.5, 0.2, 8, 32), lineMat);
    plazaRing.position.set(0, 10.15, 0); /* above the plaza */
    plazaRing.rotation.x = Math.PI/2;
    plazaRing.name = 'plaza-ring';
    g.add(plazaRing);
    // winding roads radiating from plaza — STRETCHED BIG
    curvedRoad([[12,0], [50,15], [100,10], [200,30], [400,20], [600,40], [800,60], [1000,50], [1200,70]], 16);
    curvedRoad([[12,0], [40,-25], [90,-40], [180,-35], [350,-50], [550,-40], [750,-60], [950,-50], [1150,-70]], 16);
    curvedRoad([[0,12], [-15,50], [-10,100], [-30,200], [-20,400], [-40,600], [-60,800], [-50,1000], [-70,1200]], 16);
    curvedRoad([[0,12], [20,55], [15,110], [35,220], [30,420], [50,600], [60,800], [70,1000], [80,1180]], 14);
    curvedRoad([[-12,0], [-50,-15], [-100,-10], [-200,-30], [-400,-20], [-600,-40], [-800,-60], [-1000,-50], [-1200,-70]], 16);
    curvedRoad([[0,-12], [15,-50], [10,-100], [30,-200], [20,-400], [40,-600], [50,-800], [60,-1000], [70,-1200]], 14);
    // a scenic loop — big
    curvedRoad([[60,60], [120,110], [200,100], [280,150], [220,220], [140,200], [80,240]], 14);
    /* CIVIL ENGINEERING — proper cross-section */
    // Add to each road: crowned surface, shoulders, drainage, guardrails
    (function(){
      var shoulderMat = new THREE.MeshStandardMaterial({color:0x5a5a5a, roughness:0.95});
      var drainMat = new THREE.MeshStandardMaterial({color:0x2a2a2a, roughness:1.0});
      var railMat = new THREE.MeshStandardMaterial({color:0xcccccc, metalness:0.7, roughness:0.4});
      var wallMat = new THREE.MeshStandardMaterial({color:0x6a6a6a, roughness:0.85});
      g.children.forEach(function(child){
        if(child.name==='street-curve'){
          // guardrails on both edges
          [-1,1].forEach(function(side){
            var railGeo = new THREE.TubeGeometry(
              child.geometry.parameters.path,
              32, 0.15, 6, false
            );
            // offset to the side (approximate)
            var rail = new THREE.Mesh(railGeo, railMat);
            rail.position.y = 1.2;
            rail.position.x = side * 7;
            rail.name = 'guardrail';
            // match the road elevation
            rail.position.y += 10;
            g.add(rail);
            // posts every ~20 units
            for(var d=0; d<1; d+=0.05){
              var pt = child.geometry.parameters.path.getPoint(d);
              var post = new THREE.Mesh(new THREE.BoxGeometry(0.3, 1.2, 0.3), railMat);
              post.position.set(pt.x + side*7, pt.y+0.6, pt.z);
              post.name = 'rail-post';
              g.add(post);
            }
          });
        }
      });
      // retaining walls where highways cut through terrain
      // (placed at intervals along each highway)
      if(typeof _highwayPts!=='undefined'){
        _highwayPts.forEach(function(pts){
          for(var i=2; i<pts.length-1; i+=3){
            var wx=pts[i][0], wz=pts[i][1];
            var th = (typeof getTerrainH==='function') ? getTerrainH(wx, wz) : 0;
            var rh = 10 + Math.sin(Math.sqrt(wx*wx+wz*wz)*0.02)*4; // road height
            var cut = rh - th;
            if(cut > 6){
              // retaining wall needed
              [-1,1].forEach(function(s){
                var wall = new THREE.Mesh(new THREE.BoxGeometry(2, cut, 30), wallMat);
                wall.position.set(wx+s*9, th+cut/2, wz);
                wall.rotation.y = Math.atan2(pts[i+1][0]-pts[i-1][0], pts[i+1][1]-pts[i-1][1]);
                wall.name = 'retaining-wall';
                g.add(wall);
              });
            }
          }
        });
      }
      // drainage culverts under highways at low points
      for(var ci=0; ci<7; ci++){
        var ang = ci/7*Math.PI*2;
        var dx = Math.cos(ang)*150, dz = Math.sin(ang)*150;
        var culvert = new THREE.Mesh(new THREE.CylinderGeometry(1, 1, 20, 8), drainMat);
        culvert.position.set(dx, 2, dz);
        culvert.rotation.z = Math.PI/2;
        culvert.rotation.y = ang;
        culvert.name = 'culvert';
        g.add(culvert);
      }
    })();
    // support pillars — 5 large blocks stacked under the highways
    var pill