.board {
  grid-area: board;
  width: calc(var(--cell) * 36 + 4px);
  height: calc(var(--cell) * 36 + 4px);
  display: grid;
  grid-template-columns: repeat(36, var(--cell));
  grid-template-rows: repeat(36, var(--cell));
  border: 2px solid var(--line);
  background: #dec18f url("assets/shogi-board-wood-clean.png") center / 100% 100% no-repeat;
  box-shadow: 0 14px 36px rgb(55 42 23 / 24%);
}

.cell {
  width: var(--cell);
  height: var(--cell);
  border: 1px solid rgb(95 66 37 / 44%);
  background: transparent;
  position: relative;
}

.cell:nth-child(2n) {
  background: transparent;
}

/* Go-board-style dots at the intersections of each 3-by-3 block. */
.cell.starPoint::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  width: clamp(4px, calc(var(--cell) * 0.13), 8px);
  height: clamp(4px, calc(var(--cell) * 0.13), 8px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #302317;
  z-index: 2;
  pointer-events: none;
}

.cell.campCross::after {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  width: calc(var(--cell) * 0.55);
  height: calc(var(--cell) * 0.55);
  transform: translate(-50%, -50%);
  background:
    linear-gradient(#000, #000) center / 100% 3px no-repeat,
    linear-gradient(#000, #000) center / 3px 100% no-repeat;
  z-index: 2;
  pointer-events: none;
}

.piece {
  position: absolute;
  inset: -1px;
  display: grid;
  place-items: center;
  border: 0 solid transparent;
  background: url("assets/shogi-piece-22f3e43efd5d.png") center / 100% 100% no-repeat;
  color: #000;
  clip-path: none;
  font-weight: 900;
  line-height: 1;
  font-size: round(nearest, min(calc(var(--cell) * 0.46), calc((var(--cell) - 2px) / var(--piece-characters, 2))), 1px);
  letter-spacing: 0;
  text-orientation: upright;
  writing-mode: vertical-rl;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}

/* Rotate the same piece artwork and label together for the opposite side. */
.piece.facingDown {
  transform: rotate(180deg);
  transform-origin: center;
}

.piece.promoted {
  color: #801b16;
}

.piece.current {
  outline: 3px solid #1c6fca;
  outline-offset: -2px;
}

.piece.offturn {
  opacity: 1;
}

.target {
  box-shadow: inset 0 0 0 4px rgb(11 107 104 / 68%);
  cursor: pointer;
}

.target.capture {
  box-shadow: inset 0 0 0 4px rgb(177 65 53 / 75%);
}

.cell.target.capture.lastMoveTo {
  background: #ffb8ad !important;
  box-shadow: inset 0 0 0 5px #c92f22;
}

.cell.target.capture .piece {
  outline: 3px solid #c92f22;
  outline-offset: -2px;
}

.cell.target.capture .piece.lastMovedPiece {
  border-color: #7f160f;
  outline-color: #c92f22;
  filter: saturate(1.35) brightness(1.04);
}

.lastMoveFrom {
  background: #ffe08a !important;
  box-shadow: inset 0 0 0 3px #c78300;
}

.lastMoveTo {
  background: #9ee59f !important;
  box-shadow: inset 0 0 0 4px #198754;
}

.piece.lastMovedPiece {
  border-color: #075c36;
  outline: 3px solid #0b7a49;
  outline-offset: -2px;
  filter: saturate(1.2) brightness(1.04);
}


.piece.threeCharacterPiece { writing-mode: horizontal-tb; font-size: round(nearest, calc((var(--cell) - 1px) / 3), 1px); }
.threeCharacterLabel { display: flex; flex-direction: column; align-items: center; writing-mode: horizontal-tb; }
.threeCharacterLabel > span { display: block; line-height: round(nearest, .90em, 1px); letter-spacing: 0; }

