<!-- SAGA-STAGING · part 62 -->
rdict="BLOCK";C.reason="kill_y";return C;}
 C.allowed=true;C.verdict="ALLOW";C.reason="safe_ground";return C;
};
setInterval(function(){try{if(ActorRuntime.authority==="legacy"||ActorRuntime.authority==="ai_guarded")ActorRuntime.evaluateRealCandidate();}catch(e){ActorRuntime.debug.lastError=String(e);}},16);
/* ===== END REAL MOVEMENT CANDIDATE — v215 ===== */
/* ===== SAFETY SUPERVISOR — v216 ===== */
ActorRuntime.safetySupervisor={version:216,status:"WAIT",permit:false,reason:"startup",safeSamples:0,blockedSamples:0,lastSafeAt:0};
ActorRuntime.superviseSafety=function(){
 var R=this,V=R.safetySupervisor,C=R.realCandidate,P=R.senseWorld?R.senseWorld():null;
 V.status="BLOCK";V.permit=false;V.reason="not_ready";
 if(typeof kingPos==="undefined"||!kingPos||!C||!P)return V;
 if(kingPos.y<R.safety.killY){V.reason="below_kill_y";V.blockedSamples++;return V;}
 if(!P.support||!P.safeStand){V.reason="unsafe_current_position";V.blockedSamples++;return V;}
 if(!C.allowed||C.verdict!=="ALLOW"){V.reason="candidate_"+String(C.reason||"blocked");V.blockedSamples++;return V;}
 R.safety.lastSafe.copy(kingPos);
 R.safety.hasLastSafe=true;
 V.lastSafeAt=performance.now();
 V.safeSamples++;
 V.status="SAFE";V.permit=true;V.reason="verified";
 return V;
};
setInterval(function(){try{if(ActorRuntime.authority==="legacy"||ActorRuntime.authority==="ai_guarded")ActorRuntime.superviseSafety();}catch(e){ActorRuntime.debug.lastError=String(e);}},16);
/* ===== END SAFETY SUPERVISOR — v216 ===== */
/* ===== AI CONTROL INTERFACE — v209 ===== */
window.WORLD_INTELLIGENCE={
 version:209,
 latest:null,
 snapshot:function(){
  var R=window.ACTOR_RUNTIME,F=window.WORLD_FOUNDATION;
  if(!R)return null;
  var P=R.senseWorld?R.senseWorld():null,T=R.terrainPrediction||null,I=R.input||null;
  var q=function(n){return Number.isFinite(n)?Number(n.toFixed(4)):null;};
  var out={
   version:209,authority:R.authority,control:R.enabled?"LIVE":"SHADOW",
   owner:I?I.owner:"none",mode:R.locomotion.requestedMode,
   player:(typeof kingPos!=="undefined"&&kingPos)?{x:q(kingPos.x),y:q(kingPos.y),z:q(kingPos.z)}:null,
   input:I?{x:q(I.moveX),z:q(I.moveZ),magnitude:q(I.magnitude)}:null,
   perception:P?{support:P.support,grounded:P.grounded,airborne:P.airborne,falling:P.falling,surface:P.surface,groundY:q(P.groundY),delta:q(P.delta),slope:q(P.slope),safe:P.safeStand}:null,
   terrain:T?{classification:T.classification,support:T.support,valid:T.valid,groundY:q(T.groundY),slope:q(T.slope),step:q(T.step),surface:T.surface,safe:T.safe}:null,
   surfaces:F?F.colliders.length:0,timestamp:Date.now()
  };
  this.latest=out;return out;
 },
 requestAI:function(agentId){
  var R=window.ACTOR_RUNTIME;if(!R||!R.ai.allowed)return false;
  R.ai.active=true;R.ai.agentId=String(agentId||"ai");R.ai.control="shadow";return true;
 },
 drive:function(agentId,intent){
  var R=window.ACTOR_RUNTIME;if(!R||!R.ai.active||R.ai.agentId!==String(agentId||"ai"))return false;
  return R.submitIntent("ai",intent||{});
 },
 stop:function(agentId){
  var R=window.ACTOR_RUNTIME;if(!R||R.ai.agentId!==String(agentId||"ai"))return false;
  return R.submitIntent("ai",{moveX:0,moveZ:0,jump:false,ascend:false,descend:false});
 },
 release:function(agentId){
  var R=window.ACTOR_RUNTIME;if(!R||R.ai.agentId!==String(agentId||"ai"))return false;
  R.submitIntent("human",{moveX:0,moveZ:0});R.ai.active=false;R.ai.agentId=null;R.ai.control="none";return true;
 },
 humanTakeover:function(){
  var R=window.ACTOR_RUNTIME;if(!R)return false;
  R.submitIntent("human",{moveX:0,moveZ:0});R.ai.active=false;R.ai.agentId=null;R.ai.control="none";return true;
 }
};
setInterval(function(){try{window.WORLD_INTELLIGENCE.snapshot();}catch(e){}},200);
/* ===== END AI CONTROL INTERFACE — v209 ===== */
/* ===== AI TERRAIN PILOT — v211 ===== */
window.AI_TERRAIN_PILOT={version:211,enabled:false,agentId:"world-ai",decision:"IDLE",ticks:0};
window.AI_TERRAIN_PILOT.tick=function(){var A=this,W=window.WORLD_INTELLIGENCE,R=window.ACTOR_RUNTIME;if(!A.enabled||!W||!R||!R.ai.active||R.ai.agentId!==A.agentId)return;var T=R.terrainPrediction;if(!T){A.decision="WAIT";W.stop(A.agentId);return;}if(T.safe&&T.classification==="SAFE GROUND"){A.decision="FORWARD";W.drive(A.agentId,{moveX:0,moveZ:1});}else{A.decision="STOP / "+T.classification;W.stop(A.agentId);}A.ticks++;};
window.AI_TERRAIN_PILOT.start=function(){var W=window.WORLD_INTELLIGENCE;if(!W||!W.requestAI(this.agentId))return false;this.enabled=true;this.decision="START";return true;};
window.AI_TERRAIN_PILOT.stop=function(){this.enabled=false;this.decision="IDLE";var W=window.WORLD_INTELLIGENCE;if(W)W.stop(this.agentId);return true;};
setInterval(function(){try{window.AI_TERRAIN_PILOT.tick();}catch(e){window.AI_TERRAIN_PILOT.decision="ERROR";}},100);
/* ===== END AI TERRAIN PILOT — v211 ===== */

/* ===== END ACTOR MOBILE DEBUG — v203 ===== */
/* ===== END AI ACTOR RUNTIME — v202 ===== */

function toggleMove(){
  moveModeIdx = (moveModeIdx + 1