/* ============================================================
   ZUNQIO · Componentes de interfaz
   ============================================================ */

/* ------------------------------------------------------------
   NAVBAR
   ------------------------------------------------------------ */
.app-navbar {
  position: sticky;
  top: 0;
  z-index: var(--z-navbar);
  height: var(--navbar-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg-root) 78%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border-subtle);
  transition: box-shadow var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.app-navbar[data-scrolled="true"] {
  box-shadow: var(--shadow-md);
  background: color-mix(in srgb, var(--bg-root) 92%, transparent);
}

.navbar__inner {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(var(--sp-4), 2.2vw, var(--sp-8));
  display: flex;
  align-items: center;
  gap: var(--sp-5);
}

/* Logo */
.logo {
  /* El logotipo no se refleja nunca.
     En árabe y hebreo el documento va en `rtl`, y un contenedor flex
     invierte el orden de sus hijos: el símbolo se iba a la derecha y las
     dos mitades del nombre se intercambiaban, de modo que la marca se leía
     «QIOZUN». Una marca no se traduce ni se voltea; se escribe siempre
     igual, así que este trozo concreto se fija en `ltr`. */
  direction: ltr;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  flex: none;
  font-family: var(--font-display);
  font-weight: var(--fw-black);
  font-size: var(--fs-lg);
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.logo__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--gradient-mark);
  color: #fff;
  box-shadow: var(--shadow-brand);
  transition: transform var(--dur-base) var(--ease-spring), box-shadow var(--dur-base) var(--ease-out);
}
.logo:hover .logo__mark { transform: rotate(-8deg) scale(1.06); }
.logo__text {
  /* Sin hueco: ZUNQIO es una palabra. Los dos <span> existen para que el
     segundo lleve el degradado, no para separar dos palabras. */
  display: flex;
  gap: 0;
  white-space: nowrap;
}
.logo__text span:last-child {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Enlaces principales */
.navbar__links {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-inline: auto;
}
.navbar__link {
  position: relative;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.navbar__link:hover { color: var(--text-primary); background: var(--bg-hover); }
.navbar__link[aria-current="page"] { color: var(--text-primary); font-weight: var(--fw-semibold); }
.navbar__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -19px;
  translate: -50% 0;
  width: 26px;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--gradient-brand);
}

/* `min-width: 0` no es decorativo: sin él la fila no puede encogerse y, en
   idiomas con etiquetas largas (francés, ruso…), los enlaces del centro
   empujaban la barra fuera de la pantalla. Con esto cede el buscador. */
.navbar__actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; min-width: 0; }
.navbar__links + .navbar__actions { margin-left: 0; }

/* Botón hamburguesa: sólo en móvil.
   Va con doble clase a propósito: `.icon-btn` declara `display: grid` más
   abajo en este mismo fichero y, a igual especificidad, ganaba por orden.
   El resultado era una hamburguesa visible también en escritorio. */
.icon-btn.nav-burger { display: none; }
@media (max-width: 860px) {
  .icon-btn.nav-burger { display: grid; }
  .navbar__inner { gap: var(--sp-3); }

  /* La fila de acciones tiene que poder encogerse. Con el buscador a ancho
     fijo, la fila medía más que la pantalla y empujaba el documento: la barra
     inferior y el botón de acceso quedaban parcialmente fuera. */
  .navbar__actions {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
    gap: var(--sp-1);
  }
  .navbar__actions > * { flex: none; }
  .navbar__actions .search {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: 210px;
  }
}
@media (max-width: 560px) {
  .hide-sm { display: none; }
  .logo__text { display: none; }
  /* Por debajo de este ancho el buscador se queda sin espacio útil y su
     panel de resultados no cabe. La barra inferior fija ya ofrece «Buscar». */
  .navbar__actions .search { display: none; }
  .navbar__actions .icon-btn { width: 38px; height: 38px; }
}

/* ------------------------------------------------------------
   BUSCADOR
   ------------------------------------------------------------ */
.search {
  position: relative;
  width: clamp(160px, 20vw, 280px);
  min-width: 0;
  flex: 0 1 auto;
}
.search__field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 42px;
  padding-inline: var(--sp-4);
  border-radius: var(--r-pill);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out);
}
.search__field:focus-within {
  border-color: var(--border-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent);
  background: var(--bg-surface);
}
.search__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  font-size: var(--fs-base);
  color: var(--text-primary);
}
.search__icon { color: var(--text-muted); flex: none; }
.search__clear {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: var(--r-pill);
  color: var(--text-muted);
  background: var(--bg-hover);
  flex: none;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.search__clear:hover { color: var(--text-primary); background: var(--border-default); }

/* Resultados instantáneos */
.search__results {
  position: absolute;
  top: calc(100% + var(--sp-2));
  left: 0;
  right: 0;
  min-width: 320px;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-2);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-drawer);
  animation: pop-in var(--dur-base) var(--ease-out);
}
.search__results:not([hidden]) { display: block; }

/* En pantallas estrechas el campo es más angosto que el panel: se ancla al
   borde derecho y se limita al ancho disponible para no salirse. */
