<m-prompt
  id="tb-ibs-prompt"
  message="Play ice Battleship. Fire at A1 through J10. Example: FIRE A1. RESET clears the fleet."
  placeholder="FIRE A1"
  prefill="FIRE A1"
  debug="false"
>
  <m-model
    id="tb-ibs-board-model"
    src="/assets/tb_ice_battleship_board_downloads.glb"
    x="0"
    y="0.96"
    z="2.72"
    rx="-90"
    sx="8"
    sy="8"
    sz="8"
  ></m-model>
<m-cube id="tb-ibs-slab-0-0" x="-2.25" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-0" x="-2.25" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-0-1" x="-1.75" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-1" x="-1.75" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-0-2" x="-1.25" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-2" x="-1.25" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-0-3" x="-0.75" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-3" x="-0.75" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-0-4" x="-0.25" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-4" x="-0.25" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-0-5" x="0.25" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-5" x="0.25" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-0-6" x="0.75" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-6" x="0.75" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-0-7" x="1.25" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-7" x="1.25" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-0-8" x="1.75" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-8" x="1.75" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-0-9" x="2.25" y="1.57" z="-2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-0-9" x="2.25" y="1.68" z="-2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-0" x="-2.25" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-0" x="-2.25" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-1" x="-1.75" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-1" x="-1.75" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-2" x="-1.25" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-2" x="-1.25" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-3" x="-0.75" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-3" x="-0.75" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-4" x="-0.25" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-4" x="-0.25" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-5" x="0.25" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-5" x="0.25" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-6" x="0.75" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-6" x="0.75" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-7" x="1.25" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-7" x="1.25" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-8" x="1.75" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-8" x="1.75" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-1-9" x="2.25" y="1.57" z="-1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-1-9" x="2.25" y="1.68" z="-1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-0" x="-2.25" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-0" x="-2.25" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-1" x="-1.75" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-1" x="-1.75" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-2" x="-1.25" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-2" x="-1.25" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-3" x="-0.75" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-3" x="-0.75" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-4" x="-0.25" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-4" x="-0.25" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-5" x="0.25" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-5" x="0.25" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-6" x="0.75" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-6" x="0.75" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-7" x="1.25" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-7" x="1.25" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-8" x="1.75" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-8" x="1.75" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-2-9" x="2.25" y="1.57" z="-1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-2-9" x="2.25" y="1.68" z="-1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-0" x="-2.25" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-0" x="-2.25" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-1" x="-1.75" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-1" x="-1.75" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-2" x="-1.25" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-2" x="-1.25" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-3" x="-0.75" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-3" x="-0.75" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-4" x="-0.25" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-4" x="-0.25" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-5" x="0.25" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-5" x="0.25" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-6" x="0.75" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-6" x="0.75" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-7" x="1.25" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-7" x="1.25" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-8" x="1.75" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-8" x="1.75" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-3-9" x="2.25" y="1.57" z="-0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-3-9" x="2.25" y="1.68" z="-0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-0" x="-2.25" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-0" x="-2.25" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-1" x="-1.75" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-1" x="-1.75" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-2" x="-1.25" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-2" x="-1.25" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-3" x="-0.75" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-3" x="-0.75" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-4" x="-0.25" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-4" x="-0.25" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-5" x="0.25" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-5" x="0.25" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-6" x="0.75" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-6" x="0.75" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-7" x="1.25" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-7" x="1.25" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-8" x="1.75" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-8" x="1.75" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-4-9" x="2.25" y="1.57" z="-0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-4-9" x="2.25" y="1.68" z="-0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-0" x="-2.25" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-0" x="-2.25" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-1" x="-1.75" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-1" x="-1.75" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-2" x="-1.25" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-2" x="-1.25" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-3" x="-0.75" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-3" x="-0.75" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-4" x="-0.25" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-4" x="-0.25" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-5" x="0.25" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-5" x="0.25" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-6" x="0.75" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-6" x="0.75" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-7" x="1.25" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-7" x="1.25" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-8" x="1.75" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-8" x="1.75" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-5-9" x="2.25" y="1.57" z="0.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-5-9" x="2.25" y="1.68" z="0.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-0" x="-2.25" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-0" x="-2.25" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-1" x="-1.75" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-1" x="-1.75" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-2" x="-1.25" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-2" x="-1.25" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-3" x="-0.75" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-3" x="-0.75" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-4" x="-0.25" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-4" x="-0.25" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-5" x="0.25" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-5" x="0.25" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-6" x="0.75" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-6" x="0.75" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-7" x="1.25" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-7" x="1.25" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-8" x="1.75" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-8" x="1.75" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-6-9" x="2.25" y="1.57" z="0.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-6-9" x="2.25" y="1.68" z="0.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-0" x="-2.25" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-0" x="-2.25" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-1" x="-1.75" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-1" x="-1.75" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-2" x="-1.25" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-2" x="-1.25" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-3" x="-0.75" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-3" x="-0.75" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-4" x="-0.25" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-4" x="-0.25" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-5" x="0.25" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-5" x="0.25" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-6" x="0.75" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-6" x="0.75" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-7" x="1.25" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-7" x="1.25" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-8" x="1.75" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-8" x="1.75" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-7-9" x="2.25" y="1.57" z="1.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-7-9" x="2.25" y="1.68" z="1.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-0" x="-2.25" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-0" x="-2.25" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-1" x="-1.75" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-1" x="-1.75" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-2" x="-1.25" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-2" x="-1.25" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-3" x="-0.75" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-3" x="-0.75" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-4" x="-0.25" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-4" x="-0.25" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-5" x="0.25" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-5" x="0.25" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-6" x="0.75" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-6" x="0.75" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-7" x="1.25" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-7" x="1.25" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-8" x="1.75" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-8" x="1.75" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-8-9" x="2.25" y="1.57" z="1.75" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-8-9" x="2.25" y="1.68" z="1.75" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-0" x="-2.25" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-0" x="-2.25" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-1" x="-1.75" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-1" x="-1.75" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-2" x="-1.25" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-2" x="-1.25" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-3" x="-0.75" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-3" x="-0.75" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-4" x="-0.25" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-4" x="-0.25" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-5" x="0.25" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-5" x="0.25" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-6" x="0.75" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-6" x="0.75" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-7" x="1.25" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-7" x="1.25" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-8" x="1.75" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-8" x="1.75" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
<m-cube id="tb-ibs-slab-9-9" x="2.25" y="1.57" z="2.25" width="0.46" height="0.18" depth="0.46" color="#aeefff" opacity="0.9" visible="false"></m-cube>
<m-label id="tb-ibs-cell-9-9" x="2.25" y="1.68" z="2.25" rx="-90" width="0.46" height="0.46" font-size="18" alignment="center" color="#fbfdff" font-color="#16435d" emissive="0" visible="false" content=""></m-label>
  <m-label id="tb-ibs-notice" x="0" y="2.05" z="3.8" rx="-24" width="7.6" height="0.48" font-size="20" alignment="center" color="#0b2334" font-color="#f5fbff" emissive="0" visible="false" content=""></m-label>
