<!-- RUBY-BACKUP · part 432 -->
/* SOLID tags around the city — alleys, walls */
  diamondGraffiti('SOLID', -18, 1.5, 22, 0.3);
  diamondGraffiti('SOLID', 22, 1.5, -18, -0.5);
  diamondGraffiti('SOLID', 5, 1.5, -28, 0.1);
  diamondGraffiti('SOLID', -28, 1.5, -5, 1.2);
  codeStatus('diamond graffiti — SOLID on the walls');
}
function placeRegalia(){
  if(typeof scene==='undefined') return;
  var velvets = [0x4a0080, 0x800000, 0x1a1a4a, 0x800060];
  /* banners along the main street */
  for(var i=0; i<8; i++){
    var banner = buildErmineBanner(-10 + i*3, 0, 15, velvets[i%4]);
    scene.add(banner);
    var banner2 = buildErmineBanner(-10 + i*3, 0, -15, velvets[(i+2)%4]);
    scene.add(banner2);
  }
  codeStatus('royal regalia raised — ermine, velvet, and crowns');
}
function heavyBuild(){
  if(HEAVY_BUILT) return;
  HEAVY_BUILT = true;
  if(typeof scene==='undefined') return;
  /* flying vehicles */
  for(var i=0; i<6; i++){
    (function(idx){
      var g = new THREE.Group();
      var gold = new THREE.MeshStandardMaterial({color: 0xd4af37, metalness: 0.9, roughness: 0.2});
      var glow = new THREE.MeshBasicMaterial({color: 0x88ccff, transparent: true, opacity: 0.5});
      var hull = new THREE.Mesh(new THREE.SphereGeometry(0.8, 16, 12), gold);
      hull.scale.set(2, 0.5, 1);
      g.add(hull);
      var lights = new THREE.Mesh(new THREE.TorusGeometry(1.2, 0.05, 8, 30), glow);
      lights.rotation.x = Math.PI/2;
      g.add(lights);
      var y = 15 + Math.random()*10;
      var r = 25 + Math.random()*15;
      var speed = 0.1 + Math.random()*0.15;
      var ang = Math.random()*Math.PI*2;
      g.position.set(Math.cos(ang)*r, y, Math.sin(ang)*r);
      scene.add(g);
      setInterval(function(){
        ang += speed*0.02;
        g.position.set(Math.cos(ang)*r, y + Math.sin(Date.now()*0.001+idx)*0.5, Math.sin(ang)*r);
        g.rotation.y = -ang;
      }, 50);
    })(i);
  }
  /* jeweled spires on towers */
  if(typeof scene!=='undefined'){
    scene.traverse(function(obj){
      if(obj.userData && obj.userData.permanent && obj.geometry && obj.geometry.type==='BoxGeometry'){
        /* add a spire */
        var spire = new THREE.Mesh(new THREE.ConeGeometry(0.3, 2, 8),
          new THREE.MeshStandardMaterial({color: 0xd4af37, metalness: 0.95, roughness: 0.1}));
        spire.position.copy(obj.position);
        spire.position.y += obj.geometry.parameters.height/2 + 1;
        /* find parent */
        if(obj.parent) obj.parent.add(spire);
        /* jewel on top */
        var jewel = new THREE.Mesh(new THREE.OctahedronGeometry(0.15),
          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==='functi