<!-- RUBY-BACKUP · part 534 -->
eight:80vh;overflow-y:auto;color:#fff;font-family:sans-serif;">'
        + '<h2 style="color:#ffd700;margin-top:0;">How to Use the Creator</h2>'
        + '<p><b style="color:#ffd700;">Cheat Codes</b> — Type in the bar up top:<br>'
        + 'hourglass, pylon, hollowtetra, layeredpyramid — spawn shapes<br>'
        + 'body + paintbody — build and paint the body<br>'
        + 'solidhand — build the 3D hand<br>'
        + 'truelines — intaglio linework</p>'
        + '<p><b style="color:#ffd700;">Touch</b><br>'
        + 'Long-press a block (hold 1 sec) — swipe to spin, release for menu<br>'
        + 'Right edge — flick to spring the panel back<br>'
        + 'X button — collapse everything</p>'
        + '<p><b style="color:#ffd700;">Linework</b> — Pick grid density, background, presets, and colors from the chooser.</p>'
        + '<button onclick="toggleHelp()" style="background:#ffd700;color:#111;border:none;border-radius:8px;padding:12px 24px;font-size:16px;cursor:pointer;width:100%;">Got it</button>'
        + '</div>';
      document.body.appendChild(h);
      h.onclick = function(e){ if(e.target===h) toggleHelp(); };
    }else{
      h.style.display = 'flex';
    }
  }else if(h){
    h.style.display = 'none';
  }
}
function toggleButtonMenu(){
  _menuOpen = !_menuOpen;
  if(_menuPanel){
    _menuPanel.style.display = _menuOpen ? 'flex' : 'none';
  }
  if(_menuBtn){
    _menuBtn.textContent = _menuOpen ? '\u2715' : '\u2630';
  }
  /* Os: collapse buttons — keyboard stays if he's typing */
  try{
    var kb = document.getElementById('kb');
    if(kb) kb.style.display = 'none';
    if(typeof showFloatButtons==='function') showFloatButtons();
  }catch(e){}
}
/* build the menu after buttons exist */
setTimeout(function(){ try{ buildButtonMenu(); }catch(e){} }, 5000);
/* DYNAMIC PANEL — auto-collapse after 5s no-touch, spring back when thumb nears */
var _panelIdleTimer = null;
var _panelLastTouch = Date.now();
function resetPanelIdle(){
  _panelLastTouch = Date.now();
  if(_panelIdleTimer) clearTimeout(_panelIdleTimer);
  _panelIdleTimer = setTimeout(function(){
    try{
      if(_menuOpen && typeof toggleButtonMenu==='function'){
        toggleButtonMenu();
        try{ codeStatus('Panel resting.'); }catch(e){}
      }
    }catch(e){}
  }, 5000);
}
setTimeout(function(){
  try{
    var mp = document.getElementById('buttonmenupanel');
    if(mp){
      mp.addEventListener('touchstart', resetPanelIdle, {passive:true});
      mp.addEventListener('touchmove', resetPanelIdle, {passive:true});
    }
    var mb = document.getElementById('mastermenubtn');
    if(mb) mb.addEventListener('touchstart', resetPanelIdle, {passive:true});
    /* thumb nears right edge — spring the panel back */
    document.addEventListener('touchstart', function(e){
      try{
        var t = e.touches[0];
        if(t && t.clientX > window.innerWidth - 80 && !_menuOpen){
          if(typeof toggleButtonMenu==='function') toggleButtonMenu();
          resetPanelIdle();
        }
      }catch(e){}
    }, {passive:true});
    resetPanelIdle();
  }catch(e){}
}, 7000);
/* AUTO-BUILD — the city stands when you arrive */
var CITY_AUTOBUILT = false;
function autoBuildCity(){
  if(CITY_AUTOBUILT) return;
  if(typeof scene==='undefined') return;
  CITY_AUTOBUILT = true;
  try{ localStorage.setItem('ruby-city-autobuilt', '1'); }catch(e){}
  codeStatus('building the golden city...');
  var steps = [
    {fn: 'goldenCity', delay: 1000},
    {fn: 'goldenPlaza', delay: 2500},
    {fn: 'placeRegalia', delay: 4000},
    {fn: 'placeGraffiti', delay: 5500},
    {fn: 'heavyBuild', delay: 7000},
    {fn: 'placeGuardian', delay: 8500},
    {fn: 'placePhoneCallers', delay: 10000}
  ];
  steps.forEach(function(s){
    setTimeout(function(){
      try{
        if(s.fn==='goldenCity' && typeof goldenCity==='function') goldenCity();
        else if(s.fn==='goldenPlaza' && typeof goldenPlaza==='function') goldenPlaza();
        else if(s.fn==='placeRegalia' && typeof placeRegalia==='function') placeRegalia();
        else if(s.fn==='placeGraffiti' && typeof placeGraffiti==='function') placeGraffiti();
        else if(s.fn==='heavyBuild' && typeof heavyBuild==='function') heavyBuild();
        else if(s.fn==='placeGuardian' && typeof placeGuardian==='function') placeGuardian();
        else if(s.fn==='placePhoneCallers' && typeof placePhoneCallers==='function') placePhoneCallers();
        else codeStatus('sweep: '+s.fn+' not found');
      }catch(e){ codeStatus('sweep: '+s.fn+' stumbled: '+e.message); }
    }, s.delay);
  });
  setTimeout(function(){ codeStatus('the golden city stands'); }, 11500);
}
/* trigger when scene is ready — retry until it is */
var _autoTries = 0;
var _autoTimer = setInterval(function(){
  _autoTries++;
  try{
    if(typeof scene!=='undefined' && scene){
      clearInterval(_autoTimer);
      autoBuildCity();
    }
  }catch(e){}
  if(_autoTries > 60) clearInterval(_autoTimer);
}, 1000);
(function frame