</m-prompt>

<script>

(function () {
  const SIZE = 10;
  const SHIPS = [
{ name: "Carrier", cells: ["A1", "B1", "C1", "D1", "E1"] },
{ name: "Battleship", cells: ["H2", "H3", "H4", "H5"] },
{ name: "Cruiser", cells: ["C7", "D7", "E7"] },
{ name: "Submarine", cells: ["J8", "J9", "J10"] },
{ name: "Destroyer", cells: ["F4", "G4"] }
  ];
  const prompt = document.getElementById("tb-ibs-prompt");
  const notice = document.getElementById("tb-ibs-notice");
  const board = Array.from({ length: SIZE }, function () {
return Array(SIZE).fill("");
  });
  const shipByCell = {};
  const hitsByShip = {};
  let noticeTimer = null;
  let shots = 0;
  let hits = 0;
  let finished = false;
  let lastPromptKey = "";
  let lastPromptAt = 0;

  function debug(message) {
try {
  if (typeof console !== "undefined" && console && typeof console.log === "function") {
    console.log(String(message));
  }
} catch (error) {
  // Debug output must never break gameplay.
}
  }

  function setText(el, text) {
if (el) el.setAttribute("content", String(text));
  }

  function clearNoticeTimer() {
if (!noticeTimer) return;
const clearTimer =
  typeof clearTimeout === "function"
    ? clearTimeout
    : typeof window !== "undefined" && typeof window.clearTimeout === "function"
      ? window.clearTimeout.bind(window)
      : null;
if (clearTimer) clearTimer(noticeTimer);
noticeTimer = null;
  }

  function showNotice(message, kind) {
if (!notice) return;
clearNoticeTimer();
setText(notice, message);
notice.setAttribute("visible", "true");
notice.setAttribute("emissive", "0");
if (kind === "error") {
  notice.setAttribute("color", "#220711");
  notice.setAttribute("font-color", "#ffb7ce");
} else if (kind === "success") {
  notice.setAttribute("color", "#062317");
  notice.setAttribute("font-color", "#b8ffe5");
} else {
  notice.setAttribute("color", "#0b2334");
  notice.setAttribute("font-color", "#f5fbff");
}
const setTimer =
  typeof setTimeout === "function"
    ? setTimeout
    : typeof window !== "undefined" && typeof window.setTimeout === "function"
      ? window.setTimeout.bind(window)
      : null;
if (setTimer) {
  noticeTimer = setTimer(function () {
    notice.setAttribute("visible", "false");
  }, 3600);
}
  }

  function clean(value) {
return String(value || "").toUpperCase().replace(/[^A-Z0-9 ]/g, " ").replace(/\s+/g, " ").trim();
  }

  function firstString() {
for (let i = 0; i < arguments.length; i += 1) {
  const value = arguments[i];
  if (typeof value === "string" && value.trim()) return value;
  if (typeof value === "number") return String(value);
}
return "";
  }

  function readPromptValue(event) {
const detail = event && event.detail ? event.detail : {};
const value = firstString(
  detail.value,
  detail.text,
  detail.prompt,
  detail.input,
  detail.message,
  detail.result,
  event && event.value,
  event && event.text,
  typeof event === "string" ? event : ""
);
if (value) return value;
if (prompt && typeof prompt.getAttribute === "function") {
  return firstString(prompt.getAttribute("value"), prompt.getAttribute("text"));
}
return "";
  }

  function isDuplicatePrompt(rawValue) {
const key = clean(rawValue);
const now = typeof Date !== "undefined" && Date && typeof Date.now === "function" ? Date.now() : 0;
if (key && key === lastPromptKey && now && lastPromptAt && now - lastPromptAt < 750) {
  return true;
}
lastPromptKey = key;
lastPromptAt = now;
return false;
  }

  function parseCell(token) {
let match = /^([A-J])(10|[1-9])$/.exec(token);
if (match) {
  return {
    row: Number(match[2]) - 1,
    col: match[1].charCodeAt(0) - 65,
    label: match[1] + match[2]
  };
}
match = /^(10|[1-9])([A-J])$/.exec(token);
if (match) {
  return {
    row: Number(match[1]) - 1,
    col: match[2].charCodeAt(0) - 65,
    label: match[2] + match[1]
  };
}
return null;
  }

  function parseShot(rawValue) {
const value = clean(rawValue);
if (!value) return { error: "Fire at A1 through J10." };
if (value === "RESET" || value === "CLEAR" || value === "NEW") return { reset: true };
for (const token of value.split(" ")) {
  if (token === "FIRE" || token === "SHOT" || token === "MISSILE" || token === "TARGET" || token === "AT") continue;
  const cell = parseCell(token);
  if (cell) return cell;
}
return { error: "Use FIRE A1, or just A1." };
  }

  function cellElement(row, col) {
return document.getElementById("tb-ibs-cell-" + row + "-" + col);
  }

  function slabElement(row, col) {
return document.getElementById("tb-ibs-slab-" + row + "-" + col);
  }

  function clearDisplay() {
for (let row = 0; row < SIZE; row += 1) {
  for (let col = 0; col < SIZE; col += 1) {
    board[row][col] = "";
    const el = cellElement(row, col);
    if (el) {
      el.setAttribute("content", "");
      el.setAttribute("visible", "false");
      el.setAttribute("emissive", "0");
      el.setAttribute("width", "0.46");
      el.setAttribute("height", "0.46");
      el.setAttribute("font-size", "18");
      el.setAttribute("color", "#fbfdff");
      el.setAttribute("font-color", "#16435d");
    }
    const slab = slabElement(row, col);
    if (slab) {
      slab.setAttribute("visible", "false");
      slab.setAttribute("color", "#aeefff");
      slab.setAttribute("opacity", "0.9");
    }
  }
}
  }

  function buildFleet() {
for (const key in shipByCell) delete shipByCell[key];
for (const ship of SHIPS) {
  hitsByShip[ship.name] = 0;
  for (const cell of ship.cells) {
    shipByCell[cell] = ship;
  }
}
  }

  function totalTargets() {
let total = 0;
for (const ship of SHIPS) total += ship.cells.length;
return total;
  }

  function mark(row, col, content, kind) {
const el = cellElement(row, col);
if (!el) return;
el.setAttribute("content", content);
el.setAttribute("visible", "true");
el.setAttribute("emissive", "0");
el.setAttribute("width", "0.46");
el.setAttribute("height", "0.4");
el.setAttribute("color", "#fbfdff");
const slab = slabElement(row, col);
if (slab) {
  slab.setAttribute("visible", "true");
  slab.setAttribute("opacity", "0.92");
  slab.setAttribute("color", kind === "hit" ? "#ffcaca" : "#aeefff");
}
if (kind === "hit") {
  el.setAttribute("font-size", "20");
  el.setAttribute("font-color", "#a32332");
} else {
  el.setAttribute("font-size", "16");
  el.setAttribute("font-color", "#1c6d93");
}
  }

  function resetBoard() {
clearDisplay();
buildFleet();
shots = 0;
hits = 0;
finished = false;
showNotice("Reset. Fire at hidden fleet. Try FIRE A1.", "info");
debug("ice-battleship reset");
  }

  function handlePrompt(event) {
try {
  const rawValue = readPromptValue(event);
  if (isDuplicatePrompt(rawValue)) return;
  const parsed = parseShot(rawValue);
  debug("ice-battleship prompt: " + String(rawValue || ""));

  if (parsed.reset) {
    resetBoard();
    return;
  }
  if (parsed.error) {
    showNotice(parsed.error, "error");
    debug("ice-battleship error: " + parsed.error);
    return;
  }
  if (finished) {
    showNotice("Fleet destroyed. Type RESET.", "info");
    return;
  }
  if (board[parsed.row][parsed.col]) {
    showNotice(parsed.label + " already fired.", "error");
    debug("ice-battleship error: duplicate " + parsed.label);
    return;
  }

  shots += 1;
  const ship = shipByCell[parsed.label];
  if (ship) {
    board[parsed.row][parsed.col] = "HIT";
    hits += 1;
    hitsByShip[ship.name] += 1;
    mark(parsed.row, parsed.col, "HIT", "hit");
    if (hitsByShip[ship.name] === ship.cells.length) {
      if (hits === totalTargets()) {
        finished = true;
        showNotice("Fleet sunk in " + shots + " shots. RESET.", "success");
        debug("ice-battleship win: " + shots);
        return;
      }
      showNotice("Sunk " + ship.name + " at " + parsed.label + ". " + (totalTargets() - hits) + " left.", "success");
      debug("ice-battleship sunk: " + ship.name);
      return;
    }
    showNotice("Hit " + ship.name + " at " + parsed.label + ". " + (totalTargets() - hits) + " left.", "success");
    debug("ice-battleship hit: " + parsed.label + " " + ship.name);
    return;
  }

  board[parsed.row][parsed.col] = "MISS";
  mark(parsed.row, parsed.col, "MISS", "miss");
  showNotice("Miss at " + parsed.label + ". Shots " + shots + ".", "info");
  debug("ice-battleship miss: " + parsed.label);
} catch (error) {
  const message = error && error.message ? error.message : "Prompt handler failed.";
  showNotice("Command error: " + message, "error");
  debug("ice-battleship exception: " + message);
}
  }

  if (prompt) {
prompt.addEventListener("prompt", handlePrompt);
prompt.addEventListener("submit", handlePrompt);
  }
  resetBoard();
})();

</script>
