<!-- RUBY-BACKUP · part 414 -->
f00','#0088ff','#ff00ff'];
  var col = colors[Math.floor(Math.random()*colors.length)];
  if(typeof placeStone==='function'){
    for(var i=0; i<5; i++){
      placeStone(sp.x+Math.floor(Math.random()*5)-2, sp.z+Math.floor(Math.random()*5)-2, 2, 'b', true, true, i, true);
    }
  }
  codeStatus('the ancestors surprise you with '+col+' joy!');
}
function kidRainbow(){
  if(typeof mePos==='undefined') return;
  var px = Math.round(mePos.x), pz = Math.round(mePos.z);
  var colors = ['#ff0000','#ff8800','#ffff00','#00ff00','#0088ff','#8800ff'];
  if(typeof placeStone==='function'){
    for(var i=0; i<12; i++){
      var ang = Math.PI * i/11;
      var x = px + Math.round(Math.cos(ang)*8);
      var z = pz + Math.round(Math.sin(ang)*4);
      var y = Math.round(Math.sin(ang)*6);
      placeStone(x, z, 2, 'b', true, true, y, true);
    }
  }
  codeStatus('a rainbow arcs across your sky!');
}
function kidTreasure(){
  if(typeof mePos==='undefined') return;
  var px = Math.round(mePos.x), pz = Math.round(mePos.z);
  var tx = px + Math.floor(Math.random()*10)-5;
  var tz = pz + Math.floor(Math.random()*10)-5;
  if(typeof placeStone==='function'){
    placeStone(tx, tz, 3, 'b', true, true, 0, true);
  }
  codeStatus('treasure hidden nearby... find the gold!');
}
/* CONTINUUM LIMIT — max 25, the Law */
function deskAdd(code){
  if(DESK_PAD.indexOf(code)>=0) return;
  if(DESK_PAD.length >= 25){
    codeStatus('Continuum full (25) — remove one first: padremove <code>');
    return;
  }
  DESK_PAD.push(code);
  try{ if(typeof continuumGathered==='function') continuumGathered(); }catch(e){}
  try{ localStorage.setItem('ruby-chartpad', JSON.stringify(DESK_PAD)); }catch(e){}
  codeStatus(code+' added to Continuum ('+DESK_PAD.length+'/25)');
  if(typeof renderDesk==='function') renderDesk();
}
function padRemove(code){
  var i = DESK_PAD.indexOf(code);
  if(i>=0){
    DESK_PAD.splice(i,1);
    try{ localStorage.setItem('ruby-chartpad', JSON.stringify(DESK_PAD)); }catch(e){}
    codeStatus(code+' released ('+DESK_PAD.length+'/25)');
  }else{
    codeStatus(code+' not in your Continuum');
  }
}

function hideDesk(){
  var d = document.getElementById('controldesk');
  if(d) d.style.display='none';
  /* exiting — grant the Continuum */
  codeStatus('you carry the Continuum — use "continuum" to open your chart pad');
}
function loadPad(){
  try{ DESK_PAD = JSON.parse(localStorage.getItem('ruby-chartpad')||'[]'); }catch(e){ DESK_PAD=[]; }
}
setTimeout(loadPad, 2000);

/* CONTINUUM — portable chart pad, context-aware code suggestions */

/* CONTINUUM BUTTON — floating access */
setTimeout(function(){
  if(!document.getElementById('continuumBtn')){
    var b = document.createElement('button');
    b.id = 'continuumBtn';
    b.textContent = '\u221E';
    b.title = 'CONTINUUM';
    b.style.cssText = 'position:fixed;bottom:420px;right:14px;z-index:9999;width:46px;height:46px;background:#d8a920;color:#111;border:1px solid #d8a920;border-radius:50%;font-size:24px;line-height:1;padding:0;cursor:pointer;-webkit-tap-highlight-color:transparent;';
    b.onclick = function(){ showContinuum(); };
    document.body.appendChild(b);
  }
}, 3500);

/* EASY MODE — for older eyes and hands, no frustration */
var EASY_MODE = false;
function toggleEasy(){
  EASY_MODE = !EASY_MODE;
  try{ localStorage.setItem('ruby-easy', EASY_MODE?'1':'0'); }catch(e){}
  applyEasy();
  codeStatus(EASY_MODE ? 'easy mode on — bigger, simpler' : 'easy mode off');
}
function applyEasy(){
  var size = EASY_MODE ? '18px' : '12px';
  var pad = EASY_MODE ? '20px' : '12px';
  /* continuum/pad */
  var cont = document.getElementById('continuum');
  if(cont){
    cont.style.fontSize = size;
    cont.style.padding = pad;
    cont.style.maxWidth = EASY_MODE ? '90vw' : '350px';
  }
  /* desk */
  var desk = document.getElementById('controldesk');
  if(desk){
    desk.style.fontSize = size;
    desk.style.maxWidth = EASY_MODE ? '90vw' : '400px';
  }
  /* build codes */
  var bc = document.getElementById('buildcodes');
  if(bc){
    bc.style.fontSize = size;
    bc.style.maxWidth = EASY_MODE ? '90vw' : '500px';
  }
  /* avatars */
  var av = document.getElementById('avatars');
  if(av){
    av.style.fontSize = size;
  }
  /* make all buttons bigger in easy mode */
  var btns = document.querySelectorAll('#continuum button, #controldesk button, #buildcodes button');
  btns.forEach(function(b){
    b.style.fontSize = EASY_MODE ? '18px' : '12px';
    b.style.padding = EASY_MODE ? '12px 16px' : '4px 8px';
    b.style.margin = EASY_MODE ? '6px' : '2px';
  });
}
/* auto-apply on load */
setTimeout(function(){
  try{
    if(localStorage.getItem('ruby-easy')==='1'){
      EASY_MODE = true;
      applyEasy();
    }
  }catch(e){}
}, 4000);
/* re-apply when panels open */
var origShowCont = showContinuum;
showContinuum = function(){
  origShowCont();
  setTimeout(applyEasy, 100);
};
try{ window.showContinuum = showContinuum; }catch(e){}
function showContinuum(){