<!-- RUBY-BACKUP · part 428 -->
 0.04, 0.2), blue);
  tail1.position.set(-0.6, 0.45, 0.1); tail1.rotation.y = 0.4; g.add(tail1);
  var tail2 = new THREE.Mesh(new THREE.BoxGeometry(0.15, 0.04, 0.2), blue);
  tail2.position.set(-0.6, 0.45, -0.1); tail2.rotation.y = -0.4; g.add(tail2);
  return g;
}

/* COSMIC ENHANCED — houses, sky, whole world */
var COSMIC_BUILT = false;
var COSMIC_HOUSES = [];
function buildCosmicHouse(x, z, hue){
  var g = new THREE.Group();
  /* base — crystalline */
  var baseMat = new THREE.MeshStandardMaterial({
    color: new THREE.Color().setHSL(hue, 0.7, 0.3),
    metalness: 0.8, roughness: 0.2,
    emissive: new THREE.Color().setHSL(hue, 0.8, 0.15),
    emissiveIntensity: 0.5
  });
  var base = new THREE.Mesh(new THREE.BoxGeometry(2, 1.5, 2), baseMat);
  base.position.y = 0.75; g.add(base);
  /* roof — pyramid, glowing edges */
  var roofMat = new THREE.MeshStandardMaterial({
    color: new THREE.Color().setHSL(hue+0.1, 0.8, 0.4),
    metalness: 0.9, roughness: 0.1,
    emissive: new THREE.Color().setHSL(hue+0.1, 0.9, 0.25),
    emissiveIntensity: 0.7
  });
  var roof = new THREE.Mesh(new THREE.ConeGeometry(1.6, 1.2, 4), roofMat);
  roof.position.y = 2.1; roof.rotation.y = Math.PI/4; g.add(roof);
  /* door — glowing portal */
  var door = new THREE.Mesh(new THREE.PlaneGeometry(0.5, 0.9),
    new THREE.MeshStandardMaterial({
      color: 0xffffff,
      emissive: new THREE.Color().setHSL(hue, 1, 0.6),
      emissiveIntensity: 1.5
    }));
  door.position.set(0, 0.45, 1.01); g.add(door);
  /* windows — starlight */
  [-1,1].forEach(function(s){
    var win = new THREE.Mesh(new THREE.PlaneGeometry(0.4, 0.4),
      new THREE.MeshStandardMaterial({
        color: 0xffffcc, emissive: 0xffffcc, emissiveIntensity: 1.2
      }));
    win.position.set(s*0.6, 1.0, 1.01); g.add(win);
  });
  /* spire — antenna to the stars */
  var spire = new THREE.Mesh(new THREE.CylinderGeometry(0.03, 0.05, 1.5, 8), roofMat);
  spire.position.y = 3.2; g.add(spire);
  var star = new THREE.Mesh(new THREE.SphereGeometry(0.08, 12, 12),
    new THREE.MeshStandardMaterial({color: 0xffffff, emissive: 0xffffff, emissiveIntensity: 2}));
  star.position.y = 4.0; g.add(star);
  g.position.set(x*0.13, 0, z*0.13);
  return g;
}

/* CITY MAP — towers generate permanent, streets have names */
var CITY_BUILT = false;
var CITY_TOWERS = [];
var STREET_NAMES = []; /* the King provides the list */

/* GOLDEN CITY — his vision */
var GOLD_MODE = false;

/* HEAVY BUILD — flying vehicles, spires, the guardian */
var HEAVY_BUILT = false;

/* ROYAL REGALIA — ermine, velvet, crowns */
function buildErmineBanner(x, y, z, velvetColor){
  var g = new THREE.Group();
  /* velvet drape */
  var velvet = new THREE.MeshStandardMaterial({color: velvetColor, roughness: 0.9});
  var drape = new THREE.Mesh(new THREE.PlaneGeometry(1.2, 2.0), velvet);
  drape.position.y = 1.0;
  g.add(drape);
  /* ermine trim — white with black spots */
  var ermine = new THREE.MeshStandardMaterial({color: 0xffffff, roughness: 1.0});
  var trimTop = new THREE.Mesh(new THREE.BoxGeometry(1.3, 0.15, 0.05), ermine);
  trimTop.position.y = 2.0;
  g.add(trimTop);
  var trimBottom = new THREE.Mesh(new THREE.BoxGeometry(1.3, 0.15, 0.05), ermine);
  trimBottom.position.y = 0.0;
  g.add(trimBottom);
  /* black ermine spots */
  var spotMat = new THREE.MeshBasicMaterial({color: 0x111111});
  for(var i=0; i<8; i++){
    var spot = new THREE.Mesh(new THREE.CircleGeometry(0.03, 8), spotMat);
    spot.position.set(-0.5 + (i%4)*0.33, i<4?1.92:0.08, 0.03);
    g.add(spot);
  }
  /* gold embroidery — crown emblem */
  var gold = new THREE.MeshStandardMaterial({color: 0xd4af37, metalness: 0.9, roughness: 0.2, emissive: 0x664400, emissiveIntensity: 0.3});
  var crownBase = new THREE.Mesh(new THREE.CylinderGeometry(0.18, 0.22, 0.12, 8), gold);
  crownBase.position.set(0, 1.2, 0.03);
  g.add(crownBase);
  for(var p=0; p<5; p++){
    var point = new THREE.Mesh(new THREE.ConeGeometry(0.05, 0.15, 6), gold);
    var ang = (p/5)*Math.PI*2;
    point.position.set(Math.cos(ang)*0.15, 1.35, 0.03);
    g.add(point);
  }
  /* jewels on the crown */
  var jewelColors = [0xff0000, 0x0000ff, 0x00ff00, 0xff66ff];
  for(var j=0; j<4; j++){
    var jewel = new THREE.Mesh(new THREE.SphereGeometry(0.03, 8, 8),
      new THREE.MeshStandardMaterial({color: jewelColors[j], emissive: jewelColors[j], emissiveIntensity: 1.5}));
    jewel.position.set(-0.12 + j*0.08, 1.2, 0.06);
    g.add(jewel);
  }
  /* pole */
  var pole = new THREE.Mesh(new THREE.CylinderGeometry(0.03, 0.03, 2.5, 8),
    new THREE.MeshStandardMaterial({color: 0xd4af37, metalness: 0.9, roughness: 0.2}));
  pole.position.set(-0.7, 1.25, 0);
  g.add(pole);
  g.position.set(x, y, z);
  /* wave gently */
  var t = Math.random()*10;
  setInterval(function(){
    t += 0.02;
    drape.rotation.y = Math.sin(t)*0.08;
  }, 50);
  return g;
}

/* DIAMOND GRAFFITI — SOLID on the walls */
function diamondGraffiti(text, x, y, z, rotY){
  if(typeof sce