/* ===============================
   ESTILOS GLOBALES
================================ */

body {
  font-family: Arial, sans-serif;
  background-color: #f3f3f3;
  margin: 0;
  overflow: hidden; /* Evita scroll */
}

/* Difuminado del fondo cuando el modal está activo */
body.blurred .container {
  filter: blur(10px);
}

/* Contenedor centrado vertical y horizontalmente; se usa height: 100vh y justify-content para alinear desde el tope */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  text-align: center;
  height: 100vh;
  box-sizing: border-box;
  justify-content: flex-start;
}

/* Título: un poco más pequeño y con poco margen superior */
h1 {
  margin: 5px 0;
  padding: 5px;
  font-size: 24px;
}

/* Cronómetro y cuenta regresiva (ocultos para el usuario) */
#gameTimer,
#countdown {
  display: none;
}

/* ===============================
   TABLERO DE JUEGO
================================ */

#board {
  display: grid;
  grid-template-rows: repeat(6, 60px);
  grid-gap: 5px;
  margin-bottom: 10px;
}

/* Cada fila del tablero */
.row {
  display: grid;
  grid-template-columns: repeat(5, 60px);
  grid-gap: 5px;
}

/* Celdas */
.cell {
  width: 60px;
  height: 60px;
  border: 2px solid #d3d6da;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  font-weight: bold;
  text-transform: uppercase;
  background-color: #ffffff;
  transition: transform 0.6s, background-color 0.6s;
  user-select: none;
  border-radius: 8px;
}

/* Celda activa */
.cell.active {
  border: 2px solid #3CB371;
}

/* Estados */
.cell.correct {
  background-color: #6aaa64;
  color: white;
}

.cell.present {
  background-color: #FFA500;
  color: white;
}

.cell.absent {
  background-color: #787c7e;
  color: white;
}

.cell.flip {
  transform: rotateX(360deg);
}

/* ===============================
   TECLADO VIRTUAL
================================ */

#keyboard {
  width: 100%;
  max-width: 500px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  margin-bottom: 5px;
}

.key {
  padding: 10px;
  margin: 2px;
  font-size: 18px;
  font-weight: bold;
  text-transform: uppercase;
  background-color: #d3d6da;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  flex-grow: 1;
  touch-action: manipulation;
  -ms-touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.key:active {
  background-color: #b1b3b6;
}

.key.correct {
  background-color: #6aaa64;
  color: white;
}

.key.present {
  background-color: #FFA500;
  color: white;
}

.key.absent {
  background-color: #787c7e;
  color: white;
}

.key.enter {
  background-color: #6aaa64;
  color: white;
  flex-grow: 2;
}

.key.backspace {
  background-color: #d3d6da;
  flex-grow: 2;
}

/* ===============================
   MODALES
================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
}

/* Modal alerta centrado */
.modal.alert {
  align-items: center;
  padding-top: 0;
}

/* Modal resultados centrado (en desktop) */
.modal.result .modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.modal .modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  max-width: 90%;
  text-align: center;
  position: relative;
}

.modal .close-btn {
  position: absolute;
  top: 5px;
  right: 10px;
  font-size: 20px;
  cursor: pointer;
}

.final-score {
  color: #FF4500;
  font-weight: bold;
  font-size: 1.2em;
}

/* ===============================
   BLOQUE CTA – DECISIONES
================================ */

.pdd-hub-link-secondary {
  display: block;
  margin-top: 8px;
  text-align: center;
  font-size: 0.9rem;
  color: #999;
  text-decoration: none;
}

.next-games-hub-link {
  display: block;
  margin-top: 8px;
  text-align: center;
  font-size: 0.9rem;
  color: #999;
  text-decoration: none;
}

.next-game {
  margin-top: 15px;
  padding: 12px;
  background: #fff7cc;
  border-radius: 8px;
}

.next-message {
  margin: 0 0 8px 0;
  font-size: 15px;
}

.next-link { text-decoration: none; font-weight: bold; color: #6aaa64; /* verde recomendado */

}

.next-link:hover {
  text-decoration: underline;
}

/* ===============================
   ANUNCIOS
================================ */

.ad-container {
  text-align: center;
  z-index: 1001;
}

.mobile-ad {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 100px;
}

.desktop-ad {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 728px;
  height: 90px;
}

/* Solo mostrar el contenedor de anuncio correspondiente */
@media (max-width: 600px) {
  #ad-desktop,
  .desktop-ad {
    display: none !important;
  }

  /* Ajustar el contenedor para que el anuncio superior no desplace el contenido */
  .container {
    padding-top: 110px;
  }
}

@media (min-width: 601px) {
  #ad-mobile,
  .mobile-ad {
    display: none !important;
  }

  /* Ajustar el contenedor para que el anuncio inferior no sobreponga el contenido */
  .container {
    padding-bottom: 110px;
  }
}

/* ===============================
   RESPONSIVE MÓVIL
================================ */

@media (max-width: 600px) {
  #board {
    grid-template-rows: repeat(6, 50px);
    grid-gap: 4px;
  }
  .row {
    grid-template-columns: repeat(5, 50px);
    grid-gap: 4px;
  }
  .cell {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  .key {
    padding: 8px;
    font-size: 16px;
  }
  .modal.result .modal-content {
    width: 95%;
    min-width: 350px;
  }

  /* ✅ FIX: Modal debajo del anuncio móvil */
  .modal {
    align-items: flex-start;
    padding-top: 110px; /* altura del ad (100px) + margen */
  }

  /* ✅ Quitar centrado absoluto SOLO en móvil y permitir scroll interno */
  .modal.result .modal-content {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
  }
}

/* ===============================
   RESUMEN DE INTENTOS (IMPORTANTE)
================================ */

/* Estilos para el resumen de intentos en el modal de resultados */
.attempt-row {
  display: flex;
  justify-content: center;
  margin: 5px 0;
}

.attempt-cell {
  width: 24px;
  height: 24px;
  margin: 0 2px;
  border: 1px solid #d3d6da;
  border-radius: 4px;
}

.attempt-cell.correct {
  background-color: #6aaa64;
}

.attempt-cell.present {
  background-color: #FFA500;
}

.attempt-cell.absent {
  background-color: #787c7e;
}
