<!-- SOLID CITY · part 2732 -->
 is registered under
   * the edge line: 1.1 m thick, buried 0.6 under the outboard
   * ground, and topped 0.5 m BELOW the surface — the collision
   * step forgives any body whose top is a metre under the feet,
   * so no one on the road or climbing its bank ever feels it,
   * while every ray and every approach from the side meets the
   * road as a solid thing. Clearances: 6.4 m from any other
   * centreline (stacked hairpin legs keep their air), 11 m at
   * the junction braids, 4.5 m at driveway mouths. */
  function roadBodies() {
    var JX = [[945, -1487.5], [915, -1285], [430, -1065]];
    var names = Object.keys(smithRoads);
    var cells = {};
    function cellKey(x, z) { return Math.floor(x / 16) + ',' + Math.floor(z / 16); }
    names.forEach(function (nm) {
      var sts = smithRoads[nm].stations;
      for (var i = 0; i < sts.length - 1; i++) {
        var mx = (sts[i].x + sts[i + 1].x) / 2, mz = (sts[i].z + sts[i + 1].z) / 2;
        var k = cellKey(mx, mz);
        (cells[k] = cells[k] || []).push({ nm: nm, i: i, x1: sts[i].x, z1: sts[i].z, x2: sts[i + 1].x, z2: sts[i + 1].z });
      }
    });
    function segDist(px, pz, s) {
      var dx = s.x2 - s.x1, dz = s.z2 - s.z1, L2 = dx * dx + dz * dz;
      var t = L2 ? ((px - s.x1) * dx + (pz - s.z1) * dz) / L2 : 0; t = Math.max(0, Math.min(1, t));
      return Math.hypot(px - (s.x1 + dx * t), pz - (s.z1 + dz * t));
    }
    function foreignClear(px, pz, ownNm, ownI) {
      var cx = Math.floor(px / 16), cz = Math.floor(pz / 16);
      for (var a = -1; a <= 1; a++) for (var b = -1; b <= 1; b++) {
        var list = cells[(cx + a) + ',' + (cz + b)]; if (!list) continue;
        for (var q = 0; q < list.length; q++) {
          var s = list[q];
          if (s.nm === ownNm && Math.abs(s.i - ownI) <= 12) continue;
          if (segDist(px, pz, s) < 6.4) return false;
        }
      }
      return true;
    }
    names.forEach(function (nm) {
      var sts = smithRoads[nm].stations;
      [-1, 1].forEach(function (sd) {
        var run = null, crun = null;
        function flush() {
          if (!run) return;
          var dx = run.x1 - run.x0, dz = run.z1 - run.z0;
          foot.push([(run.x0 + run.x1) / 2, (run.z0 + run.z1) / 2, Math.hypot(dx, dz) + 0.2, 1.1, run.y0, run.y1, Math.atan2(-dz, dx)]);
          run = null;
        }
        function cflush() {
          if (!crun) return;
          var dx = crun.x1 - crun.x0, dz = crun.z1 - crun.z0;
          foot.push([(crun.x0 + crun.x1) / 2, (crun.z0 + crun.z1) / 2, Math.hypot(dx, dz) + 0.2, 1.1, crun.y0, crun.y1, Math.atan2(-dz, dx)]);
          crun = null;
        }
        for (var i = 0; i < sts.length - 1; i++) {
          var A = sts[i], B = sts[i + 1];
          var ca = sd < 0 ? A.L : A.R, cb = sd < 0 ? B.L : B.R;
          var mx = (ca[0] + cb[0]) / 2, mz = (ca[2] + cb[2]) / 2;
          var rx = (A.rx + B.rx) / 2, rz = (A.rz + B.rz) / 2, rl = Math.hypot(rx, rz) || 1; rx /= rl; rz /= rl;
          var edgeY = (ca[1] + cb[1]) / 2;
          var drop = edgeY - groundAt(mx + sd * rx * 2.2, mz + sd * rz * 2.2);
          var skip = drop < 1.0;
          if (!skip) for (var j = 0; j < JX.length && !skip; j++) { if (Math.hypot(ca[0] - JX[j][0], ca[2] - JX[j][1]) < 11 || Math.hypot(cb[0] - JX[j][0], cb[2] - JX[j][1]) < 11) skip = true; }
          if (!skip) for (var k = 0; k < driveMouths.length && !skip; k++) if (Math.hypot(mx - driveMouths[k][0], mz - driveMouths[k][1]) < 4.5) skip = true;
          if (!skip && (!foreignClear(ca[0], ca[2], nm, i) || !foreignClear(cb[0], cb[2], nm, i))) skip = true;
          if (skip) { flush(); }
          else {
            var y1 = Math.max(ca[1], cb[1]) - 0.5, y0 = Math.min(groundAt(ca[0], ca[2]), groundAt(cb[0], cb[2])) - 0.6;
            if (y1 - y0 < 0.7) { flush(); }
            else {
              if (run) {
                var adx = cb[0] - run.x1, adz = cb[2] - run.z1, rdx = run.x1 - run.x0, rdz = run.z1 - run.z0;
                var turn = Math.abs(Math.atan2(-adz, adx) - Math.atan2(-rdz, rdx));
                /* a merged body is ONE straight box: if the true
                 * line's last joint strays more than 0.25 m from
                 * the chord the box would draw, the run ends —
                 * a chord may never cut a bend into a neighbour's
                 * carriageway (one cut 0.62 m into Road C's edge,
                 * measured) — and no run outlasts 4 m */
                var chx = cb[0] - run.x0, chz = cb[2] - run.z0, chl = Math.hypot(chx, chz) || 1;
                var dev = Math.abs((run.x1 - run.x0) * chz - (run.z1 - run.z0) * chx) / chl;
                if (turn > 0.06 || Math.hypot(run.x1 - run.x0, run.z1 - run.z0) > 4 || dev > 0.25) flush();
              }
              /* a run's rise is capped at 0.8 m: the body's top is set
               * by its highest edge, and at the run's low end that top
               * must stay a full metre under the local surface, or the
          