/* ============================================================
   EL INDICE - SUDOKU
   Tablero clásico 9x9 con sub-cuadros 3x3
   ============================================================ */

.ei-sudoku {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: start;
}

@media (max-width: 760px) {
  .ei-sudoku { grid-template-columns: 1fr; }
}

/* ----------- TABLERO ----------- */
.ei-sudoku__board-wrap {
  display: flex;
  justify-content: center;
}

.ei-sudoku__board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: 100%;
  max-width: 540px;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--ei-juego-text);
  background: #fff;
  user-select: none;
}

.ei-sudoku__cell {
  position: relative;
  border-right: 1px solid var(--ei-juego-line);
  border-bottom: 1px solid var(--ei-juego-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ei-juego-font-serif);
  font-size: clamp(16px, 4.5vw, 26px);
  font-weight: 500;
  cursor: pointer;
  background: #fff;
  transition: background 0.1s;
  color: var(--ei-juego-text);
}

/* última columna y fila no necesitan borde extra */
.ei-sudoku__cell:nth-child(9n) { border-right: none; }
.ei-sudoku__cell:nth-child(n+73) { border-bottom: none; }

/* lineas gruesas para sub-cuadros 3x3 */
.ei-sudoku__cell:nth-child(3n):not(:nth-child(9n)) {
  border-right: 2px solid var(--ei-juego-text);
}
.ei-sudoku__cell:nth-child(n+19):nth-child(-n+27),
.ei-sudoku__cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 2px solid var(--ei-juego-text);
}

/* celdas dadas (no editables) */
.ei-sudoku__cell--given {
  font-weight: 700;
  color: var(--ei-juego-text);
  background: #fafafa;
  cursor: default;
}

/* celdas editables - número del usuario */
.ei-sudoku__cell--user {
  color: var(--ei-juego-azul);
  font-weight: 600;
}

/* celda seleccionada */
.ei-sudoku__cell--selected {
  background: var(--ei-juego-azul-soft) !important;
}

/* resaltar misma fila / col / cuadro de la seleccionada */
.ei-sudoku__cell--peer {
  background: rgba(0, 0, 0, 0.035);
}

/* resaltar mismas cifras */
.ei-sudoku__cell--same {
  background: rgba(31, 75, 138, 0.14);
}

/* celdas en error (al validar) */
.ei-sudoku__cell--error {
  color: var(--ei-juego-rojo) !important;
  background: var(--ei-juego-rojo-soft) !important;
}

/* notas (números chicos) */
.ei-sudoku__notes {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-family: var(--ei-juego-font-ui);
  font-size: 9px;
  color: var(--ei-juego-text-muted);
  font-weight: 600;
  pointer-events: none;
}
.ei-sudoku__note {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ----------- PANEL LATERAL ----------- */
.ei-sudoku__side {
  width: 280px;
  max-width: 100%;
}

@media (max-width: 760px) {
  .ei-sudoku__side {
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
  }
}

.ei-sudoku__pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.ei-sudoku__num {
  font-family: var(--ei-juego-font-serif);
  font-size: 22px;
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--ei-juego-line);
  border-radius: var(--ei-juego-radius);
  padding: 14px 0;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  color: var(--ei-juego-text);
}
.ei-sudoku__num:hover {
  background: #f5f5f5;
  border-color: #b8b8b8;
}
.ei-sudoku__num--done {
  opacity: 0.35;
}

.ei-sudoku__pad-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.ei-sudoku__toggle {
  font-family: var(--ei-juego-font-ui);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--ei-juego-line);
  border-radius: var(--ei-juego-radius);
  padding: 10px 8px;
  cursor: pointer;
  color: var(--ei-juego-text);
}
.ei-sudoku__toggle--active {
  background: var(--ei-juego-text);
  color: #fff;
  border-color: var(--ei-juego-text);
}

.ei-sudoku__info {
  border-top: 1px solid var(--ei-juego-line-soft);
  padding-top: 14px;
  margin-top: 8px;
  font-family: var(--ei-juego-font-ui);
  font-size: 12px;
  color: var(--ei-juego-text-muted);
  line-height: 1.6;
}
.ei-sudoku__info strong {
  color: var(--ei-juego-text);
}

/* completado */
.ei-sudoku--completed .ei-sudoku__board {
  border-color: #2c5e20;
}

/* animación de completado en celdas */
@keyframes ei-sudoku-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.ei-sudoku__cell--win {
  animation: ei-sudoku-pop 0.4s ease;
  color: #2c5e20 !important;
}
