.sudoku-page {
  max-width: 720px;
  margin-inline: auto;
  padding-block: 4px 38px;
}

.sudoku-main {
  width: min(1120px, calc(100% - 64px));
}

.sudoku-page .breadcrumbs ol {
  flex-wrap: nowrap;
  white-space: nowrap;
  font-size: 12px;
}

.sudoku-page .breadcrumbs li + li::before {
  margin-inline: 4px;
}

.sudoku-intro {
  margin-bottom: 7px;
}

.sudoku-intro h1 {
  margin-bottom: 2px;
  font-size: clamp(32px, 8vw, 42px);
  letter-spacing: -2px;
  line-height: 1.1;
}

.sudoku-intro p,
.sudoku-how-to-play p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.sudoku-intro p {
  white-space: nowrap;
}

.sudoku-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: 0 12px 30px #29234a0a;
}

.sudoku-metrics {
  width: min(100%, 420px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}

.sudoku-metric {
  min-width: 0;
  min-height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 0;
  padding: 3px;
  border: 1px solid #ece7ff;
  border-radius: 10px;
  background: #f7f5ff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.sudoku-metric select {
  max-width: 100%;
  min-height: 25px;
  padding: 0 16px 0 4px;
  border: 0;
  background: transparent;
  color: var(--purple-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.sudoku-metric dd {
  margin: 0;
  color: var(--purple-dark);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.sudoku-board {
  width: min(100%, 44svh, 420px);
  display: grid;
  grid-template-rows: repeat(9, minmax(0, 1fr));
  aspect-ratio: 1;
  border: 2px solid #776b95;
  background: white;
}

.sudoku-row {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
}

.sudoku-cell {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #ddd9e8;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: clamp(14px, 4.4vw, 22px);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.sudoku-cell:nth-child(3n) {
  border-right: 2px solid #9a90ad;
}

.sudoku-row:nth-child(3n) .sudoku-cell {
  border-bottom: 2px solid #9a90ad;
}

.sudoku-cell.is-related {
  background: #f5f2fc;
}

.sudoku-cell.is-match {
  background: #e9e3ff;
  color: var(--purple-dark);
  font-weight: 800;
}

.sudoku-cell.is-entered {
  color: var(--purple-dark);
  font-weight: 800;
}

.sudoku-cell.is-selected {
  position: relative;
  z-index: 1;
  background: #dcd3ff;
  box-shadow: inset 0 0 0 2px var(--purple);
}

.sudoku-cell.is-incorrect {
  animation: sudoku-incorrect 650ms ease;
}

.sudoku-number-bar {
  width: min(100%, 420px);
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 3px;
}

.sudoku-number {
  min-width: 0;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px 0;
  border: 1px solid #ece7ff;
  border-radius: 8px;
  background: #f7f5ff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.05;
  touch-action: manipulation;
}

.sudoku-number span {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.sudoku-number.is-available {
  border-color: #9c87ff;
  background: #ebe6ff;
  color: var(--purple-dark);
  box-shadow: inset 0 0 0 1px #9c87ff;
}

.sudoku-number:disabled {
  color: #b7b3c2;
  cursor: default;
}

.sudoku-cell:focus-visible,
.sudoku-number:focus-visible,
.sudoku-metric select:focus-visible,
.sudoku-new-game:focus-visible {
  outline: 3px solid #a391ff;
  outline-offset: 2px;
}

.sudoku-status {
  width: min(100%, 420px);
  min-height: 20px;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.sudoku-new-game {
  min-width: 140px;
  min-height: 44px;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.sudoku-how-to-play {
  margin-top: 20px;
}

.sudoku-how-to-play h2 {
  margin-bottom: 6px;
  font-size: 20px;
  letter-spacing: -0.5px;
}

.related-games {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.related-games a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--purple-dark);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@keyframes sudoku-incorrect {
  0%,
  100% {
    background: #fff;
  }
  25%,
  65% {
    background: #ffbfc3;
    box-shadow: inset 0 0 0 2px #d74b59;
  }
}

@media (min-width: 600px) {
  .sudoku-page {
    padding-block: 8px 48px;
  }

  .sudoku-panel {
    gap: 9px;
    padding: 12px;
  }

  .sudoku-board td {
    border-color: #d5d0e1;
  }
}

@media (max-height: 700px) {
  .sudoku-page {
    padding-top: 2px;
  }

  .sudoku-page .breadcrumbs {
    margin-bottom: 4px;
  }

  .sudoku-intro {
    margin-bottom: 3px;
  }

  .sudoku-intro p {
    font-size: 12px;
  }

  .sudoku-panel {
    gap: 4px;
    padding: 3px;
  }

  .sudoku-board {
    width: min(100%, 41svh, 380px);
  }

  .sudoku-metric {
    min-height: 36px;
  }

  .sudoku-metric select {
    min-height: 20px;
    font-size: 12px;
  }

  .sudoku-number {
    min-height: 40px;
  }

  .sudoku-status {
    min-height: 16px;
  }

  .sudoku-new-game {
    min-height: 40px;
  }
}

@media (max-width: 520px) {
  .sudoku-main {
    width: calc(100% - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sudoku-cell.is-incorrect {
    animation-duration: 1ms;
  }
}
