/* Variables del sistema de diseño */
:root {
  --verde-oscuro:  #026937;
  --verde-lima:    #8dc63f;
  --turquesa:      #3ebdac;
  --verde-azulado: #0e7774;
  --bg:            #f6faf7;
  --superficie:    #ffffff;
  --texto:         #102019;
  --texto-suave:   #5a6b62;
  --borde:         #e2ece6;

  --radio:         8px;
  --sombra:        0 1px 4px rgba(2, 105, 55, 0.08);
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  --max-ancho:     680px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--texto);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Cabecera ─────────────────────────────────────── */
.cabecera {
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.titulo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--verde-oscuro);
  letter-spacing: -0.02em;
}

.titulo-fisica {
  color: var(--verde-azulado);
}

.contador-cabecera {
  font-size: 0.85rem;
  color: var(--texto-suave);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.sep {
  opacity: 0.5;
}

/* ── Layout principal ─────────────────────────────── */
.contenido {
  max-width: var(--max-ancho);
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Sección input ────────────────────────────────── */
.seccion-input {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1.25rem;
  box-shadow: var(--sombra);
}

#forma-guess {
  display: flex;
  gap: 0.5rem;
}

#input-palabra {
  flex: 1;
  padding: 0.6rem 0.875rem;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  font-size: 1rem;
  font-family: inherit;
  color: var(--texto);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}

#input-palabra:focus {
  border-color: var(--verde-azulado);
  box-shadow: 0 0 0 3px rgba(14, 119, 116, 0.15);
}

/* ── Botones ──────────────────────────────────────── */
.btn-primario {
  padding: 0.6rem 1.25rem;
  background: var(--verde-azulado);
  color: #fff;
  border: none;
  border-radius: var(--radio);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-primario:hover {
  background: var(--verde-oscuro);
}

.btn-primario:focus-visible {
  outline: 3px solid var(--verde-lima);
  outline-offset: 2px;
}

.btn-primario:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secundario {
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--verde-azulado);
  border: 1.5px solid var(--verde-azulado);
  border-radius: var(--radio);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-secundario:hover {
  background: var(--verde-azulado);
  color: #fff;
}

.btn-secundario:focus-visible {
  outline: 3px solid var(--verde-lima);
  outline-offset: 2px;
}

.btn-secundario:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Mensaje de error ─────────────────────────────── */
.mensaje-error {
  margin-top: 0.6rem;
  font-size: 0.875rem;
  color: var(--verde-azulado);
  min-height: 1.2em;
}

/* ── Sección pistas ───────────────────────────────── */
.seccion-pistas {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1.25rem;
  box-shadow: var(--sombra);
}

.lista-pistas {
  margin-top: 0.75rem;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lista-pistas li {
  font-size: 0.925rem;
  color: var(--texto);
  line-height: 1.45;
}

/* ── Sección intentos ─────────────────────────────── */
.seccion-intentos {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1.25rem;
  box-shadow: var(--sombra);
}

.subtitulo {
  font-size: 1rem;
  font-weight: 600;
  color: var(--texto-suave);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.78rem;
}

.lista-intentos {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* ── Fila de intento ──────────────────────────────── */
.intento-fila {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  border-radius: 6px;
  background: var(--bg);
  transition: background 0.1s;
}

.intento-fila.duplicado {
  animation: parpadeo 0.4s ease;
}

@keyframes parpadeo {
  0%, 100% { background: var(--bg); }
  50%       { background: #d4edd8; }
}

.intento-barra-wrap {
  height: 8px;
  background: var(--borde);
  border-radius: 4px;
  overflow: hidden;
}

.intento-barra {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.intento-palabra {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--texto);
  text-align: right;
  min-width: 7rem;
}

.intento-rank {
  font-size: 0.8rem;
  color: var(--texto-suave);
  text-align: right;
  min-width: 3.5rem;
}

/* Rank 1 — ganaste */
.intento-fila.rank-ganador .intento-palabra {
  color: var(--verde-oscuro);
  font-weight: 700;
}

/* ── Banner victoria ──────────────────────────────── */
.banner-victoria {
  position: fixed;
  inset: 0;
  background: rgba(2, 105, 55, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.banner-victoria[hidden] {
  display: none;
}

.banner-contenido {
  background: var(--superficie);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}

.banner-contenido h2 {
  font-size: 2rem;
  color: var(--verde-oscuro);
  margin-bottom: 0.75rem;
}

.banner-contenido p {
  font-size: 1.1rem;
  color: var(--texto);
  margin-bottom: 0.5rem;
}

.banner-contenido strong {
  color: var(--verde-azulado);
  font-size: 1.3rem;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 480px) {
  .cabecera {
    flex-direction: column;
    gap: 0.25rem;
  }

  #forma-guess {
    flex-direction: column;
  }

  .btn-primario {
    width: 100%;
  }

  .intento-fila {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  .intento-barra-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
