<!-- RUBY-BACKUP · part 274 -->
dGroundY(bpx, bpz) + size/2;
        var bmesh = null;
        var bmat = new THREE.MeshStandardMaterial({color:0xffd700, metalness:0.5, roughness:0.4});
        if(shape==='box') bmesh = new THREE.Mesh(new THREE.BoxGeometry(size, size, size), bmat);
        else if(shape==='sphere') bmesh = new THREE.Mesh(new THREE.SphereGeometry(size/2, 16, 12), bmat);
        else if(shape==='tower') bmesh = new THREE.Mesh(new THREE.BoxGeometry(size/2, size*3, size/2), bmat);
        else if(shape==='wall') bmesh = new THREE.Mesh(new THREE.BoxGeometry(size*3, size, size/4), bmat);
        if(bmesh){
          bmesh.position.set(bpx, bpy, bpz);
          bmesh.name = 'bam-' + shape + '-' + Date.now() + '-' + bi;
          if(typeof scene!=='undefined') scene.add(bmesh);
          built++;
        }
      }
      /* batch loop handled all builds above */
        /* BACKUP: save to localStorage */
        try{
          var bamKey = 'bam-builds-v1';
          var builds = [];
          try{ builds = JSON.parse(localStorage.getItem(bamKey)||'[]'); }catch(e3){}
          builds.push({shape:shape, size:size, x:px, y:py, z:pz, count:count, line:lineMode, t:Date.now()});
          localStorage.setItem(bamKey, JSON.stringify(builds));
        }catch(e2){}
        codeStatus('BAM! ' + built + 'x ' + shape + ' built');
    }catch(e){ codeStatus('bam failed'); }
    return;
  }
  if(tl==='again'){
    try{
      if(window._lastBam){
        /* re-run last bam */
        var evt = window._lastBam;
        codeStatus('Again: ' + evt);
        /* simulate by directly calling — simplest: set and reprocess */
        setTimeout(function(){
          try{
            var input = document.querySelector('input');
            if(input){ input.value = evt; }
            /* find and click send */
            var sendBtns = document.querySelectorAll('button');
            for(var i=0; i<sendBtns.length; i++){
              if(sendBtns[i].textContent.toLowerCase().indexOf('send')>=0){
                sendBtns[i].click(); break;
              }
            }
          }catch(e){}
        }, 100);
      }else{
        codeStatus('Nothing to repeat yet');
      }
    }catch(e){}
    return;
  }
  if(tl==='nightcity'){
    try{
      /* night mode: dark sky, glowing windows */
      if(typeof skyState==='function') skyState('night');
      /* boost all window emissives */
      if(typeof scene!=='undefined'){
        scene.traverse(function(o){
          if(o.name && o.name.indexOf('win')>=0 && o.material && o.material.emissive){
            o.material.emissiveIntensity = 1.0;
          }
        });
      }
      codeStatus('NIGHT CITY — the lights are on');
    }catch(e){}
    return;
  }
  if(tl==='daycity'){
    try{
      if(typeof skyState==='function') skyState('day');
      if(typeof scene!=='undefined'){
        scene.traverse(function(o){
          if(o.name && o.name.indexOf('win')>=0 && o.material && o.material.emissive){
            o.material.emissiveIntensity = 0.1;
          }
        });
      }
      codeStatus('DAY CITY');
    }catch(e){}
    return;
  }
  if(tl==='intaglio'){
    /* Ultra-dense intaglio linework — thin tubes, renders clean */
    try{
      var density = 60; /* lines per building */
      var goldMat = new THREE.MeshBasicMaterial({color:0xffd700});
      var count = 0;
      if(typeof scene!=='undefined'){
        scene.traverse(function(o){
          if(o.name && (o.name.indexOf('city-bld')===0 || o.name.indexOf('downtown')===0) && count < 20){
            var pos = o.position;
            var size = 8;
            try{
              if(o.geometry && o.geometry.parameters) size = o.geometry.parameters.width || 8;
            }catch(e){}
            /* crosshatch: diagonal thin tubes across each face */
            for(var li=0; li<density; li++){
              var t = li/density;
              /* front face diagonals */
              var lg = new THREE.TubeGeometry(
                new THREE.CatmullRomCurve3([
                  new THREE.Vector3(pos.x - size/2 + t*size, pos.y - size/2, pos.z + size/2 + 0.1),
                  new THREE.Vector3(pos.x - size/2 + t*size + size*0.3, pos.y + size/2, pos.z + size/2 + 0.1)
                ]), 4, 0.03, 4, false
              );
              var lm = new THREE.Mesh(lg, goldMat);
              lm.name = 'intaglio-line';
              scene.add(lm);
            }
            count++;
          }
        });
      }
      codeStatus('INTAGLIO — ultra-dense linework on ' + count + ' buildings');
    }catch(e){ codeStatus('intaglio failed'); }
    return;
  }
  if(tl==='bamtest'){
    /* Test the bam backup system */
    try{
      var bamKey = 'bam-builds-v1';
      var builds = [];
      try{ builds = JSON.parse(localStorage.getItem(bamKey)||'[]'); }catch(e2){}
      var count = builds.length;
      /* create a test build */
      var tx = 0, tz = 0;
      if(typeof mePos!=='undefined'){ tx = mePos.x; tz = mePos.z; }
      builds.push({sha