<!-- RUBY-BACKUP · part 137 -->
k.material && typeof blk.material.opacity!=='undefined'){
        slider.value = Math.round(blk.material.opacity*100);
      }
    }catch(e){}
    var label = document.createElement('div');
    label.style.cssText = 'color:#fff;font-size:12px;';
    label.textContent = slider.value + '%';
    slider.oninput = function(){
      var v = parseInt(slider.value)/100;
      label.textContent = slider.value + '%';
      try{
        blk.traverse ? blk.traverse(function(o){
          if(o.material){ o.material.transparent = v<1; o.material.opacity = v; }
        }) : (function(){
          if(blk.material){ blk.material.transparent = v<1; blk.material.opacity = v; }
        })();
      }catch(e){}
    };
    d.appendChild(slider);
    d.appendChild(label);
    var x = document.createElement('button');
    x.textContent = '\u2715'; x.title = 'Os';
    x.style.cssText = 'width:40px;height:40px;font-size:16px;background:#d8a920;color:#111;'
      + 'border:none;border-radius:50%;cursor:pointer;';
    x.onclick = function(){ document.body.removeChild(d); try{ codeStatus('Opacity set.'); }catch(e){} };
    d.appendChild(x);
    document.body.appendChild(d);
  }catch(e){}
}
function showBuildOptions(block, sx, sy){
  try{
    var old = document.getElementById('lpbuildmenu');
    if(old) document.body.removeChild(old);
    var m = document.createElement('div');
    m.id = 'lpbuildmenu';
    m.style.cssText = 'position:fixed;left:' + Math.max(8, (sx-70)) + 'px;top:' + Math.max(8, (sy-180)) + 'px;z-index:20003;'
      + 'background:rgba(10,10,15,0.95);border:2px solid #ffd700;border-radius:12px;padding:8px;'
      + 'display:flex;flex-direction:column;gap:6px;max-height:60vh;overflow-y:auto;-webkit-overflow-scrolling:touch;';
    var opts = [
      ['🎯','calibrate', function(){ if(typeof runCodeByName==='function') runCodeByName('calibrate'); }],
      ['🥞','layer', function(){ if(typeof runCodeByName==='function') runCodeByName('layer'); }],
      ['🧲','snap', function(){ if(typeof runCodeByName==='function') runCodeByName('snap'); }],
      ['✂️','section', function(){ if(typeof runCodeByName==='function') runCodeByName('section'); }],
      ['🌊','smooth', function(){ if(typeof runCodeByName==='function') runCodeByName('smooth'); }],
      ['⚔️','sharpen', function(){ if(typeof runCodeByName==='function') runCodeByName('sharpen'); }],
      ['🌙','bend', function(){ if(typeof runCodeByName==='function') runCodeByName('bend'); }],
      ['↔️','stretch', function(){ if(typeof runCodeByName==='function') runCodeByName('stretch'); }],
      ['🔄','flip', function(){ if(typeof runCodeByName==='function') runCodeByName('flip'); }],
      ['🕳️','hollow', function(){ if(typeof runCodeByName==='function') runCodeByName('hollow'); }],
      ['👥','duplicate', function(){ if(typeof runCodeByName==='function') runCodeByName('duplicate'); }],
      ['🎨','color', function(){ if(typeof runCodeByName==='function') runCodeByName('color'); }],
      ['↩️','undo', function(){ if(typeof runCodeByName==='function') runCodeByName('undo'); }],
      ['🤲','creator', function(){ if(typeof warpFixStation==='function') warpFixStation(); }],
      ['◐','opacity', function(){ showOpacityShifter(); }]
    ];
    opts.forEach(function(o){
      var b = document.createElement('button');
      b.textContent = o[0]; b.title = o[1];
      b.style.cssText = 'width:52px;height:52px;font-size:24px;background:rgba(255,215,0,0.1);'
        + 'border:1px solid #8a6a1c;border-radius:50%;cursor:pointer;';
      b.onclick = function(){ try{ o[2](); }catch(e){} document.body.removeChild(m); };
      m.appendChild(b);
    });
    var x = document.createElement('button');
    x.textContent = '\u2715'; x.title = 'Os';
    x.style.cssText = 'width:40px;height:40px;font-size:16px;background:#d8a920;color:#111;'
      + 'border:none;border-radius:50%;cursor:pointer;align-self:center;';
    x.onclick = function(){ document.body.removeChild(m); };
    m.appendChild(x);
    document.body.appendChild(m);
    try{ codeStatus('Build options.'); }catch(e){}
  }catch(e){}
}
canvas.addEventListener('pointerdown', function(e){
  shapePanel.classList.remove('open');
  if(typeof renderPanel !== 'undefined') renderPanel.classList.remove('open');
  canvas.setPointerCapture && canvas.setPointerCapture(e.pointerId);
  pointers[e.pointerId] = ptrPos(e);
  downInfo = {x:e.clientX, y:e.clientY, t:performance.now(), moved:0, n:Object.keys(pointers).length};
  /* long-press detection */
  _lpFired = false;
  cancelLongPress();
  (function(px, py){
    _lpTimer = setTimeout(function(){
      try{
        if(downInfo && downInfo.moved < 10){
          _lpFired = true;
          /* raycast to find the block */
          if(typeof raycaster!=='undefined' && typeof camera!=='undefined' && typeof THREE!=='undefined'){
            var mv = new THREE.Vector2((px/window.innerWidth)*2-1, -(py/window.innerHeight)*2+1);
            raycaster.setFromCamera(mv, came