<!-- RUBY-BACKUP · part 456 -->
deliver after months of play, when they are deep in their world */
setInterval(function(){
  try{
    if(CAPSULE_DELIVERED) return;
    if(typeof courtIsReady!=='function') return;
    if(!courtIsReady()) return;
    if(FORBIDDEN_TOUCHED) return;
    /* they are playing and playing, caught up in their world */
    /* 5% chance per check (every 30s) — it happens when it happens */
    if(Math.random() < 0.05){
      deliverCapsule();
    }
  }catch(e){}
}, 30000);
try{
  if(localStorage.getItem('ruby-capsule-delivered')==='1') CAPSULE_DELIVERED = true;
  if(localStorage.getItem('ruby-gold-mode')==='1'){ GOLD_MODE = true; setTimeout(function(){ goldenCity(); }, 3000); }
}catch(e){}
function checkForbiddenTouch(){
  if(FORBIDDEN_TOUCHED) return;
  if(!FORBIDDEN_OBJ) return;
  if(typeof mePos==='undefined') return;
  var px = mePos.x * 0.13, pz = mePos.z * 0.13;
  var fx = FORBIDDEN_OBJ.position.x, fz = FORBIDDEN_OBJ.position.z;
  var dist = Math.sqrt((px-fx)*(px-fx) + (pz-fz)*(pz-fz));
  if(dist < 2.0){
    /* they touch it */
    FORBIDDEN_TOUCHED = true;
    try{ localStorage.setItem('ruby-forbidden-touched', '1'); }catch(e){}
    forbiddenTouchSequence();
  }
}
function forbiddenTouchSequence(){
  var div = document.createElement('div');
  div.id = 'forbidden-touch';
  div.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;z-index:20000;background:rgba(5,5,20,0.95);display:flex;flex-direction:column;justify-content:center;align-items:center;color:#fff;font-family:Georgia,serif;text-align:center;';
  div.innerHTML = '<div style="font-size:16px;color:#888;margin-bottom:15px;">You reach out...</div>'
    + '<div id="touch-words" style="font-style:italic;font-size:18px;line-height:2;max-width:600px;min-height:200px;"></div>';
  document.body.appendChild(div);
  var words = [
    '"I do not know what it is yet."',
    '"But it is futuristic. It seems like it should be mine."',
    '"It makes so much sense to own this."',
    '"It looks like it has a reasonable chance of being good for me."',
    '<span style="color:#00ffff;">Your fingers close around the twin crystal.</span>',
    '<span style="color:#ff6666;">The lightning remembers you.</span>'
  ];
  var w = document.getElementById('touch-words');
  var i = 0;
  var wt = setInterval(function(){
    if(i < words.length){
      w.innerHTML += '<div style="margin:12px 0;opacity:0;animation:fadein 1s forwards;">'+words[i]+'</div>';
      i++;
    }else{
      clearInterval(wt);
      setTimeout(function(){
        var d = document.getElementById('forbidden-touch');
        if(d) d.remove();
        /* THE CASE BEGINS */
        if(courtIsReady()){
          startTwinCase();
        }else{
          codeStatus('the lightning sleeps... for now. The court has not convened yet.');
        }
      }, 2000);
    }
  }, 1800);
}
/* check on load */
try{
  if(localStorage.getItem('ruby-forbidden-touched')==='1') FORBIDDEN_TOUCHED = true;
}catch(e){}
function startTwinCase(){
  TWIN_CASE.active = true;
  TWIN_CASE.stage = 0;
  showTwinStage();
  codeStatus('CASE: The Twin Lightning — the court will try to make you look bad. Stand firm.');
}
function showTwinStage(){
  var s = TWIN_CASE.stages[TWIN_CASE.stage];
  if(!s){
    endTwinCase();
    return;
  }
  var div = document.createElement('div');
  var existing = document.getElementById('quest-hud');
  if(existing) existing.remove();
  div.id = 'quest-hud';
  div.style.cssText = 'position:fixed;top:15%;left:50%;transform:translateX(-50%);z-index:9999;background:rgba(25,10,30,0.97);border:3px solid #8844ff;border-radius:12px;padding:20px 30px;color:#fff;font-family:Georgia,serif;max-width:85%;text-align:center;';
  var choicesHtml = s.choices.map(function(ch, i){
    return '<button onclick="twinChoose('+i+')" style="display:block;width:100%;margin:8px 0;padding:10px;background:#332055;color:#fff;border:1px solid #8844ff;border-radius:6px;cursor:pointer;">'+ch+'</button>';
  }).join('');
  div.innerHTML = '<div style="color:#aa88ff;font-weight:bold;font-size:20px;margin-bottom:10px;">⚡ THE TWIN LIGHTNING</div>'
    + '<div style="font-size:13px;color:#888;margin-bottom:15px;">Stage '+(TWIN_CASE.stage+1)+' of '+TWIN_CASE.stages.length+' — the court is trying to make you look bad</div>'
    + '<div style="font-style:italic;font-size:17px;margin-bottom:15px;line-height:1.5;">"'+s.prosecution+'"</div>'
    + choicesHtml;
  document.body.appendChild(div);
}
function twinChoose(idx){
  var s = TWIN_CASE.stages[TWIN_CASE.stage];
  if(s.sink && !CONTINUUM_LOCKED){
    sinkContinuum();
  }
  var div = document.getElementById('quest-hud');
  /* reveal the truth */
  if(div){
    div.innerHTML = '<div style="color:#aa88ff;font-weight:bold;font-size:20px;margin-bottom:15px;">⚡ THE TRUTH</div>'
      + '<div style="font-style:italic;font-size:16px;line-height:1.6;color:#ddccff;">'+s.truth+'</div>'
      + '<div style="margin-top:20px;"><button onclick="twinNext()" style="padding:10px 2