<!-- RUBY-BACKUP · part 263 -->
tdir.x + _dz * _tdir.z;
        if(_along > 0 && _along < 40){
          var _px = _dx - _along * _tdir.x, _pz = _dz - _along * _tdir.z;
          if(Math.sqrt(_px*_px + _pz*_pz) < 5 && Math.abs(_dy) < 8) _inTunnel = true;
        }
        if(_dist < _br || _inTunnel){
          scene.remove(_blk);
          window._solidBlocks.splice(i, 1);
          _count++;
        }
      }
      /* Shockwave effect */
      try{
        var _sw = new THREE.Mesh(new THREE.SphereGeometry(_br, 16, 16),
          new THREE.MeshBasicMaterial({color: 0xffd700, transparent: true, opacity: 0.5}));
        _sw.position.set(_bx, _by, _bz);
        scene.add(_sw);
        setTimeout(function(){ scene.remove(_sw); }, 500);
      }catch(e){}
      if(typeof codeStatus==='function') codeStatus('BREAKOUT — ' + _count + ' blocks shattered');
    }catch(e){ if(typeof codeStatus==='function') codeStatus('breakout failed'); }
    return;
  }
  if(tl==='grassmap'){
    /* Grass blocks across the map, never on roads */
    try{
      var step = 20, count = 0;
      var grassTex = null;
      try{
        var _gl = new THREE.TextureLoader();
        grassTex = _gl.load('/ruby2/grass-top.png');
      }catch(e){}
      for(var gx = -500; gx <= 500; gx += step){
        for(var gz = -500; gz <= 500; gz += step){
          /* Skip near ancestor roads (city center spiral) */
          var _dc = Math.sqrt((gx-25)*(gx-25) + (gz+10)*(gz+10));
          if(_dc < 80) continue;
          /* Skip near known road lines */
          if(Math.abs(gx - 30) < 10 && Math.abs(gz - 200) < 100) continue;
          if(Math.abs(gx + 50) < 10 && Math.abs(gz - 400) < 100) continue;
          if(Math.abs(gx - 200) < 10 && Math.abs(gz - 300) < 100) continue;
          /* FLAT EARTH — fixed height, King's order */
          var gy = 0;
          var gGeo = new THREE.BoxGeometry(18, 2, 18);
          var gMat = new THREE.MeshStandardMaterial({color: 0x4a8f3c, roughness: 0.9});
          if(grassTex){ gMat.map = grassTex; }
          var blk = new THREE.Mesh(gGeo, gMat);
          blk.position.set(gx, gy + 1, gz);
          blk.userData.isGrass = true;
          scene.add(blk);
          count++;
          if(count > 2000) break;
        }
        if(count > 2000) break;
      }
      if(typeof codeStatus==='function') codeStatus('grass map — ' + count + ' blocks, roads clear');
      if(typeof trackNewThing==='function') trackNewThing('grassmap', 'Grass blocks across the map');
    }catch(e){ if(typeof codeStatus==='function') codeStatus('grassmap failed'); }
    return;
  }
  if(tl==='fillmap'){
    /* Fill the map with solid blocks except at the heart. Baby steps below. */
    try{
      if(!window._solidBlocks) window._solidBlocks = [];
      var heartR = 50; /* heart radius — stays open */
      var step = 20; /* block spacing */
      var count = 0;
      for(var gx = -1000; gx <= 1000; gx += step){
        for(var gz = -1000; gz <= 1000; gz += step){
          var dc = Math.sqrt(gx*gx + gz*gz);
          if(dc < heartR) continue; /* skip the heart */
          var gy = fortifiedGroundY(gx, gz);
          /* Baby step below the map */
          var bGeo = new THREE.BoxGeometry(4, 1, 4);
          var bMat = new THREE.MeshStandardMaterial({color: 0x5a5a5a, roughness: 0.9});
          var baby = new THREE.Mesh(bGeo, bMat);
          baby.position.set(gx, gy - 1, gz);
          baby.userData.solid = true;
          baby.userData.solidBox = new THREE.Box3().setFromObject(baby);
          scene.add(baby);
          window._solidBlocks.push(baby);
          /* Solid block on the surface */
          var sGeo = new THREE.BoxGeometry(6, 6, 6);
          var sMat = new THREE.MeshStandardMaterial({color: 0x8B4513, roughness: 0.8, metalness: 0.2});
          var blk = new THREE.Mesh(sGeo, sMat);
          blk.position.set(gx, gy + 3, gz);
          blk.userData.solid = true;
          blk.userData.solidBox = new THREE.Box3().setFromObject(blk);
          scene.add(blk);
          window._solidBlocks.push(blk);
          count += 2;
          if(count > 2000) break; /* safety cap */
        }
        if(count > 2000) break;
      }
      if(typeof codeStatus === 'function') codeStatus('map filled — ' + count + ' stones, heart open');
    }catch(e){ if(typeof codeStatus === 'function') codeStatus('fill failed: ' + e.message); }
    return;
  }
  if(tl==='clearfill'){
    if(!window._isAdmin) return;
    try{
      if(window._solidBlocks){
        if(typeof window.trackNewThing === 'function')
          window.trackNewThing('REMOVED all blocks (' + window._solidBlocks.length + ')', 0, 0, 0);
        window._solidBlocks.forEach(function(b){
          scene.remove(b);
          if(b.geometry) b.geometry.dispose();
          if(b.material) b.material.dispose();
        });
        window._solidBlocks = [];
      }
      if(typeof codeStatus === 'function') codeStatus('map cleared by admin');
    }catch(e){}
    return;
  }
  if(tl==='solidblock')