/* POPUP INICIAL */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.popup-content {
  background: white;
  padding: 2rem;
  text-align: center;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

#start-game {
  margin-top: 1rem;
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  border: none;
  border-radius: 5px;
  background-color: #007428;
  color: white;
  cursor: pointer;
}

#difficulty-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.difficulty-btn {
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background-color: #8053B4;
  color: white;
  transition: background 0.3s;
}

.difficulty-btn:hover {
  background-color: #6a3fa0;
}


/* TOOLBAR SUPERIOR */
#sudoku-topbar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: sans-serif;
  font-size: 0.95rem;
  gap: 0;
  /* Eliminamos el gap para que los tercios sean precisos */
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
  width: 33.333%;
  display: flex;
  align-items: center;
}

.toolbar-left {
  justify-content: flex-start;
}

.toolbar-center {
  justify-content: center;
}

.toolbar-right {
  justify-content: flex-end;
  gap: 0.5rem;
}


/* TABLERO DE JUEGO */
#sudoku-wrapper {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 3rem 0;
  padding: 0 24px;
  flex-wrap: wrap;
}

#sudoku-container {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  max-width: 450px;
  aspect-ratio: 1;
  border-left: 2px solid #000;
  border-top: 2px solid #000;
  border-bottom: 2px solid #000;
}

.sudoku-cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid #ccc;
  font-size: 1.5rem;
  text-align: center;
  background-color: #f5f5f5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.sudoku-cell.given {
  background: #f5f5f5;
  font-weight: bold;
}

.sudoku-cell.selected {
  background: #cceeff;
}

.pencil {
  position: absolute;
  font-size: 0.6rem;
  color: #555;
}

.sudoku-cell:nth-child(3n) {
  border-right: 2px solid black;
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 2px solid black;
}


/* CONTROLES */
#controls {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 400px;
  gap: 10px;
}

.mode-toggle {
    display: flex;
    width: 100%;
    justify-content: space-between;    
  }

#numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.num-button,
.mode-button,
#erase-button,
#solve-button,
#reset-button {
  padding: 10px;
  font-size: 1rem;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 5px;
  background: #f9f9f9;
  text-align: center;
}

.mode-button {
  width: 45%;
}

.mode-button.active {
  background: #ddd;
}


/* RESPONSIVE */
@media (max-width: 600px) {
  #sudoku-wrapper {
    flex-direction: row;
    align-items: stretch;
    gap: 1.5rem;
    margin: 1rem 0;
    padding: 0 10px;
  }

  #sudoku-container {
    margin-bottom: 2rem;
  }

  #controls {    
    flex-direction: column;    
    padding: 0 1rem;
  }

  .mode-toggle {
    gap: 1rem;
    margin-bottom: 1rem;
  }

  #numbers {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    width: 100%;
  }

  .num-button,
  .mode-button,
  #erase-button,
  #solve-button,
  #reset-button {
    width: 100%;
    font-size: 1.1rem;
    padding: 0.8rem 0;
    text-align: center;
  }
  

  .action-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
  }

  #solve-button,
  #reset-button {
    flex: 1;
  }

  .sudoku-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .toolbar-left,
  .toolbar-center,
  .toolbar-right {
    width: 100%;
    justify-content: center;
  }

  .toolbar-left {
    justify-content: flex-start;
  }

  .toolbar-right {
    justify-content: flex-end;
  }
}