/*
 * Estilos del cliente. El juego es accesible ante todo por lector de pantalla:
 * lo visual es un apoyo. Reglas que no se rompen: alto contraste, foco siempre
 * visible, la información nunca depende solo del color (los resultados llevan
 * texto), y se respeta "reducir movimiento". La fuente de verdad para quien no
 * ve son el texto y las regiones aria-live.
 *
 * El tema se adapta al sistema (claro/oscuro) con prefers-color-scheme.
 */

/*
 * Las dos paletas, con sus colores escritos UNA sola vez. Debajo se eligen
 * según el tema: automático (lo que diga el sistema) o el que haya forzado el
 * jugador con el botón, que pone `data-theme` en el elemento raíz.
 */
:root {
  /* Paleta oscura */
  --dark-bg: #0e1117;
  --dark-bg-2: #131a24;
  --dark-panel: #171c26;
  --dark-panel-2: #1e2532;
  --dark-text: #eef1f6;
  --dark-muted: #9aa4b7;
  --dark-accent: #5aa9ff;
  --dark-accent-strong: #2563eb;
  --dark-danger: #f87171;
  --dark-good: #34d399;
  --dark-good-bg: rgba(52, 211, 153, 0.14);
  --dark-bad: #f87171;
  --dark-bad-bg: rgba(248, 113, 113, 0.14);
  --dark-border: #29313f;
  --dark-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);

  /* Paleta clara */
  --light-bg: #eef2f9;
  --light-bg-2: #e4eaf4;
  --light-panel: #ffffff;
  --light-panel-2: #f4f7fc;
  --light-text: #16202e;
  --light-muted: #55617a;
  --light-accent: #1b74e4;
  --light-accent-strong: #1b74e4;
  --light-danger: #cc2f2f;
  --light-good: #0f8a4d;
  --light-good-bg: #e6f6ee;
  --light-bad: #cc2f2f;
  --light-bad-bg: #fdeaea;
  --light-border: #d5dde9;
  --light-shadow: 0 1px 2px rgba(20, 30, 50, 0.08), 0 10px 30px rgba(20, 30, 50, 0.08);
}

/* Oscuro: es el de partida, y también el que se aplica si se fuerza. */
:root,
:root[data-theme="dark"] {
  --bg: var(--dark-bg);
  --bg-2: var(--dark-bg-2);
  --panel: var(--dark-panel);
  --panel-2: var(--dark-panel-2);
  --text: var(--dark-text);
  --muted: var(--dark-muted);
  --accent: var(--dark-accent);
  --accent-strong: var(--dark-accent-strong);
  --danger: var(--dark-danger);
  --good: var(--dark-good);
  --good-bg: var(--dark-good-bg);
  --bad: var(--dark-bad);
  --bad-bg: var(--dark-bad-bg);
  --border: var(--dark-border);
  --shadow: var(--dark-shadow);
  color-scheme: dark;
}

/* Claro automático: lo pide el sistema y el jugador no ha forzado el oscuro. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: var(--light-bg);
    --bg-2: var(--light-bg-2);
    --panel: var(--light-panel);
    --panel-2: var(--light-panel-2);
    --text: var(--light-text);
    --muted: var(--light-muted);
    --accent: var(--light-accent);
    --accent-strong: var(--light-accent-strong);
    --danger: var(--light-danger);
    --good: var(--light-good);
    --good-bg: var(--light-good-bg);
    --bad: var(--light-bad);
    --bad-bg: var(--light-bad-bg);
    --border: var(--light-border);
    --shadow: var(--light-shadow);
    color-scheme: light;
  }
}

/* Claro forzado por el jugador: manda sobre lo que diga el sistema. */
:root[data-theme="light"] {
  --bg: var(--light-bg);
  --bg-2: var(--light-bg-2);
  --panel: var(--light-panel);
  --panel-2: var(--light-panel-2);
  --text: var(--light-text);
  --muted: var(--light-muted);
  --accent: var(--light-accent);
  --accent-strong: var(--light-accent-strong);
  --danger: var(--light-danger);
  --good: var(--light-good);
  --good-bg: var(--light-good-bg);
  --bad: var(--light-bad);
  --bad-bg: var(--light-bad-bg);
  --border: var(--light-border);
  --shadow: var(--light-shadow);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--bg-2), transparent 70%),
    var(--bg);
  min-height: 100vh;
}

