/* ════════════════════════════════════════════════════════════════════════
   Juego diario de palabras (/games). Va DESPUÉS de landing.css y usa sus tokens
   (--ink, --fg, --n-red, --n-gold, --n-blue, --n-purple, --font, --display).
   La página es oscura siempre, como la landing (color-scheme: dark).
   ════════════════════════════════════════════════════════════════════════ */
.jg {
  /* paleta: azul/oro (decidida el 26-oct). data-paleta="roja" solo para la comparativa. */
  --jg-ok: var(--n-blue);       /* en su sitio: cuadrado relleno */
  --jg-ok-ink: #fff;
  --jg-en: var(--n-gold);       /* en otro sitio: disco relleno */
  --jg-en-ink: #050508;
  --jg-no-ink: rgba(255, 255, 255, 0.4); /* no está: sin relleno, atenuada */
  --jg-borde: rgba(255, 255, 255, 0.16);
  --jg-acento: var(--n-red);    /* reto del día */
  --jg-tile: 58px;
  --jg-gap: 6px;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
.jg[data-paleta="roja"] { --jg-ok: var(--n-red); }
.jg[data-modo="libre"] { --jg-acento: var(--n-purple); }

.jg-solo-lector {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ── Cabecera ──────────────────────────────────────────────────────────── */
.jg-top {
  position: sticky; top: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(5, 5, 8, 0.86);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.jg-top .nav-brand { margin-right: 0; justify-self: start; }
/* El título es descriptivo y cambia de largo con el idioma («Palabras del día» es el más
   largo): nunca parte en dos líneas, encoge en pantallas chicas y en las más chicas se
   quita (el h1 sigue para el lector y la pastilla de abajo ya dice dónde estás). */
.jg-titulo {
  font-family: var(--display); font-size: 16px; line-height: 1.5; letter-spacing: 0.03em;
  justify-self: center; white-space: nowrap;
}
.jg-titulo em { font-style: normal; color: var(--jg-acento); }
.jg-top-der { justify-self: end; display: flex; align-items: center; gap: 8px; }
.jg-top .nav-langsw { margin-right: 0; }
.jg-redondo {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16); background: transparent; color: var(--fg2);
  font: 700 15px var(--font); cursor: pointer;
}
.jg-redondo:hover { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
@media (max-width: 719px) {
  .jg-top .nav-word { display: none; }
  .jg-titulo { font-size: 13px; }
}
@media (max-width: 359px) {
  .jg-titulo { display: none; }
}
.jg-sin-js { padding: 24px 16px; text-align: center; color: var(--fg2); }

/* ── Aviso de navegador dentro de una app ──────────────────────────────── */
.jg-app-aviso {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 10px 16px 0; padding: 12px 14px;
  border-radius: 14px;
  background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.35);
  font-size: 14px; line-height: 1.4; color: var(--fg);
}
.jg-app-aviso strong { display: block; font-weight: 700; }
.jg-app-aviso small { display: block; color: var(--fg2); margin-top: 2px; font-size: 12.5px; }
.jg-app-aviso button { margin-left: auto; flex-shrink: 0; background: none; border: 0; color: var(--fg2); font-size: 18px; cursor: pointer; line-height: 1; }

/* ── Duelo ─────────────────────────────────────────────────────────────── */
.jg-reto { margin: 10px auto 0; width: calc(100% - 32px); max-width: 520px; padding: 11px 14px; border-radius: 14px; background: rgba(251, 191, 36, 0.08); border: 1.5px solid rgba(251, 191, 36, 0.5); font-weight: 600; text-align: center; }
.jg-reto small { display: block; font-weight: 400; color: var(--fg2); }
.jg-reto.breve { padding: 4px 12px; font-size: 13px; font-weight: 800; color: var(--n-gold); }
@media (max-height: 600px) { .jg-reto { margin-top: 6px; padding: 5px 10px; font-size: 13px; line-height: 1.25; } }
.jg-tarjeta .jg-duelo-res { display: flex; align-items: center; justify-content: center; gap: 10px; font: 21px/1.6 var(--display); color: #fff; }
/* ▲ ganas, ● empate, ▼ pierdes */
.jg-duelo-res i { width: 16px; height: 16px; background: var(--n-blue); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.jg-duelo-res[data-r="0"] i { background: var(--n-gold); clip-path: circle(50%); }
.jg-duelo-res[data-r="-1"] i { background: #8b8b9e; rotate: 180deg; }
.jg-duelo tr.decide td { color: #fff; font-weight: 800; }
.jg-duelo tr.decide td:first-child::before { content: "◆ "; color: var(--n-gold); }
.jg-tarjeta .jg-nota-copia { margin: -6px 0 14px; color: #fff; }
.jg :focus-visible { outline: 2px solid var(--n-gold); outline-offset: 2px; }

/* ── Estructura ────────────────────────────────────────────────────────── */
.jg-main {
  flex: 1;
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-content: start;
  gap: 24px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.jg-panel { display: none; }
@media (min-width: 1100px) {
  .jg-main {
    grid-template-columns: minmax(220px, 290px) minmax(440px, 520px) minmax(220px, 290px);
    justify-content: center; align-items: start; gap: 40px; padding-top: 36px;
  }
  .jg-panel { display: block; }
}
.jg-centro { width: 100%; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 12px; position: relative; }

/* ── Barra de modo: reto del día o modo libre ──────────────────────────── */
.jg-modo { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; }
.jg-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: #fff; background: color-mix(in srgb, var(--jg-acento) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--jg-acento) 55%, transparent);
}
.jg-chip i { font-style: normal; width: 7px; height: 7px; border-radius: 50%; background: var(--jg-acento); box-shadow: 0 0 10px var(--jg-acento); }
.jg-chip.libre { border-style: dashed; }
.jg-pasos { display: flex; gap: 6px; list-style: none; }
.jg-pasos li {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: var(--fg3); border: 1.5px solid rgba(255, 255, 255, 0.14);
}
.jg-pasos li.actual { color: #fff; border-color: var(--jg-acento); box-shadow: 0 0 14px -2px var(--jg-acento); }
.jg-pasos li.hecho { color: #fff; background: var(--jg-acento); border-color: transparent; }
.jg-pasos li.fallo { color: #fff; background: #2a2a36; border-color: transparent; }
.jg-nota { font-size: 12px; color: var(--fg3); text-align: right; }
@media (max-width: 440px) {
  .jg-chip { font-size: 11px; letter-spacing: 0.06em; padding: 6px 10px; gap: 6px; white-space: nowrap; }
  .jg-pasos li { width: 28px; height: 28px; font-size: 11px; }
  .jg-pasos { gap: 4px; }
}

/* ── Tablero ───────────────────────────────────────────────────────────── */
.jg-tablero { display: grid; gap: var(--jg-gap); }
.jg[data-modo="libre"] .jg-tablero { padding: 10px; border: 1.5px dashed color-mix(in srgb, var(--n-purple) 45%, transparent); border-radius: 18px; }
.jg-fila { display: grid; grid-template-columns: repeat(5, var(--jg-tile)); gap: var(--jg-gap); }
.jg-casilla {
  width: var(--jg-tile); height: var(--jg-tile);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font); font-weight: 800; font-size: calc(var(--jg-tile) * 0.48); line-height: 1;
  text-transform: uppercase; color: #fff;
  border: 2px solid var(--jg-borde); border-radius: 10px;
  background: transparent;
}
.jg-casilla.escrita { border-color: rgba(255, 255, 255, 0.55); animation: jgPop 0.12s ease-out; }
/* Forma, además de color: cuadrado relleno / disco relleno / sin relleno. */
.jg-casilla[data-e="2"] { background: var(--jg-ok); color: var(--jg-ok-ink); border-color: transparent; border-radius: 8px; }
.jg-casilla[data-e="1"] { background: var(--jg-en); color: var(--jg-en-ink); border-color: transparent; border-radius: 50%; }
.jg-casilla[data-e="0"] { background: transparent; color: var(--jg-no-ink); border-color: transparent; }
.jg-casilla.gira { animation: jgGira 0.45s ease-in-out both; animation-delay: calc(var(--i) * 0.16s); }
.jg-fila.sacude { animation: jgSacude 0.4s; }
@keyframes jgPop { 50% { transform: scale(1.08); } }
@keyframes jgGira { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes jgSacude { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.jg-msg { min-height: 22px; font-size: 14px; font-weight: 600; color: var(--fg2); text-align: center; }
.jg-msg.alerta { color: #fff; }

/* ── Teclado en pantalla (sin <input>: el teclado del sistema no sale) ── */
.jg-teclado { width: 100%; max-width: 500px; display: flex; flex-direction: column; gap: 7px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.jg-tfila { display: flex; gap: 5px; justify-content: center; }
.jg-tecla {
  flex: 1 1 0; min-width: 0; height: var(--jg-key, 54px);
  border: 0; border-radius: 8px;
  background: #23232f; color: #fff;
  font: 700 15px var(--font); text-transform: uppercase;
  cursor: pointer; position: relative;
  -webkit-tap-highlight-color: transparent;
}
.jg-tecla:active { transform: translateY(1px); filter: brightness(1.2); }
.jg-tecla.ancha { flex: 1.55 1 0; font-size: 11.5px; letter-spacing: 0.04em; }
/* «ENVIAR» y «ENTRÉE» no caben a 11,5 px por debajo de ~380 px de ancho */
@media (max-width: 379px) { .jg-tecla.ancha { font-size: 9.5px; letter-spacing: 0; } }
.jg-tecla[data-e="2"] { background: var(--jg-ok); color: var(--jg-ok-ink); }
.jg-tecla[data-e="1"] { background: var(--jg-en); color: var(--jg-en-ink); }
.jg-tecla[data-e="0"] { background: #121219; color: rgba(255, 255, 255, 0.28); }
/* marcas de forma también en el teclado: punto redondo = otro sitio, cuadrito = en su sitio */
.jg-tecla[data-e="1"]::after, .jg-tecla[data-e="2"]::after {
  content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px;
  background: currentColor; opacity: 0.6;
}
.jg-tecla[data-e="1"]::after { border-radius: 50%; }
.jg-tecla[data-e="2"]::after { border-radius: 1px; }

/* ── Capas: paso entre palabras, resumen, compartir, ya jugaste ─────────── */
.jg-capa {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8px 0 16px;
  overflow-y: auto; overscroll-behavior: contain;
  background: rgba(5, 5, 8, 0.72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.jg-capa[hidden] { display: none; }
.jg-tarjeta {
  width: min(440px, 100%);
  border-radius: 24px; padding: 24px 22px;
  border: 1.5px solid transparent;
  background:
    linear-gradient(165deg, #10101a, #07070b) padding-box,
    linear-gradient(165deg, var(--jg-acento), color-mix(in srgb, var(--jg-acento) 25%, transparent) 60%, rgba(255, 255, 255, 0.12)) border-box;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.9), 0 0 40px -18px var(--jg-acento);
  text-align: center;
  animation: jgEntra 0.35s var(--ease) both;
}
@keyframes jgEntra { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.jg-tarjeta .kicker { margin-bottom: 8px; }
.jg-tarjeta h2 { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1.6; margin-bottom: 6px; }
.jg-tarjeta p { color: var(--fg2); font-size: 15px; }
.jg-palabra { display: inline-grid; grid-auto-flow: column; gap: 5px; margin: 14px 0 10px; }
.jg-palabra span { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 7px; background: var(--jg-ok); color: var(--jg-ok-ink); font-weight: 800; font-size: 20px; }
.jg-palabra.fallo span { background: #23232f; color: #fff; }
.jg-datos { display: flex; justify-content: center; gap: 18px; margin: 6px 0 18px; font-size: 14px; color: var(--fg2); }
.jg-datos b { color: #fff; font-weight: 700; }
.jg-botones { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.jg-botones .btn { width: 100%; padding: 14px 20px; }
button.btn-ghost { background: transparent; }
.jg-enlace { font-size: 14px; color: var(--fg2); text-decoration: underline; text-underline-offset: 3px; margin-top: 6px; display: inline-block; }

/* Resumen */
.jg-tabla { width: 100%; border-collapse: collapse; margin: 14px 0 10px; font-size: 14px; }
.jg-tabla th { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg3); text-align: left; padding: 0 6px 8px; }
.jg-tabla td { padding: 9px 6px; border-top: 1px solid var(--line); text-align: left; color: var(--fg2); }
.jg-tabla td:first-child { color: #fff; font-weight: 700; letter-spacing: 0.06em; }
.jg-tabla td.num, .jg-tabla th.num { text-align: right; font-variant-numeric: tabular-nums; }
.jg-tabla tfoot td { color: #fff; font-weight: 800; border-top: 1.5px solid rgba(255, 255, 255, 0.25); }
.jg-racha { display: flex; justify-content: center; gap: 10px; margin: 6px 0 18px; flex-wrap: wrap; }
.jg-racha span { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); font-size: 13px; color: var(--fg2); }
.jg-racha b { color: #fff; }

/* Tarjeta para compartir (solo texto: esto es su vista previa) */
.jg-mini { display: flex; justify-content: center; gap: 14px; margin: 14px 0 6px; }
.jg-mini-col { display: grid; gap: 3px; }
.jg-mini-col small { font-size: 11px; color: var(--fg3); font-weight: 700; margin-bottom: 2px; }
.jg-mini-fila { display: grid; grid-template-columns: repeat(5, 12px); gap: 3px; }
.jg-mini-fila i { width: 12px; height: 12px; display: block; background: #23232f; border-radius: 2px; }
.jg-mini-fila i[data-e="2"] { background: var(--jg-ok); }
.jg-mini-fila i[data-e="1"] { background: var(--jg-en); border-radius: 50%; }
.jg-texto {
  /* pre-wrap: la primera línea (título, #día, resultado) parte si no cabe; las de cuadritos son cortas */
  text-align: left; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 500 12.5px/1.35 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin: 12px 0 16px; color: #fff;
  max-height: min(38vh, 340px); overflow-y: auto;
}
.jg-toast {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; background: #fff; color: #050508; font-weight: 800; font-size: 14px;
  z-index: 12; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.8);
}
.jg-cuenta { font-family: var(--display); font-size: 30px; line-height: 1.5; margin: 6px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }

/* ── Paneles de escritorio ─────────────────────────────────────────────── */
.jg-panel { width: 100%; }
.jg-panel h3 { font-size: 12px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--fg3); margin-bottom: 14px; }
.jg-panel p, .jg-panel li { color: var(--fg2); font-size: 14.5px; line-height: 1.55; }
.jg-panel ul { display: grid; gap: 10px; margin-bottom: 22px; }
.jg-leyenda { display: grid; gap: 12px; margin-bottom: 22px; }
.jg-leyenda div { display: flex; align-items: center; gap: 12px; }
.jg-leyenda .jg-casilla { --jg-tile: 38px; flex-shrink: 0; }
.jg-caja { border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: rgba(255, 255, 255, 0.02); margin-bottom: 16px; }
.jg-lista-dia { display: grid; gap: 10px; }
.jg-lista-dia li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.jg-lista-dia li b { color: #fff; }
.jg-grande { font-family: var(--display); font-size: 26px; line-height: 1.5; color: #fff; }
.jg-pie-privacidad { font-size: 12.5px; color: var(--fg3); }
.jg-pie-privacidad a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
/* Pie bajo el juego: lo mismo que el final del panel izquierdo, que debajo de 1100 px no se ve. */
.jg-pie { text-align: center; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
.jg-pie p { max-width: 520px; margin: 0 auto; line-height: 1.5; }
@media (min-width: 1100px) { .jg-pie { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .jg-casilla.gira, .jg-casilla.escrita, .jg-fila.sacude, .jg-tarjeta { animation: none !important; }
}