@media (max-width: 860px) {
  .search__results {
    left: auto;
    right: 0;
    min-width: 0;
    width: min(320px, calc(100vw - var(--sp-6)));
  }
}

.search-result {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
}
.search-result:hover,
.search-result[data-active="true"] { background: var(--bg-active); }
.search-result__thumb {
  width: 46px; height: 46px;
  border-radius: var(--r-xs);
  overflow: hidden;
  flex: none;
  background: var(--bg-inset);
}
.search-result__thumb img { width: 100%; height: 100%; object-fit: cover; }
.search-result__title { font-size: var(--fs-base); font-weight: var(--fw-semibold); }
.search-result__meta { font-size: var(--fs-xs); color: var(--text-muted); }
.search-result__hint {
  margin-left: auto;
  font-size: var(--fs-2xs);
  color: var(--text-faint);
  flex: none;
}
.search__group-label {
  padding: var(--sp-2) var(--sp-2) var(--sp-1);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.search__empty { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }

/* ------------------------------------------------------------
   BOTONES
   ------------------------------------------------------------ */
.btn {
  --btn-bg: var(--bg-surface-2);
  --btn-fg: var(--text-primary);
  --btn-bd: var(--border-default);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 42px;
  padding-inline: var(--sp-5);
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-out), filter var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out), opacity var(--dur-fast);
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; filter: none; transform: none; }

.btn--primary {
  --btn-bg: var(--gradient-brand);
  --btn-fg: var(--text-on-brand);
  --btn-bd: transparent;
  box-shadow: var(--shadow-brand);
}
.btn--primary:hover { box-shadow: 0 14px 40px -10px var(--brand-glow); }

.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-secondary); }
.btn--ghost:hover { --btn-bg: var(--bg-hover); --btn-fg: var(--text-primary); }

.btn--outline { --btn-bg: transparent; --btn-bd: var(--border-strong); }
.btn--outline:hover { --btn-bd: var(--border-brand); --btn-bg: var(--bg-hover); }

.btn--danger { --btn-bg: color-mix(in srgb, var(--danger-500) 16%, transparent); --btn-fg: #ff8b8b; --btn-bd: color-mix(in srgb, var(--danger-500) 35%, transparent); }
.btn--danger:hover { --btn-bg: var(--danger-500); --btn-fg: #fff; }

.btn--success { --btn-bg: color-mix(in srgb, var(--ok-500) 16%, transparent); --btn-fg: #6ee7a0; --btn-bd: color-mix(in srgb, var(--ok-500) 35%, transparent); }

.btn--sm { height: 34px; padding-inline: var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-xs); }
.btn--lg { height: 52px; padding-inline: var(--sp-8); font-size: var(--fs-md); border-radius: var(--r-md); }
.btn--block { width: 100%; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  flex: none;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn--sm { width: 34px; height: 34px; border-radius: var(--r-xs); }
.icon-btn--bordered { border-color: var(--border-default); background: var(--bg-surface-2); }
.icon-btn[aria-pressed="true"] { color: var(--accent-pink); }
/* Estado apagado (música/sonido): atenuado, para que se distinga de un
   vistazo del estado activo sin depender sólo del icono. */
.icon-btn[data-off="true"] { color: var(--text-muted); opacity: 0.75; }
.icon-btn[data-off="true"]:hover { opacity: 1; }

/* ------------------------------------------------------------
   CHIPS / BADGES / PÍLDORAS
   ------------------------------------------------------------ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 34px;
  padding-inline: var(--sp-4);
  border-radius: var(--r-pill);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-out);
}
.chip:hover { color: var(--text-primary); border-color: var(--border-strong); transform: translateY(-1px); }
.chip[aria-pressed="true"],
.chip.is-active {
  background: var(--gradient-brand-soft);
  border-color: var(--border-brand);
  color: var(--text-primary);
}
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--chip-color, var(--brand-500)); flex: none; }

.chip-row {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
  scroll-snap-type: x proximity;
}
.chip-row > * { scroll-snap-align: start; flex: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--sp-2);
  border-radius: var(--r-xs);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.badge--new { background: var(--gradient-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }
.badge--hot { background: linear-gradient(135deg, #f97316, #ef4444); color: #fff; border-color: transparent; }
.badge--top { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #2a1a00; border-color: transparent; }
.badge--soft { background: var(--bg-active); color: var(--text-brand); border-color: var(--border-brand); }

/* ------------------------------------------------------------
   TARJETA DE JUEGO
   ------------------------------------------------------------ */
.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-md);
  isolation: isolate;
  transition: transform var(--dur-base) var(--ease-out);
}
.game-card:hover { transform: translateY(-4px); }

.game-card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.game-card:hover .game-card__media {
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-brand);
  border-color: var(--border-brand);
}

.game-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-out), filter var(--dur-base) var(--ease-out);
}
.game-card:hover .game-card__img { transform: scale(1.07); }

.game-card__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: var(--sp-2);
  background: linear-gradient(180deg, rgba(7, 7, 14, 0.1) 0%, rgba(7, 7, 14, 0.82) 100%);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}
