<!-- RUBY-BACKUP · part 171 -->
domeDoorPos(){ return {x: DOME_CX, z: DOME_CZ + DOME_R + 1}; }
function domeInsidePos(){ return {x: DOME_CX, z: DOME_CZ}; }
function isInsideDome(){
  if(typeof mePos==='undefined') return false;
  var dx = mePos.x - DOME_CX, dz = mePos.z - DOME_CZ;
  return Math.sqrt(dx*dx+dz*dz) < DOME_R;
}

/* SOVEREIGN RIGHT — Solid holds all codes */
var SOVEREIGN_RIGHT = true; /* Solid: full access, no restrictions */
var IS_KING = false; /* set true for the King's client */
function hasSovereign(){ return SOVEREIGN_RIGHT; }

/* KING'S BUILDING CODES — 200, titled, described, 25 per page */
var BUILD_CODES = [{"code": "found1", "title": "Stone Foundation", "desc": "Lays a solid stone base for any structure", "cat": "Foundations"}, {"code": "found2", "title": "Deep Footing", "desc": "Digs deep and sets an unshakable foundation", "cat": "Foundations"}, {"code": "found3", "title": "Platform Base", "desc": "Creates a flat platform to build upon", "cat": "Foundations"}, {"code": "found4", "title": "Pillar Foot", "desc": "Sets a single strong pillar as foundation", "cat": "Foundations"}, {"code": "found5", "title": "Cornerstone", "desc": "Places the ceremonial first stone", "cat": "Foundations"}, {"code": "found6", "title": "Raft Slab", "desc": "A wide flat slab that floats on any terrain", "cat": "Foundations"}, {"code": "found7", "title": "Stepped Base", "desc": "Tiered foundation, three levels deep", "cat": "Foundations"}, {"code": "found8", "title": "Circular Pad", "desc": "Round foundation for towers and domes", "cat": "Foundations"}, {"code": "found9", "title": "Bridge Abutment", "desc": "Foundation engineered for bridge ends", "cat": "Foundations"}, {"code": "found10", "title": "Retaining Wall", "desc": "Holds back earth, creates level ground", "cat": "Foundations"}, {"code": "found11", "title": "Pier Foundation", "desc": "Deep piers for waterfront building", "cat": "Foundations"}, {"code": "found12", "title": "Mat Slab", "desc": "Thick slab spreading weight evenly", "cat": "Foundations"}, {"code": "found13", "title": "Grade Beam", "desc": "Connects footings into one solid frame", "cat": "Foundations"}, {"code": "found14", "title": "Helical Pier", "desc": "Screws deep for unstable ground", "cat": "Foundations"}, {"code": "found15", "title": "Floating Dock", "desc": "Foundation that rides the water", "cat": "Foundations"}, {"code": "found16", "title": "Cliff Anchor", "desc": "Bolts your build to the cliff face", "cat": "Foundations"}, {"code": "found17", "title": "Sky Platform", "desc": "Foundation suspended in the air", "cat": "Foundations"}, {"code": "found18", "title": "Ice Footing", "desc": "Sets firm even on frozen ground", "cat": "Foundations"}, {"code": "found19", "title": "Sand Pad", "desc": "Stabilizes shifting desert sand", "cat": "Foundations"}, {"code": "found20", "title": "Bedrock Key", "desc": "Locks directly into the bedrock below", "cat": "Foundations"}, {"code": "wall1", "title": "Straight Wall", "desc": "A clean straight wall, ten stones long", "cat": "Walls"}, {"code": "wall2", "title": "Corner Wall", "desc": "L-shaped wall for building corners", "cat": "Walls"}, {"code": "wall3", "title": "Curved Wall", "desc": "Gently arcing wall, smooth and strong", "cat": "Walls"}, {"code": "wall4", "title": "High Wall", "desc": "Towering wall, twenty stones tall", "cat": "Walls"}, {"code": "wall5", "title": "Low Wall", "desc": "Garden-height wall, easy to see over", "cat": "Walls"}, {"code": "wall6", "title": "Thick Wall", "desc": "Double-wide, fortress grade", "cat": "Walls"}, {"code": "wall7", "title": "Thin Partition", "desc": "Single-stone divider for interiors", "cat": "Walls"}, {"code": "wall8", "title": "Window Wall", "desc": "Wall with window openings built in", "cat": "Walls"}, {"code": "wall9", "title": "Door Wall", "desc": "Wall with a doorframe ready", "cat": "Walls"}, {"code": "wall10", "title": "Crenellated", "desc": "Castle top with battlements", "cat": "Walls"}, {"code": "wall11", "title": "Slanted Wall", "desc": "Leans at an angle, modern style", "cat": "Walls"}, {"code": "wall12", "title": "Stepped Wall", "desc": "Stairs up in sections", "cat": "Walls"}, {"code": "wall13", "title": "Circular Wall", "desc": "Round enclosure, perfect circle", "cat": "Walls"}, {"code": "wall14", "title": "Zigzag Wall", "desc": "Angular defensive pattern", "cat": "Walls"}, {"code": "wall15", "title": "Glass Wall", "desc": "Transparent, light flows through", "cat": "Walls"}, {"code": "wall16", "title": "Living Wall", "desc": "Stone with green growing through", "cat": "Walls"}, {"code": "wall17", "title": "Glowing Wall", "desc": "Embedded with soft blue light", "cat": "Walls"}, {"code": "wall18", "title": "Carved Wall", "desc": "Intricate patterns etched in stone", "cat": "Walls"}, {"code": "wall19", "title": "Ruined Wall", "desc": "Ancient, broken, full of character", "cat": "Walls"}, {"code": "wall20", "title": "Invisible Wall", "desc": "Barrier you can see through but not pass", 