<!-- RUBY-BACKUP · part 412 -->
xt = 'position:fixed;bottom:246px;right:14px;z-index:9999;width:46px;height:46px;background:#d8a920;color:#111;border:1px solid #d8a920;border-radius:50%;font-size:24px;line-height:1;padding:0;cursor:pointer;-webkit-tap-highlight-color:transparent;';
    b.onclick = toggleMoveMode;
    document.body.appendChild(b);
    updateMoveToggle();
  }
}, 3000);
/* gap filling — merge open spaces between objects */

/* CONNECTION COLOR + TEXTURE EDITING */
var CONN_COLOR = '#00ffcc'; /* default connection color */
var CONN_TEX = 'chrome'; /* default texture */
var CONN_LIST = []; /* tracks connection stones {x,z,y} */

function setConnColor(col){
  CONN_COLOR = col;
  try{ localStorage.setItem('ruby-conncolor', col); }catch(e){}
  codeStatus('connection color set to '+col+' — new connections use it');
}
function setConnTex(tex){
  CONN_TEX = tex;
  try{ localStorage.setItem('ruby-conntex', tex); }catch(e){}
  codeStatus('connection texture set to '+tex+' — new connections use it');
}
function getConnColor(){
  try{ return localStorage.getItem('ruby-conncolor')||CONN_COLOR; }catch(e){ return CONN_COLOR; }
}
function getConnTex(){
  try{ return localStorage.getItem('ruby-conntex')||CONN_TEX; }catch(e){ return CONN_TEX; }
}
/* apply color/tex to a connection stone */
function styleConnection(stone){
  if(!stone) return;
  var col = getConnColor();
  var tex = getConnTex();
  /* set material color */
  if(stone.material && stone.material.color){
    /* parse hex */
    var hex = col.replace('#','');
    if(hex.length===6){
      var r = parseInt(hex.substr(0,2),16)/255;
      var g = parseInt(hex.substr(2,2),16)/255;
      var b = parseInt(hex.substr(4,2),16)/255;
      stone.material.color.setRGB(r,g,b);
    }
  }
  /* texture name stored for reference */
  stone.userData.connTex = tex;
  stone.userData.isConnection = true;
}
/* recolor all existing connections */
function recolorConnections(){
  var count = 0;
  CONN_LIST.forEach(function(pos){
    if(typeof getStoneMesh==='function'){
      var mesh = getStoneMesh(pos.x, pos.z, pos.y);
      if(mesh){ styleConnection(mesh); count++; }
    }
  });
  codeStatus(count ? 'recolored '+count+' connections to '+getConnColor()+' / '+getConnTex() : 'no connections to recolor yet — build some first');
}
/* hook: when fillGaps creates a stone, mark as connection */
var origFillGaps = fillGaps;
function fillGaps(){
  if(typeof stones==='undefined' || typeof stoneAt==='undefined') return;
  var filled = 0;
  /* scan a 20x20 area around player */
  var px = Math.round(mePos.x), pz = Math.round(mePos.z);
  for(var dx=-10; dx<=10; dx++){
    for(var dz=-10; dz<=10; dz++){
      var x = px+dx, z = pz+dz;
      /* if empty at ground but neighbors exist, fill */
      if(!stoneAt(x, z, 0)){
        var neighbors = 0;
        [[1,0],[-1,0],[0,1],[0,-1]].forEach(function(d){
          if(stoneAt(x+d[0], z+d[1], 0)) neighbors++;
        });
        if(neighbors>=2){
          /* fill with small stone — precisely fits, never leaves empty */
          /* styled as a connection with user color/texture */
          if(typeof placeStone==='function'){
            var st = placeStone(x, z, 2, 'cube', true, true, 0, true);
            CONN_LIST.push({x:x, z:z, y:0});
            /* style it — find the mesh */
            setTimeout((function(px,pz){
              return function(){
                if(typeof getStoneMesh==='function'){
                  var mesh = getStoneMesh(px, pz, 0);
                  if(mesh) styleConnection(mesh);
                }
              };
            })(x,z), 100);
            filled++;
          }
        }
      }
    }
  }
  codeStatus(filled ? 'merged '+filled+' gaps — no empty space left' : 'no gaps to merge');
}

/* SUPER CONTROLLER — one panel, all systems, minimal code */
var SC_ON=false;
function sc(){
  SC_ON=!SC_ON;
  var p=document.getElementById('superctrl');
  if(SC_ON){
    if(!p){
      p=document.createElement('div');
      p.id='superctrl';
      p.style.cssText='position:fixed;top:10px;left:10px;z-index:9999;background:rgba(0,0,0,0.85);border:1px solid #00ffff;border-radius:10px;padding:10px;color:#fff;font:11px monospace;max-width:220px;';
      p.innerHTML=
        '<b style="color:#0ff">SOLIDITRONIUM</b><br>'+
        'SPAWN: <button onclick="setSpawnPoint();showSpawnMarker()">SET</button> <button onclick="spawnMoveHelp()">MOVE</button><br>'+
        'MOVE: <button id="sc-move" onclick="toggleMoveMode()">OFF</button><br>'+
        'DIM: <button onclick="setDim(2)">2D</button><button onclick="setDim(3)">3D</button><button onclick="setDim(4)">4D</button><button onclick="setDim(5)">5D</button><button onclick="setDim(6)">6D</button><br>'+
        'MAP: <button onclick="toggleHolomap()">HOLO</button><br>'+
        'WP: <button onclick="scWpSet()">SET</button> <button onclick="scWpGo()">GO</button><br>'+
        'CONN: <button onclick="scConnColor()">COLOR</button> <button onclick="scConnTex()">TEX</button> <button