<!-- SOLID CITY · part 2655 -->

      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.25, 0.3, run.y0, run.y1, Math.atan2(-dz, dx)]);
        run = 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 pa = [ca[0] + sd * A.rx * 0.62, ca[1], ca[2] + sd * A.rz * 0.62];
        var pb = [cb[0] + sd * B.rx * 0.62, cb[1], cb[2] + sd * B.rz * 0.62];
        var mx = (pa[0] + pb[0]) / 2, mz = (pa[2] + pb[2]) / 2, skip = false;
        /* the braid-head lesson (first audit): a body whose ENDS
         * reach into a junction braid, or whose chord cuts any
         * carriageway — its own road's bend included — walls the
         * very road it guards. Both ends are judged: 11 m from a
         * junction heart, 4.5 m from a driveway mouth, and never
         * inside 3.95 m of any built centreline. */
        var ends = [pa, pb];
        for (var e2 = 0; e2 < 2 && !skip; e2++) {
          for (var j = 0; j < JX.length && !skip; j++) if (Math.hypot(ends[e2][0] - JX[j][0], ends[e2][2] - JX[j][1]) < 11) skip = true;
          if (!skip && segDistToRoad(ends[e2][0], ends[e2][2]).d < 3.95) skip = true;
        }
        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) { flush(); continue; }
        var y0 = Math.min(pa[1], pb[1]) - 0.12, y1 = Math.max(pa[1], pb[1]) + 0.7;
        if (run) {
          var adx = pb[0] - run.x1, adz = pb[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));
          /* runs stay under 2.6 m: the placer splits entries into
           * cells of half the length, and a 1.3 m cell's bounding
           * box hugs a hairpin's curve where a 2.5 m cell's corners
           * reached half a metre into the road (the body gate
           * counted 80 car pushes over 0.6 m at the coarse grain) */
          if (turn > 0.055 || Math.hypot(run.x1 - run.x0, run.z1 - run.z0) > 2.6) flush();
        }
        if (!run) run = { x0: pa[0], z0: pa[2], x1: pb[0], z1: pb[2], y0: y0, y1: y1 };
        else { run.x1 = pb[0]; run.z1 = pb[2]; if (y0 < run.y0) run.y0 = y0; if (y1 > run.y1) run.y1 = y1; }
      }
      flush();
    });
  }
  /* THE ROAD TAKES A BODY (the King's word, 2026-10-13 ~23:41:
   * "I think you should put it on — this way you can raycast
   * everything to see them"). Until now the road was a floor and
   * nothing else: stood upon, invisible to every collision ray —
   * the Survey Camera's stopAt found open air where a road
   * embankment stands. Now, wherever an edge stands over falling
   * ground (drop >= 1.0 m outboard), a body 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 = n