<!-- RUBY-BACKUP · part 36 -->
    if(st2 > 40) clearInterval(iv2);
    }, 1000);
    // 3D button needs the scene — poll
    var tries = 0;
    var iv = setInterval(function(){
      tries++;
      try{
        if(window.scene){ make3DButton(); clearInterval(iv); }
      }catch(e){}
      if(tries > 60) clearInterval(iv);
    }, 500);
  }

  if(document.readyState === 'complete') init();
  else window.addEventListener('load', init);

  try{ console.log('[code-pyramid] ready'); }catch(e){}
})();


===== FILE: public/ruby-backup/grand-rigging.js =====
/* ============================================================================
   GRAND RIGGING — the worthy system. The King's order:
   "Create a whole system like this even more powerful and worthy."
   ----------------------------------------------------------------------------
   Seven new machines on the foundation (grab/pulley/rig/anchor/lift/diamond):
     compound      chain sheaves — 2:1, 3:1, 4:1. PULL n = LIFT 1
     counterweight balance the load — m1 = m2, a finger moves it
     winch         crank the drum — ΔROPE = Δθ × r, true circumference
     gearlink      rack and pinion — turn the gear, the rope travels
     lever         fulcrum and beam — EFFORT × b = LOAD × a
     spring        Hooke's law — F = −kx. The ONLY elastic thing. All else rigid.
     codex         the whole system: every function, its antonym, its reason
   Every machine has its antonym. Real physics. Nothing teleports.
   Touch only, thumb-grabbable, gold on black.
   ============================================================================ */
(function(){
'use strict';
if(typeof window==='undefined') return;
var T = window.THREE;
if(!T) return;
var UP = new T.Vector3(0,1,0);

/* ---------------- helpers (self-contained) ---------------- */
function status(m){ try{ codeStatus(m); }catch(e){} }
function groundAt(wx,wz){
  try{ if(typeof fortifiedGroundY==='function') return fortifiedGroundY(wx/0.13, wz/0.13); }catch(e){}
  return 0.3;
}
function playerWorld(){
  var px=0,pz=0;
  try{ if(typeof mePos!=='undefined'&&mePos){ px=mePos.x*0.13; pz=mePos.z*0.13; } }catch(e){}
  return {x:px,z:pz};
}
function forwardPoint(dist,up){
  var pw=playerWorld();
  var dir=new T.Vector3(0,0,1);
  try{
    if(typeof camera!=='undefined'&&camera){
      camera.getWorldDirection(dir); dir.y=0;
      if(dir.lengthSq()<1e-6) dir.set(0,0,1);
      dir.normalize();
    }
  }catch(e){}
  var x=pw.x+dir.x*dist, z=pw.z+dir.z*dist;
  return new T.Vector3(x, groundAt(x,z)+(up||0), z);
}
var raycaster=new T.Raycaster(), ndc=new T.Vector2();
function setNDC(cx,cy){ ndc.x=(cx/window.innerWidth)*2-1; ndc.y=-(cy/window.innerHeight)*2+1; }
var _va=new T.Vector3(), _vb=new T.Vector3();
function aimCyl(mesh,a,b){
  _va.subVectors(b,a);
  var len=_va.length()||0.0001;
  _vb.addVectors(a,b).multiplyScalar(0.5);
  mesh.position.copy(_vb);
  mesh.quaternion.setFromUnitVectors(UP,_va.normalize());
  mesh.scale.set(1,len,1);
}
function worldPosOf(o){ try{ return o.getWorldPosition(new T.Vector3()); }catch(e){ return new T.Vector3(); } }
function textSprite(text,scale){
  try{
    var c=document.createElement('canvas'); c.width=512; c.height=96;
    var g=c.getContext('2d');
    g.fillStyle='rgba(5,3,1,0.85)'; g.fillRect(0,0,512,96);
    g.strokeStyle='#d8a920'; g.lineWidth=3; g.strokeRect(3,3,506,90);
    g.fillStyle='#ffd700'; g.font='bold 30px Georgia,serif';
    g.textAlign='center'; g.textBaseline='middle';
    g.fillText(text,256,50);
    var tex=new T.CanvasTexture(c);
    var s=new T.Sprite(new T.SpriteMaterial({map:tex,transparent:true,depthTest:false}));
    var sc=scale||1; s.scale.set(3.4*sc,0.64*sc,1);
    return s;
  }catch(e){ return null; }
}
function riseIn(g,toY,depth,dur){
  try{
    depth=depth||2.5; dur=dur||0.6;
    g.position.y=toY-depth;
    var t0=performance.now()/1000;
    (function step(){
      var t=(performance.now()/1000-t0)/dur;
      if(t>=1){ g.position.y=toY; return; }
      g.position.y=toY-depth+depth*t; /* linear — rigid, no easing */
      requestAnimationFrame(step);
    })();
  }catch(e){}
}

/* ---------------- materials ---------------- */
var MAT=null;
function mats(){
  if(MAT) return MAT;
  MAT={
    gold:  new T.MeshStandardMaterial({color:0xffd700,metalness:0.9,roughness:0.25,emissive:0x664d00,emissiveIntensity:0.55}),
    rope:  new T.MeshStandardMaterial({color:0xd8a920,metalness:0.55,roughness:0.45}),
    steel: new T.MeshStandardMaterial({color:0x555560,metalness:0.8,roughness:0.35}),
    red:   new T.MeshStandardMaterial({color:0x8a0f0f,metalness:0.4,roughness:0.5}),
    wood:  new T.MeshStandardMaterial({color:0x6b4a26,roughness:0.8}),
    crate: new T.MeshStandardMaterial({color:0x7a5230,roughness:0.75}),
    ghost: new T.MeshBasicMaterial({visible:false})
  };
  return MAT;
}
function ropeSeg(){
  var m=new T.Mesh(new T.CylinderGeometry(0.045,0.045,1,8), mats().rope);
  m.userData.grandPart=true;
  return m;
}
function goldRing(r){
  var m=new T.Mesh(new 