/* ==========================================================================
   BrainTrain - Styles Sudoku (Grille 9x9 & Pavé Numérique Mobile)
   ========================================================================== */

.sudoku-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  gap: clamp(0.5rem, 1.5vh, 0.875rem);
}

/* --------------------------------------------------------------------------
   Grille Sudoku 9x9
   -------------------------------------------------------------------------- */
.sudoku-board-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
}

.sudoku-board {
  width: 100%;
  max-width: min(420px, 92vw, 48vh);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background-color: #1C1917; /* Bordures épaisses */
  border: 2.5px solid #1C1917;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  user-select: none;
  touch-action: manipulation;
}

.sudoku-cell {
  background-color: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 4.5vw, 1.5rem);
  font-weight: 600;
  color: var(--accent-primary);
  cursor: pointer;
  position: relative;
  transition: background-color 100ms ease, color 100ms ease;
  outline: 1px solid var(--border-subtle);
  min-width: 0;
}

/* Séparateurs épais pour les blocs 3x3 */
.sudoku-cell:nth-child(3n) {
  border-right: 2px solid #1C1917;
}
.sudoku-cell:nth-child(9n) {
  border-right: none;
}

.sudoku-cell[data-row="2"],
.sudoku-cell[data-row="5"] {
  border-bottom: 2px solid #1C1917;
}

/* Indices initiaux (cases fixes de départ) */
.sudoku-cell.clue {
  color: var(--text-primary);
  font-weight: 800;
  background-color: #FAF8F5;
}

/* Surbrillances interactives */
.sudoku-cell.highlight-peer {
  background-color: #F5F3FF; /* Même ligne, colonne ou bloc */
}

.sudoku-cell.highlight-same-val {
  background-color: #FEF3C7; /* Mêmes chiffres sur la grille */
  color: #92400E;
}

.sudoku-cell.selected {
  background-color: #C7D2FE !important;
  color: #312E81 !important;
  font-weight: 800;
  box-shadow: inset 0 0 0 2px var(--accent-primary);
  z-index: 2;
}

/* Erreurs */
.sudoku-cell.error {
  background-color: #FEE2E2 !important;
  color: #DC2626 !important;
  animation: shake 300ms ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* --------------------------------------------------------------------------
   Mini-Grille de Notes au Crayon (Pencil Marks)
   -------------------------------------------------------------------------- */
.sudoku-notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 1px;
  pointer-events: none;
}

.note-digit {
  font-size: clamp(0.45rem, 1.8vw, 0.7rem);
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Barre d'outils secondaire (Notes, Annuler, Effacer, Vérifier)
   -------------------------------------------------------------------------- */
.sudoku-toolbar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: min(420px, 92vw);
  gap: clamp(0.25rem, 1vw, 0.5rem);
}

.tool-btn {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0.25rem 0.125rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: clamp(0.6875rem, 2.2vw, 0.8125rem);
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
}

.tool-btn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
}

.tool-btn:active {
  transform: scale(0.95);
}

.tool-btn.active {
  background-color: var(--accent-primary-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.tool-btn .tool-icon {
  font-size: clamp(0.9375rem, 3vw, 1.125rem);
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Pavé Numérique Tactile (1-9) - Anti-débordement Mobile
   -------------------------------------------------------------------------- */
.sudoku-keypad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: clamp(2px, 1.2vw, 6px);
  width: 100%;
  max-width: min(420px, 92vw);
  box-sizing: border-box;
  padding: 0;
}

.keypad-btn {
  min-width: 0;
  width: 100%;
  aspect-ratio: 1 / 1.2;
  min-height: 42px;
  padding: 0;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: clamp(0.9375rem, 3.8vw, 1.25rem);
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  user-select: none;
  touch-action: manipulation;
}

.keypad-btn:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-subtle);
}

.keypad-btn:active {
  transform: scale(0.92);
  background-color: var(--accent-primary-subtle);
  border-color: var(--accent-primary);
}

.keypad-count {
  font-size: clamp(0.5rem, 1.8vw, 0.625rem);
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
  margin-top: 1px;
}

.keypad-btn.completed {
  opacity: 0.3;
  pointer-events: none;
}