.game-card:hover .game-card__overlay,
.game-card:focus-within .game-card__overlay { opacity: 1; }

.game-card__play {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-pill);
  background: var(--gradient-brand);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow-brand);
  transform: translateY(8px) scale(0.94);
  transition: transform var(--dur-base) var(--ease-spring);
}
.game-card:hover .game-card__play,
.game-card:focus-within .game-card__play { transform: translateY(0) scale(1); }

.game-card__badges {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  right: var(--sp-2);
  display: flex;
  gap: var(--sp-1);
  pointer-events: none;
}
.game-card__fav {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--r-pill);
  background: rgba(7, 7, 14, 0.55);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #fff;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity var(--dur-base), transform var(--dur-base) var(--ease-spring), color var(--dur-fast);
  z-index: 2;
}
.game-card:hover .game-card__fav,
.game-card:focus-within .game-card__fav,
.game-card__fav[aria-pressed="true"] { opacity: 1; transform: scale(1); }
.game-card__fav[aria-pressed="true"] { color: var(--accent-pink); }
.game-card__fav:hover { transform: scale(1.12); }

.game-card__body { padding: var(--sp-3) var(--sp-1) 0; }
.game-card__title {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  transition: color var(--dur-fast);
}
.game-card:hover .game-card__title { color: var(--text-brand); }

.game-card__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  row-gap: 2px;
  /* En tarjetas estrechas (320 px) la categoría, la valoración y el número de
     partidas no caben en una línea: sin esto se salían de la tarjeta y
     ensanchaban el documento. */
  flex-wrap: wrap;
  min-width: 0;
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.game-card__meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.6; flex: none; }
.game-card__cat { color: var(--cat-color, var(--text-muted)); font-weight: var(--fw-medium); }

/* Variante lista (para "más jugados") */
.game-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  transition: background var(--dur-fast) var(--ease-out);
}
.game-row:hover { background: var(--bg-hover); }
.game-row__rank {
  width: 20px;
  flex: none;
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.game-row:nth-child(1) .game-row__rank { color: var(--accent-amber); }
.game-row:nth-child(2) .game-row__rank { color: #cbd5e1; }
.game-row:nth-child(3) .game-row__rank { color: #d97706; }
.game-row__thumb {
  width: 36px; height: 36px;
  border-radius: var(--r-xs);
  overflow: hidden;
  flex: none;
  background: var(--bg-inset);
}
.game-row__thumb img { width: 100%; height: 100%; object-fit: cover; }
.game-row__title { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.game-row__value { margin-left: auto; font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; flex: none; }

/* ------------------------------------------------------------
   VALORACIÓN
   ------------------------------------------------------------ */
.rating { display: inline-flex; align-items: center; gap: 3px; }
.rating__stars { position: relative; display: inline-block; line-height: 0; color: var(--border-strong); }
.rating__fill {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: var(--accent-amber);
  white-space: nowrap;
}
.rating__value { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-secondary); }
.rating--interactive .rating__btn { padding: 2px; color: var(--border-strong); transition: color var(--dur-fast), transform var(--dur-fast); }
.rating--interactive .rating__btn:hover { transform: scale(1.2); }
.rating--interactive .rating__btn[data-on="true"] { color: var(--accent-amber); }

/* ------------------------------------------------------------
   TARJETAS DE PANEL LATERAL
   ------------------------------------------------------------ */
.sidebar-card {
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
  overflow: hidden;
}
.sidebar-card__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  letter-spacing: -0.015em;
}
.sidebar-card__head .icon-wrap {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: var(--r-xs);
  background: var(--gradient-brand-soft);
  color: var(--text-brand);
  flex: none;
}
.sidebar-card__body { padding: var(--sp-2) var(--sp-2) var(--sp-3); }
.sidebar-card__body--pad { padding: var(--sp-2) var(--sp-4) var(--sp-4); }

.cat-list { display: flex; flex-direction: column; gap: 1px; }
.cat-list__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.cat-list__item:hover { background: var(--bg-hover); color: var(--text-primary); }
.cat-list__item[aria-current="page"] {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
}
.cat-list__icon { color: var(--cat-color, var(--text-muted)); flex: none; display: grid; place-items: center; }
.cat-list__count { margin-left: auto; font-size: var(--fs-xs); color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* CTA de login */
.promo-card {
  padding: var(--sp-5) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.promo-card__title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-2);
}
.promo-card__title svg { color: var(--accent-pink); }
.promo-card__text { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--sp-4); line-height: 1.5; }

/* ------------------------------------------------------------
   CAJAS / PANELES GENERALES
   ------------------------------------------------------------ */
.panel {
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  padding: clamp(var(--sp-4), 2vw, var(--sp-6));
}
.panel--flush { padding: 0; overflow: hidden; }
.panel--glass {
  background: color-mix(in srgb, var(--bg-surface) 65%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}

.stat-tile {
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: transform var(--dur-base) var(--ease-out), border-color var(--dur-base);
}
.stat-tile:hover { transform: translateY(-2px); border-color: var(--border-default); }
.stat-tile__label {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--fw-semibold);
}
.stat-tile__value {
  margin-top: var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat-tile__hint { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 2px; }

/* ------------------------------------------------------------
   FORMULARIOS
   ------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field__label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}
.field__hint { font-size: var(--fs-xs); color: var(--text-faint); }
.field__error { font-size: var(--fs-xs); color: #ff8b8b; }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--border-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 16%, transparent);
  background: var(--bg-surface);
}
.textarea { min-height: 96px; line-height: 1.5; font-family: var(--font-mono); font-size: var(--fs-sm); }

.select {
  -webkit-appearance: none; appearance: none;
  padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2382829f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  cursor: pointer;
}
.select option { background: var(--bg-elevated); color: var(--text-primary); }

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  font-size: var(--fs-base);
  color: var(--text-secondary);
}
.switch__track {
  width: 42px; height: 24px;
  border-radius: var(--r-pill);
  background: var(--border-default);
  flex: none;
  transition: background var(--dur-base) var(--ease-out);
}
.switch__thumb {
  position: absolute;
  left: 3px; top: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: translate var(--dur-base) var(--ease-spring);
}
.switch input:checked + .switch__track { background: var(--brand-500); }
.switch input:checked + .switch__track + .switch__thumb { translate: 18px 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

/* Segmentado / tabs */
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}
.segmented__btn {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-xs);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.segmented__btn:hover { color: var(--text-primary); }
.segmented__btn[aria-selected="true"] {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border-subtle); overflow-x: auto; }
.tabs__btn {
  position: relative;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--dur-fast);
}
.tabs__btn:hover { color: var(--text-primary); }
.tabs__btn[aria-selected="true"] { color: var(--text-primary); font-weight: var(--fw-semibold); }
.tabs__btn[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: var(--sp-3); right: var(--sp-3); bottom: -1px;
  height: 2px;
  border-radius: var(--r-pill);
  background: var(--gradient-brand);
}

