<!-- RUBY-BACKUP · part 545 -->
Creator(); }
        if(typeof codeStatus==='function') codeStatus('Playa 2.0 engaged — build');
      }
    }catch(err){}
  }
  if(typeof document!=='undefined'){
    document.addEventListener('click', onTap, true);
  }
})();
/* ANCESTOR HIGHWAY SIGNS — each name individually (streets come later) */
var ANCESTOR_NAMES = [
'Maui-Potiki','Hihiriotu','Maui-tikitiki-a-Taranga','Taharawa','Hekaponga',
'Toi-Kai-Rakau','Rua-rangi-takin','Whatoma','Poutiriao','Te Manutohikura-a-tane',
'Uenuku','Kamea','Pohukaina','Hua','Pau',
'Huanuikalalailai','Paumakua','Haho','Palena','Hanalaanui',
'Lanakawai','Pili','Koa','Loe','Kaniuhi',
'Kukohou','Kanipahu','Kalapanakuioiomoa','Kahaimoelea','Kalaunuiohua',
'Kuaiwa','Kahoukapu','Kauholanuimahu','Kiha-nui-lulu-moku','Liloa',
'Hakau','Kealiiokaloa','Umi-a-Liloa','Kukailani','Kapukamola',
'Makakaualii','Iwikauikaua','Kaneikaiwilani','Kalanikauleleiawi','Keawe',
'Kalaninuiiamamao','Keawemauhili','Mokulani','Papaikaniaunui','Ululani',
'Kaiwaokalani','Kanakaole','Wilcox','Kailiwai','Kamaile'
]; /* 55 ancestors — no doubles, one name each */
function buildHighwaySigns(parentGroup){ /* signs attach TO the highways — one body */
  try{
    // NEVER replace — only build if missing (King's law)
    var g = parentGroup || window._streets;
    if(!g){
      if(window._highwaySigns) return; // already there, don't rebuild
      g = new THREE.Group();
      var _separate = true;
    }
    // positions along the winding roads — one sign per name
    // 55 positions — spread along all roads, one per ancestor
    var positions = [];
    // road 1 east (12 signs)
    var r1 = [[50,15],[100,12],[200,20],[350,25],[500,35],[650,40],[800,55],[950,50],[1100,65]];
    // road 2 southeast (10 signs)
    var r2 = [[40,-25],[70,-30],[100,-38],[140,-36],[180,-35],[230,-40],[280,-45],[330,-48],[400,-50],[480,-45]];
    // road 3 north (10 signs)
    var r3 = [[-15,50],[-12,80],[-18,110],[-25,150],[-30,200],[-28,250],[-25,300],[-22,350],[-20,400],[-30,480]];
    // road 4 northeast (8 signs)
    var r4 = [[20,55],[18,80],[22,110],[28,150],[35,220],[32,280],[30,350],[40,450]];
    // road 5 west (8 signs)
    var r5 = [[-50,-15],[-80,-12],[-110,-14],[-150,-20],[-200,-30],[-280,-25],[-350,-28],[-450,-35]];
    // road 6 south (7 signs)
    var r6 = [[15,-50],[12,-80],[18,-110],[25,-150],[30,-200],[28,-280],[35,-400]];
    positions = r1.concat(r2, r3, r4, r5, r6);
    for(var i=0; i<ANCESTOR_NAMES.length && i<positions.length; i++){
      var name = ANCESTOR_NAMES[i];
      var px = positions[i][0], pz = positions[i][1];
      // sign post
      var post = new THREE.Mesh(
        new THREE.CylinderGeometry(0.1, 0.1, 3, 8),
        new THREE.MeshStandardMaterial({color:0x333333, roughness:0.7})
      );
      post.position.set(px, 1.5, pz);
      post.name = 'hwy-post-'+name;
      g.add(post);
      // sign board with the name
      var canvas = document.createElement('canvas');
      canvas.width = 512;
      canvas.height = 128;
      var ctx = canvas.getContext('2d');
      // black background, gold intaglio border
      ctx.fillStyle = '#0a0a0a';
      ctx.fillRect(0, 0, 512, 128);
      ctx.strokeStyle = '#d8a920';
      ctx.lineWidth = 4;
      ctx.strokeRect(8, 8, 496, 112);
      ctx.strokeStyle = '#d8a920';
      ctx.lineWidth = 2;
      ctx.strokeRect(16, 16, 480, 96);
      // name in gold
      ctx.fillStyle = '#ffd700';
      ctx.font = 'bold 48px serif';
      ctx.textAlign = 'center';
      ctx.textBaseline = 'middle';
      ctx.fillText(name, 256, 64);
      var tex = new THREE.CanvasTexture(canvas);
      var board = new THREE.Mesh(
        new THREE.BoxGeometry(4, 1, 0.1),
        new THREE.MeshStandardMaterial({map: tex, roughness:0.5})
      );
      board.position.set(px, 3.2, pz);
      board.name = 'hwy-'+name;
      // face the road
      board.rotation.y = Math.atan2(px, pz);
      g.add(board);
    }
    g.userData.isPrimitive = true;
    if(typeof _separate!=='undefined' && _separate){
      if(typeof scene!=='undefined') scene.add(g);
      window._highwaySigns = g;
    }
    /* else: signs live inside the highway group — permanently fixed */
    var sceneRef = (typeof scene!=='undefined') ? scene : null;
    pushCommand({
      name: 'build highway signs',
      execute: function(){ if(sceneRef) sceneRef.add(g); },
      undo: function(){ if(sceneRef) sceneRef.remove(g); }
    });
    if(typeof codeStatus==='function') codeStatus(ANCESTOR_NAMES.length + ' ancestor signs stand');
  }catch(e){ if(typeof codeStatus==='function') codeStatus('highway signs failed'); }
}
/* DISTRICT ACTIVATION — King chooses what loads, nothing auto */
window._districts = {};
function registerDistrict(name, label, buildFn){
  window._districts[name] = {label:label, build:buildFn, loaded:false};
}
function toggleDistrict(name){
  try{
    var d = window._districts[name];
    if(!d) return;
    if(!d.loaded){
      d.build();
      d.loaded = true;
      if(typeof codeSt