.sudoku-board {
  position: relative;
  width: min(100%, 560px);
  --cell-size: 34px;
  background: #fffdf8;
  border: 2px solid #5c4b3c;
  border-radius: 10px;
  padding: 3px;
  box-shadow: var(--shadow);
  touch-action: manipulation;
}

.board-grid {
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 1;
  gap: 0;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid #c9bfb0;
  border-bottom: 1px solid #c9bfb0;
  background: var(--color-light-square);
  color: #e9e2d8;
  font-size: clamp(14px, 3.2vw, 26px);
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cell.alt { background: var(--color-dark-square); }
.sudoku-board[style*="--board-size: 16"] .cell { font-size: clamp(9px, 2.1vw, 16px); }

.cell.box-right { border-right: 3px solid #5c4b3c; }
.cell.box-bottom { border-bottom: 3px solid #5c4b3c; }
.cell.samurai-edge { border-right-width: 3px; border-bottom-width: 3px; border-color: #8b6b4c; }

.cell.inactive { background: transparent; border-color: transparent; pointer-events: none; }
.cell.given { color: var(--color-given); font-weight: 800; }
.cell.user-value { color: var(--color-user); font-weight: 600; }
.cell.selected { background: #f5d79c !important; box-shadow: inset 0 0 0 2px #b58138; z-index: 2; }
.cell.peer { background: #efe2c8 !important; }
.cell.same-value { background: #e7d2a7 !important; color: #7c4c22; }
.cell.conflict, .cell.wrong { background: #f2c7c2 !important; color: var(--color-conflict) !important; }
.cell.hint { background: #d5ebd2 !important; box-shadow: inset 0 0 0 2px var(--color-success); }

.cell-value { pointer-events: none; }

.cell-notes {
  position: absolute;
  inset: 2px;
  display: none;
  grid-template-columns: repeat(var(--note-cols, 3), 1fr);
  grid-auto-rows: 1fr;
  align-items: center;
  justify-items: center;
  font-size: clamp(7px, 1.3vw, 11px);
  line-height: 1;
  color: #6d5c4c;
  white-space: pre;
  pointer-events: none;
}

.cell-notes.visible { display: grid; }

.board-overlay {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

@media (max-width: 520px) {
  .sudoku-board { width: 100%; --cell-size: 28px; }
  .cell { font-size: clamp(12px, 4.4vw, 20px); }
}
