<!-- RUBY-BACKUP · part 207 -->
el like they always win now.</small>';
  document.body.appendChild(div);
  setTimeout(function(){ var d=document.getElementById('bad-guys'); if(d) d.remove(); }, 8000);
  codeStatus('the bad guys feel like they always win');
}
function homelessAngry(){
  /* adult mode — the funny homeless become angry */
  var div = document.createElement('div');
  div.id = 'homeless-angry';
  div.style.cssText = 'position:fixed;bottom:100px;right:20px;z-index:9998;background:rgba(20,20,20,0.9);border:2px solid #888;border-radius:8px;padding:10px 15px;color:#aaa;font-family:Arial;font-size:13px;max-width:280px;';
  div.innerHTML = '<b>THE HOMELESS</b> (adult mode)<br><i>"You had everything. You lost it. Now you know."</i><br><small>They are angry. Not funny anymore.</small>';
  document.body.appendChild(div);
  setTimeout(function(){ var d=document.getElementById('homeless-angry'); if(d) d.remove(); }, 8000);
  codeStatus('the homeless are angry');
}
function friendsAvoid(){
  var div = document.createElement('div');
  div.id = 'friends-avoid';
  div.style.cssText = 'position:fixed;top:100px;left:50%;transform:translateX(-50%);z-index:9998;background:rgba(15,15,25,0.9);border:2px solid #5555ff;border-radius:8px;padding:10px 20px;color:#aaaaff;font-family:Arial;font-size:13px;text-align:center;';
  div.innerHTML = 'People you used to know cross the street when they see you.<br><small>They avoid you.</small>';
  document.body.appendChild(div);
  setTimeout(function(){ var d=document.getElementById('friends-avoid'); if(d) d.remove(); }, 8000);
  codeStatus('people you knew avoid you');
}
function scaryValley(){
  var div = document.createElement('div');
  div.id = 'scary-valley';
  div.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;z-index:20000;background:rgba(5,5,10,0.97);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:14px;color:#888;letter-spacing:3px;margin-bottom:15px;">THE ONLY WAY FORWARD</div>'
    + '<div style="font-size:28px;color:#ff6666;font-weight:bold;margin-bottom:20px;">THE SCARY VALLEY</div>'
    + '<div id="valley-words" style="font-style:italic;font-size:17px;line-height:2;max-width:600px;min-height:200px;"></div>'
    + '<div id="valley-btn" style="margin-top:20px;"></div>';
  document.body.appendChild(div);
  var words = [
    'There is only one thing you can do.',
    'Walk down the scary valley.',
    'Creatures move in the dark between the walls.',
    'You have no gun. The stores are closed.',
    'The bad guys watch. The homeless glare. Your friends are gone.',
    'All you have is your feet. And the twin crystal burning in your pocket.',
    '<span style="color:#ff6666;">Walk.</span>'
  ];
  var w = document.getElementById('valley-words');
  var i = 0;
  var wt = setInterval(function(){
    if(i < words.length){
      w.innerHTML += '<div style="margin:10px 0;opacity:0;animation:fadein 1s forwards;">'+words[i]+'</div>';
      i++;
    }else{
      clearInterval(wt);
      document.getElementById('valley-btn').innerHTML =
        '<button onclick="walkValley()" style="padding:15px 40px;background:#330000;color:#ff6666;border:2px solid #ff6666;font-size:18px;border-radius:8px;cursor:pointer;">Walk Down</button>';
    }
  }, 1800);
}

/* THE RETURN — pad shuts down, the mission, the search */
var PAD_CHARGE = 100;
function loadPadCharge(){
  try{
    var ch = localStorage.getItem('ruby-pad-charge');
    if(ch!==null) PAD_CHARGE = parseInt(ch);
  }catch(e){}
}
function savePadCharge(){
  try{ localStorage.setItem('ruby-pad-charge', PAD_CHARGE.toString()); }catch(e){}
}

/* BACKWARDS — the crystal steals, never gives */
setInterval(function(){
  try{
    var inv = getInventory();
    var hasCrystal = inv.find(function(i){ return i.id==='twin-crystal'; });
    if(hasCrystal){
      /* it steals pad energy */
      loadPadCharge();
      if(PAD_CHARGE > 0){
        PAD_CHARGE = Math.max(0, PAD_CHARGE - 2);
        savePadCharge();
        if(PAD_CHARGE === 0 && !document.getElementById('pad-shutdown')){
          padShutdown();
        }
      }
    }
  }catch(e){}
}, 10000);
function drainPad(amount){
  loadPadCharge();
  PAD_CHARGE = Math.max(0, PAD_CHARGE - amount);
  savePadCharge();
  if(PAD_CHARGE <= 0){
    padShutdown();
  }
  return PAD_CHARGE;
}
function padShutdown(){
  var div = document.createElement('div');
  div.id = 'pad-shutdown';
  div.style.cssText = 'position:fixed;top:40%;left:50%;transform:translate(-50%,-50%);z-index:20000;background:rgba(10,10,10,0.97);border:3px solid #333;border-radius:12px;padding:25px 40px;color:#fff;font-family:monospace;text-align:center;';
  div.innerHTML = '<div style="font-size:24px;margin-bottom:15px;">📴</div>'
    + '<div style="font-weight:bold;font-size:18px;margin-bottom:10px;">CONTINUUM PAD SHUT DOWN</div>'
    + '<div style="font-size:14px;color:#888;">The long walk dr