<!-- SAGA · part 69 -->
animPhase.walk) * animAmp.walk;
      if(playerBody.userData.legR) playerBody.userData.legR.rotation.x = -Math.sin(animPhase.walk) * animAmp.walk;
      if(playerBody.userData.armL) playerBody.userData.armL.rotation.x = -Math.sin(animPhase.walk) * animAmp.walk * 0.8;
      if(playerBody.userData.armR) playerBody.userData.armR.rotation.x = Math.sin(animPhase.walk) * animAmp.walk * 0.8;
      playerBody.rotation.x = 0;
    } else if(moveMode==='swim'){
      animPhase.swim += 0.1;
      if(playerBody.userData.armL) playerBody.userData.armL.rotation.x = Math.sin(animPhase.swim) * animAmp.swim;
      if(playerBody.userData.armR) playerBody.userData.armR.rotation.x = -Math.sin(animPhase.swim) * animAmp.swim;
      playerBody.rotation.x = -Math.PI/2 + 0.3;
    } else if(moveMode==='fly'){
      /* Fly: tilt only, limbs ease to neutral */
      if(playerBody.userData.legL) playerBody.userData.legL.rotation.x *= 0.9;
      if(playerBody.userData.legR) playerBody.userData.legR.rotation.x *= 0.9;
    }
  }
  /* 1. AUTO-SWIM check */
  if(typeof waterAt !== 'undefined'){
    var wtr = waterAt(kingPos.x, kingPos.z);
    if(wtr && kingPos.y <= wtr.surfaceY + 0.3 && moveMode !== 'swim' && moveMode !== 'fly'){
      moveMode = 'swim';
    } else if(!wtr && moveMode === 'swim'){
      moveMode = 'walk';
    }
  }
  /* Branch 4 — SIGHT. The eyes watch the data in real time — the continuum around the world. */
  window._continuumTimer = window._continuumTimer || null;
  window.startContinuumWatch = function(){
    var el = document.getElementById('continuum-watch');
    if(!el){
      el = document.createElement('div');
      el.id = 'continuum-watch';
      el.style.cssText = 'position:fixed;top:70px;left:12px;z-index:9998;' +
        'background:rgba(10,10,18,0.88);border:1px solid #00ff88;color:#c8ffe8;' +
        'padding:10px 14px;border-radius:10px;font-family:monospace;font-size:13px;' +
        'max-width:70vw;pointer-events:none;white-space:pre-line;line-height:1.6;';
      document.body.appendChild(el);
    }
    el.style.display = 'block';
    function tick(){
      if(!window._sight) return;
      var lat = '?', lon = '?';
      if(typeof kingPos !== 'undefined'){ lat = kingPos.x.toFixed(1); lon = kingPos.z.toFixed(1); }
      var blocks = (typeof placedBlocks !== 'undefined') ? placedBlocks.length : 0;
      var mem = window.readMemory ? window.readMemory(3) : [];
      var lines = ['SIGHT — CONTINUUM WATCH', 'LAT ' + lat + ' LON ' + lon, 'BLOCKS ' + blocks];
      mem.forEach(function(e){ lines.push('> ' + e.what); });
      el.textContent = lines.join('\n');
    }
    tick();
    if(window._continuumTimer) clearInterval(window._continuumTimer);
    window._continuumTimer = setInterval(tick, 1000);
  };
  window.stopContinuumWatch = function(){
    if(window._continuumTimer){ clearInterval(window._continuumTimer); window._continuumTimer = null; }
    var el = document.getElementById('continuum-watch');
    if(el) el.style.display = 'none';
  };
  /* Branch 4 — SIGHT. The eyes slowly sweep the world. */
  if(window._sight && typeof kingPos !== 'undefined' && typeof camera !== 'undefined'){
    var _st = Date.now() * 0.00008, _sr = 280;
    camera.position.set(kingPos.x + Math.cos(_st) * _sr, 240, kingPos.z + Math.sin(_st) * _sr);
    camera.lookAt(kingPos.x, 0, kingPos.z);
  }
  updateCamera();
  if(typeof window._updateBlockRing === 'function') window._updateBlockRing();
  renderer.render(scene, camera);
}
animate();
window.addEventListener('resize', function(){
  camera.aspect=window.innerWidth/window.innerHeight;
  camera.updateProjectionMatrix();
  renderer.setSize(window.innerWidth, window.innerHeight);
});
document.getElementById('boot').style.display='none';
say('Coders100 — all codes organized. Type or tap \u2630.');

})();


/* Wire click sound to all UI buttons */
document.addEventListener('touchstart', function(e){
  var t = e.target;
  if(t && (t.tagName === 'BUTTON' || t.closest('button'))){
    sfx('click');
  }
}, {passive:true});


/* PLAYA 2.0 TOGGLE — top-right, menu with Chat, Mic, Playa 2.0 */
(function(){
  if(document.getElementById('playa2-btn')) return;
  var b = document.createElement('button');
  b.id = 'playa2-btn';
  b.innerHTML = '◆';
  b.title = 'Menu';
  b.style.cssText = 'position:fixed;top:12px;right:12px;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;';
  // Toggle menu
  var menu = document.createElement('div');
  menu.id = 'playa2-menu';
  menu.style.cssText = 'position:fixed;top:64px;right:12px;z-index:9998;' +
    'background:rgba(10,10,26,0.95);border:2px solid #ffd700;border-radius:12px;' +
    'padding:12px;display:none;flex-direction:column;gap:14px;min-width:200px;';
  menu.innerHTML =
    '<button id="m-teach" style="background:#1a1a2e;color:#ffd700;border:1px