<!-- RUBY-BACKUP · part 100 -->
defined'){ cursor.x = _ks.x; cursor.z = _ks.z; }
      } else {
        mePos.set(13, 50, 13);
        if(typeof cursor !== 'undefined'){ cursor.x = 13; cursor.z = 13; }
      }
    /* AUTO-DELETE THE JAIL on startup — King's order 2026-10-03 */
    try{
      var _jb2 = (typeof _solidBlocks !== 'undefined' ? _solidBlocks : []);
      for(var _ji2 = _jb2.length - 1; _ji2 >= 0; _ji2--){
        var _jm2 = _jb2[_ji2];
        if(!_jm2 || !_jm2.position) continue;
        var _jdx2 = _jm2.position.x - 25, _jdz2 = _jm2.position.z - (-10);
        if(Math.sqrt(_jdx2*_jdx2 + _jdz2*_jdz2) < 40 && _jm2.position.y > 5){
          if(_jm2.parent) _jm2.parent.remove(_jm2);
          _jb2.splice(_ji2, 1);
        }
      }
    }catch(e){};
      if(typeof meVel!=='undefined') meVel.set(0,0,0);
    }
    /* 4. Mirror stones below */
    try{
      if(typeof mirrorStones!=='undefined' && mirrorStones.length===2 && typeof groundY==='function'){
        var gy2=groundY(mePos.x, mePos.z);
        mirrorStones[0].position.set(mePos.x-0.12, gy2-0.25, mePos.z);
        mirrorStones[1].position.set(mePos.x+0.12, gy2-0.25, mePos.z);
      }
    }catch(e){}
    /* 5. Verify shoes on land, else fly */
    setTimeout(function(){
      try{
        if(typeof groundY==='function' && typeof mePos!=='undefined'){
          var gy3=groundY(mePos.x, mePos.z);
          if(Math.abs(mePos.y - gy3) > 0.5 && typeof setFly==='function' && !FLYM){
            setFly(true);
          }
        }
      }catch(e){}
    }, 1000);
  }catch(e){}
}
/* auto-load 8ms after load */

/* TOPOGRAPHICAL MAP — on load, chart the land so nothing builds below it */
var TOPO = null, TOPO_MIN = -70, TOPO_MAX = 70;
function buildTopoMap(){
  try{
    if(typeof groundY==='undefined') return;
    TOPO = {};
    for(var x=TOPO_MIN; x<=TOPO_MAX; x++){
      for(var z=TOPO_MIN; z<=TOPO_MAX; z++){
        TOPO[x+','+z] = groundY(x, z);
      }
    }
  }catch(e){}
}
function topoY(x, z){
  try{
    if(!TOPO) return null;
    var ix = Math.round(x), iz = Math.round(z);
    if(ix<TOPO_MIN || ix>TOPO_MAX || iz<TOPO_MIN || iz>TOPO_MAX) return null;
    return TOPO[ix+','+iz];
  }catch(e){ return null; }
}

/* FORTIFIED FOUNDATION — the land is impenetrable from all error */
var LAND_FORTIFIED = true;
var _lastGoodGround = {};
function fortifiedGroundY(x, z){
  try{
    if(typeof x!=='number' || typeof z!=='number' || !isFinite(x) || !isFinite(z)){
      return 0.3; /* invalid input → safe default */
    }
    /* clamp to sane world bounds */
    x = Math.max(-1000, Math.min(1000, x));
    z = Math.max(-1000, Math.min(1000, z));
    var y;
    try{
      y = groundY(x, z);
    }catch(e){
      y = NaN;
    }
    /* validate the result */
    if(typeof y!=='number' || !isFinite(y)){
      var key = Math.round(x)+','+Math.round(z);
      y = _lastGoodGround[key];
      if(typeof y!=='number' || !isFinite(y)) y = 0.3;
    }else{
      /* remember the good value */
      var key2 = Math.round(x)+','+Math.round(z);
      _lastGoodGround[key2] = y;
      /* prune cache if too large */
      if(Object.keys(_lastGoodGround).length > 5000) _lastGoodGround = {};
    }
    /* never below the absolute floor */
    y = Math.max(0.02, y);
    /* never absurdly high (error spike) */
    y = Math.min(100, y);
    return y;
  }catch(e){
    return 0.3;
  }
}
/* harden landH — never return invalid */
var _origLandH = landH;
landH = function(x, z){
  try{
    var h = _origLandH(x, z);
    if(typeof h!=='number' || !isFinite(h)) return 0.3;
    return Math.max(0.02, Math.min(100, h));
  }catch(e){ return 0.3; }
};
/* build it after the organized map */
var _oldBuildMapOrganized = buildMapOrganized;
buildMapOrganized = function(){
  _oldBuildMapOrganized();
  setTimeout(buildTopoMap, 100);
};
if(document.readyState==='complete') setTimeout(buildMapOrganized, 8);
else window.addEventListener('load', function(){ setTimeout(buildMapOrganized, 8); });
/* CINEMATIC LOAD — camera spins around his head, zoomed out, on arrival */
(function(){
  var spinStart=null, spinDur=4000, spinDist=12;
  function startCinematic(){
    try{
      if(typeof camYaw==='undefined' || typeof camDist==='undefined') return;
      camDist=spinDist;
      spinStart=performance.now();
      requestAnimationFrame(cinematicStep);
    }catch(e){}
  }
  function cinematicStep(now){
    try{
      if(spinStart===null) return;
      var t=Math.min(1, (now-spinStart)/spinDur);
      /* one full spin around his head */
      if(typeof camYaw!=='undefined') camYaw+=0.03;
      /* settle at the far angle */
      if(t>0.7 && typeof camDist!=='undefined'){
        var e=(t-0.7)/0.3;
        camDist=spinDist+(10-spinDist)*e*e;
      }
      if(t<1) requestAnimationFrame(cinematicStep);
      else { spinStart=null; if(typeof camDist!=='undefined') camDist=10; }
    }catch(e){}
  }
  if(document.readyState==='complete') setTimeout(startCinematic, 8);
  else window.addEventListener('load', function(){ setTi