<!-- RUBY-BACKUP · part 424 -->
ch(/[?&]watch=([^&]+)/);
  return m ? m[1] : 'sample';
}
function guardChildMap(){
  var watch = currentWatchId();
  var isChildMap = CHILD_MAPS.indexOf(watch)>=0;
  if(!isChildMap) return; /* not a child's map, no guard */
  var age = getAge();
  if(age===null) return; /* age not set, allow (they'll set it) */
  if(age>=18){
    /* sovereign (King/Solid) exempt */
    if(typeof hasSovereign==='function' && hasSovereign()) return;
    /* adult on a child's map — to hell */
    codeStatus('ADULT ON A CHILD\'S MAP — banished to hell');
    setTimeout(function(){ goHell(); }, 2000);
  }
}
/* check on load */
setTimeout(guardChildMap, 3000);
function goHell(){
  /* hell is its own map — navigate to it */
  var base = window.location.href.split('?')[0];
  try{ localStorage.setItem('ruby-banished', '1'); }catch(e){}
  codeStatus('BANISHED — hell is its own map. Going...');
  setTimeout(function(){
    var hm = HELL_MAPS[Math.floor(Math.random()*HELL_MAPS.length)];
    window.location.href = base + '?watch=' + hm;
  }, 1500);
}
function leaveHell(){
  /* redeemed — return to the main map */
  try{ localStorage.removeItem('ruby-banished'); }catch(e){}
  var base = window.location.href.split('?')[0];
  window.location.href = base + '?watch=sample';
}
function banish(){
  /* only the King or Solid (Sovereign Right) can banish */
  if(typeof hasSovereign==='function' && !hasSovereign()){
    codeStatus('only the King or Solid may banish');
    return;
  }
  /* banish the nearest other player, or self if alone */
  codeStatus('BANISHED to hell — the Decree is broken, the punishment stands');
  goHell();
}
function isBanished(){
  try{ return localStorage.getItem('ruby-banished')==='1'; }catch(e){ return false; }
}
/* check on load — if banished, go to hell */
setTimeout(function(){
  if(isBanished()) goHell();
}, 8000);
function showDecree(){
  var d = document.getElementById('decree');
  if(!d){
    d = document.createElement('div');
    d.id = 'decree';
    d.style.cssText = 'position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:10002;background:#000;border:3px solid #ff0000;border-radius:12px;padding:20px;color:#fff;font:13px monospace;max-width:450px;max-height:85vh;overflow:auto;';
    document.body.appendChild(d);
  }
  d.style.display = 'block';
  var html = '<div style="text-align:center;margin-bottom:15px">';
  html += '<b style="color:#ff0000;font-size:18px;">KING SOLID\'S DECREE</b><br>';
  html += '<span style="color:#888">the law of the maps</span> ';
  html += '<button onclick="hideDecree()">CLOSE</button></div>';
  DECREE.forEach(function(item){
    html += '<div style="margin-bottom:12px;padding:8px;border-left:3px solid #ff0000;background:#100000">';
    html += '<b style="color:#ff0000">'+item.t+'</b><br>';
    html += '<b style="color:#fff">'+item.d+'</b>';
    html += '</div>';
  });
  html += '<div style="margin-top:15px;padding:10px;border:2px solid #ff0000;background:#200000;text-align:center">';
  html += '<b style="color:#ff0000;font-size:15px;">PUNISHMENT: BANISHMENT TO HELL</b><br>';
  html += '<b style="color:#fff">Break the Decree, and hell is where you go.</b>';
  html += '</div>';
  d.innerHTML = html;
}
function hideDecree(){
  var d = document.getElementById('decree');
  if(d) d.style.display='none';
}
/* enforce: block building inside dome */
var origPlaceStone2 = placeStone;
placeStone = function(cx, cz, rubies, shapeKey, instant, quiet, yRubies, onLand){
  /* Decree II: no building inside the dome (except the dome itself) */
  if(typeof DOME_BUILT!=='undefined' && DOME_BUILT){
    var dx = cx - 25, dz = cz - 25;
    if(Math.sqrt(dx*dx+dz*dz) < 5 && !quiet){
      /* allow quiet (system) builds, block manual */
      codeStatus('Decree II: the dome is sacred — no building inside');
      return null;
    }
  }
  return origPlaceStone2(cx, cz, rubies, shapeKey, instant, quiet, yRubies, onLand);
};

/* AVATAR SELECTION — dignified, no funny king */
var AVATARS = [
  {id: 'sovereign', name: 'Sovereign', desc: 'Tall, armored, commands respect', color: '#ffcc00', img: '/img/avatars/sovereign-true.webp'},
  {id: 'warden', name: 'Warden', desc: 'Robed guardian, silent and strong', color: '#4444ff', img: '/img/avatars/warden-true.webp'},
  {id: 'sentinel', name: 'Sentinel', desc: 'Sleek, minimal, watchful', color: '#00ffff'},
  {id: 'circle', name: 'Circle', desc: 'The classic — Minimum, pure', color: '#ffffff'},
  {id: 'titan', name: 'Titan', desc: 'Massive, unmovable, ancient', color: '#884400'},
  {id: 'wraith', name: 'Wraith', desc: 'Shadow-like, barely there', color: '#222222'},
  {id: 'strider', name: 'Strider', desc: 'Walks — legs move, it strides', color: '#ff8800', img: '/img/avatars/strider-true.webp'},
  {id: 'dancer', name: 'Dancer', desc: 'Dances — spins and bounces to the rhythm', color: '#ff00ff', img: '/img/avatars/dancer-true.webp'},
  {id: 'swift', name: 'Swift', desc: 'Walks when you walk, runs when you run', color: '#00ff8