.layout {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

h1 {
  font-size: 1.7rem;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.2rem;
  margin-top: 1.8rem;
}
h3 {
  font-size: 1.05rem;
}
p {
  margin: 0.6rem 0;
}

/* Solo para lector de pantalla: fuera de la vista pero anunciable. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-strong);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 8px 0;
  z-index: 10;
}
.skip-link:focus {
  left: 0;
}

/* --- Formularios y campos --- */

.field {
  margin: 0.8rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

label {
  font-weight: 600;
}

input[type="text"],
input:not([type]) {
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]::placeholder {
  color: var(--muted);
}
input[type="text"]:hover,
input:not([type]):hover {
  border-color: var(--accent);
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* --- Botones --- */

button {
  font-size: 1rem;
  font-family: inherit;
  padding: 0.65rem 1.1rem;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--accent-strong);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s ease, transform 0.05s ease, border-color 0.15s ease;
}
button:hover {
  filter: brightness(1.08);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
}
button.secondary:hover {
  border-color: var(--accent);
}
button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-strong);
  color: #fff;
}

.action-row,
.toolbar,
.team-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.team-picker {
  margin: 0;
}

/* --- Estado y avisos --- */

.status {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 0.75rem 0.95rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.clock {
  border-left-color: var(--good);
  font-variant-numeric: tabular-nums;
}

.hint {
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-weight: 600;
  min-height: 1.4em;
}

/* --- Jugadores y marcador --- */

.players {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.player {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  box-shadow: var(--shadow);
}
.player.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}
.player .name {
  font-weight: 700;
}
.player .meta {
  color: var(--muted);
  font-size: 0.9rem;
}
.player button {
  margin-left: auto;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
}

/* --- Configuración --- */

#config-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.4rem 1rem 1rem;
  margin: 0.5rem 0 1rem;
  box-shadow: var(--shadow);
}
.config-row {
  margin: 0.8rem 0;
}
.config-legend {
  font-weight: 600;
  margin: 0.2rem 0;
}

#actions {
  margin-top: 0.5rem;
}

/* --- Juego --- */

.secret-word {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: var(--shadow);
}

.clues-title {
  font-size: 1.05rem;
  margin: 1.1rem 0 0.4rem;
}

/* Pistas como fichas numeradas, en fila. */
.clues {
  list-style: none;
  counter-reset: pista;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.3rem 0;
  padding: 0;
}
.clues li {
  counter-increment: pista;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.8rem 0.35rem 0.5rem;
  font-weight: 600;
}
.clues li::before {
  content: counter(pista);
  display: inline-grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--accent-strong);
  color: #fff;
  font-size: 0.85rem;
}

/* Intentos: verde acierto, rojo fallo — SIEMPRE con texto, el color solo apoya. */
.guesses {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.3rem 0;
  padding: 0;
}
.guess {
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
}
.guess.wrong {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: var(--bad);
}
.guess.correct {
  background: var(--good-bg);
  color: var(--good);
  border-color: var(--good);
}
.guess::before {
  margin-right: 0.4rem;
  font-weight: 700;
}
.guess.wrong::before {
  content: "✗";
}
.guess.correct::before {
  content: "✓";
}

.play-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
  margin: 0.7rem 0;
}
.play-form .field {
  flex: 1 1 12rem;
  margin: 0;
}

.summary {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem 1.1rem;
  margin: 0.5rem 0 1rem;
  box-shadow: var(--shadow);
}
.summary ul {
  margin: 0.3rem 0 0;
  padding-left: 1.4rem;
}

/* Respeta la preferencia de menos movimiento: sin transiciones ni animaciones. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