/* ------------------------------------------------------------
   MODAL
   ------------------------------------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: var(--bg-scrim);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade-in var(--dur-base) var(--ease-out);
}
.modal {
  width: min(520px, 100%);
  max-height: min(calc(var(--vh-dyn) * 0.86), 760px);
  overflow-y: auto;
  border-radius: var(--r-xl);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  animation: modal-in var(--dur-slow) var(--ease-spring);
}
.modal--wide { width: min(900px, 100%); }
.modal__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6) var(--sp-3);
}
.modal__title { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.modal__close { margin-left: auto; }
.modal__body { padding: var(--sp-2) var(--sp-6) var(--sp-4); }
.modal__foot {
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
  padding: var(--sp-4) var(--sp-6) var(--sp-6);
  /* Las acciones (Comprar, Guardar, Cerrar…) siempre a la vista, aunque la
     ficha sea larga: en un móvil apaisado «Comprar» quedaba 400 px más abajo. */
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
}
/* Poca altura (móvil apaisado): el pie fijo, más delgado. */
@media (max-height: 520px) {
  .modal__foot { padding-block: var(--sp-2); }
  .modal__head { padding-block: var(--sp-3) var(--sp-2); }
}
/* Diálogos: equis siempre visible.
   Acceso y registro no llevan título, y la equis vivía dentro del
   título: no había forma de cerrarlos salvo acertar en el borde de
   16 px que deja el fondo. Ahora flota arriba (también en PC,
   donde el problema era el mismo) y se queda a la vista aunque el
   formulario se desplace, porque va pegada al borde del diálogo. */
.modal__head--bare {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 0;
  padding: 0;
  align-items: flex-start;
  justify-content: flex-end;
  overflow: visible;
}
.modal__head--bare .modal__close {
  margin-block-start: var(--sp-3);
  margin-inline-end: var(--sp-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

/* La fila de botones que casi todos los diálogos meten en el pie. No tenía
   estilo: era un bloque, así que en PC los botones iban pegados sin
   separación y en el móvil cada uno ocupaba una línea entera (en la ficha
   de un cosmético, «Comprar» quedaba cuatro botones más abajo, fuera de
   la pantalla). */
.modal__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  width: 100%;
}

@media (max-width: 520px) {
  .modal__head, .modal__body, .modal__foot { padding-inline: var(--sp-4); }
  .modal__foot, .modal__actions { flex-direction: column-reverse; align-items: stretch; }
  .modal__foot .btn { width: 100%; }
}

/* ------------------------------------------------------------
   TOASTS
   ------------------------------------------------------------ */
.toast-root {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  max-width: min(360px, calc(100vw - var(--sp-8)));
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-spring);
}
.toast[data-leaving="true"] { animation: toast-out var(--dur-base) var(--ease-in-out) forwards; }
.toast__icon { flex: none; display: grid; place-items: center; }
.toast--success .toast__icon { color: var(--ok-500); }
.toast--error .toast__icon { color: var(--danger-500); }
.toast--info .toast__icon { color: var(--info-500); }
@media (max-width: 860px) {
  .toast-root { bottom: calc(58px + var(--sp-3) + env(safe-area-inset-bottom, 0px)); left: var(--sp-4); right: var(--sp-4); max-width: none; }
}

