/*
 * Sudoku Game Stylesheet
 * Complete styling for the Sudoku game: grid, controls, number pad,
 * victory modal, and responsive layout. Dark theme consistent with
 * the iivanovxyz games shared styles.
 */

/* ================================================================
   Grid Sizing
   ================================================================ */
:root {
  --sudoku-cell-min: 34px;
  --sudoku-cell-max: 50px;
  --sudoku-cell-size: clamp(var(--sudoku-cell-min), 6.5vw, var(--sudoku-cell-max));
  --grid-border-thin: 1px solid #333333;
  --grid-border-thick: 3px solid #64b5f6;

  --color-bg: #111111;
  --color-cell-bg: #1a1a1a;
  --color-cell-clue-bg: #1e1e1e;
  --color-cell-user-bg: #17202a;
  --color-cell-hint-bg: #1a2a1a;
  --color-cell-selected-bg: #1a3a5c;
  --color-cell-highlight-bg: #162d40;
  --color-cell-same-num-bg: #1c3550;
  --color-cell-conflict-bg: #3a1a1a;
  --color-text-clue: #e0e0e0;
  --color-text-user: #64b5f6;
  --color-text-hint: #66bb6a;
  --color-text-conflict: #ef5350;
  --color-accent: #1e88e5;
  --color-accent-hover: #42a5f5;
  --color-border: #2a2a2a;
}

/* ================================================================
   Controls Bar
   ================================================================ */
.sudoku-controls {
  width: 100%;
  max-width: 600px;
  margin: 0 auto 20px auto;
}

.sudoku-controls .controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  row-gap: 10px;
}

.sudoku-controls .control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sudoku-controls .control-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888888;
  font-weight: 600;
}

/* Difficulty buttons */
.difficulty-buttons {
  display: flex;
  gap: 4px;
}

.diff-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #aaaaaa;
  background-color: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.diff-btn:hover {
  background-color: #252525;
  color: #e0e0e0;
  border-color: #3a3a3a;
}

.diff-btn.active {
  background-color: #1e88e5;
  color: #ffffff;
  border-color: #1e88e5;
}

.diff-btn:focus-visible {
  outline: 2px solid #64b5f6;
  outline-offset: 2px;
}

/* New Game button */
.btn-new-game {
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  background-color: #1e88e5;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-new-game:hover {
  background-color: #42a5f5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 136, 229, 0.35);
}

.btn-new-game:active {
  transform: translateY(0);
}

.btn-new-game:focus-visible {
  outline: 2px solid #64b5f6;
  outline-offset: 2px;
}

/* Timer display */
.timer-display {
  font-size: 1.15rem;
  font-weight: 700;
  color: #e0e0e0;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  background-color: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  min-width: 70px;
  text-align: center;
}

/* Hint button */
.btn-hint {
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  background-color: #37474f;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.btn-hint:hover:not(:disabled) {
  background-color: #546e7a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(84, 110, 122, 0.35);
}

.btn-hint:active:not(:disabled) {
  transform: translateY(0);
}

.btn-hint:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-hint:focus-visible {
  outline: 2px solid #64b5f6;
  outline-offset: 2px;
}

/* Score display */
.score-display {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffb74d;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  background-color: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  min-width: 50px;
  text-align: center;
}

/* ================================================================
   Sudoku Grid
   ================================================================ */
.sudoku-board-wrapper {
  width: 100%;
  max-width: 600px;
  margin: 0 auto 20px auto;
  display: flex;
  justify-content: center;
}

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, var(--sudoku-cell-size));
  grid-template-rows: repeat(9, var(--sudoku-cell-size));
  border: var(--grid-border-thick);
  border-radius: 4px;
  overflow: hidden;
  background-color: #333333;
}

/* Individual cell */
.sudoku-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.85rem, 2.8vw, 1.35rem);
  font-weight: 600;
  background-color: var(--color-cell-bg);
  border-right: var(--grid-border-thin);
  border-bottom: var(--grid-border-thin);
  cursor: pointer;
  transition: background-color 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  color: var(--color-text-user);
}

/* Thick borders for 3x3 box separation */
.sudoku-cell:nth-child(3n) {
  border-right: var(--grid-border-thick);
}

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

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: var(--grid-border-thick);
}

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

/* Cell states */
.sudoku-cell.clue {
  background-color: var(--color-cell-clue-bg);
  color: var(--color-text-clue);
  cursor: default;
  font-weight: 700;
}

.sudoku-cell.user-input {
  background-color: var(--color-cell-user-bg);
  color: var(--color-text-user);
}

.sudoku-cell.hint-filled {
  background-color: var(--color-cell-hint-bg);
  color: var(--color-text-hint);
}

.sudoku-cell.selected {
  background-color: var(--color-cell-selected-bg) !important;
  box-shadow: inset 0 0 0 2px #64b5f6;
  z-index: 2;
}

.sudoku-cell.highlighted {
  background-color: var(--color-cell-highlight-bg);
}

.sudoku-cell.same-number {
  background-color: var(--color-cell-same-num-bg);
}

.sudoku-cell.conflict {
  background-color: var(--color-cell-conflict-bg) !important;
  color: var(--color-text-conflict) !important;
  animation: conflictPulse 0.4s ease-out;
}

