<!-- NEW1 — TEST 1 · THE LIVING DISTRICT · part 5 -->
a = (a + 0x6D2B79F5) | 0;
    let t = Math.imul(a ^ (a >>> 15), 1 | a);
    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
  };
}
const rng = mulberry32(20261015);
function rr(lo, hi) { return lo + rng() * (hi - lo); }
function pick(arr) { return arr[Math.floor(rng() * arr.length)]; }

/* ---------- the district plan: THE LIST ----------
 * grid: 6 columns x 5 rows of blocks. Row 2 is the RIVER band.
 * kinds: downtown | midrise | market | parking | suburb | park  */
const BLOCK = 64;          // block face size
const STREET = 18;         // street width between blocks
const PITCH = BLOCK + STREET;
const COLS = 6, ROWS = 5;
const RIVER_ROW = 2;

const COMPLEXES = [
  { name: 'Crown Towers',      kind: 'downtown', col: 0, row: 0 },
  { name: 'Ledger Heights',    kind: 'downtown', col: 1, row: 0 },
  { name: 'The Midrise Mile',  kind: 'midrise',  col: 2, row: 0 },
  { name: 'Foundry Flats',     kind: 'midrise',  col: 3, row: 0 },
  { name: 'Eastgate Homes',    kind: 'suburb',   col: 4, row: 0 },
  { name: 'Palms End',         kind: 'suburb',   col: 5, row: 0 },
  { name: 'Grand Market Row',  kind: 'market',   col: 0, row: 1 },
  { name: 'Signal Square',     kind: 'downtown', col: 1, row: 1 },
  { name: 'The Stacks Parking', kind: 'parking', col: 2, row: 1 },
  { name: 'Harbor Steps',      kind: 'midrise',  col: 3, row: 1 },
  { name: 'Lantern Market',    kind: 'market',   col: 4, row: 1 },
  { name: 'Juniper Homes',     kind: 'suburb',   col: 5, row: 1 },
  /* row 2 = the river */
  { name: 'Southbank Market',  kind: 'market',   col: 0, row: 3 },
  { name: 'Old Crown',         kind: 'downtown', col: 1, row: 3 },
  { name: 'The Long Park',     kind: 'park',     col: 2, row: 3 },
  { name: 'Canal Flats',       kind: 'midrise',  col: 3, row: 3 },
  { name: 'Stableyard Parking', kind: 'parking', col: 4, row: 3 },
  { name: 'Reed Homes',        kind: 'suburb',   col: 5, row: 3 },
  { name: 'South Mile',        kind: 'midrise',  col: 0, row: 4 },
  { name: 'Bazaar End',        kind: 'market',   col: 1, row: 4 },
  { name: 'Tidewater Towers',  kind: 'downtown', col: 2, row: 4 },
  { name: 'Far Foundry',       kind: 'midrise',  col: 3, row: 4 },
  { name: 'Last Palms',        kind: 'suburb',   col: 4, row: 4 },
  { name: 'Journey’s End Homes', kind: 'suburb', col: 5, row: 4 },
];
/* bridges cross the river on these street columns (vertical streets) */
const BRIDGE_STREETS = [1, 3, 5];

/* world extents */
const W = COLS * PITCH + STREET;              // total width  (x)
const D = ROWS * PITCH + STREET;              // total depth  (z)
function blockCenter(col, row) {
  return {
    x: -W / 2 + STREET + BLOCK / 2 + col * PITCH,
    z: -D / 2 + STREET + BLOCK / 2 + row * PITCH,
  };
}
function streetX(i) { return -W / 2 + STREET / 2 + i * PITCH; }  // vertical street i (0..COLS)
function streetZ(j) { return -D / 2 + STREET / 2 + j * PITCH; }  // horizontal street j (0..ROWS)

export function buildCity(THREE) {
  const group = new THREE.Group();
  group.name = 'new1-city';

  /* ---------- shared materials (flat-shaded, no textures) ---------- */
  const M = {
    ground:  new THREE.MeshStandardMaterial({ color: 0x3d4a35, roughness: 1 }),
    road:    new THREE.MeshStandardMaterial({ color: 0x23242a, roughness: 1 }),
    walk:    new THREE.MeshStandardMaterial({ color: 0x9a958c, roughness: 1 }),
    stall:   new THREE.MeshStandardMaterial({ color: 0xd8d4c8, roughness: 1 }),
    park:    new THREE.MeshStandardMaterial({ color: 0x4a7a3a, roughness: 1 }),
    water:   new THREE.MeshStandardMaterial({ color: 0x2a6a9a, roughness: 0.35, metalness: 0.1 }),
    bank:    new THREE.MeshStandardMaterial({ color: 0x6a6055, roughness: 1 }),
    deck:    new THREE.MeshStandardMaterial({ color: 0x55565e, roughness: 1 }),
    trunk:   new THREE.MeshStandardMaterial({ color: 0x5a4230, roughness: 1 }),
    leaf:    new THREE.MeshStandardMaterial({ color: 0x3f7031, roughness: 1, flatShading: true }),
    pole:    new THREE.MeshStandardMaterial({ color: 0x2e2e33, roughness: 0.8 }),
    lampOff: new THREE.MeshStandardMaterial({ color: 0x1c1c1c, roughness: 0.6 }),
    lampR:   new THREE.MeshStandardMaterial({ color: 0x330d0d, emissive: 0xff2a1a, emissiveIntensity: 1.6 }),
    lampY:   new THREE.MeshStandardMaterial({ color: 0x2e2408, emissive: 0xffb020, emissiveIntensity: 0.25 }),
    lampG:   new THREE.MeshStandardMaterial({ color: 0x0a2412, emissive: 0x2aff66, emissiveIntensity: 0.25 }),
    roof:    new THREE.MeshStandardMaterial({ color: 0x74422c, roughness: 1, flatShading: true }),
    awning:  new THREE.MeshStandardMaterial({ color: 0x8a2f2a, roughness: 1 }),
    deckCar: new THREE.MeshStandardMaterial({ color: 0x707880, roughness: 0.7 }),
  };
  const towerPalette = [0x8a8f9a, 0x6a707c, 0x9a8a76, 0x707a8a, 0x7c6a5e, 0x5e6a72]
    .map(c => new THREE.MeshStandardMaterial({ color: c, roughness: 0.9, flatShading: true }));
  const