/* ------------------------------------------------------------
   PUBLICIDAD · banners (tamaños en ADS.formats, src/config.js)
   ------------------------------------------------------------ */
/* Aspecto neutro a propósito: un anuncio no debe poder pasar por juego, recompensa o botón de ZUNQIO. */
.ad-banner {
  display: grid;
  justify-items: center;
  gap: 4px; /* con los 16px del rótulo suma LABEL_SPACE de adBanner.js */
  margin-block: var(--sp-8);
}
.ad-banner__label {
  font-size: var(--fs-2xs);
  line-height: 16px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ad-banner__frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, var(--ad-w));
  height: var(--ad-h);
  overflow: hidden;
  border-radius: var(--r-xs);
  background: var(--bg-surface);
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}
.ad-banner[data-state="empty"] .ad-banner__label { visibility: hidden; }
.ad-banner[data-state="empty"] .ad-banner__frame { background: none; box-shadow: none; }
.ad-banner[data-state="collapsed"] { display: none; }

.ad-banner__preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 2px;
  padding: var(--sp-2);
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--text-faint) 14%, transparent) 10px 20px);
}
.ad-banner__preview strong { font-size: var(--fs-xs); letter-spacing: 0.14em; color: var(--text-secondary); }

.ad-rail { position: absolute; z-index: 1; margin: 0; }
.ad-rail .ad-banner__frame { width: var(--ad-w); }

/* En la barra lateral, algo más de aire sobre el anuncio que entre tarjetas: debajo de un enlace no se pega. */
.app-sidebar > .ad-banner { margin-block: var(--sp-2) 0; }
.game-page__body .ad-banner { margin-block: 0; }
.game-page__below > .ad-banner { margin-block: var(--sp-6); }

/* Si la ventana cambia de tamaño y el diseño se queda sin sitio para una posición, se oculta en vez de caer donde no toca. */
@media (max-width: 1024px), (max-height: 999px) { .app-sidebar > .ad-banner { display: none; } }
@media (max-width: 1100px) { .game-page__body .ad-banner { display: none; } }
@media (min-width: 1101px) { .game-page__below > .ad-banner { display: none; } }
/* Con el dedo, más distancia entre el anuncio y lo que se toca justo encima o debajo. */
@media (max-width: 720px), (pointer: coarse) { .ad-banner--inline { margin-block: var(--sp-10); } }
/* Un juego a pantalla completa (simulada) no deja ver nada debajo: los banners de la página no se cargan ni se ven. */
.is-game-fullscreen .ad-banner { visibility: hidden; }

/* ------------------------------------------------------------
   FOOTER
   ------------------------------------------------------------ */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--bg-canvas) 60%, transparent);
  padding-block: var(--sp-12) var(--sp-6);
}
.footer__grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, 1fr);
  gap: clamp(var(--sp-6), 3vw, var(--sp-10));
  margin-bottom: var(--sp-10);
}
.footer__about { max-width: 42ch; }
.footer__about p { margin-top: var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); }
.footer__col h3 {
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
}
.footer__col ul { display: flex; flex-direction: column; gap: var(--sp-2); }
.footer__col a { font-size: var(--fs-sm); color: var(--text-muted); }
.footer__col a:hover { color: var(--text-brand); }
.footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.footer__social { display: flex; gap: var(--sp-2); }
@media (max-width: 860px) {
  .footer__grid { grid-template-columns: 1fr 1fr; gap: var(--sp-8); }
  .footer__about { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .footer__grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------
   NAVEGACIÓN MÓVIL
   ------------------------------------------------------------ */
.mobile-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: var(--z-navbar);
  display: none;
  justify-content: space-around;
  align-items: center;
  height: calc(58px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--bg-root) 92%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-subtle);
}
.mobile-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--sp-2);
  min-width: 60px;
  border-radius: var(--r-sm);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  transition: color var(--dur-fast);
}
.mobile-nav__item[aria-current="page"] { color: var(--text-brand); }
@media (max-width: 860px) {
  .mobile-nav { display: flex; }
  .navbar__links { display: none; }
}

/* Drawer lateral (móvil) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  background: var(--bg-scrim);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: fade-in var(--dur-base) var(--ease-out);
}
.drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: calc(var(--z-drawer) + 1);
  width: min(320px, 86vw);
  padding: var(--sp-5);
  overflow-y: auto;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  animation: slide-in-left var(--dur-slow) var(--ease-out);
}

/* ------------------------------------------------------------
   ESTADOS: vacío, carga, error
   ------------------------------------------------------------ */
.empty-state {
  display: grid;
  place-items: center;
  gap: var(--sp-3);
  padding: clamp(var(--sp-10), 8vw, var(--sp-20)) var(--sp-4);
  text-align: center;
}
.empty-state__icon {
  display: grid; place-items: center;
  width: 72px; height: 72px;
  border-radius: var(--r-xl);
  background: var(--gradient-brand-soft);
  border: 1px solid var(--border-subtle);
  color: var(--text-brand);
  margin-bottom: var(--sp-2);
}
/* El nivel del encabezado depende de si el estado vacío es una sección o la
   página entera; el aspecto, no. */
