/* =========================================================
   RatoLibre — De la A a la Z: estilos propios del juego
   Depende de los tokens de ../../assets/css/base.css
   Cada letra lleva color y símbolo: ✓ acertada (verde),
   ✕ fallada (roja), gris pendiente; la de ahora, con borde terracota.
   ========================================================= */

:root {
  --az-bien: #2f6f4e;
  --az-mal: #b3261e;
  --az-pendiente: #ece6db;
  --az-hueco: 5px;
}

/* Los botones del sitio usan display: inline-flex; sin esto, hidden no los ocultaría. */
[hidden] {
  display: none !important;
}

/* ---------- Zona de juego ---------- */

.az-area {
  padding: 10px;
}

.az-area > * {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Opción de reloj ---------- */

.az-opciones {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.az-etiqueta {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.az-botones-opcion {
  display: flex;
  gap: 6px;
  max-width: 520px;
}

.az-opcion {
  flex: 1 1 0;
  min-height: 48px;
  padding: 4px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
}

.az-opcion:hover {
  border-color: var(--accent);
}

.az-opcion[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.az-opcion:focus-visible,
.az-enie:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

/* ---------- Letras de la ronda ---------- */

.az-letras {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--az-hueco);
  margin-top: 0;
  margin-bottom: 12px;
  padding: 0;
  list-style: none;
}

.az-ficha {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 40px;
  aspect-ratio: 1 / 1;
  margin: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--az-pendiente);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
}

.az-ficha-marca {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 1;
}

.az-ficha.es-pasada {
  border: 2px dashed var(--muted);
}

.az-ficha.es-actual {
  border: 3px solid var(--accent);
  background: var(--surface);
  color: var(--accent-dark);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.az-ficha.es-actual.es-pasada {
  border-style: solid;
}

.az-ficha.es-acierto {
  background: var(--az-bien);
  color: #ffffff;
}

.az-ficha.es-fallo {
  background: var(--az-mal);
  color: #ffffff;
}

.az-ficha.es-sin {
  color: var(--muted);
}

.az-ficha.es-recien {
  animation: az-giro 0.45s ease-out;
}

@keyframes az-giro {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ---------- Marcador ---------- */

.az-marcador {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.az-marcador .dato {
  flex: 1 1 0;
  min-width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.az-marcador .etiqueta {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.az-marcador strong {
  font-size: 1.2rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.az-marcador .es-acierto strong { color: var(--az-bien); }
.az-marcador .es-fallo strong { color: var(--az-mal); }
.az-marcador .es-poco strong { color: var(--az-mal); }

/* ---------- Pregunta ---------- */

.az-pregunta {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 7.2em;
  padding: 12px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.az-letra-grande {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.az-pregunta-texto {
  flex: 1 1 auto;
  min-width: 0;
}

.az-regla {
  margin: 0 0 2px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.az-definicion {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

/* ---------- Respuesta ---------- */

.az-formulario {
  margin-top: 12px;
}

.az-campo-fila {
  display: flex;
  gap: 6px;
}

.az-campo {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 56px;
  padding: 0 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
}

.az-campo:hover {
  border-color: var(--accent);
}

.az-campo:focus-visible,
.az-campo:focus {
  outline: var(--focus);
  outline-offset: 1px;
  border-color: var(--accent-2);
}

.az-campo::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.az-enie {
  flex: 0 0 auto;
  width: 56px;
  min-height: 56px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.az-enie:hover {
  border-color: var(--accent);
}

/* Caja de mensajes de alto fijo: la página no salta al cambiar el texto. */
.az-mensaje {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.8em;
  margin: 6px 0;
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  color: var(--muted);
}

.az-mensaje.es-exito { color: var(--az-bien); }
.az-mensaje.es-fallo { color: var(--az-mal); }
.az-mensaje.es-aviso { color: var(--accent-dark); }

.az-acciones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.az-acciones .btn {
  width: 100%;
  padding-left: 0.6rem;
  padding-right: 0.6rem;
}

.az-acciones .az-responder {
  grid-column: 1 / -1;
  min-height: 56px;
  font-size: 1.1rem;
}

.az-formulario.es-pausa .az-acciones .btn {
  opacity: 0.55;
}

/* ---------- Paneles (confirmación y fin de la ronda) ---------- */

.az-panel {
  margin-top: 4px;
  padding: 18px 16px;
  border: 2px solid var(--accent-2);
  border-radius: var(--radius);
  background: var(--accent-2-soft);
  text-align: center;
}

/* El panel recibe el foco solo para que el lector de pantalla lo lea; no lleva contorno. */
.az-panel:focus,
.az-panel:focus-visible {
  outline: none;
}

.az-panel .titulo {
  margin: 0 0 0.4rem;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--accent-2);
}

.az-panel p {
  margin-bottom: 0.5rem;
}

.az-fin-resumen {
  font-size: 1.2rem;
  font-weight: 800;
}

.az-panel .botones {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.az-panel .botones .btn {
  flex: 1 1 200px;
  max-width: 320px;
}

.az-confirmar,
.az-fin.es-flojo {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.az-confirmar .titulo,
.az-fin.es-flojo .titulo {
  color: var(--accent-dark);
}

/* Repaso de las 27 respuestas */

.az-repaso {
  margin: 10px 0 0;
  text-align: left;
}

.az-repaso summary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 6px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.az-repaso summary::-webkit-details-marker {
  display: none;
}

.az-repaso summary::before {
  content: "▸";
  margin-right: 8px;
}

.az-repaso[open] summary::before {
  content: "▾";
}

.az-repaso summary:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

.az-repaso-lista {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.az-repaso-lista li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}

.az-repaso-letra {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--az-pendiente);
  font-weight: 800;
}

.az-repaso-lista .es-acierto .az-repaso-letra {
  background: var(--az-bien);
  color: #ffffff;
}

.az-repaso-lista .es-fallo .az-repaso-letra {
  background: var(--az-mal);
  color: #ffffff;
}

.az-repaso-texto {
  min-width: 0;
  overflow-wrap: anywhere;
}

.az-repaso-def {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- Estadísticas ---------- */

.az-estado {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0 32px;
}

.az-estado .dato {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.az-estado .etiqueta {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.az-estado strong {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.az-ayuda li {
  margin-bottom: 0.4rem;
}

/* ---------- Pantallas más anchas ---------- */

@media (min-width: 480px) {
  .az-letras {
    grid-template-columns: repeat(9, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  .az-area {
    padding: 16px;
  }

  .az-letras {
    grid-template-columns: repeat(14, minmax(0, 1fr));
    --az-hueco: 6px;
  }

  .az-ficha {
    font-size: 1.2rem;
  }

  .az-pregunta {
    min-height: 6em;
    padding: 16px;
  }

  .az-letra-grande {
    width: 72px;
    height: 72px;
    font-size: 2.4rem;
  }

  .az-definicion {
    font-size: 1.25rem;
  }

  .az-acciones {
    grid-template-columns: 2fr 1fr 1fr;
  }

  .az-acciones .az-responder {
    grid-column: auto;
  }

  .az-estado {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .az-ficha.es-recien {
    animation: none;
  }
}
