<!-- RUBY-BACKUP · part 543 -->
der-radius:4px;font-size:16px;font-weight:bold;';
      back.onclick = function(){ showCats(); };
      p.appendChild(back);
      var cnt = document.createElement('div');
      cnt.innerHTML = list.length + ' codes';
      cnt.style.cssText = 'color:#888;font-size:12px;margin:4px 0;text-align:center;';
      p.appendChild(cnt);
      list.forEach(function(c){
        var b = document.createElement('button');
        b.innerHTML = c;
        b.style.cssText = 'display:block;width:100%;margin:4px 0;padding:10px;background:#222;color:gold;border:1px solid #444;border-radius:4px;font-size:16px;'; b.title = c;
        b.onclick = function(){ if(typeof Mainframe!=="undefined" && Mainframe.run) Mainframe.run(c); };
        p.appendChild(b);
      });
      p.scrollTop = 0;
    }
    function showCats(){
      p.innerHTML = '';
      var t = document.createElement('div');
      t.innerHTML = 'Choose a scroll';
      t.style.cssText = 'color:gold;font-size:18px;text-align:center;margin:8px 0;font-weight:bold;';
      p.appendChild(t);
      cats.forEach(function(cat){
        var list = codes.filter(cat.m);
        if(!list.length) return;
        var b = document.createElement('button');
        b.innerHTML = cat.n + ' (' + list.length + ')';
        b.style.cssText = 'display:block;width:100%;margin:6px 0;padding:14px;background:#2a2a1a;color:gold;border:2px solid gold;border-radius:6px;font-size:18px;font-weight:bold;';
        b.onclick = function(){ showCodes(list, cat.n); };
        p.appendChild(b);
      });
      /* uncategorized */
      var used = {};
      cats.forEach(function(cat){ codes.filter(cat.m).forEach(function(c){ used[c]=1; }); });
      var rest = codes.filter(function(c){ return !used[c]; });
      if(rest.length){
        var b = document.createElement('button');
        b.innerHTML = 'More (' + rest.length + ')';
        b.style.cssText = 'display:block;width:100%;margin:6px 0;padding:14px;background:#1a1a2a;color:#aaf;border:2px solid #66f;border-radius:6px;font-size:18px;font-weight:bold;';
        b.onclick = function(){ showCodes(rest, 'More'); };
        p.appendChild(b);
      }
    }
    showCats();
    document.body.appendChild(p);
  };
  document.body.appendChild(btn);
})();

})();

/* hide the fake loader — the world is here */
if(typeof window.hideFakeLoader==='function'){ setTimeout(window.hideFakeLoader, 1500); }
/* streets load on start, every time — locked in */
/* AMBIENT MUSIC — procedural, generated live */
var _musicCtx = null, _musicOn = false, _musicNodes = [];
function toggleMusic(){
  try{
    if(!_musicCtx){
      _musicCtx = new (window.AudioContext || window.webkitAudioContext)();
    }
    if(_musicCtx.state==='suspended') _musicCtx.resume();
    _musicOn = !_musicOn;
    var btn = document.getElementById('musicbtn');
    if(btn) btn.style.opacity = _musicOn ? '1' : '0.4';
    if(_musicOn){
      startAmbient();
      if(typeof codeStatus==='function') codeStatus('music on');
    }else{
      stopAmbient();
      if(typeof codeStatus==='function') codeStatus('music off');
    }
  }catch(e){}
}
function startAmbient(){
  try{
    stopAmbient();
    var ctx = _musicCtx;
    // deep drone
    var droneOsc = ctx.createOscillator();
    droneOsc.type = 'sine';
    droneOsc.frequency.value = 55; // A1
    var droneGain = ctx.createGain();
    droneGain.gain.value = 0.08;
    droneOsc.connect(droneGain);
    droneGain.connect(ctx.destination);
    droneOsc.start();
    _musicNodes.push(droneOsc, droneGain);
    // fifth
    var fifthOsc = ctx.createOscillator();
    fifthOsc.type = 'sine';
    fifthOsc.frequency.value = 82.5; // E2
    var fifthGain = ctx.createGain();
    fifthGain.gain.value = 0.05;
    fifthOsc.connect(fifthGain);
    fifthGain.connect(ctx.destination);
    fifthOsc.start();
    _musicNodes.push(fifthOsc, fifthGain);
    // slow shimmer — pentatonic plucks
    var notes = [220, 246.94, 277.18, 329.63, 369.99, 440]; // A major pentatonic
    function pluck(){
      if(!_musicOn) return;
      var o = ctx.createOscillator();
      o.type = 'triangle';
      o.frequency.value = notes[Math.floor(Math.random()*notes.length)];
      var g = ctx.createGain();
      g.gain.setValueAtTime(0.12, ctx.currentTime);
      g.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 3);
      o.connect(g);
      g.connect(ctx.destination);
      o.start();
      o.stop(ctx.currentTime + 3);
      setTimeout(pluck, 2000 + Math.random()*4000);
    }
    pluck();
    // gentle filter sweep on the drone
    var lfo = ctx.createOscillator();
    lfo.frequency.value = 0.05;
    var lfoGain = ctx.createGain();
    lfoGain.gain.value = 20;
    lfo.connect(lfoGain);
    lfoGain.connect(droneOsc.frequency);
    lfo.start();
    _musicNodes.push(lfo, lfoGain);
  }catch(e){}
}
function stopAmbient(){
  try{
    _musicNodes.forEach(function(n){
      try{ if(n.stop) n.stop(); }catch(e){}
      try{ n.disconnect(); }catch(e){}
    });
    _mus