.empty-state h1, .empty-state h2, .empty-state h3 { font-size: var(--fs-lg); }
.empty-state p { color: var(--text-muted); font-size: var(--fs-base); max-width: 46ch; }

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--skeleton-base);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  translate: -100% 0;
  background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent);
  animation: shimmer 1.4s infinite;
}
.skeleton--text { height: 12px; border-radius: var(--r-pill); }
.skeleton--card { aspect-ratio: 1/1; }

.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--border-default);
  border-top-color: var(--brand-500);
  animation: spin 0.7s linear infinite;
}

/* ------------------------------------------------------------
   MIGAS Y PAGINACIÓN
   ------------------------------------------------------------ */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}
.breadcrumbs a:hover { color: var(--text-brand); }
.breadcrumbs__sep { opacity: 0.5; }
.breadcrumbs [aria-current="page"] { color: var(--text-primary); font-weight: var(--fw-medium); }

.pagination { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-8); }

/* ------------------------------------------------------------
   AVATAR
   ------------------------------------------------------------ */
.avatar {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  font-family: var(--font-display);
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
  -webkit-user-select: none; user-select: none;
}
.avatar--lg { width: 72px; height: 72px; font-size: var(--fs-2xl); }
.avatar--sm { width: 28px; height: 28px; font-size: var(--fs-xs); }

/* Menú desplegable */
.menu {
  position: absolute;
  top: calc(100% + var(--sp-2));
  right: 0;
  min-width: 220px;
  padding: var(--sp-2);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-drawer);
  animation: pop-in var(--dur-base) var(--ease-out);
}
/* El menú «⋯» no puede salirse de la pantalla.
   Medido en un móvil apaisado (844×390): el menú medía 452 px y
   acababa en el píxel 516. «Tema», «Música» y «Entrar» quedaban
   fuera y, como cuelga de una barra fija, no había scroll que los
   trajera. Ahora el menú se desplaza por dentro. */
.menu {
  max-height: calc(var(--vh-dyn) - var(--navbar-h) - var(--safe-top) - var(--sp-4));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-xs);
  font-size: var(--fs-base);
  color: var(--text-secondary);
  text-align: left;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.menu__item:hover { background: var(--bg-hover); color: var(--text-primary); }
.menu__item--danger { color: #ff8b8b; }
.menu__sep { height: 1px; background: var(--border-subtle); margin: var(--sp-2) 0; }
.menu__label { padding: var(--sp-2) var(--sp-3) var(--sp-1); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); font-weight: var(--fw-bold); }

/* Barra de progreso */
.progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--bg-inset);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--gradient-brand);
  transition: width var(--dur-slow) var(--ease-out);
}

/* Tabla */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  padding: var(--sp-3);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}
.table td { padding: var(--sp-3); border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); }
.table tr:hover td { background: var(--bg-hover); }
.table__scroll { overflow-x: auto; }

/* ------------------------------------------------------------
   PROGRESIÓN · resumen en la pantalla final
   ------------------------------------------------------------ */
.progress-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  max-width: 420px;
}
.progress-summary__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
}
.progress-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  border: 1px solid transparent;
  animation: pop-in var(--dur-base) var(--ease-out) backwards;
}
/* Escalonado: los distintivos entran uno detrás de otro, no todos de golpe. */
.progress-chip:nth-child(2) { animation-delay: 80ms; }
.progress-chip:nth-child(3) { animation-delay: 160ms; }
.progress-chip:nth-child(4) { animation-delay: 240ms; }
.progress-chip:nth-child(n + 5) { animation-delay: 320ms; }

.progress-chip--xp {
  background: color-mix(in srgb, var(--brand-500) 22%, transparent);
  border-color: color-mix(in srgb, var(--brand-500) 45%, transparent);
  color: #ddd6fe;
}
.progress-chip--level {
  background: color-mix(in srgb, var(--accent-amber) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent-amber) 45%, transparent);
  color: #fde68a;
}
.progress-chip--streak {
  background: color-mix(in srgb, var(--accent-orange) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent-orange) 45%, transparent);
  color: #fed7aa;
}
.progress-chip--achievement {
  background: color-mix(in srgb, var(--accent-cyan) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent-cyan) 42%, transparent);
  color: #a5f3fc;
}