@keyframes conflictPulse {
  0% { transform: scale(1.05); }
  50% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.sudoku-cell:focus-visible {
  outline: 2px solid #64b5f6;
  outline-offset: -2px;
  z-index: 3;
}

/* ================================================================
   Number Pad
   ================================================================ */
.number-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 400px;
  margin: 0 auto 16px auto;
  padding: 0 12px;
}

.num-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-height: 44px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #e0e0e0;
  background-color: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.num-btn:hover {
  background-color: #252525;
  border-color: #3a3a3a;
  transform: translateY(-1px);
}

.num-btn:active {
  background-color: #1e88e5;
  border-color: #1e88e5;
  color: #ffffff;
  transform: translateY(0);
}

.num-btn:focus-visible {
  outline: 2px solid #64b5f6;
  outline-offset: 2px;
}

.num-btn-clear {
  font-size: 1.1rem;
  color: #ef5350;
}

.num-btn-clear:hover {
  background-color: #2a1a1a;
  border-color: #4a2a2a;
}

/* ================================================================
   Status Bar
   ================================================================ */
.status-bar {
  text-align: center;
  min-height: 28px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #aaaaaa;
  padding: 4px 16px;
  transition: color 0.3s ease;
}

.status-bar.error {
  color: #ef5350;
}

.status-bar.success {
  color: #66bb6a;
}

.status-bar.info {
  color: #64b5f6;
}

/* ================================================================
   Victory Modal Overlay
   ================================================================ */
.victory-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: victoryFadeIn 0.3s ease-out;
}

.victory-modal-overlay[hidden] {
  display: none;
}

@keyframes victoryFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.victory-modal {
  position: relative;
  background-color: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  padding: 40px 36px 32px 36px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: victorySlideUp 0.4s ease-out;
}

@keyframes victorySlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.victory-modal-header {
  margin-bottom: 24px;
}

.victory-icon {
  font-size: 3.5rem;
  margin-bottom: 8px;
}

.victory-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 4px 0;
}

.victory-subtitle {
  font-size: 1rem;
  color: #aaaaaa;
  margin: 0;
}

.victory-stats {
  background-color: #111111;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 16px 24px;
  margin-bottom: 24px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #1e1e1e;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  font-size: 0.9rem;
  color: #888888;
  font-weight: 500;
}

.stat-value {
  font-size: 1rem;
  color: #e0e0e0;
  font-weight: 700;
}

.victory-actions {
  display: flex;
  justify-content: center;
}

.btn-play-again {
  padding: 12px 36px;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  background-color: #1e88e5;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-play-again:hover {
  background-color: #42a5f5;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(30, 136, 229, 0.4);
}

.btn-play-again:active {
  transform: translateY(0);
}

.btn-play-again:focus-visible {
  outline: 2px solid #64b5f6;
  outline-offset: 2px;
}

.victory-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #666666;
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.2s ease, background-color 0.2s ease;
  line-height: 1;
}

.victory-modal-close:hover {
  color: #e0e0e0;
  background-color: #2a2a2a;
}

.victory-modal-close:focus-visible {
  outline: 2px solid #64b5f6;
  outline-offset: 2px;
}

/* ================================================================
   Responsive: Tablet
   ================================================================ */
@media screen and (max-width: 768px) {
  .sudoku-controls .controls-row {
    gap: 10px;
  }

  .sudoku-board-wrapper {
    max-width: 100%;
  }

  .number-pad {
    max-width: 360px;
    gap: 6px;
  }

  .victory-modal {
    padding: 32px 24px 24px 24px;
  }

  .victory-title {
    font-size: 1.5rem;
  }
}

/* ================================================================
   Responsive: Small Mobile
   ================================================================ */
@media screen and (max-width: 480px) {
  :root {
    --sudoku-cell-min: 30px;
    --sudoku-cell-max: 38px;
  }

  .sudoku-controls {
    margin-bottom: 14px;
  }

  .sudoku-controls .controls-row {
    gap: 8px;
    row-gap: 6px;
  }

  .diff-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  .btn-new-game {
    padding: 7px 14px;
    font-size: 0.78rem;
  }

  .timer-display,
  .score-display {
    font-size: 1rem;
    padding: 3px 8px;
    min-width: 55px;
  }

  .btn-hint {
    padding: 7px 12px;
    font-size: 0.75rem;
  }

  .sudoku-board-wrapper {
    margin-bottom: 14px;
  }

  .number-pad {
    max-width: 320px;
    gap: 5px;
    padding: 0 8px;
  }

  .num-btn {
    min-height: 40px;
    font-size: 1.05rem;
    border-radius: 6px;
  }

  .status-bar {
    font-size: 0.82rem;
    min-height: 24px;
  }

  .victory-modal {
    padding: 28px 20px 20px 20px;
    border-radius: 12px;
  }

  .victory-icon {
    font-size: 2.8rem;
  }

  .victory-title {
    font-size: 1.3rem;
  }

  .victory-subtitle {
    font-size: 0.9rem;
  }

  .victory-stats {
    padding: 12px 16px;
  }

  .stat-label {
    font-size: 0.82rem;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .btn-play-again {
    padding: 10px 28px;
    font-size: 0.9rem;
  }
}

/* ================================================================
   Accessibility: Reduced Motion
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  .sudoku-cell,
  .num-btn,
  .diff-btn,
  .btn-new-game,
  .btn-hint,
  .btn-play-again,
  .victory-modal-overlay,
  .victory-modal {
    transition: none;
    animation: none;
  }
}
