<!-- RUBY-BACKUP · part 183 -->
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 scene==='undefined') return;
  var cv = document.createElement('canvas');
  cv.width = 1024; cv.height = 256;
  var ctx = cv.getContext('2d');
  /* brick wall background */
  ctx.fillStyle = '#3a2a20';
  ctx.fillRect(0, 0, 1024, 256);
  /* brick lines */
  ctx.strokeStyle = '#2a1a10';
  ctx.lineWidth = 2;
  for(var by=0; by<256; by+=32){
    ctx.beginPath(); ctx.moveTo(0, by); ctx.lineTo(1024, by); ctx.stroke();
    for(var bx=(by%64?0:32); bx<1024; bx+=64){
      ctx.beginPath(); ctx.moveTo(bx, by); ctx.lineTo(bx, by+32); ctx.stroke();
    }
  }
  /* gold outline letters */
  ctx.font = 'bold 160px Arial Black, Arial';
  ctx.textAlign = 'center';
  ctx.lineWidth = 12;
  ctx.strokeStyle = '#d4af37';
  ctx.strokeText(text, 512, 190);
  /* diamond fill — sparkling */
  ctx.fillStyle = '#e8f4ff';
  ctx.fillText(text, 512, 190);
  /* diamond sparkles */
  for(var s=0; s<60; s++){
    var sx = 200 + Math.random()*624;
    var sy = 60 + Math.random()*150;
    var sr = 2 + Math.random()*5;
    ctx.fillStyle = 'rgba(255,255,255,'+(0.5+Math.random()*0.5)+')';
    ctx.beginPath();
    /* diamond shape */
    ctx.moveTo(sx, sy-sr);
    ctx.lineTo(sx+sr*0.7, sy);
    ctx.lineTo(sx, sy+sr);
    ctx.lineTo(sx-sr*0.7, sy);
    ctx.closePath();
    ctx.fill();
  }
  /* gold drips */
  ctx.fillStyle = '#d4af37';
  for(var d=0; d<15; d++){
    var dx = 200 + Math.random()*624;
    var dh = 10 + Math.random()*40;
    ctx.fillRect(dx, 195, 4, dh);
  }
  var tex = new THREE.CanvasTexture(cv);
  var wall = new THREE.Mesh(new THREE.PlaneGeometry(10, 2.5),
    new THREE.MeshStandardMaterial({map: tex, roughness: 0.8}));
  wall.position.set(x, y, z);
  wall.rotation.y = rotY || 0;
  scene.add(wall);
  /* spotlight on it */
  var spot = new THREE.SpotLight(0xffffff, 1.5, 20);
  spot.position.set(x, y+5, z+3);
  spot.target = wall;
  scene.add(spot);
  scene.add(spot.target);
}


/* PROVOLTA — rebuilt in ultra-dense intaglio */
var GUARDIAN = null;
function intaglioRing(radius, tube, color, opacity){
  return new THREE.Mesh(new THREE.TorusGeometry(radius, tube, 6, 48),
    new THREE.MeshBasicMaterial({color: color, transparent: true, opacity: opacity}));
}

/* PROVOLTA'S TRUE FORM — warrior.glb */
function loadWarriorModel(x, y, z){
  if(typeof THREE==='undefined' || typeof THREE.GLTFLoader==='undefined'){
    codeStatus('GLTFLoader not ready — using built form');
    return null;
  }
  var loader = new THREE.GLTFLoader();
  var g = new THREE.Group();
  g.position.set(x, y, z);
  loader.load('/ruby/warrior.glb?v=1',
    function(glb){
      var mod