<!-- RUBY-BACKUP · part 318 -->
t > 0.005){
            /* Ease, don't snap — the body settles like it fits */
            mePos.x += dx * 0.15; mePos.z += dz * 0.15;
          }
        }
        /* Tuck settle — crawl into the corner like water finding its level */
        if(window._tuckPoint && window._crawling && typeof myAvatar !== 'undefined' && myAvatar){
          var tp = window._tuckPoint;
          var tdx = tp.x - mePos.x, tdz = tp.z - mePos.z;
          var tdist = Math.sqrt(tdx*tdx + tdz*tdz);
          if(tdist > 0.35){
            /* Still approaching — keep crawling */
          }else{
            /* Close enough — settle, don't push through */
            meVel.x *= 0.5; meVel.z *= 0.5;
          }
        }
      }catch(e){}
      /* Belly wiggle — trying to move while laying is funny */
      try{
        if(window._laying && typeof myAvatar !== 'undefined' && myAvatar){
          var bellyTime = (Date.now() - (window._layStart || 0)) / 1000;
          if(window._crawling) bellyTime = 0; /* crawl mode: no funny wiggle, all business */
          var joyActive = Math.abs(joyX) > 0.15 || Math.abs(joyY) > 0.15;
          if(joyActive && bellyTime > 5){
            var wt = Date.now() * 0.012;
            myAvatar.rotation.z = Math.sin(wt) * 0.25;
            myAvatar.position.x += Math.sin(wt * 1.3) * 0.008;
          }else{
            myAvatar.rotation.z *= 0.9;
          }
        }
      }catch(e){}
      trackPlateau();
      var gy = fortifiedGroundY(mePos.x, mePos.z);
      /* highways are walkable — stand on top, not inside */
      try{
        if(typeof isOnHighway==='function' && isOnHighway(mePos.x, mePos.z)){
          var _rd = Math.sqrt(mePos.x*mePos.x + mePos.z*mePos.z);
          var _rh = 10 + Math.sin(_rd*0.02)*4 + Math.sin(_rd*0.05+1.3)*2 + 0.5;
          if(_rh > gy) gy = _rh;
        }
      }catch(e){}
      /* two invisible stones mirror him below the land */
      try{
        if(mirrorStones.length===2){
          mirrorStones[0].position.set(mePos.x-0.12, gy-0.25, mePos.z);
          mirrorStones[1].position.set(mePos.x+0.12, gy-0.25, mePos.z);
          /* they stop him — never below the mirrors */
          var mirrorY = gy-0.2;
          if(mePos.y < mirrorY+0.3){ mePos.y = mirrorY+0.3; if(meVel.y<0) meVel.y=0; onGround=true; }
        }
      }catch(e){}
      /* never through the land — absolute */
      if(mePos.y < gy+0.1){ mePos.y = gy+0.1; if(meVel.y<0) meVel.y = 0; onGround = true; }
      if(mePos.y < gy-0.5){ if(typeof setFly==="function" && !FLYM){ setFly(true); codeStatus("shoes left the land — flying"); } meVel.y = Math.max(meVel.y, 0); onGround = false; } /* shoes pass the land → fly */
      var _half = (typeof MAP_UNITS!=='undefined' ? MAP_UNITS/2 : 600) - 2;
      mePos.x = Math.max(-_half, Math.min(_half, mePos.x));
      mePos.z = Math.max(-_half, Math.min(_half, mePos.z));
      if(_a3.lengthSq()>0.001){
        var wantFace = Math.atan2(_a3.x, _a3.z), df = wantFace-faceYaw;
        while(df>Math.PI) df -= Math.PI*2; while(df<-Math.PI) df += Math.PI*2;
        faceYaw += df*Math.min(1, dt*10);
      }
    }
    mePos.x = Math.max(-((typeof MAP_UNITS!=='undefined'?MAP_UNITS/2:600)-2), Math.min(((typeof MAP_UNITS!=='undefined'?MAP_UNITS/2:600)-2), mePos.x));
    mePos.z = Math.max(-((typeof MAP_UNITS!=='undefined'?MAP_UNITS/2:600)-2), Math.min(((typeof MAP_UNITS!=='undefined'?MAP_UNITS/2:600)-2), mePos.z));
    if(WALKLINE && WALK){
      var wlx = Math.round(mePos.x), wlz = Math.round(mePos.z);
      if(!walkLineLast || Math.abs(wlx-walkLineLast.x)+Math.abs(wlz-walkLineLast.z) >= 2){
        walkLineLast = {x:wlx, z:wlz};
        if(!(wlx===0 && wlz===0) && !stoneAt(wlx, wlz, 0)){
          var wlg = placeStone(wlx, wlz, 1, curShapeKey, false, true, 0);
          if(wlg){ addSeamsFor(wlg); shareStones([wlg]); }
        }
      }
    }
    var cpw = Math.cos(camPitch);
    if(MIRROR){
      /* the mirror — the camera stands before you, so you see yourself */
      var mhh = (typeof _duckMode!=='undefined' && _duckMode) ? 0.05 : (AVATAR==='king' ? 0.75 : 0.2);
      _a1.set(Math.sin(camYaw), 0, Math.cos(camYaw));
      (function(){
      var cgy=(typeof groundY==='function')?groundY(mePos.x, mePos.z):0;
      camera.position.set(mePos.x + _a1.x*2.4, Math.max(mePos.y + mhh, cgy+0.6), mePos.z + _a1.z*2.4);
    })();
      camera.lookAt(mePos.x, mePos.y + 0.5, mePos.z);
      if(myAvatar) myAvatar.visible = true;
      if(myWearGrp) myWearGrp.visible = true;
    }else if(CROWN){
      /* the camera sits in the crown — through your own eyes */
      var hh = AVATAR==='king' ? 0.95 : (AVATAR==='provolta' ? 1.75 : 0.2);
      if(crownIntro){
        /* startup: glide in from outside — the gaze lifts from his face to the horizon
           as the camera settles into the crown. never stares at his feet. */
        if(crownIntroT === 0 || !crownIntroFrom){
          crownIntroFrom = new T.Vector3(mePos.x - 20*Math.sin(camYaw), mePos.y + 11, mePos.z - 2