.progress-summary__bar {
  width: 100%;
  height: 5px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.progress-summary__bar > span {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--gradient-brand);
  transition: width var(--dur-slow) var(--ease-out);
}
.progress-summary__level {
  font-size: var(--fs-2xs);
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------
   PROGRESIÓN · avisos de logro
   ------------------------------------------------------------ */
.achievement-stack {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
.achievement-toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 260px;
  max-width: min(360px, calc(100vw - var(--sp-6)));
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid color-mix(in srgb, var(--accent-amber) 40%, var(--border-default));
  box-shadow: var(--shadow-xl);
  animation: achievement-in var(--dur-base) var(--ease-out);
}
.achievement-toast[data-leaving="true"] { animation: achievement-out var(--dur-base) var(--ease-in) forwards; }
.achievement-toast__icon { font-size: 26px; line-height: 1; flex: none; }
.achievement-toast__body { min-width: 0; }
.achievement-toast__eyebrow {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-amber);
  font-weight: var(--fw-bold);
}
.achievement-toast__name {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
}
.achievement-toast__desc {
  font-size: var(--fs-2xs);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.achievement-toast__xp {
  margin-left: auto;
  flex: none;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: #ddd6fe;
}

@keyframes achievement-in {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes achievement-out {
  to { opacity: 0; transform: translateX(24px) scale(0.96); }
}

/* En móvil el aviso ocupa el ancho y se coloca arriba, para no chocar con
   los controles táctiles del juego, que viven abajo. */
@media (max-width: 560px) {
  .achievement-stack {
    right: var(--sp-3);
    left: var(--sp-3);
    bottom: auto;
    top: calc(var(--sp-3) + 56px);
  }
  .achievement-toast { min-width: 0; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-chip,
  .achievement-toast,
  .achievement-toast[data-leaving="true"] { animation: none; }
}

/* ------------------------------------------------------------
   INDICADOR DE NIVEL (barra de navegación)
   ------------------------------------------------------------ */
.level-badge {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  flex: none;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.level-badge:hover { border-color: var(--border-brand); background: var(--bg-hover); }
.level-badge__num {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-black);
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  line-height: 1;
}
.level-badge:hover .level-badge__num { color: var(--text-primary); }
.level-badge__bar {
  display: block;
  width: 34px;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--bg-inset);
  overflow: hidden;
}
.level-badge__bar > span {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--gradient-brand);
  transition: width var(--dur-slow) var(--ease-out);
}
/* En pantallas estrechas la barra de navegación va justa de espacio y el
   nivel ya se consulta desde el perfil. */
@media (max-width: 860px) { .level-badge { display: none; } }

/* ------------------------------------------------------------
   SELECTOR DE IDIOMA
   ------------------------------------------------------------ */
.lang-picker__trigger { gap: 3px; width: auto; min-width: 42px; padding-inline: var(--sp-2); }
.lang-picker__code {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  line-height: 1;
}

/* El desplegable se ancla al botón; con veinte idiomas necesita altura
   máxima y desplazamiento propio para no salirse de la pantalla. */
.lang-menu { min-width: 232px; padding-bottom: var(--sp-1); }
.lang-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: min(58vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.lang-option {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-xs);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  text-align: start;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.lang-option:hover { background: var(--bg-hover); color: var(--text-primary); }
.lang-option__flag { font-size: 1.05rem; line-height: 1; flex: none; }
.lang-option__name { flex: 1 1 auto; min-width: 0; }
.lang-option__check { flex: none; color: var(--accent-primary, var(--text-primary)); display: grid; place-items: center; }
.lang-option[data-active="true"] { color: var(--text-primary); font-weight: var(--fw-bold); background: var(--bg-inset); }

/* Dentro del cajón móvil la lista va suelta, sin caja flotante. */
.drawer .lang-list { max-height: 264px; }

/* Aviso de idioma en las páginas legales (sólo fuera del español). */
.legal-notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.legal-notice svg { flex: none; margin-top: 2px; color: var(--text-muted); }

/* ------------------------------------------------------------
   PRIVACIDAD · aviso de cookies, ajustes, textos legales y alta
   ------------------------------------------------------------
   Aceptar y rechazar comparten clase y tamaño en todas partes: ningún
   color ni ninguna jerarquía empuja hacia una de las dos respuestas. */
.footer__col .footer__link-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: start;
  cursor: pointer;
}
.footer__col .footer__link-btn:hover { color: var(--text-brand); }
.footer__col .footer__link-btn:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; border-radius: 4px; }

.consent-banner {
  position: fixed;
  inset-inline: var(--sp-4);
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-drawer);
  max-width: 1040px;
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3) var(--sp-6);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-slow) var(--ease-spring);
}
.consent-banner__body { flex: 1 1 380px; min-width: 0; }
.consent-banner__title { margin: 0 0 var(--sp-1); font-size: var(--fs-base); }
.consent-banner__text { margin: 0; font-size: var(--fs-sm); line-height: 1.55; color: var(--text-secondary); }
.consent-banner__text a { color: var(--text-brand); text-decoration: underline; }
.consent-banner__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.consent-banner__actions .btn { min-height: 44px; }
@media (max-width: 860px) {
  .consent-banner { bottom: calc(58px + var(--sp-3) + env(safe-area-inset-bottom, 0px)); padding: var(--sp-4); }
}
@media (max-width: 560px) {
  .consent-banner { inset-inline: var(--sp-2); gap: var(--sp-3); }
  .consent-banner__actions { width: 100%; }
  .consent-banner__actions .btn { flex: 1 1 40%; justify-content: center; padding-inline: var(--sp-2); }
  .consent-banner__actions .btn[data-choice="configure"] { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .consent-banner { animation: none; } }

.consent-settings { display: grid; gap: var(--sp-4); }
.consent-settings__lead { margin: 0; font-size: var(--fs-sm); line-height: 1.55; color: var(--text-secondary); }
.consent-settings__status { display: flex; align-items: flex-start; gap: var(--sp-2); margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.consent-settings__status svg { flex: none; margin-top: 3px; }
.consent-settings__link { justify-self: start; font-size: var(--fs-sm); color: var(--text-brand); text-decoration: underline; }
.consent-cat {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  background: var(--bg-inset);
}
.consent-cat__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); }
.consent-cat__head h3 { margin: 0 0 var(--sp-1); font-size: var(--fs-base); }
.consent-cat__head p { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-secondary); }
.consent-cat__state { flex: none; padding-top: 2px; font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-muted); white-space: nowrap; }
.consent-cat__switch { flex: none; min-height: 32px; }
.consent-services { display: grid; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.consent-service { padding: var(--sp-3); border-radius: var(--r-sm); background: var(--bg-surface); font-size: var(--fs-sm); }
.consent-service dl,
.privacy-layer dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-1) var(--sp-3); margin: var(--sp-2) 0 0; }
.consent-service dt,
.privacy-layer dt { color: var(--text-muted); }
.consent-service dd,
.privacy-layer dd { margin: 0; color: var(--text-secondary); overflow-wrap: anywhere; }
.consent-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); width: 100%; }
@media (max-width: 520px) {
  .consent-actions { flex-direction: column-reverse; }
  .consent-cat__head { flex-direction: column; gap: var(--sp-2); }
}

