/* =========================================================
   RatoLibre — Palabras encadenadas
   Estilos propios del juego. Depende de los tokens de
   ../../assets/css/base.css. Móvil primero.
   ========================================================= */

/* ---------- Barra de herramientas ---------- */

.pe-selector {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  flex: 1 1 240px;
  min-width: 0;
  font-weight: 700;
}

.pe-selector select {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  padding: 0 40px 0 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%231f2a37' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M4 7l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.pe-selector select:hover {
  border-color: var(--accent);
}

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

.pe-area {
  padding: 16px;
}

.pe-area [hidden] {
  display: none !important;
}

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

/* ---------- Vidas y largo de la cadena ---------- */

.pe-marcador {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}

.pe-jugador {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 6px 2px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.pe-jugador.es-turno {
  border-color: var(--accent-2);
  background: var(--accent-2-soft);
  box-shadow: 0 0 0 2px var(--accent-2);
}

#jugador-pc.es-turno {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent);
}

.pe-nombre {
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.2;
}

.pe-vidas {
  display: flex;
  gap: 4px;
  font-size: 1.4rem;
  line-height: 1;
}

.pe-vida {
  color: #c0392b;
  display: inline-block;
}

.pe-vida.es-perdida {
  color: var(--border);
}

.pe-vida.es-recien {
  animation: pe-latido 0.8s ease;
}

@keyframes pe-latido {
  0% { transform: scale(1); color: #c0392b; }
  40% { transform: scale(1.5); color: #c0392b; }
  100% { transform: scale(1); }
}

.pe-largo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 6px 6px;
  border-radius: var(--radius);
  background: var(--bg);
  text-align: center;
}

.pe-largo-etiqueta {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.pe-largo strong {
  font-size: 1.5rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* ---------- Cadena ---------- */

.pe-cadena {
  padding: 10px 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Palabras anteriores: alto fijo para que la página no salte. */
.pe-anteriores {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: 6px 8px;
  height: calc(2 * 2em + 6px);
  overflow: hidden;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.pe-ficha {
  display: inline-flex;
  align-items: center;
  min-height: 2em;
  margin: 0;
  padding: 2px 10px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-weight: 700;
  line-height: 1.2;
}

.pe-ficha::after {
  content: "\2192";
  margin-left: 8px;
  color: var(--muted);
  font-weight: 400;
}

.pe-ficha.es-tuya {
  border-color: var(--accent-2);
}

.pe-ficha.es-pc {
  border-color: #d9a291;
}

.pe-ficha mark,
.pe-palabra mark {
  padding: 0 2px;
  border-radius: 4px;
  background: #fdf0c2;
  color: inherit;
}

.pe-actual {
  text-align: center;
}

.pe-quien {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.pe-palabra {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.pe-palabra mark {
  padding: 0 4px;
  background: var(--accent);
  color: #ffffff;
}

.pe-palabra.es-tuya mark {
  background: var(--accent-2);
}

.pe-palabra.es-vacia {
  color: var(--muted);
}

/* ---------- Caja de mensajes de alto fijo ---------- */

.pe-mensaje {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 4.2em;
  margin: 8px auto;
  text-align: center;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.pe-mensaje.es-exito {
  color: var(--accent-2);
}

.pe-mensaje.es-error {
  color: var(--accent-dark);
}

.pe-mensaje.es-pista {
  color: #6b4e00;
}

/* ---------- Turno: escribir la palabra ---------- */

.pe-turno {
  margin-bottom: 12px;
}

.pe-indicacion {
  display: block;
  margin: 0 0 8px;
  font-weight: 700;
  text-align: center;
}

.pe-chip {
  display: inline-block;
  min-width: 2.2em;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
}

.pe-chip-nota {
  font-weight: 600;
  color: var(--muted);
}

.pe-escribir {
  display: flex;
  gap: 8px;
}

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

.pe-campo:focus {
  outline: 3px solid var(--accent-2);
  outline-offset: 1px;
}

.pe-campo[readonly] {
  border-color: var(--border);
  background: var(--bg);
}

.pe-campo::placeholder {
  color: #8a8f98;
  font-weight: 600;
}

.pe-escribir .btn {
  flex: 0 0 auto;
  min-height: 56px;
  padding-left: 1.1rem;
  padding-right: 1.1rem;
}

.pe-acciones {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.pe-acciones .btn {
  min-height: 48px;
  padding: 0.45rem 0.5rem;
}

/* ---------- Paneles: confirmar, ¿la cuentas?, fin ---------- */

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

.pe-panel:focus {
  outline: none;
}

.pe-panel:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

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

.pe-panel p {
  margin: 0 0 0.5rem;
}

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

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

.pe-confirmar,
.pe-duda {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pe-confirmar .titulo,
.pe-duda .titulo {
  color: var(--accent-dark);
}

.pe-duda-palabra {
  font-size: 1.6rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.pe-nota {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- Todas las palabras de la partida ---------- */

.pe-todas {
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Sin flex: así el «(10)» no se separa del texto en el celular. */
.pe-todas summary {
  min-height: 40px;
  padding: 8px 0;
  font-weight: 700;
  cursor: pointer;
}

.pe-todas p {
  margin: 6px 0 4px;
  line-height: 1.6;
}

/* ---------- Barra de estado ---------- */

.pe-estado {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 16px 0 32px;
}

.pe-estado .dato {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.pe-estado strong {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.pe-ayuda ol li {
  margin-bottom: 0.7rem;
}

/* ---------- Pantallas medianas y grandes ---------- */

@media (min-width: 600px) {
  .pe-anteriores {
    height: 2em;
    font-size: 0.95rem;
  }

  .pe-palabra {
    font-size: 2.6rem;
  }

  .pe-nombre {
    font-size: 0.95rem;
  }

  .pe-estado {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

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

@media print {
  .pe-turno,
  .pe-todas {
    display: none;
  }
}
