/* --- Definición de Variables (Light Mode por defecto) --- */
:root {
  --bg-body: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  --bg-card: #ffffff;
  --text-main: #2c3e50;
  --text-secondary: #7f8c8d;
  --bg-feedback: #f8f9fa;
  --border-color: #eee;
  --input-bg: #ffffff;
  --input-text: #2c3e50;
  --li-bg: #ffffff;
}

/* --- Variables para Dark Mode (Activadas con la clase) --- */
body.dark-mode {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f1f5f9;
  --text-secondary: #94a3b8;
  --bg-feedback: #0f172a;
  --border-color: #334155;
  --input-bg: #0f172a;
  --input-text: #ffffff;
  --li-bg: #1e293b;
}

/* --- Configuración General --- */
body {
  font-family: "Nunito Sans", sans-serif;
  background: var(--bg-body);
  background-attachment: fixed;
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  transition:
    background 0.4s ease,
    color 0.4s ease;
}

/* --- El Contenedor del Juego --- */
#game-container {
  background-color: var(--bg-card);
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  text-align: center;
  width: 90%;
  max-width: 450px;
  transition: background-color 0.4s ease;
}

h1 {
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

/* --- Área de Entrada --- */
.input-area {
  margin: 1.5rem 0;
  display: flex;
  justify-content: center;
  gap: 10px;
}

#inputNumero {
  padding: 10px;
  border: 2px solid var(--border-color);
  background-color: var(--input-bg);
  color: var(--input-text);
  border-radius: 8px;
  width: 100%;
  max-width: 140px;
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition:
    border-color 0.3s,
    background-color 0.3s;
}

#inputNumero:focus {
  border-color: #3498db;
}

button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition:
    transform 0.2s,
    background-color 0.2s;
}

#btnAdivinar {
  background-color: #3498db;
  color: white;
}

#btnAdivinar:hover {
  background-color: #2980b9;
  transform: scale(1.05);
}

/* --- Feedback y Mensajes --- */
.feedback-area {
  background-color: var(--bg-feedback);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  transition: background-color 0.3s;
}

#mensaje {
  font-size: 1.1rem;
  font-weight: 700;
  min-height: 1.6em;
}

#nombre-jugador {
  color: #e67e22;
}

/* --- Área de Historial --- */
.history-area {
  text-align: left;
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.history-area h3 {
  font-size: 1rem;
  color: var(--text-secondary);
}

#listaIntentos {
  list-style: none;
  padding: 0;
}

#listaIntentos li {
  background-color: var(--li-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 0;
  font-size: 0.9rem;
  color: var(--text-main);
  transition: background-color 0.3s;
}

/* --- Botón Reiniciar --- */
#btnReiniciar {
  background-color: #2ecc71;
  color: white;
  margin-top: 1rem;
  width: 100%;
}

#btnReiniciar:hover {
  background-color: #27ae60;
}

/* --- Botón del Switcher de Tema --- */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  font-size: 1.5rem;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.3s,
    transform 0.2s,
    color 0.3s;
}

.theme-toggle:hover {
  transform: rotate(15deg) scale(1.1);
}

/* --- Pantallas menores de 480px (móviles) --- */
@media (max-width: 480px) {
  #game-container {
    padding: 1rem;
    border-radius: 10px;
  }

  .input-area {
    flex-direction: column;
  }

  #inputNumero {
    width: 100%;
  }
}

/* --- Clase para ocultar elementos --- */
.hidden {
  display: none !important;
}

/* --- Pantalla de Inicio --- */
#pantalla-inicio {
  background-color: var(--bg-card);
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  text-align: center;
  width: 90%;
  max-width: 450px;
  transition: background-color 0.4s ease;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#inputNombre,
#inputEdad {
  padding: 10px;
  border: 2px solid var(--border-color);
  background-color: var(--input-bg);
  color: var(--input-text);
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition:
    border-color 0.3s,
    background-color 0.3s;
}

#inputNombre:focus,
#inputEdad:focus {
  border-color: #3498db;
}

#btnJugar {
  background-color: #3498db;
  color: white;
  font-size: 1rem;
}

#btnJugar:hover {
  background-color: #2980b9;
  transform: scale(1.05);
}

#error-registro {
  color: #e74c3c;
  font-size: 0.9rem;
  font-weight: bold;
  min-height: 1.2em;
}