<!-- RUBY-BACKUP · part 187 -->
new THREE.MeshStandardMaterial({color: 0xff66ff, emissive: 0xff66ff, emissiveIntensity: 2}));
        jewel.position.copy(spire.position);
        jewel.position.y += 1.2;
        if(obj.parent) obj.parent.add(jewel);
      }
    });
  }
  codeStatus('heavy build complete — vehicles in the sky, jewels on the spires');
}

/* FREE MAP — the golden district takes what it needs */

/* SWEEP — build and move, section by section */

/* GOLDEN RATIO — phi spreads the city */
var PHI = 1.618033988749;
function goldenSpiralPos(n, baseR){
  /* golden angle: 137.5 degrees */
  var goldenAngle = Math.PI * (3 - Math.sqrt(5));
  var r = baseR * Math.pow(PHI, n * 0.5);
  var theta = n * goldenAngle;
  return {x: Math.cos(theta)*r, z: Math.sin(theta)*r, r: r};
}
function layoutGoldenRatio(){
  codeStatus('spreading the city by golden ratio...');
  var baseR = 15;
  var sections = [
    {name: 'Golden Plaza', n: 0},
    {name: 'Royal Mile', n: 1},
    {name: 'Tower District', n: 2},
    {name: 'Graffiti Alleys', n: 3},
    {name: 'The Sky', n: 4}
  ];
  sections.forEach(function(s){
    var pos = goldenSpiralPos(s.n, baseR);
    codeStatus(s.name+' — phi position ('+pos.x.toFixed(1)+', '+pos.z.toFixed(1)+') r='+pos.r.toFixed(1));
  });
  /* move key structures to phi positions */
  return sections.map(function(s){
    var pos = goldenSpiralPos(s.n, baseR);
    return {name: s.name, x: pos.x, z: pos.z};
  });
}
var SWEEP_SECTIONS = [
  {name: 'Golden Plaza', fn: 'goldenPlaza'},
  {name: 'Royal Mile', fn: 'placeRegalia'},
  {name: 'Tower District', fn: 'goldenCity'},
  {name: 'Graffiti Alleys', fn: 'placeGraffiti'},
  {name: 'The Sky', fn: 'heavyBuild'}
];
var SWEEP_IDX = 0;
var SWEEP_ACTIVE = false;
function sweep(){
  if(SWEEP_ACTIVE){
    codeStatus('sweep already running');
    return;
  }
  SWEEP_ACTIVE = true;
  SWEEP_IDX = 0;
  codeStatus('sweep started — build and move');
  sweepNext();
}
function sweepNext(){
  if(SWEEP_IDX >= SWEEP_SECTIONS.length){
    SWEEP_ACTIVE = false;
    codeStatus('sweep complete — all sections built');
    unlockAchievement('Swept the Map');
    return;
  }
  var sec = SWEEP_SECTIONS[SWEEP_IDX];
  codeStatus('sweep: building '+sec.name+' ('+(SWEEP_IDX+1)+'/'+SWEEP_SECTIONS.length+')...');
  try{
    if(sec.fn==='goldenPlaza' && typeof goldenPlaza==='function') goldenPlaza();
    else if(sec.fn==='placeRegalia' && typeof placeRegalia==='function') placeRegalia();
    else if(sec.fn==='goldenCity' && typeof goldenCity==='function') goldenCity();
    else if(sec.fn==='placeGraffiti' && typeof placeGraffiti==='function') placeGraffiti();
    else if(sec.fn==='heavyBuild' && typeof heavyBuild==='function') heavyBuild();
  }catch(e){}
  SWEEP_IDX++;
  /* move to next */
  setTimeout(function(){ sweepNext(); }, 4000);
}
function freeMap(){
  codeStatus('freeing the map...');
  /* clear a wide district for gold: x from -50 to 50, z from -50 to 50 */
  /* remove non-permanent clutter in the district */
  if(typeof scene!=='undefined'){
    var toRemove = [];
    scene.traverse(function(obj){
      if(obj.userData && !obj.userData.permanent && !obj.userData.isPhoneCaller
         && !obj.userData.isForbidden && !obj.userData.isCapsule
         && obj.position && Math.abs(obj.position.x)<50 && Math.abs(obj.position.z)<50
         && obj.geometry && obj.geometry.type==='BoxGeometry'){
        toRemove.push(obj);
      }
    });
    toRemove.forEach(function(obj){
      if(obj.parent) obj.parent.remove(obj);
    });
    codeStatus('freed '+toRemove.length+' clutter stones — the district breathes');
  }
  /* expand: golden plaza at center */
  goldenPlaza();
}
function goldenPlaza(){
  if(typeof scene==='undefined') return;
  /* a golden plaza floor — 40x40 */
  var plaza = new THREE.Mesh(new THREE.PlaneGeometry(40, 40),
    new THREE.MeshStandardMaterial({color: 0x8a6d2f, metalness: 0.7, roughness: 0.3}));
  plaza.rotation.x = -Math.PI/2;
  plaza.position.y = 0.01;
  scene.add(plaza);
  /* gold trim border */
  var border = new THREE.Mesh(new THREE.RingGeometry(19, 20, 64),
    new THREE.MeshStandardMaterial({color: 0xd4af37, metalness: 0.95, roughness: 0.1, emissive: 0x664400, emissiveIntensity: 0.5}));
  border.rotation.x = -Math.PI/2;
  border.position.y = 0.02;
  scene.add(border);
  /* center fountain — galaxy water */
  var fountainBase = new THREE.Mesh(new THREE.CylinderGeometry(2, 2.5, 1, 16),
    new THREE.MeshStandardMaterial({color: 0xd4af37, metalness: 0.9, roughness: 0.2}));
  fountainBase.position.y = 0.5;
  scene.add(fountainBase);
  var water = new THREE.Mesh(new THREE.CylinderGeometry(1.8, 1.8, 0.2, 16),
    new THREE.MeshStandardMaterial({color: 0x1a0f4a, emissive: 0x4422aa, emissiveIntensity: 0.8, transparent: true, opacity: 0.8}));
  water.position.y = 1.05;
  scene.add(water);
  /* galaxy sparkles above fountain */
  setInterval(function(){
    water.material.emissiveIntensity = 0.6 + Math.random()*0.5;
  }, 1000);
  codeStatus('the golden plaza st