<!-- SAGA-SOLID · part 64 -->
 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){
    e.stopPropagation(); e.preventDefault();
    for(var k=0; k<e.changedTouches.length; k++){
      var t = e.changedTouches[k];
      if(t.identifier === touchId) setKnob(t.clientX - cx, t.clientY - cy);
    }
  }, {passive:false});
  base.addEventListener('touchend', function(e){
    e.stopPropagation();
    for(var k=0; k<e.changedTouches.length; k++){
      if(e.changedTouches[k].identifier === touchId){
        touchId = null;
        knob.style.transform = 'translate(0,0)';
        onMove(0, 0);
      }
    }
  }, {passive:true});
  return base;
}

/* LEFT stick — moves the king */
var lastDX = 0, lastDZ = 0, walkPhase = 0;
/* Fast flight state - hoisted */
var _fvx = 0, _fvy = 0, _fvz = 0;
var _ftvx = 0, _ftvy = 0, _ftvz = 0;
/* V219: dedicated movement-loop timestamp for AI_GUARDED delta-time (not shared with hyperMove/ShadowMotion) */
var _moveLoopLastT = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now();
var _fcos = 1, _fsin = 0, _fyaw = 999;
var _fdy = 0;
/* Continuous movement loop - runs even when finger holds still */
if(!window._moveLoop){
  window._moveLoop = true;
  setInterval(function(){
    try{
      /* V219: measured delta-seconds; timestamp updates even on early return so no stale dt on mode switch */
      var _v219now = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now();
      var _dtMove = Math.min(Math.max((_v219now - _moveLoopLastT) / 1000, 0), 0.05);
      _moveLoopLastT = _v219now;
      if(hyperMove.enabled) return;
      /* 4. Acceleration/deceleration — fast to start, weighty to stop */
      var ax = Math.abs(_ftvx) > Math.abs(_fvx) ? 0.22 : 0.12;
      var az = Math.abs(_ftvz) > Math.abs(_fvz) ? 0.22 : 0.12;
      _fvx += (_ftvx - _fvx) * ax;
      _fvz += (_ftvz - _fvz) * az;
      _fvy += (_ftvy - _fvy) * 0.18;
      if(typeof kingPos !== 'undefined' && kingPos){
        var _aiLive=window.ACTOR_RUNTIME&&ActorRuntime.authority==="ai_guarded"&&ActorRuntime.ai.active;
        if(_aiLive){
          var _sv=ActorRuntime.safetySupervisor,_sm=ActorRuntime.shadowMotion;
          if(_sv&&_sv.permit&&_sm){
            /* V219: delta-time integration — velocity (u/s) x measured seconds */
            var _aidx = _sm.velocity.x * _dtMove, _aidz = _sm.velocity.z * _dtMove;
            kingPos.x += _aidx;
            kingPos.z += _aidz;
            lastDX = _aidx;
            lastDZ = _aidz;
          }
        }else{
          kingPos.x += _fvx * 0.16;
          kingPos.z += _fvz * 0.16;
          var ny = kingPos.y + _fvy * 0.16;
          kingPos.y = ny < 0.5 ? 0.5 : ny;
        }
        /* MOUNTAIN COLLISION — push out of solid terrain */
        if(window._mountains && window._mountains.length){
          var _v3 = new THREE.Vector3();
          for(var mi = 0; mi < window._mountains.length; mi++){
            var mm = window._mountains[mi];
            if(!mm.userData.isSolidTerrain) 