<!-- SAGA-STAGING · part 64 -->
tion(); }],
  ['p2-sky','Sky',function(){ showSky(); }],
  ['p2-treasure','Treasure',function(){ startTreasure(); }],
  ['p2-clearcache','Clear cache',function(){ if(confirm('Clear?')) location.reload(); }],
  ['p2-waypoints','Waypoints',function(){ manageWaypoints(); }],
  ['p2-kidmode','Kid mode',function(){ toggleKidMode(); }],
  ['p2-crown','Crown',function(){ crownView(); }],
  ['p2-dimension','Dimension',function(){ switchDimension(); }],
  ['p3-soliditronium','Soliditronium',function(){ openSoliditronium(); }],
  ['p3-capsule','Capsule',function(){ openCapsule(); }],
  ['p3-fillgaps','Fill gaps',function(){ fillGaps(); }],
  ['p3-recolor','Recolor',function(){ recolorBlocks(); }],
  ['p3-saveview','Save view',function(){ saveView(); }],
  ['p3-gotoview','Go to view',function(){ goToView(); }],
  ['p3-presets','Presets',function(){ showPresets(); }],
  ['p3-aurora','Aurora',function(){ setAurora(); }],
  ['p3-ember','Ember',function(){ setEmber(); }],
  ['p3-storm','Storm',function(){ setStorm(); }],
  ['p3-dawn','Dawn',function(){ setDawn(); }],
  ['p3-invite','Invite',function(){ sendInvite(); }],
  ['p4-whiteout','Whiteout',function(){ setWhiteout(); }],
  ['p4-rain','Rain',function(){ setRain(); }],
  ['p4-wear','Wear',function(){ openWear(); }],
  ['p4-walkline','Walkline',function(){ toggleWalkline(); }],
  ['p4-redseams','Red seams',function(){ toggleRedSeams(); }],
  ['p4-glide','Glide',function(){ runCode('glide'); }],
  ['p4-taptocrown','Tap to crown',function(){ tapToCrown(); }],
  ['p4-tutorial','Tutorial',function(){ startTutorial(); }],
  ['p4-presence','Presence',function(){ showPresence(); }],
  ['p4-balance','Balance',function(){ checkBalance(); }],
  ['p4-ship','Ship',function(){ shipStatus(); }],
  ['p4-history','History',function(){ showHistory(); }],
];
/* Organize by function with section headers */
var GROUPS = [
  ['CORE', 0, 20],
  ['BUILD', 20, 32],
  ['WORLD', 32, 44],
  ['SYSTEM', 44, 56],
];
GROUPS.forEach(function(g){
  var header = document.createElement('div');
  header.textContent = g[0];
  header.style.cssText = 'width:100%;text-align:center;color:#ffd700;font:16px Georgia,\'Times New Roman\',serif;letter-spacing:6px;margin:10px 0 6px 0;border-bottom:1px solid #d8a920;padding-bottom:6px;';
  osEl.appendChild(header);
  for(var i=g[1]; i<g[2]; i++){
    (function(b){
      var cell = document.createElement('div');
      cell.style.cssText = 'display:flex;flex-direction:column;align-items:center;gap:2px;width:72px;flex-shrink:0;';
      var btn = document.createElement('button');
  btn.title = b[1];
  btn.innerHTML = '<img src="/coders100/buttons/'+b[0]+'.webp" style="width:100%;height:100%;border-radius:50%;object-fit:cover;" draggable="false">';
  btn.style.cssText = 'width:48px;height:48px;min-width:48px;min-height:48px;border-radius:50%;padding:0;margin:0;border:2px solid #d8a920;background:#141006;cursor:pointer;flex-shrink:0;overflow:hidden;';
      btn.onclick = (function(fn){ return function(){ fn(); }; })(b[2]);
      cell.appendChild(btn);
      var lbl = document.createElement('div');
      lbl.textContent = b[1];
      lbl.style.cssText = 'color:#d8a920;font-size:13px;font-family:Georgia,\'Times New Roman\',serif;text-align:center;line-height:1.2;max-width:72px;letter-spacing:0.5px;';
      cell.appendChild(lbl);
      osEl.appendChild(cell);
    })(BTNS[i]);
  }
});
/* REAL TOGGLES — switches with on/off state */











/* ===== DUAL JOYSTICKS — left: body, right: camera ===== */
/* FRESH STICKS — v80. Two thumbs, zero overlap. King's order 2026-10-05.
   Left = move the king. Right = aim the camera (the cannon fires where it faces).
   Right stick sits above the cannon button — nothing touches. */
function makeStick(pos, onMove){
  var base = document.createElement('div');
  base.className = 'fresh-stick';
  base.style.cssText = 'position:fixed;'+pos+'width:150px;height:150px;border-radius:50%;' +
    'border:2px solid #d8a920;background:rgba(20,14,6,0.45);z-index:90;touch-action:none;';
  var knob = document.createElement('div');
  knob.style.cssText = 'position:absolute;left:50%;top:50%;width:62px;height:62px;margin:-31px 0 0 -31px;' +
    'border-radius:50%;background:radial-gradient(circle at 30% 30%, #ffd700, #8a6a1c);' +
    'box-shadow:0 0 10px rgba(255,215,0,0.6);';
  base.appendChild(knob);
  document.body.appendChild(base);
  var touchId = null, cx = 0, cy = 0;
  function setKnob(dx, dy){
    var max = 45;
    var len = Math.sqrt(dx*dx + dy*dy);
    if(len > max){ dx = dx/len*max; dy = dy/len*max; }
    knob.style.transform = 'translate('+dx+'px,'+dy+'px)';
    onMove(dx/max, dy/max);
  }
  base.addEventListener('touchstart', function(e){
    e.stopPropagation(); e.preventDefault();
    var t = e.changedTouches[0];
    touchId = t.identifier;
    var r = base.getBoundingClientRect();
    cx = r.left + r.width/2; cy = r.top + r.height/2;
  }, {passive:false});
  base.addEventListener('touchmove', function(e){