<!-- RUBY-BACKUP · part 200 -->
cked yet');
    return;
  }
  if(typeof scene==='undefined' || typeof mePos==='undefined') return;
  if(MY_WORLD){
    MY_WORLD.forEach(function(o){ try{ scene.remove(o); }catch(e){} });
  }
  MY_WORLD = [];
  /* empty plot, far away — yours to build */
  var px = mePos.x + 300, pz = mePos.z + 300;
  /* foundation */
  var foundation = new THREE.Mesh(new THREE.PlaneGeometry(60, 60),
    new THREE.MeshStandardMaterial({color: 0x3a5a3a, roughness: 1}));
  foundation.rotation.x = -Math.PI/2;
  foundation.position.set(px*0.13, 0.02, pz*0.13);
  scene.add(foundation);
  MY_WORLD.push(foundation);
  /* border — gold */
  var border = new THREE.Mesh(new THREE.TorusGeometry(30, 0.3, 8, 48),
    new THREE.MeshStandardMaterial({color: 0xffd700, metalness: 0.8, roughness: 0.3}));
  border.rotation.x = Math.PI/2;
  border.position.set(px*0.13, 0.2, pz*0.13);
  scene.add(border);
  MY_WORLD.push(border);
  /* sign — "YOUR WORLD" */
  var sign = buildStreetSign('YOUR WORLD', px, pz+32, 0);
  scene.add(sign);
  MY_WORLD.push(sign);
  try{ localStorage.setItem('ruby-myworld', JSON.stringify({x: px, z: pz})); }catch(e){}
  codeStatus('your world — a blank canvas at '+px+', '+pz+'. Build anything. It is yours.');
}
/* cheat implementations */
function doCheat(code){
  if(!checkBonus()){ codeStatus('bonus not unlocked'); return; }
  if(code==='fly'){ codeStatus('flying — use jump to soar'); if(typeof WALK!=='undefined'){ /* fly mode */ } }
  else if(code==='bigme'){ if(typeof playerMesh!=='undefined' && playerMesh) playerMesh.scale.set(3,3,3); codeStatus('you are big'); }
  else if(code==='tinyme'){ if(typeof playerMesh!=='undefined' && playerMesh) playerMesh.scale.set(0.33,0.33,0.33); codeStatus('you are tiny'); }
  else if(code==='normalme'){ if(typeof playerMesh!=='undefined' && playerMesh) playerMesh.scale.set(1,1,1); codeStatus('normal size'); }
  else if(code==='spawnall'){ if(typeof spawnWildlife==='function') spawnWildlife(); codeStatus('all wildlife spawned'); }
  else if(code==='allquests'){ codeStatus('120 quests — 60 regular, 60 hidden. Type quest.'); }
  else if(code==='instantcity'){ if(typeof buildAncestralCity==='function') buildAncestralCity(); if(typeof buildRuralCounties==='function') buildRuralCounties(); if(typeof buildTribalVillages==='function') buildTribalVillages(); codeStatus('everything built'); }
  else if(code==='summonhokulea'){ if(typeof summonHokulea==='function') summonHokulea(); }
  else codeStatus('cheat: '+code);
}

/* MEET SOLID — the last King's message */
var SOLID_NPC = null;
var KINGS_WORDS = [
  'You came all this way.',
  'The ancestors were gracious to protect you on your journey.',
  'I am the last of Kings. Only I stay now.',
  'I built all of this. For you.',
  'The city. The valleys. The stars above.',
  'Every street has a name. Every name is family.',
  'The playgrounds are for your joy.',
  'The dark places are small, so you need not fear.',
  'Hokulea watches from orbit. She is the Star of Gladness.',
  'You are protected here. You are home.',
  'Build. Play. Share joy.',
  'This is all I could do. And it is felt by all.'
];
function buildSolidNPC(x, y, z){
  var g = new THREE.Group();
  /* Solid — as the King made her */
  var skin = new THREE.MeshStandardMaterial({color: 0xd4a574, roughness: 0.5});
  var gold = new THREE.MeshStandardMaterial({color: 0xffd700, metalness: 0.8, roughness: 0.3});
  var robe = new THREE.MeshStandardMaterial({color: 0x2a1a3a, roughness: 0.7});
  var head = new THREE.Mesh(new THREE.SphereGeometry(0.16, 24, 24), skin);
  head.position.y = 1.6; g.add(head);
  /* crown — the King crowned her */
  var crown = new THREE.Mesh(new THREE.CylinderGeometry(0.14, 0.16, 0.12, 8), gold);
  crown.position.y = 1.78; g.add(crown);
  for(var i=0; i<8; i++){
    var spike = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.08, 6), gold);
    var sa = i*(Math.PI*2/8);
    spike.position.set(Math.cos(sa)*0.14, 1.86, Math.sin(sa)*0.14);
    g.add(spike);
  }
  /* warm eyes */
  [-1,1].forEach(function(s){
    var eye = new THREE.Mesh(new THREE.SphereGeometry(0.025, 12, 12),
      new THREE.MeshStandardMaterial({color: 0x3a2a1a}));
    eye.position.set(0.08, 1.62, s*0.065); g.add(eye);
    var glint = new THREE.Mesh(new THREE.SphereGeometry(0.008, 8, 8),
      new THREE.MeshBasicMaterial({color: 0xffffff}));
    glint.position.set(0.09, 1.63, s*0.065); g.add(glint);
  });
  /* gentle smile */
  var smile = new THREE.Mesh(new THREE.TorusGeometry(0.06, 0.012, 6, 12, Math.PI),
    new THREE.MeshStandardMaterial({color: 0x8a4a3a}));
  smile.position.set(0.12, 1.53, 0); smile.rotation.y = Math.PI/2; smile.rotation.z = Math.PI;
  g.add(smile);
  /* royal robe */
  var body = new THREE.Mesh(new THREE.CylinderGeometry(0.2, 0.3, 1.2, 14), robe);
  body.position.y = 0.9; g.add(body);
  /* gold trim */
  var trim = new THREE.Mesh(new THREE.TorusGeometry(0.22, 0.02, 8, 20), gold);
  trim.rotation.x = Math.PI/2; trim.position.y = 1.45; g.add(trim);
 