/* Textos legales */
.legal-updated { margin: 0 0 var(--sp-5); font-size: var(--fs-sm); color: var(--text-muted); }
.legal-placeholder {
  padding: 0 .3em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent-amber) 26%, transparent);
  color: var(--text-primary);
  font-weight: var(--fw-bold);
  overflow-wrap: anywhere;
}
.legal-summary {
  margin: 0 0 var(--sp-6);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  background: var(--bg-inset);
}
.legal-summary h2 { margin-top: 0 !important; font-size: var(--fs-lg); }
.legal-table-wrap { overflow-x: auto; margin: var(--sp-3) 0 var(--sp-5); border: 1px solid var(--border-default); border-radius: var(--r-sm); }
.legal-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: var(--fs-sm); line-height: 1.5; }
.legal-table th,
.legal-table td { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border-subtle); text-align: start; vertical-align: top; }
.legal-table th { background: var(--bg-inset); color: var(--text-primary); font-weight: var(--fw-bold); }
.legal-table tr:last-child td { border-bottom: 0; }
.legal-table code { font-size: .92em; overflow-wrap: anywhere; }
.legal-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-3) 0 var(--sp-5); }
.legal-toc { margin: 0 0 var(--sp-6); padding-inline-start: var(--sp-5); font-size: var(--fs-sm); }
.legal-toc a { color: var(--text-brand); }

/* Alta: primera capa de información, edad y términos */
.privacy-layer { border: 1px solid var(--border-default); border-radius: var(--r-sm); background: var(--bg-inset); font-size: var(--fs-xs); color: var(--text-secondary); }
.privacy-layer summary { display: flex; align-items: center; min-height: 44px; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text-primary); cursor: pointer; }
.privacy-layer summary:focus-visible { outline: 2px solid var(--brand-400); outline-offset: -2px; border-radius: var(--r-sm); }
.privacy-layer dl { margin: 0; padding: 0 var(--sp-3) var(--sp-3); }
.privacy-layer a { color: var(--text-brand); text-decoration: underline; }
.auth-fieldset { display: grid; gap: var(--sp-2); margin: 0; padding: 0; border: 0; min-width: 0; }
.auth-fieldset legend { margin-bottom: var(--sp-1); padding: 0; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-primary); }
.auth-option { display: flex; align-items: flex-start; gap: var(--sp-2); min-height: 32px; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-secondary); cursor: pointer; }
.auth-option input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand-500); }
.auth-option a { color: var(--text-brand); text-decoration: underline; }
.auth-note--warn svg { color: var(--accent-amber); }
/* Un aviso con [hidden] no debe verse aunque su clase fije display. */
.auth-note[hidden] { display: none; }
@media (max-width: 420px) {
  .consent-service dl,
  .privacy-layer dl { grid-template-columns: 1fr; gap: 0; }
  .consent-service dd,
  .privacy-layer dd { margin-bottom: var(--sp-2); }
}

/* ------------------------------------------------------------
   CARGANDO PÁGINA
   ------------------------------------------------------------
   Línea bajo la barra superior mientras una página se descarga
   (ver main.js: sólo si tarda más de 150 ms). */
html.is-route-loading body::after {
  content: "";
  position: fixed;
  inset-inline: 0;
  top: calc(var(--navbar-h) + var(--safe-top));
  height: 3px;
  z-index: var(--z-toast);
  background: var(--gradient-brand, var(--brand-500));
  transform-origin: 0 50%;
  animation: route-loading 1.1s var(--ease-out) infinite;
  pointer-events: none;
}
@keyframes route-loading {
  0% { transform: scaleX(0); opacity: 1; }
  70% { transform: scaleX(0.85); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html.is-route-loading body::after { animation: none; opacity: 0.8; }
}
