@import url("../numbrix/styles.css");

.sudoku-page .play-sidebar {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  width: min(100%, calc(100dvh - 120px), 680px);
  max-width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  padding: clamp(8px, 1.4dvh, 13px);
  overflow: hidden;
  border: 2px solid rgba(232,236,248,0.5);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 80% 60% at 50% 30%, rgba(107,127,232,0.07) 0%, transparent 70%),
    rgba(255,255,255,0.03);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  touch-action: manipulation;
  user-select: none;
}

.sudoku-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-right: 1px solid rgba(232,236,248,0.13);
  border-bottom: 1px solid rgba(232,236,248,0.13);
  background: rgba(255,255,255,0.045);
  color: var(--ink);
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease, box-shadow 130ms ease, transform 130ms ease;
}

.sudoku-cell:nth-child(3n) {
  border-right-color: rgba(232,236,248,0.5);
  border-right-width: 2px;
}

.sudoku-cell:nth-child(9n) {
  border-right: 0;
}

.sudoku-cell:nth-child(n + 19):nth-child(-n + 27),
.sudoku-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom-color: rgba(232,236,248,0.5);
  border-bottom-width: 2px;
}

.sudoku-cell:nth-child(n + 73) {
  border-bottom: 0;
}

.sudoku-cell:hover {
  z-index: 1;
  background: rgba(255,255,255,0.09);
}

.sudoku-cell.peer {
  background: rgba(107,127,232,0.12);
}

.sudoku-cell.selected {
  z-index: 2;
  background: rgba(107,127,232,0.28);
  box-shadow: inset 0 0 0 2px var(--blue), 0 0 18px rgba(107,127,232,0.24);
}

.sudoku-cell.same-value {
  color: #fff;
  background: rgba(91,191,153,0.22);
}

.sudoku-cell.given {
  color: #ffffff;
  background: rgba(255,255,255,0.095);
}

.sudoku-cell.conflict {
  color: #fff;
  background: rgba(224,115,153,0.28);
  animation: shake 230ms ease-in-out 2;
}

.sudoku-cell.hint {
  animation: pulse 680ms ease-in-out 2;
  background: rgba(245,194,107,0.35);
  box-shadow: inset 0 0 0 2px var(--amber), 0 0 18px rgba(245,194,107,0.38);
}

.sudoku-cell.wrong {
  animation: shake 230ms ease-in-out 2;
}

.cell-value {
  font-size: clamp(18px, 3.6vw, 36px);
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}

.sudoku-cell.given .cell-value {
  font-weight: 950;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 82%;
  height: 82%;
  color: rgba(232,236,248,0.62);
  font-size: clamp(7px, 1.35vw, 12px);
  font-weight: 800;
  line-height: 1;
}

.note-grid span {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
}

.number-button {
  min-width: 0;
  min-height: 40px;
  border: 1px solid rgba(107,127,232,0.25);
  border-radius: var(--radius-sm);
  background: rgba(107,127,232,0.13);
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease;
}

.number-button:hover {
  transform: translateY(-1px);
  border-color: rgba(107,127,232,0.55);
  background: rgba(107,127,232,0.22);
}

.sudoku-tools {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

#noteButton.is-active {
  border-color: rgba(245,194,107,0.55);
  background: rgba(245,194,107,0.18);
  color: #ffe2a0;
}

.modal.is-celebration #victoryNewGameButton {
  animation: record-button-pulse 1100ms ease-in-out 2;
}

@media (max-width: 760px) {
  .sudoku-page .game-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto auto;
    grid-template-areas:
      "top"
      "difficulty"
      "status"
      "board"
      "info"
      "numbers"
      "tools"
      "controls";
    padding: 7px;
  }

  .sudoku-page .topbar,
  .sudoku-page .difficulty-row,
  .sudoku-page .status-strip,
  .sudoku-page .board-wrap,
  .sudoku-page .info-row,
  .sudoku-page .number-pad,
  .sudoku-page .sudoku-tools,
  .sudoku-page .controls {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .sudoku-board {
    width: min(100%, calc(100vw - 30px), calc(100dvh - 332px));
    padding: 5px;
  }

  .sudoku-page .board-wrap {
    margin-bottom: 5px;
  }

  .sudoku-page .topbar {
    gap: 6px;
    margin-bottom: 4px;
    padding-bottom: 6px;
  }

  .sudoku-page .icon-button {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    font-size: 18px;
  }

  .sudoku-page .game-title-logo {
    width: 30px;
    height: 30px;
  }

  .sudoku-page .top-actions {
    gap: 5px;
  }

  .sudoku-page .small-button {
    min-height: 30px;
    padding: 0 9px;
    border-radius: 8px;
    font-size: 12px;
  }

  .sudoku-page .level-chip {
    min-width: 72px;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
  }

  .sudoku-page .difficulty-row {
    gap: 5px;
    margin-bottom: 5px;
  }

  .sudoku-page .difficulty-button {
    min-height: 30px;
    font-size: 12px;
  }

  .sudoku-page .status-strip {
    gap: 5px;
    margin-bottom: 5px;
  }

  .sudoku-page .status-strip > div {
    padding: 6px 9px;
    border-radius: 8px;
  }

  .sudoku-page .label {
    margin-bottom: 1px;
    font-size: 9px;
  }

  .sudoku-page .status-strip strong {
    font-size: 20px;
  }

  .cell-value {
    font-size: clamp(17px, 5.5vw, 28px);
  }

  .note-grid {
    font-size: clamp(6px, 2vw, 10px);
  }

  .number-pad {
    grid-area: numbers;
    gap: 4px;
    margin-bottom: 5px;
  }

  .number-button {
    min-height: 29px;
    border-radius: 7px;
    font-size: 14px;
  }

  .sudoku-tools {
    grid-area: tools;
    gap: 5px;
    margin-bottom: 5px;
  }

  .sudoku-page .sudoku-tools .button {
    min-height: 34px;
    border-radius: 8px;
    font-size: 13px;
  }

  .sudoku-page .controls {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }

  .sudoku-page .controls .button {
    min-height: 34px;
    border-radius: 8px;
    font-size: 13px;
  }

  .sudoku-page .message,
  .sudoku-page .seed {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 380px) {
  .sudoku-page .game-shell {
    padding: 4px;
  }

  .sudoku-page .game-panel {
    padding: 6px;
  }

  .sudoku-board {
    width: min(100%, calc(100vw - 22px), calc(100dvh - 318px));
  }

  .number-button {
    min-height: 27px;
    font-size: 13px;
  }
}

@media (max-height: 700px) {
  .sudoku-board {
    width: min(100%, calc(100vw - 30px), calc(100dvh - 298px));
  }

  .number-button {
    min-height: 26px;
  }

  .sudoku-page .sudoku-tools .button,
  .sudoku-page .controls .button {
    min-height: 31px;
  }
}
