<!-- RUBY-BACKUP · part 260 -->
        _toRemove.push(obj);
          }
        }
        /* Red glowing meshes */
        if(obj.isMesh && obj.material && obj.material.emissive){
          var _e = obj.material.emissive.getHex();
          if(_e === 0xff0000 || _e === 0xff2222){
            _toRemove.push(obj);
          }
        }
      });
      _toRemove.forEach(function(obj){
        if(obj.parent) obj.parent.remove(obj);
        else scene.remove(obj);
        _count++;
      });
      /* Also clear from solid blocks list */
      if(window._solidBlocks){
        for(var i = window._solidBlocks.length - 1; i >= 0; i--){
          var _blk = window._solidBlocks[i];
          if(_blk && _blk.material && _blk.material.color && _blk.material.color.getHex() === 0x8B4513){
            var _dx = _blk.position.x - mePos.x, _dz = _blk.position.z - mePos.z;
            if(Math.sqrt(_dx*_dx + _dz*_dz) < 30){
              scene.remove(_blk);
              window._solidBlocks.splice(i, 1);
              _count++;
            }
          }
        }
      }
      if(typeof codeStatus==='function') codeStatus('RED GONE — ' + _count + ' objects removed');
    }catch(e){ if(typeof codeStatus==='function') codeStatus('nored failed'); }
    return;
  }
  if(tl==='deletejail'){
    /* DELETE THE JAIL — King's order 2026-10-03. Removes solid blocks at (25,-10), preserves the frame below y=5. */
    var _jc = 0;
    try{
      var _jb = (typeof _solidBlocks !== 'undefined' ? _solidBlocks : (typeof _blocks !== 'undefined' ? _blocks : []));
      for(var _ji = _jb.length - 1; _ji >= 0; _ji--){
        var _jm = _jb[_ji];
        if(!_jm || !_jm.position) continue;
        var _jdx = _jm.position.x - 25, _jdz = _jm.position.z - (-10);
        if(Math.sqrt(_jdx*_jdx + _jdz*_jdz) < 40 && _jm.position.y > 5){
          if(_jm.parent) _jm.parent.remove(_jm);
          _jb.splice(_ji, 1);
          _jc++;
        }
      }
    }catch(e){}
    if(typeof codeStatus==='function') codeStatus('JAIL DELETED — ' + _jc + ' blocks removed');
    return;
  }
  if(tl==='spawnstone'){
    /* HOLDABLE SPAWN STONE — King's order 2026-10-03. A ruby he carries, places where he wants to spawn. */
    try{
      var _sg = new THREE.OctahedronGeometry(1.5);
      var _sm = new THREE.MeshStandardMaterial({color:0x00ffff, emissive:0x00ffff, emissiveIntensity:2, roughness:0.2, metalness:0.8});
      var _stone = new THREE.Mesh(_sg, _sm);
      _stone.position.set(mePos.x, mePos.y + 3, mePos.z);
      _stone.userData.spawnstone = true;
      _stone.userData.holdable = true;
      scene.add(_stone);
      window._spawnstone = _stone;
      /* Pulsing animation */
      if(!window._spawnstonePulse){
        window._spawnstonePulse = setInterval(function(){
          if(window._spawnstone){
            var _p = 1 + Math.sin(Date.now() * 0.005) * 0.2;
            window._spawnstone.scale.set(_p, _p, _p);
            window._spawnstone.rotation.y += 0.02;
          }
        }, 50);
      }
      if(typeof codeStatus==='function') codeStatus('SPAWN STONE — carry it where you want, then type setspawn');
    }catch(e){ if(typeof codeStatus==='function') codeStatus('spawnstone failed: ' + e.message); }
    return;
  }
  if(tl==='setspawn'){
    /* DESIGNATE SPAWN — sets spawn to current position, removes old marker. King's order 2026-10-03. */
    try{
      /* Use cursor if placed on map, else player position */
      var _nx, _nz;
      if(typeof cursor !== 'undefined' && cursor && (Math.abs(cursor.x) > 0.5 || Math.abs(cursor.z) > 0.5)){
        _nx = Math.round(cursor.x); _nz = Math.round(cursor.z);
      } else {
        _nx = Math.round(mePos.x); _nz = Math.round(mePos.z);
      }
      /* Save to localStorage so it persists */
      try{ localStorage.setItem('ruby-spawn', JSON.stringify({x:_nx, z:_nz})); }catch(e){}
      /* Remove old spawnstone */
      if(window._spawnstone){
        if(window._spawnstone.parent) window._spawnstone.parent.remove(window._spawnstone);
        window._spawnstone = null;
      }
      /* Remove old Cloud 9 marker circle */
      try{
        scene.traverse(function(obj){
          if(obj && obj.userData && obj.userData.spawncircle){
            if(obj.parent) obj.parent.remove(obj);
          }
        });
      }catch(e){}
      /* Build new marker at this spot */
      var _mg = new THREE.TorusGeometry(3, 0.3, 8, 32);
      var _mm = new THREE.MeshBasicMaterial({color:0x00ffff});
      var _marker = new THREE.Mesh(_mg, _mm);
      _marker.rotation.x = -Math.PI/2;
      _marker.position.set(_nx, groundY(_nx, _nz) + 0.5, _nz);
      _marker.userData.spawncircle = true;
      scene.add(_marker);
      if(typeof codeStatus==='function') codeStatus('SPAWN SET — LAT ' + _nz + ' LON ' + _nx + ' (from map). Old spawn removed.');
    }catch(e){ if(typeof codeStatus==='function') codeStatus('setspawn failed: ' + e.message); }
    return;
  }
  if(tl==='clearspawn'){
    try{ localStorage.removeItem('ruby-spawn'); }catch(e){}
