<!-- SAGA-SOLID · part 69 -->
" deg":"NONE"),"SAFE STAND  "+(P?(P.safeStand?"YES":"NO"):"NONE"),"SURFACES    "+(F?F.colliders.length:0),"","NEXT MOVE   "+(T?T.classification:"NONE"),"ROUTE SAFE  "+(T?(T.safe?"YES":"NO"):"NONE"),"NEXT GROUND "+(T&&T.groundY!==null?T.groundY.toFixed(2):"NONE"),"NEXT SLOPE  "+(T&&T.slope!==null?T.slope.toFixed(1)+" deg":"NONE"),"STEP DELTA  "+(T&&T.step!==null?T.step.toFixed(2):"NONE"),"NEXT SURFACE "+(T?T.surface:"NONE"),"","REAL CANDIDATE","VERDICT     "+(C?C.verdict:"NONE"),"REASON      "+(C?C.reason:"NONE"),"CANDIDATE   "+(C&&C.x!==null?C.x.toFixed(2)+" / "+C.y.toFixed(2)+" / "+C.z.toFixed(2):"NONE"),"GROUND      "+(C&&C.groundY!==null?C.groundY.toFixed(2):"NONE"),"STEP        "+(C&&C.step!==null?C.step.toFixed(2):"NONE"),"SLOPE       "+(C&&C.slope!==null?C.slope.toFixed(1)+" deg":"NONE"),"SURFACE     "+(C?C.surface:"NONE"),"","SAFETY SUPERVISOR","STATUS      "+(V?V.status:"NONE"),"PERMIT      "+(V&&V.permit?"YES":"NO"),"REASON      "+(V?V.reason:"NONE"),"LAST SAFE   "+(R&&R.safety.hasLastSafe?R.safety.lastSafe.x.toFixed(2)+" / "+R.safety.lastSafe.y.toFixed(2)+" / "+R.safety.lastSafe.z.toFixed(2):"NONE"),"SAFE SAMPLES "+(V?V.safeSamples:0),"BLOCKED     "+(V?V.blockedSamples:0),"","AI API      window.WORLD_INTELLIGENCE","MOVEMENT AUTHORITY: "+String(R?R.authority:"NONE").toUpperCase()];
      readout.textContent=lines.join(String.fromCharCode(10));
      aiBtn.textContent=R&&R.ai.active?"AI DRIVE: ARMED":"AI DRIVE";
      setTimeout(update,200);
    }
    update();
  });
  menu.querySelector('#m-playa').addEventListener('click', function(){
    window.location.href = '/ruby';
  });
  if(!document.getElementById("ai-stats-btn")){var ab=document.createElement("button");ab.id="ai-stats-btn";ab.textContent="AI";ab.title="AI World Intelligence";ab.style.cssText="position:fixed;top:12px;right:116px;z-index:9999;width:44px;height:44px;border-radius:50%;background:#1a1a2e;color:#ffd700;font:bold 13px monospace;border:2px solid #ffd700;cursor:pointer;display:flex;align-items:center;justify-content:center;";ab.addEventListener("click",function(){var p=document.getElementById("world-intelligence-panel");if(p){p.remove();return;}var x=document.getElementById("m-worldintel");if(x){x.click();if(menu.style.display!=="none")toggleMenu();}});document.body.appendChild(ab);}
  document.body.appendChild(b);
})();


/* IN-GAME CHAT — talk while building */
(function(){
  if(document.getElementById('game-chat')) return;

  /* CLEAR CACHE — on screen next to the diamond. King order 2026-10-05. */
  if(!document.getElementById('clearcache-btn')){
    var ccb = document.createElement('button');
    ccb.id = 'clearcache-btn';
    ccb.innerHTML = '🧹';
    ccb.title = 'Clear cache';
    ccb.style.cssText = 'position:fixed;top:12px;right:64px;z-index:9999;' +
      'width:44px;height:44px;border-radius:50%;' +
      'background:#1a1a2e;color:#ffd700;font-size:20px;' +
      'border:2px solid #ffd700;cursor:pointer;' +
      'display:flex;align-items:center;justify-content:center;';
    ccb.addEventListener('click', function(){ if(confirm('Clear?')) location.reload(); });
    document.body.appendChild(ccb);
  }
  // Chat toggle button (bottom-left)
  var chatBtn = document.createElement('button');
  chatBtn.id = 'game-chat-btn';
  chatBtn.innerHTML = '💬';
  chatBtn.style.cssText = 'position:fixed;top:12px;left:175px;z-index:9999;display:none;' +
    'width:44px;height:44px;border-radius:50%;' +
    'background:#1a1a2e;color:#ffd700;font-size:20px;' +
    'border:2px solid #ffd700;cursor:pointer;';
  document.body.appendChild(chatBtn);

  // Chat panel (hidden by default)
  var panel = document.createElement('div');
  panel.id = 'game-chat';
  panel.style.cssText = 'position:fixed;top:120px;left:12px;z-index:9998;' +
    'width:280px;height:300px;background:rgba(10,10,26,0.95);' +
    'border:2px solid #ffd700;border-radius:12px;display:none;' +
    'flex-direction:column;overflow:hidden;';
  panel.innerHTML =
    '<div id="game-chat-msgs" style="flex:1;overflow-y:auto;padding:8px;color:#ffd700;font-size:13px;"></div>' +
    '<div style="display:flex;border-top:1px solid #ffd700;">' +
    '<input id="game-chat-input" placeholder="Talk..." ' +
    'style="flex:1;background:transparent;border:none;color:#ffd700;padding:10px;font-size:14px;outline:none;">' +
    '<button id="game-chat-send" style="background:#ffd700;color:#1a1a2e;border:none;padding:10px 14px;cursor:pointer;">➤</button>' +
    '</div>';
  document.body.appendChild(panel);

  var open = false;
  function toggleChat(){
    open = !open;
    panel.style.display = open ? 'flex' : 'none';
    if(typeof sfx === 'function') sfx('click');
  }
  chatBtn.addEventListener('click', function(e){ e.stopPropagation(); toggleChat(); });
  chatBtn.addEventListener('touchstart', function(e){ e.stopPropagation(); toggleChat(); }, {passive:true});

  var msgs = panel.querySelector('#game-chat-msgs');
  var input = panel.querySelector('#game-chat-input');
