<!-- SOLID CITY · part 2553 -->
 ends its neighbours use — a path of ramps that
      // follow the land, not a staircase dropped on it.
      var ga = groundAt(x0 + (x1 - x0) * (j / n), z0 + (z1 - z0) * (j / n));
      // a driveway's last stone lands ON the road: when the caller
      // names the carriageway's height, the final stone's far end
      // is that height, and the drive meets the road flush.
      var gb = (endY != null && j === n - 1) ? endY - 0.08 : groundAt(x0 + (x1 - x0) * ((j + 1) / n), z0 + (z1 - z0) * ((j + 1) / n));
      var rx = -Math.atan2(gb - ga, run);   // pitch truth (2026-10-13): atan2, as above
      BASE = M4(px, (ga + gb) / 2 + 0.08, pz, ang, rx, 0);
      box(solid, wdt, 0.18, stepLen + 0.7, 0, 0, 0, col);
      standQuad(px, (ga + gb) / 2 + 0.08, pz, ang, rx, wdt, stepLen + 0.7, 0.09);
      BASE = new T.Matrix4();
    }
  }

  /* ================= SITING — the placement law, enforced ================= */
  var EXCLUDE = [   // [x, z, radius] — structures and ground that stay untouched
    [0, -1600, 578],      // THE ANCESTRAL ROADS terrace (platform r=560)
    [0, -3200, 430],      // Imperial Colosseum
    [0, 0, 1060],         // the capital
    [0, -950, 205],       // Gate of Ancestors
    [450, -1150, 205],    // Compass Meridian
    [750, -1600, 255],    // Overlook Mira
    [-750, -1600, 255],   // Roost Keel
    [-700, -700, 290]     // Quadrant Crown
  ];
  var placed = [];
  function clearOf(x, z, r) {
    for (var i = 0; i < EXCLUDE.length; i++) {
      var e = EXCLUDE[i];
      if (Math.hypot(x - e[0], z - e[1]) < e[2] + r) return false;
    }
    for (var j = 0; j < placed.length; j++) {
      if (Math.hypot(x - placed[j][0], z - placed[j][1]) < placed[j][2] + r) return false;
    }
    return true;
  }
  function findSpot(cx, cz, rad, lotR) {
    for (var ring = 0; ring < 11; ring++) {
      var rr = rad * ring / 10;
      for (var k = 0; k < 16; k++) {
        var a = (k / 16) * Math.PI * 2 + ring * 0.7 + R() * 0.3;
        var x = cx + Math.cos(a) * rr, z = cz + Math.sin(a) * rr;
        if (benchAt(x, z, lotR) >= 0 && clearOf(x, z, lotR + 4) && roadClear(x, z, lotR)) return [x, z];
      }
    }
    // the lattice fallback: where the polar search cannot see a
    // lawful pocket, walk the disc plainly before refusing the home.
    for (var gx = -rad; gx <= rad; gx += 6) for (var gz = -rad; gz <= rad; gz += 6) {
      if (gx * gx + gz * gz > rad * rad) continue;
      var x2 = cx + gx, z2 = cz + gz;
      if (benchAt(x2, z2, lotR) >= 0 && clearOf(x2, z2, lotR + 4) && roadClear(x2, z2, lotR)) return [x2, z2];
    }
    return null;
  }
  function faceAngle(x, z, tx, tz) { return Math.atan2(tx - x, tz - z); }
  function plantAt(x, z, fn) {
    BASE = M4(x, groundAt(x, z) - 0.15, z, R() * Math.PI * 2, 0, 0); fn(); BASE = new T.Matrix4();
  }

  // drive + parking + path for one home (the placement law: every house has a driveway)
  function serveHome(rec, roadPt) {
    var fx = Math.sin(rec.ry), fz = Math.cos(rec.ry);            // front dir
    var rx = Math.cos(rec.ry), rz = -Math.sin(rec.ry);           // right dir
    var frontL = rec.padCz + rec.padD / 2;
    var doorX = rec.x + fx * (frontL + 0.9), doorZ = rec.z + fz * (frontL + 0.9);
    // parking pad on the home's right-front side, at terrain height
    var pkX = rec.x + rx * (rec.padW / 2 + 3.6) + fx * (frontL - 3), pkZ = rec.z + rz * (rec.padW / 2 + 3.6) + fz * (frontL - 3);
    var pkY = groundAt(pkX, pkZ);
    BASE = M4(pkX, pkY + 0.06, pkZ, rec.ry, 0, 0);
    box(solid, 5.6, 0.16, 5.6, 0, 0, 0, C.path);
    standQuad(pkX, pkY + 0.06, pkZ, rec.ry, 0, 5.6, 5.6, 0.08);
    BASE = new T.Matrix4();
    if (R() < 0.55) { BASE = M4(pkX, pkY + 0.14, pkZ, rec.ry + (R() - 0.5) * 0.2, 0, 0); car(CAR_COLS[Math.floor(R() * CAR_COLS.length)]); BASE = new T.Matrix4(); }
    // driveway: parking pad -> nearest road (shared/short spurs are fine)
    if (roadPt.dist < 85) {
      // THE DRIVEWAY GRADE LAW: the nearest point of road is not
      // always a lawful target — a pad 3.4 m below a road's edge
      // and 3 m from it can only be reached by a paved wall.
      // Choose, among every station within reach, the gentlest
      // climb: rise over run, the pad's height against the
      // station's. The drive still ends at the road's own
      // surface (endY), on whichever road asks the least of it.
      var tgt = null, tScore = 1e12;
      for (var rn2 in smithRoads) { var ests = smithRoads[rn2].stations; for (var eq = 0; eq < ests.length; eq++) { var es = ests[eq], edx = es.x - pkX, edz = es.z - pkZ, edist = Math.sqrt(edx * edx + edz * edz); if (edist > 40) continue; var esc = Math.abs(es.y - (pkY + 0.06)) / Math.max(edist, 2.5); if (esc < tScore) { tScore = esc; tgt = es; } } }
      if (tgt) steppedPath(pkX, pkZ, tgt.x, tgt.z, 3.4, C.drive, 3.6, tgt.y);
    }
    // walking path: parking pad -> front steps, lined with small yellow stones (the King's photos)
    steppedPath(pkX, pkZ, doorX, doorZ,