* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: auto;
  position: relative;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(
    var(--gradient-angle),
    rgb(227, 255, 231),
    rgb(217, 231, 255)
  );
  animation: gradient-rotation 30s linear infinite;
}

@property --gradient-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@keyframes gradient-rotation {
  from {
    --gradient-angle: 0deg;
  }
  to {
    --gradient-angle: 360deg;
  }
}

.background-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  display: block;
}

.page {
  width: min(95vw, 95vh);
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sudoku-wrapper {
  width: 100%;
  aspect-ratio: 1;
}

.techniques-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.techniques-panel h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.technique-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
}

.control-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.technique-button {
  padding: 0.85rem 1rem;
  border: 1px solid #000;
  background: #fff;
  border-radius: 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s ease;
}

.technique-button:hover {
  background: #f3f3f3;
}

.puzzle-param {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.puzzle-param label {
  font-weight: 600;
  font-size: 0.95rem;
}

.puzzle-param-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #000;
  border-radius: 0.5rem;
  font-family: monospace;
  font-size: 0.9rem;
  background: #fff;
}

.puzzle-param-input:focus {
  outline: 2px solid rgba(0, 0, 0, 0.12);
}

.sudoku-grid {
  width: 100%;
  height: 100%;
  border: 5px solid #000;
  border-radius: 5px;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  background: #000;
  padding: 0;
}

.sudoku-cell {
  display: grid;
  place-items: center;
  min-height: 0;
  background: #fff;
  position: relative;
  margin-right: 1px;
  margin-bottom: 1px;
}

.sudoku-cell.invalid {
  background: #ffd6ea;
}

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

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

.sudoku-cell:nth-child(9n + 3),
.sudoku-cell:nth-child(9n + 6) {
  margin-right: 3px;
}

.sudoku-cell:nth-child(n + 19):nth-child(-n + 27),
.sudoku-cell:nth-child(n + 46):nth-child(-n + 54) {
  margin-bottom: 3px;
}

.cell-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: #000;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(24rem, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  padding: 1.5rem;
  text-align: center;
}

.modal-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.modal-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.modal-buttons button,
.modal-close {
  padding: 0.9rem 1rem;
  border: 1px solid #000;
  background: #fff;
  border-radius: 0.75rem;
  cursor: pointer;
  font-size: 1rem;
}

.modal-buttons button:hover,
.modal-close:hover {
  background: #f3f3f3;
}

.modal-close {
  width: 100%;
}

.candidate-grid {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 0.3rem;
  padding: 0.3rem;
  align-items: center;
  justify-items: center;
}

.candidate-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: #000;
  opacity: 0.3;
}

.candidate-dot.removed {
  background: #d33;
}

.candidate-dot.added {
  background: #3a7cff;
}

.candidate-dot.fade-to-normal {
  transition: background 3s ease-out;
  background: #000;
}

.candidate-dot.fade-to-invisible {
  transition: opacity 3s ease-out;
  opacity: 0;
}

.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}

.toast {
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  transform-origin: right bottom;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
