<!-- RUBY-BACKUP · part 449 -->
hievements */
var ACHIEVEMENTS = [];
function unlockAchievement(name){
  if(ACHIEVEMENTS.indexOf(name) < 0){
    ACHIEVEMENTS.push(name);
    try{ localStorage.setItem('ruby-achievements', JSON.stringify(ACHIEVEMENTS)); }catch(e){}
    codeStatus('ACHIEVEMENT: '+name);
  }
}
function loadAchievements(){
  try{ ACHIEVEMENTS = JSON.parse(localStorage.getItem('ruby-achievements')||'[]'); }catch(e){ ACHIEVEMENTS = []; }
}
var COURT_CASES = [
  {claim: 'The sky is blue because the ocean reflects it', fallacy: 'False Cause', correct: 'Rayleigh scattering'},
  {claim: 'All towers are tall, therefore all tall things are towers', fallacy: 'Affirming the Consequent', correct: 'Invalid conversion'},
  {claim: 'You are either with us or against us', fallacy: 'False Dilemma', correct: 'More options exist'}
];

/* THE TWIN LIGHTNING — a hard case. You are a victim of circumstance. */
var TWIN_CASE = {
  title: 'The Twin Lightning',
  active: false,
  stage: 0,
  stages: [
    {
      prosecution: 'On the night of the storm, TWO lightning bolts struck. You were seen at BOTH places. How do you explain this?',
      choices: ['I was at the beach', 'I was at the peak', 'I do not know'],
      truth: 'You were at the beach. The second bolt was your twin — not by blood, but by lightning. The storm split you.'
    },
    {
      prosecution: 'Witnesses say you looked guilty. You were running. Innocent people do not run.',
      choices: ['I was running from the storm', 'I was running to help', 'I was scared'],
      truth: 'You were running to warn the village. The court calls it fleeing. It was courage.'
    },
    {
      prosecution: 'Your twin — this "other you" — has never been seen before or since. Convenient.',
      choices: ['The storm made us', 'We are one split in two', 'Believe me'],
      truth: 'Twin lightning creates twin souls. It lasts one night. Then you are whole again, but the court remembers the split.',
      sink: true
    },
    {
      prosecution: 'The court finds your story... unlikely. The lightning does not choose people.',
      choices: ['But it chose me', 'I am a victim of circumstance', 'Let the storm testify'],
      truth: 'You are a victim of circumstance. The storm chose. Not you.'
    },
    {
      prosecution: 'Tell us — did the twin lightning make you powerful? Is that why you took it?',
      choices: ['It gave me nothing', 'It took from me', 'It is backwards'],
      truth: 'It does not make him powerful at all. It is backwards. It steals his pad\'s energy. It takes and takes and gives nothing back.'
    }
  ]
};

/* THE SINKING — Continuum to max for 2 minutes. No alternative. */
var CONTINUUM_LOCKED = false;
function sinkContinuum(){
  if(typeof DESK_PAD==='undefined') return;
  /* force to max 25 */
  var paradoxCodes = [
    'twin', 'flare', 'court', 'solid', 'quest',
    'ancestors', 'hokulea', 'dark', 'city', 'plaza',
    'wildlife', 'spaceport', 'cosmic', 'valleys', 'wildterrain',
    'rural', 'tribal', 'play', 'officer', 'spacemission',
    'continuum', 'dome', 'stranger', 'stats', 'ending'
  ];
  DESK_PAD = paradoxCodes.slice(0, 25);
  try{ localStorage.setItem('ruby-chartpad', JSON.stringify(DESK_PAD)); }catch(e){}
  CONTINUUM_LOCKED = true;
  /* show the sinking */
  var div = document.createElement('div');
  div.id = 'continuum-sink';
  div.style.cssText = 'position:fixed;top:40%;left:50%;transform:translate(-50%,-50%);z-index:20000;background:rgba(10,5,30,0.97);border:3px solid #8844ff;border-radius:12px;padding:25px 40px;color:#fff;font-family:Georgia,serif;text-align:center;max-width:85%;';
  div.innerHTML = '<div style="color:#aa88ff;font-size:22px;font-weight:bold;margin-bottom:15px;">THE CONTINUUM SINKS</div>'
    + '<div style="font-style:italic;font-size:17px;line-height:1.7;">'
    + 'Your pad fills to max. 25/25.<br>'
    + 'You cannot help it.<br><br>'
    + 'That is all you could do.<br>'
    + 'There was no other option.<br>'
    + 'No alternative.'
    + '</div>'
    + '<div style="margin-top:15px;font-size:14px;color:#888;">Locked for 2 minutes</div>'
    + '<div id="sink-timer" style="font-size:28px;color:#aa88ff;margin-top:10px;">2:00</div>';
  document.body.appendChild(div);
  /* 2 minute countdown */
  var remaining = 120;
  var timer = setInterval(function(){
    remaining--;
    var t = document.getElementById('sink-timer');
    if(t){
      var m = Math.floor(remaining/60), s = remaining%60;
      t.innerHTML = m+':'+(s<10?'0':'')+s;
    }
    if(remaining <= 0){
      clearInterval(timer);
      CONTINUUM_LOCKED = false;
      var d = document.getElementById('continuum-sink');
      if(d){
        d.innerHTML = '<div style="color:#ffd700;font-size:20px;font-weight:bold;">RELEASED</div>'
          + '<div style="font-style:italic;margin-top:10px;">The paradox passes.<br>You did all you could do.</div>'
          + '<button onclick="document.getElementById(\'continuum-sink\').remove()" style="margin-top:15px;padding:10p