.board-card {
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  min-height: 560px;
}

.board-wrap {
  width: min(100%, 560px);
  aspect-ratio: 1;
  position: relative;
}

.board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--size, 7), 1fr);
  grid-template-rows: repeat(var(--size, 7), 1fr);
  border: 3px solid var(--text);
  background: var(--text);
  gap: 1px;
  touch-action: none;
}

.board-row {
  display: contents;
}

/* Repeating :hover keeps button:hover from painting over the region color. */
.cell,
.cell:hover {
  position: relative;
  border: 0;
  border-radius: 0;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  isolation: isolate;
  background: var(--region-color);
}

.cell:hover {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--text) 22%, transparent);
}

/* Lift the focused cell so later cells don't paint over its focus ring. */
.cell:focus-visible {
  z-index: 4;
}

.cell.crossed::before,
.cell.crossed::after {
  z-index: 1;
  content: '';
  position: absolute;
  width: 38%;
  height: 2px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--text) 72%, transparent);
  transform: rotate(45deg);
}

.cell.crossed::after {
  transform: rotate(-45deg);
}

.mark {
  display: none;
  position: relative;
  z-index: 2;
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  place-items: center;
  background: var(--text);
  box-shadow:
    inset 0 0 0 3px color-mix(in srgb, var(--bg) 55%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

.mark::after {
  content: '';
  width: 30%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--region-color);
}

.cell.marked .mark {
  display: grid;
}

.cell.hint-target {
  box-shadow: inset 0 0 0 4px var(--accent);
  animation: hint-pulse 1.4s ease-in-out infinite;
}

/* Mistakes come after :hover so the red tint survives hovering. */
.cell.mistake {
  background: color-mix(in srgb, var(--bad) 22%, var(--region-color));
  animation: mistake-shake 0.3s ease-in-out;
}

.cell.mistake::before,
.cell.mistake::after {
  z-index: 1;
  content: '';
  position: absolute;
  width: 46%;
  height: 3px;
  border-radius: 2px;
  background: var(--bad);
  transform: rotate(45deg);
}

.cell.mistake::after {
  transform: rotate(-45deg);
}

@keyframes mistake-shake {
  25% {
    translate: -3px 0;
  }

  75% {
    translate: 3px 0;
  }
}

.cell.revealed .mark {
  display: grid;
  opacity: 0.45;
}

.board.locked .cell {
  cursor: default;
}

.board.locked .cell:hover {
  box-shadow: none;
}

@keyframes hint-pulse {
  50% {
    box-shadow: inset 0 0 0 2px var(--accent);
  }
}

.region-edge {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  background: var(--text);
}

.region-edge.top {
  height: 4px;
  left: -2px;
  right: -2px;
  top: -2px;
}

.region-edge.left {
  width: 4px;
  top: -2px;
  bottom: -2px;
  left: -2px;
}

.puzzle-caption {
  margin: 14px 0 0;
  min-height: 1.45em;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 820px) {
  .board-card {
    min-height: 0;
    padding: 14px;
  }
}

@media (max-width: 520px) {
  .board-card {
    margin-inline: -4px;
  }

  .mark {
    width: 44%;
  }

  .cell.crossed::before,
  .cell.crossed::after {
    width: 45%;
  }
}
