<!-- RUBY-BACKUP · part 551 -->
      arm.position.set(px, 11, pz);
      arm.name = 'power-arm';
      g.add(arm);
      if(prevTop){
        var dirx = px-prevTop.x, dirz = pz-prevTop.z;
        var len = Math.sqrt(dirx*dirx+dirz*dirz);
        var wire = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.05, len, 6), wireMat);
        wire.position.set((px+prevTop.x)/2, 11, (pz+prevTop.z)/2);
        wire.rotation.z = Math.PI/2;
        wire.rotation.y = -Math.atan2(dirz, dirx);
        wire.name = 'power-wire';
        g.add(wire);
      }
      prevTop = {x:px, z:pz};
    }
    g.userData.isPrimitive = true;
    if(typeof scene!=='undefined') scene.add(g);
    if(typeof codeStatus==='function') codeStatus(count+' power poles stand');
    if(typeof pushCommand==='function'){
      var sr = (typeof scene!=='undefined') ? scene : null;
      pushCommand({name:'build powerline', execute:function(){ if(sr) sr.add(g); }, undo:function(){ if(sr) sr.remove(g); }});
    }
  }catch(e){
    if(typeof codeStatus==='function') codeStatus('powerline failed');
  }finally{
    _buildingPower = false;
  }
}
/* creator block loads on start, every time — locked in */
setTimeout(function(){ try{ if(typeof buildCreatorBlock==='function') buildCreatorBlock(); }catch(e){} }, 2500);
/* ALL BUTTONS PERMANENT — like the streets, always there */
function makeButtonsPermanent(){
  try{
    var ids = ['joy','joyknob','jumpbtn','flybtn','homebtn','grabbtn','creatorblockbtn','creatorcompass','streetmap','expandbtn','musicbtn','songbtn'];
    ids.forEach(function(id){
      var el = document.getElementById(id);
      if(el){
        el.style.setProperty('display', '', 'important');
        el.style.display = 'block';
        el.style.visibility = 'visible';
        el.style.opacity = '1';
      }
    });
    /* no more 5s loop — buttons set once, they stay */
  }catch(e){}
}
setTimeout(makeButtonsPermanent, 3000);
/* CONTROLS-ONLY VIEW — just the toggle and buttons */
(function(){
  var CONTROLS_ONLY = false;
  function toggleControlsOnly(){
    CONTROLS_ONLY = !CONTROLS_ONLY;
    try{
      var canvas = document.querySelector('canvas');
      if(canvas) canvas.style.display = CONTROLS_ONLY ? 'none' : '';
      // hide everything except joystick and buttons
      var keep = ['joy','joyknob','jumpbtn','flybtn','homebtn','grabbtn','expandbtn','creatorblockbtn','creatorcompass','streetmap'];
      document.querySelectorAll('body > *').forEach(function(el){
        if(el.tagName==='SCRIPT' || el.tagName==='STYLE') return;
        var id = el.id || '';
        var isControl = keep.some(function(k){ return id.indexOf(k)===0 || id===k; });
        // also keep the control buttons by class
        if(el.classList && el.classList.contains('modebtn')) isControl = true;
        if(!isControl){
          el.style.display = CONTROLS_ONLY ? 'none' : '';
        }
      });
      // black background
      document.body.style.background = CONTROLS_ONLY ? '#000' : '';
      if(typeof codeStatus==='function') codeStatus(CONTROLS_ONLY ? 'controls only' : 'world back');
    }catch(e){}
  }
  window._controlsOnly = toggleControlsOnly;
})();
/* COMPASS to the creator block + MAP of the streets */
(function(){
  var compassEl = null;
  var mapEl = null;
  var mapCanvas = null;
  function init(){
    // compass — points to the creator block
    compassEl = document.createElement('div');
    compassEl.id = 'creatorcompass';
    compassEl.style.cssText = 'position:fixed;top:70px;right:14px;z-index:10000;width:80px;height:80px;background:rgba(0,0,0,0.7);border:2px solid #cc0000;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:28px;';
    compassEl.innerHTML = '<div id="compassarrow" style="transform-origin:center;">◈</div>';
    compassEl.title = 'Compass to Creator Block';
    document.body.appendChild(compassEl);
    // street map — minimap
    mapEl = document.createElement('div');
    mapEl.id = 'streetmap';
    mapEl.style.cssText = 'position:fixed;top:160px;right:14px;z-index:10000;width:80px;height:80px;background:rgba(0,0,0,0.7);border:2px solid #d8a920;border-radius:10px;overflow:hidden;';
    mapEl.title = 'Street Map';
    mapCanvas = document.createElement('canvas');
    mapCanvas.width = 80;
    mapCanvas.height = 80;
    mapEl.appendChild(mapCanvas);
    document.body.appendChild(mapEl);
    // tap map to toggle
    mapEl.addEventListener('click', function(){
      mapEl.style.display = mapEl.style.display==='none' ? '' : 'none';
    });
    requestAnimationFrame(update);
  }
  function update(){
    try{
      // compass: point to creator block
      if(window._creatorBlock && typeof mePos!=='undefined'){
        var bx = window._creatorBlock.position.x;
        var bz = window._creatorBlock.position.z;
        var dx = bx - mePos.x;
        var dz = bz - mePos.z;
        var angle = Math.atan2(dx, dz);
        // adjust for camera yaw
        var camAngle = (typeof camYaw!=='undefined') ? camYaw : 0;
        v