<!-- RUBY-BACKUP · part 277 -->
, 'cyl', true, true, 0, true);
      }
      placeStone(ox, oz, 3, 'cube', true, true, 8, true);
      placeStone(ox, oz-2, 6, 'pyramid', true, true, 11, true);
    }catch(e){}
    codeStatus('portico raised'); return; }
  if(tl==='rotunda'){
    var ox=cursor.x, oz=cursor.z;
    try{
      for(var i=0; i<8; i++){
        var a=i/8*2*Math.PI;
        placeStone(ox+6*Math.cos(a), oz+6*Math.sin(a), 7, 'cyl', true, true, 0, true);
      }
      placeStone(ox, oz, 8, 'cyl', true, true, 0, true);
      placeStone(ox, oz, 7, 'sphere', true, true, 8, true);
    }catch(e){}
    codeStatus('rotunda built'); return; }
  if(tl==='buttress'){
    var ox=cursor.x, oz=cursor.z;
    try{
      placeStone(ox, oz, 10, 'cube', true, true, 0, true);
      placeStone(ox+2, oz, 6, 'tri', true, true, 4, true);
    }catch(e){}
    codeStatus('buttress set'); return; }
  if(tl==='obelisk'){
    var ox=cursor.x, oz=cursor.z;
    try{
      placeStone(ox, oz, 4, 'cube', true, true, 0, true);
      placeStone(ox, oz, 14, 'cube', true, true, 4, true);
      placeStone(ox, oz, 3, 'pyramid', true, true, 18, true);
    }catch(e){}
    codeStatus('obelisk raised'); return; }
  if(tl==='cupola'){
    var ox=cursor.x, oz=cursor.z;
    try{
      placeStone(ox, oz, 4, 'cyl', true, true, 0, true);
      placeStone(ox, oz, 4, 'sphere', true, true, 4, true);
      placeStone(ox, oz, 2, 'cone', true, true, 8, true);
    }catch(e){}
    codeStatus('cupola set'); return; }
  /* PRECISE CASTLE PERFORMANCE CODES */
  if(tl==='turret'){
    var ox=cursor.x, oz=cursor.z;
    try{
      placeStone(ox, oz, 8, 'cyl', true, true, 0, true);
      placeStone(ox, oz, 7, 'cone', true, true, 8, true);
    }catch(e){}
    codeStatus('turret raised'); return; }
  if(tl==='greattower'){
    var ox=cursor.x, oz=cursor.z;
    try{
      placeStone(ox, oz, 14, 'cube', true, true, 0, true);
      placeStone(ox, oz, 6, 'cyl', true, true, 14, true);
      placeStone(ox, oz, 5, 'cone', true, true, 20, true);
    }catch(e){}
    codeStatus('great tower raised'); return; }
  if(tl.indexOf('wallrun')===0){ var wp=tl.split(/\s+/); var wn=parseInt(wp[1])||6;
    var ox=cursor.x, oz=cursor.z;
    try{
      for(var i=0; i<wn; i++){
        placeStone(ox+i*5, oz, 5, 'cube', true, true, 0, true);
        placeStone(ox+i*5, oz, 2, 'cube', true, true, 5, true);
      }
    }catch(e){}
    codeStatus('wall run of '+wn); return; }
  if(tl==='curtain'){
    var ox=cursor.x, oz=cursor.z;
    try{
      placeStone(ox, oz, 6, 'cube', true, true, 0, true);
      placeStone(ox, oz, 6, 'cube', true, true, 6, true);
      placeStone(ox, oz, 3, 'cube', true, true, 12, true);
    }catch(e){}
    codeStatus('curtain wall raised'); return; }
  if(tl==='gatehouse2'){
    var ox=cursor.x, oz=cursor.z;
    try{
      placeStone(ox-4, oz, 10, 'cyl', true, true, 0, true);
      placeStone(ox+4, oz, 10, 'cyl', true, true, 0, true);
      placeStone(ox-4, oz, 8, 'cone', true, true, 10, true);
      placeStone(ox+4, oz, 8, 'cone', true, true, 10, true);
      placeStone(ox, oz, 5, 'cube', true, true, 8, true);
    }catch(e){}
    codeStatus('gatehouse raised'); return; }
  if(tl==='donjon'){
    var ox=cursor.x, oz=cursor.z;
    try{
      placeStone(ox, oz, 16, 'cube', true, true, 0, true);
      placeStone(ox, oz, 12, 'cube', true, true, 16, true);
      for(var i=-1; i<=1; i+=2){
        placeStone(ox+i*8, oz+8, 5, 'cyl', true, true, 28, true);
        placeStone(ox+i*8, oz+8, 4, 'cone', true, true, 33, true);
      }
    }catch(e){}
    codeStatus('donjon raised'); return; }
  if(tl==='battlements'){
    var ox=cursor.x, oz=cursor.z;
    try{
      for(var i=0; i<5; i++){
        if(i%2===0) placeStone(ox+i*3, oz, 3, 'cube', true, true, 0, true);
      }
    }catch(e){}
    codeStatus('battlements set'); return; }
  if(tl.indexOf('spire')===0 && tl!=='spire'){ } /* avoid clash */
  if(tl.indexOf('spire ')===0){ var sp=tl.split(/\s+/); var sh=parseFloat(sp[1])||12;
    var ox=cursor.x, oz=cursor.z;
    try{
      placeStone(ox, oz, Math.round(sh), 'cyl', true, true, 0, true);
      placeStone(ox, oz, Math.round(sh*0.8), 'cone', true, true, Math.round(sh), true);
    }catch(e){}
    codeStatus('spire '+sh+' high'); return; }
  /* COPY/PASTE stone groups (King's tool 2026-10-01) */
  var COPY_KEY = 'ruby-copy-buffer';
  function getCopyBuf(){ try{ return JSON.parse(localStorage.getItem(COPY_KEY)||'[]'); }catch(e){ return []; } }
  function setCopyBuf(b){ try{ localStorage.setItem(COPY_KEY, JSON.stringify(b)); }catch(e){} }
  if(tl.indexOf('copy')===0 && tl.indexOf('copy ')!==0 && tl==='copy' || tl.indexOf('copy ')===0){
    var cp2=tl.split(/\s+/); var cr=parseFloat(cp2[1])||10;
    var buf=[];
    try{
      var all = (typeof stones!=='undefined' ? stones : (typeof STONES!=='undefined' ? STONES : []));
      for(var i=0; i<all.length; i++){
        var st=all[i];
        var dx=(st.x-cursor.x), dz=(st.z-cursor.z);
        if(Math.sqrt(dx*dx+dz*dz) <= cr){
          