/* ==========================================================================
   Ojímetro — sistema de diseño v3 ("juego premium")
   Contrato: docs/DESIGN-V3.md + docs/UI-CONTRACT.md. Sin fuentes externas ni CDN.
   El canvas lee de :root con getComputedStyle: --bg --surface --ink --ink-2
   --accent --accent-soft --good --bad --separator (valores LITERALES, sin var()).

   Índice
     1. Tokens (oscuro primero / claro) + curvas
     2. Base, aurora, ruido, layout (topbar, main#app, tabbar flotante)
     3. Tipografía (+ .grad-text .num)
     4. Contenedores (section, card/.glass, card-hero, list, grid, scroller, divider)
     5. Controles (btn*, ripple, icon-btn, segmented, switch, field)
     6. Clases compartidas v3 (chip, kpi, icon-badge, section-title, ring, animaciones)
     7. Juego (stage, hud, reveal-panel)
     8. Resultado (score-hero, stars, breakdown)
     9. Niveles, ranking, perfil
    10. Otros (avatar, badge, progress, banner, empty, skeleton)
    11. Sheet, toast, consent
    12. Páginas de texto (.legal, .foot, .page-*)
    13. Transiciones de pantalla (View Transitions + fallback)
    14. Escritorio, reduced-motion, reduced-transparency, contraste
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens — oscuro por defecto; claro si el sistema lo pide o [data-theme=light]
   --------------------------------------------------------------------------
   Contraste (WCAG):
     oscuro ink #F3F2FF / #07071A ≈ 18:1 · ink-2 #ABA9CC / #07071A ≈ 9:1, / cristal (#1B1A3A) ≈ 7:1
            ink-3 #8B89B3 / #07071A ≈ 6:1, / surface #141333 ≈ 5.4:1 (antes #6F6D96: 3.8:1, no AA)
            accent-text #A992FF / #07071A ≈ 7.6:1
     claro  ink #15132B / #F4F3FF ≈ 16:1 · ink-2 #57547A / #F4F3FF ≈ 6.8:1, / #FFF ≈ 7.3:1
            ink-3 #67648B / #F4F3FF ≈ 5:1, / surface-2 #ECEAFB ≈ 4.7:1 (antes #9794B6: 2.6:1, no AA)
            good/bad/gold-text ≥ 4.8:1 en ambos temas. --warn NO es color de texto (claro 2:1): usar --gold-text.
            accent-text #5A3BE0 / #F4F3FF ≈ 6.3:1
     Blanco sobre --grad-brand-deep (#6C47F5 → #9B35E0 → #D8345F) ≥ 4.7:1 en los tres puntos:
     botones primarios, tabbar activa y .card-hero usan ese degradado profundo.
     --grad-brand (más vivo) se usa para rellenos, texto degradado grande y decoración.
   -------------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  /* v2 (compatibilidad: canvas, share, pantallas) */
  --bg: #07071A;
  --bg-elevated: #121130;
  --surface: #141333;
  --surface-2: #211F48;
  --ink: #F3F2FF;
  --ink-2: #ABA9CC;
  --ink-3: #8B89B3;
  --separator: rgba(255, 255, 255, 0.11);

  --accent: #7C5CFF;
  --accent-text: #A992FF;
  --accent-fill: #6C47F5;
  --accent-soft: rgba(124, 92, 255, 0.2);
  --good: #2FDC9B;
  --bad: #FF5470;
  --warn: #FFB547;
  --gold: #FFC940;
  --good-text: #5BF0B0;
  --bad-text: #FF8095;
  --gold-text: #FFD466;

  --material: rgba(16, 15, 42, 0.62);
  --scrim: rgba(3, 3, 14, 0.62);
  --shimmer: rgba(255, 255, 255, 0.08);
  --knob: #FFFFFF;
  --track-off: rgba(255, 255, 255, 0.14);
  --seg-on: rgba(255, 255, 255, 0.14);

  /* v3: marca y degradados */
  --brand-1: #7C5CFF;
  --brand-2: #C155FF;
  --brand-3: #FF5E8A;
  --brand-4: #FFB547;
  --grad-brand: linear-gradient(135deg, var(--brand-1), var(--brand-2) 50%, var(--brand-3));
  --grad-brand-deep: linear-gradient(135deg, #6C47F5, #9B35E0 52%, #D8345F);
  --grad-warm: linear-gradient(135deg, #FFB547, #FF7A59 55%, #FF5E8A);
  --grad-cool: linear-gradient(135deg, #3DD6FF, #5B8CFF 50%, #7C5CFF);
  --grad-gold: linear-gradient(135deg, #FFE27A, #FFB547 50%, #FF8A3D);
  --grad-good: linear-gradient(135deg, #5BF0B0, #1FC98A 55%, #12A7A0);
  --grad-bad: linear-gradient(135deg, #FF8A7A, #FF4D6A 55%, #E0306A);
  --grad-text: linear-gradient(100deg, #B9A6FF, #E08BFF 45%, #FF8FAE);

  /* v3: cristal */
  --glass: rgba(26, 24, 62, 0.52);
  --glass-strong: rgba(18, 17, 46, 0.8);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-hi: rgba(255, 255, 255, 0.07);
  --glass-hover: rgba(40, 37, 88, 0.6);
  --blur: 20px;

  /* v3: sombras y halos */
  --shadow-1: 0 1px 1px rgba(0, 0, 0, 0.2), 0 8px 24px -8px rgba(0, 0, 0, 0.55);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 60px -12px rgba(0, 0, 0, 0.7);
  --glow-brand: 0 10px 30px -8px rgba(124, 92, 255, 0.75), 0 6px 18px -6px rgba(255, 94, 138, 0.5);
  --glow-gold: 0 10px 30px -8px rgba(255, 181, 71, 0.75), 0 4px 14px -4px rgba(255, 138, 61, 0.5);
  --glow-good: 0 10px 28px -10px rgba(47, 220, 155, 0.7);

  /* aurora */
  --aurora-1: rgba(124, 92, 255, 0.55);
  --aurora-2: rgba(255, 94, 138, 0.38);
  --aurora-3: rgba(61, 214, 255, 0.3);
  --noise-opacity: 0.07;

  /* forma */
  --radius: 14px;
  --radius-lg: 20px;
  --radius-card: 20px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --radius-pill: 999px;

  /* movimiento */
  --spring: cubic-bezier(0.2, 0.9, 0.3, 1);
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 150ms;
  --dur: 300ms;
  --dur-slow: 600ms;

  /* tipo */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, system-ui, sans-serif;

  /* layout */
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --tabbar-gap: 12px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --hairline: 1px;
  --page-max: 560px;
}

/* Muelle con rebote leve cuando el navegador entiende linear() */
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --ease-spring: linear(0, 0.06 2.4%, 0.23 5.1%, 0.51 8.8%, 0.86 14%, 1.03 19.4%, 1.08 24%, 1.07 29%, 1.02 37%, 0.995 47%, 1.002 64%, 1);
  }
}

@media (min-resolution: 2dppx) {
  :root {
    --hairline: 0.5px;
  }
}

/* Tema claro: pastel. Automático (salvo [data-theme="dark"]) o forzado con [data-theme="light"] */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #F4F3FF;
    --bg-elevated: #FFFFFF;
    --surface: #FFFFFF;
    --surface-2: #ECEAFB;
    --ink: #15132B;
    --ink-2: #57547A;
    --ink-3: #67648B;
    --separator: rgba(52, 40, 130, 0.13);
    --accent: #7C5CFF;
    --accent-text: #5A3BE0;
    --accent-fill: #6C47F5;
    --accent-soft: rgba(124, 92, 255, 0.13);
    --good: #17B57A;
    --bad: #E8385A;
    --warn: #F29A1A;
    --gold: #F5A500;
    --good-text: #0B7A52;
    --bad-text: #C21F41;
    --gold-text: #8F5A00;
    --material: rgba(255, 255, 255, 0.66);
    --scrim: rgba(28, 22, 70, 0.34);
    --shimmer: rgba(255, 255, 255, 0.7);
    --track-off: rgba(52, 40, 130, 0.14);
    --seg-on: #FFFFFF;
    --grad-text: linear-gradient(100deg, #5A3BE0, #A12FD9 50%, #E0356A);
    --glass: rgba(255, 255, 255, 0.62);
    --glass-strong: rgba(255, 255, 255, 0.84);
    --glass-border: rgba(255, 255, 255, 0.9);
    --glass-hi: rgba(255, 255, 255, 0.9);
    --glass-hover: rgba(255, 255, 255, 0.82);
    --shadow-1: 0 1px 2px rgba(40, 30, 110, 0.06), 0 10px 30px -12px rgba(60, 40, 160, 0.22);
    --shadow-2: 0 2px 8px rgba(40, 30, 110, 0.08), 0 28px 60px -16px rgba(60, 40, 160, 0.35);
    --glow-brand: 0 10px 28px -8px rgba(124, 92, 255, 0.55), 0 6px 16px -6px rgba(255, 94, 138, 0.35);
    --glow-gold: 0 10px 28px -8px rgba(245, 165, 0, 0.5);
    --glow-good: 0 10px 26px -10px rgba(23, 181, 122, 0.5);
    --aurora-1: rgba(160, 136, 255, 0.45);
    --aurora-2: rgba(255, 150, 185, 0.4);
    --aurora-3: rgba(120, 220, 255, 0.36);
    --noise-opacity: 0.045;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F3FF;
  --bg-elevated: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #ECEAFB;
  --ink: #15132B;
  --ink-2: #57547A;
  --ink-3: #67648B;
  --separator: rgba(52, 40, 130, 0.13);
  --accent: #7C5CFF;
  --accent-text: #5A3BE0;
  --accent-fill: #6C47F5;
  --accent-soft: rgba(124, 92, 255, 0.13);
  --good: #17B57A;
  --bad: #E8385A;
  --warn: #F29A1A;
  --gold: #F5A500;
  --good-text: #0B7A52;
  --bad-text: #C21F41;
  --gold-text: #8F5A00;
  --material: rgba(255, 255, 255, 0.66);
  --scrim: rgba(28, 22, 70, 0.34);
  --shimmer: rgba(255, 255, 255, 0.7);
  --track-off: rgba(52, 40, 130, 0.14);
  --seg-on: #FFFFFF;
  --grad-text: linear-gradient(100deg, #5A3BE0, #A12FD9 50%, #E0356A);
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.84);
  --glass-border: rgba(255, 255, 255, 0.9);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --glass-hover: rgba(255, 255, 255, 0.82);
  --shadow-1: 0 1px 2px rgba(40, 30, 110, 0.06), 0 10px 30px -12px rgba(60, 40, 160, 0.22);
  --shadow-2: 0 2px 8px rgba(40, 30, 110, 0.08), 0 28px 60px -16px rgba(60, 40, 160, 0.35);
  --glow-brand: 0 10px 28px -8px rgba(124, 92, 255, 0.55), 0 6px 16px -6px rgba(255, 94, 138, 0.35);
  --glow-gold: 0 10px 28px -8px rgba(245, 165, 0, 0.5);
  --glow-good: 0 10px 26px -10px rgba(23, 181, 122, 0.5);
  --aurora-1: rgba(160, 136, 255, 0.45);
  --aurora-2: rgba(255, 150, 185, 0.4);
  --aurora-3: rgba(120, 220, 255, 0.36);
  --noise-opacity: 0.045;
}

/* --------------------------------------------------------------------------
   2. Base, aurora y layout
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* overflow-x: clip (no hidden): recorta sin crear contenedor de scroll; con hidden + overscroll-behavior
   en body, la rueda del ratón no llegaba al documento y la página no hacía scroll. */
html {
  overflow-x: clip;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

/* body transparente: la .aurora (z-index −1) pinta sobre el fondo del html */
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  letter-spacing: -0.005em;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

h1, h2, h3, h4, p, ol, ul, figure {
  margin: 0;
}

h1, h2, h3 {
  font-family: var(--font-display);
}

button {
  font: inherit;
  color: inherit;
  margin: 0;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

img, svg, canvas {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection {
  background: rgba(193, 85, 255, 0.35);
  color: inherit;
}

.icon {
  width: 24px;
  height: 24px;
  flex: none;
}

/* --- Aurora: 3 manchas que derivan detrás de todo --- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
  view-transition-name: aurora;
}

.aurora > span {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  opacity: 1;
  will-change: transform;
  translate: var(--ax, 0px) var(--ay, 0px);
  transition: translate 1.2s var(--ease-out-expo);
}

.aurora > span:nth-of-type(1) {
  top: -32vmax;
  left: -24vmax;
  background: radial-gradient(closest-side, var(--aurora-1), transparent 72%);
  animation: aurora-a 26s ease-in-out infinite alternate;
}

.aurora > span:nth-of-type(2) {
  top: 10vh;
  right: -34vmax;
  background: radial-gradient(closest-side, var(--aurora-2), transparent 72%);
  animation: aurora-b 32s ease-in-out infinite alternate;
  translate: calc(var(--ax, 0px) * -1.4) calc(var(--ay, 0px) * -1.2);
}

.aurora > span:nth-of-type(3) {
  bottom: -40vmax;
  left: 5vw;
  background: radial-gradient(closest-side, var(--aurora-3), transparent 72%);
  animation: aurora-c 38s ease-in-out infinite alternate;
  translate: calc(var(--ax, 0px) * 0.8) calc(var(--ay, 0px) * -0.6 - var(--scroll-shift, 0px));
}

@keyframes aurora-a {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(18vw, 10vh) scale(1.15); }
  100% { transform: translate(6vw, 22vh) scale(0.92); }
}

@keyframes aurora-b {
  0% { transform: translate(0, 0) scale(1.05); }
  50% { transform: translate(-16vw, 16vh) scale(0.9); }
  100% { transform: translate(-6vw, -8vh) scale(1.12); }
}

@keyframes aurora-c {
  0% { transform: translate(0, 0) scale(0.95); }
  50% { transform: translate(22vw, -14vh) scale(1.12); }
  100% { transform: translate(-8vw, -4vh) scale(1); }
}

/* Grano: capa de ruido SVG (shell y tarjetas héroe) */
.noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--noise-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.aurora > .noise {
  opacity: calc(var(--noise-opacity) * 1.4);
}

/* --- Contenido principal --- */
main {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding-top: calc(var(--topbar-h) + var(--sat) + 12px);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: calc(32px + var(--sab));
}

/* App (index.html): el documento NO hace scroll; lo hace #scroller, fijo a toda la pantalla. Así las barras
   fixed (tabbar, botón atrás) nunca dependen del scroll de Safari: en iOS 26 se despegaban y flotaban a media
   pantalla al desplazar el documento. Las páginas estáticas (sin #scroller) siguen con scroll normal. */
html:has(#scroller),
html:has(#scroller) body {
  height: 100%;
  overflow: hidden;
}
.app-scroller {
  position: fixed;
  inset: 0;
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  /* PC con barra clásica: hueco simétrico y fijo. Así el contenido queda centrado con la tabbar (que se
     centra en la ventana) y no salta 7-8 px al pasar de una pantalla que cabe a otra con scroll. */
  scrollbar-gutter: stable both-edges;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ink-3) 55%, transparent) transparent;
}

main#app {
  padding-bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--sab) + 32px);
  min-height: 100%;
  /* Cada pantalla monta un único bloque: si cabe en el alto de la pantalla queda centrado en vertical;
     si no cabe, los márgenes automáticos valen 0 y empieza arriba con scroll normal (centrado «seguro»). */
  display: flex;
  flex-direction: column;
}
main#app > * {
  width: 100%;
}
/* Solo el primero y el último: con varios bloques no se reparten huecos entre ellos */
main#app > :first-child {
  margin-top: auto;
}
main#app > :last-child {
  margin-bottom: auto;
}
/* Aviso de consentimiento visible: el final de la pantalla no queda debajo */
body:not([data-screen="play"]):has(#consent:not([hidden])) main#app {
  padding-bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--sab) + 190px);
}

/* --- Topbar translúcida --- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: calc(var(--topbar-h) + var(--sat));
  padding: var(--sat) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, var(--material), color-mix(in srgb, var(--material) 70%, transparent));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
  backdrop-filter: blur(var(--blur)) saturate(170%);
  view-transition-name: topbar;
}

/* hilo de luz inferior con el degradado de marca */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124, 92, 255, 0.5) 25%, rgba(255, 94, 138, 0.45) 75%, transparent);
  opacity: 0.7;
}

.topbar-back {
  grid-column: 1;
  justify-self: start;
  color: var(--ink);
}

.topbar-title,
.brand {
  grid-column: 2;
  justify-self: center;
  max-width: min(60vw, 420px);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.brand::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: var(--grad-brand);
  box-shadow: var(--glow-brand), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 4px, #000 4.5px);
  mask: radial-gradient(circle at 50% 50%, transparent 4px, #000 4.5px);
}

.topbar-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.topbar-actions .progress {
  width: 96px;
}

/* SPA (body[data-screen]): sin barra superior. El título ya lo dice la tabbar; solo quedan
   flotando el botón atrás y las acciones (p. ej. salir de la partida), como botones de cristal.
   Las páginas estáticas (sin data-screen) conservan su topbar con marca. */
body[data-screen] {
  --topbar-h: 0px;
}

body[data-screen] .topbar {
  top: calc(var(--sat) + 10px);
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  height: 44px;
  padding: 0;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  pointer-events: none;
}

body[data-screen] .topbar::after,
body[data-screen] .topbar-title {
  display: none;
}

body[data-screen] .topbar-back,
body[data-screen] .topbar-actions > * {
  pointer-events: auto;
}

body[data-screen] .topbar-back,
body[data-screen] .topbar-actions > .icon-btn {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
  backdrop-filter: blur(var(--blur)) saturate(170%);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--glass-border);
}

/* Con botón atrás visible, el contenido baja lo justo para no quedar debajo */
body[data-screen]:has(#topbar-back:not([hidden])) main#app {
  padding-top: calc(var(--sat) + 64px);
}

/* --- Tabbar flotante (píldora de cristal con indicador animado) --- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-gap) + var(--sab));
  z-index: 50;
  display: flex;
  align-items: stretch;
  width: min(calc(100% - 20px), 440px);
  height: var(--tabbar-h);
  padding: 6px;
  border-radius: var(--radius-pill);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-border);
  transform: translateX(-50%);
  isolation: isolate;
  view-transition-name: tabbar;
}

/* Indicador: el JS fija --ind-x / --ind-w y [data-ind] a partir de la pestaña activa */
.tabbar::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: var(--ind-w, 0px);
  border-radius: var(--radius-pill);
  background: var(--grad-brand-deep);
  box-shadow: var(--glow-brand), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transform: translateX(var(--ind-x, 0px));
  opacity: 0;
  transition: transform 520ms var(--ease-spring), width 520ms var(--ease-spring), opacity 200ms;
}

.tabbar[data-ind]::before {
  opacity: 1;
}

.tabbar[data-ind="none"]::before {
  opacity: 0;
}

.tabbar.no-ind-anim::before {
  transition: none;
}

.tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
  transition: color 250ms var(--ease-out);
}

.tab span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab .icon {
  width: 23px;
  height: 23px;
  transition: transform 450ms var(--ease-spring);
}

.tab:active .icon {
  transform: scale(0.86);
  transition-duration: 90ms;
}

.tab[aria-current] {
  color: #FFFFFF;
}

.tab[aria-current] .icon {
  transform: translateY(-1px) scale(1.06);
  filter: drop-shadow(0 2px 6px rgba(255, 255, 255, 0.35));
}

/* Sin JS de indicador: la pestaña activa se pinta a sí misma */
.tabbar:not([data-ind]) .tab[aria-current] {
  background: var(--grad-brand-deep);
  box-shadow: var(--glow-brand);
}

@media (hover: hover) {
  .tab:not([aria-current]):hover {
    color: var(--ink);
  }
}

/* Pantalla de juego: sin tabbar */
body[data-screen="play"] .tabbar {
  display: none;
}

body[data-screen="play"] main#app {
  padding-bottom: calc(16px + var(--sab));
}

/* --------------------------------------------------------------------------
   3. Tipografía
   -------------------------------------------------------------------------- */
.large-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.title-1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.title-2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.headline {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.body {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.45;
}

.callout {
  font-size: 16px;
  line-height: 1.4;
}

.subhead {
  font-size: 15px;
  line-height: 1.4;
}

.footnote {
  font-size: 13px;
  line-height: 1.4;
}

.caption {
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.text-secondary {
  color: var(--ink-2);
}

.text-tertiary {
  color: var(--ink-3);
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Texto con degradado de marca */
.grad-text {
  color: var(--accent-text);
  background: var(--grad-text);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: grad-pan 8s ease-in-out infinite alternate;
}

@keyframes grad-pan {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

/* --------------------------------------------------------------------------
   4. Contenedores
   -------------------------------------------------------------------------- */
.section {
  margin: 0 0 32px;
}

.section:last-child {
  margin-bottom: 0;
}

.section-header,
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.section-header > :first-child,
.section-title > :first-child {
  min-width: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

/* .section-title sin hijos (texto directo) */
.section-title:not(:has(> *)) {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.section-header > :last-child:not(:first-child),
.section-title > :last-child:not(:first-child) {
  flex: none;
  color: var(--accent-text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

/* Cristal: superficie base de v3. .card v2 se ve igual. */
.glass,
.card {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border);
}

.card {
  padding: 18px;
}

.card + .card {
  margin-top: 12px;
}

/* :where() = especificidad 0: las hojas de pantalla pueden cambiar display/width sin pelear */
:where(a.card, button.card, a.glass, button.glass) {
  display: block;
  width: 100%;
  border: 0;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
  transition: transform 450ms var(--ease-spring), background-color var(--dur), box-shadow var(--dur);
}

a.card:active,
button.card:active,
a.glass:active,
button.glass:active {
  transform: scale(0.98);
  transition-duration: 100ms;
}

/* Tarjeta héroe: degradado de marca, manchas internas, brillo periódico y grano */
.card-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--radius-2xl);
  background: var(--grad-brand-deep);
  color: #FFFFFF;
  box-shadow: var(--glow-brand), var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.card-hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -40%;
  background:
    radial-gradient(closest-side at 25% 30%, rgba(255, 255, 255, 0.28), transparent 70%),
    radial-gradient(closest-side at 80% 20%, rgba(255, 181, 71, 0.5), transparent 70%),
    radial-gradient(closest-side at 70% 85%, rgba(61, 214, 255, 0.35), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: hero-blobs 14s ease-in-out infinite alternate;
}

.card-hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.22) 48%, transparent 60%);
  background-size: 250% 100%;
  background-position: 150% 0;
  animation: shine-sweep 5.5s var(--ease-out) 1.2s infinite;
}

.card-hero :is(.text-secondary, .footnote, .caption, .subhead) {
  color: rgba(255, 255, 255, 0.86);
}

.card-hero a:not(.btn) {
  color: #FFFFFF;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.card-hero .grad-text {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: #FFFFFF;
}

.card-hero .btn-glass,
.card-hero .btn-secondary {
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.card-hero .btn-primary {
  background: #FFFFFF;
  color: #4B22C9;
  box-shadow: 0 10px 26px -8px rgba(20, 0, 60, 0.55);
}

@keyframes hero-blobs {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(6%, -4%) rotate(8deg); }
}

.inset {
  padding-left: 16px;
  padding-right: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* Carrusel horizontal con scroll-snap que sangra hasta los bordes */
.scroller {
  display: flex;
  gap: 12px;
  margin: 0 -16px;
  padding: 4px 16px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 16px;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scroller::-webkit-scrollbar {
  display: none;
}

.scroller > * {
  flex: none;
  scroll-snap-align: start;
}

.divider {
  height: 1px;
  margin: 18px 0;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--separator) 15%, var(--separator) 85%, transparent);
}

/* Lista (filas de cristal con separador inset) */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border);
  overflow: hidden;
}

.list-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.3;
  text-align: left;
  text-decoration: none;
}

.list-item::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: var(--hairline);
  background: var(--separator);
}

.list-item:has(> .list-item-leading)::after {
  left: 66px;
}

.list-item:last-child::after {
  display: none;
}

a.list-item,
button.list-item {
  cursor: pointer;
  transition: background-color 150ms var(--ease-out);
}

a.list-item:active,
button.list-item:active {
  background: var(--accent-soft);
}

.list-item-leading {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.list-item-leading .icon {
  width: 20px;
  height: 20px;
}

.list-item-leading:has(> .avatar) {
  background: none;
}

.list-item-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-item-content > :first-child {
  font-weight: 600;
}

.list-item-content > :nth-child(2) {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.3;
}

.list-item-trailing {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.chevron {
  flex: none;
  width: 9px;
  height: 9px;
  margin: 0 3px 0 2px;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  transform: rotate(-45deg);
  transition: transform 300ms var(--ease-spring);
}

/* --------------------------------------------------------------------------
   5. Controles
   -------------------------------------------------------------------------- */
.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--glass);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--glass-border), inset 0 1px 0 var(--glass-hi);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition:
    transform 480ms var(--ease-spring),
    box-shadow var(--dur) var(--ease-out),
    background-color var(--dur),
    opacity var(--dur-fast),
    filter var(--dur-fast);
}

.btn .icon {
  width: 20px;
  height: 20px;
}

.btn:active {
  transform: scale(0.97);
  transition-duration: 90ms;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  filter: saturate(0.6);
}

/* Onda al pulsar (la crea motion.ripple) */
.ripple {
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.12) 70%, transparent);
  pointer-events: none;
  transform: scale(0);
  animation: ripple-out 650ms var(--ease-out-expo) forwards;
}

.btn > :not(.ripple) {
  position: relative;
  z-index: 1;
}

@keyframes ripple-out {
  0% { transform: scale(0); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

/* Primario: degradado + halo + barrido de brillo en hover */
.btn-primary {
  background: var(--grad-brand-deep);
  background-size: 140% 140%;
  background-position: 0% 50%;
  color: #FFFFFF;
  text-shadow: 0 1px 1px rgba(40, 0, 80, 0.25);
  box-shadow: var(--glow-brand), inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -2px 0 rgba(40, 0, 90, 0.18);
  transition:
    transform 480ms var(--ease-spring),
    box-shadow var(--dur) var(--ease-out),
    background-position 700ms var(--ease-out-expo),
    filter var(--dur-fast);
}

.btn-primary::after,
.btn-gold::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.38) 48%, transparent 64%);
  background-size: 250% 100%;
  background-position: 150% 0;
  pointer-events: none;
}

.btn-primary:active {
  filter: brightness(0.94);
}

.btn-secondary,
.btn-glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  color: var(--ink);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--glass-border), inset 0 1px 0 var(--glass-hi);
}

.btn-tinted {
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.25);
}

.btn-plain {
  background: transparent;
  color: var(--accent-text);
  box-shadow: none;
  padding: 0 12px;
}

.btn-plain:active {
  opacity: 0.6;
}

.btn-gold {
  background: var(--grad-gold);
  color: #2B1700;
  box-shadow: var(--glow-gold), inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 0 rgba(120, 50, 0, 0.18);
}

.btn-large {
  width: 100%;
  min-height: 56px;
  padding: 0 24px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.btn-large .icon {
  width: 22px;
  height: 22px;
}

.btn-small {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
}

.btn-small .icon {
  width: 16px;
  height: 16px;
}

/* Botón de icono 44×44 */
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 450ms var(--ease-spring), background-color var(--dur-fast);
}

.icon-btn:active {
  transform: scale(0.88);
  transition-duration: 90ms;
  background: var(--accent-soft);
}

.icon-btn .icon {
  width: 24px;
  height: 24px;
}

.icon-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.topbar .icon-btn {
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--glass-border);
  width: 44px;
  height: 44px;
}

.topbar .icon-btn .icon {
  width: 22px;
  height: 22px;
}

/* Segmented: pastilla que se desliza (vía :has) */
.segmented {
  position: relative;
  isolation: isolate;
  display: flex;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: inset 0 0 0 1px var(--glass-border);
  --seg-n: 2;
  --seg-i: 0;
}

.segmented-item {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  min-height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: color 250ms var(--ease-out), transform 400ms var(--ease-spring), background-color 250ms;
}

.segmented-item:active {
  transform: scale(0.95);
  transition-duration: 90ms;
}

.segmented-item[aria-pressed="true"] {
  color: #FFFFFF;
  background: var(--grad-brand-deep);
  box-shadow: var(--glow-brand);
}

@supports selector(:has(a)) {
  .segmented::before {
    content: "";
    position: absolute;
    z-index: 0;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 8px) / var(--seg-n));
    border-radius: var(--radius-pill);
    background: var(--grad-brand-deep);
    box-shadow: var(--glow-brand), inset 0 1px 0 rgba(255, 255, 255, 0.28);
    transform: translateX(calc(100% * var(--seg-i)));
    transition: transform 520ms var(--ease-spring);
    opacity: 0;
  }

  .segmented:has(> .segmented-item[aria-pressed="true"])::before {
    opacity: 1;
  }

  .segmented:has(> .segmented-item[aria-pressed="true"]) > .segmented-item[aria-pressed="true"] {
    background: transparent;
    box-shadow: none;
  }

  .segmented:has(> .segmented-item:nth-child(3)) { --seg-n: 3; }
  .segmented:has(> .segmented-item:nth-child(4)) { --seg-n: 4; }
  .segmented:has(> .segmented-item:nth-child(5)) { --seg-n: 5; }
  .segmented:has(> .segmented-item:nth-child(6)) { --seg-n: 6; }
  .segmented:has(> .segmented-item:nth-child(2)[aria-pressed="true"]) { --seg-i: 1; }
  .segmented:has(> .segmented-item:nth-child(3)[aria-pressed="true"]) { --seg-i: 2; }
  .segmented:has(> .segmented-item:nth-child(4)[aria-pressed="true"]) { --seg-i: 3; }
  .segmented:has(> .segmented-item:nth-child(5)[aria-pressed="true"]) { --seg-i: 4; }
  .segmented:has(> .segmented-item:nth-child(6)[aria-pressed="true"]) { --seg-i: 5; }
}

/* Switch (checkbox estilizado) */
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  margin: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--track-off);
  box-shadow: inset 0 0 0 1px var(--glass-border);
  cursor: pointer;
  transition: background-color 250ms var(--ease-out), box-shadow 250ms;
}

.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 480ms var(--ease-spring), width 200ms var(--ease-out);
}

.switch:active::before {
  width: 32px;
}

.switch:checked {
  background: var(--grad-brand-deep);
  box-shadow: var(--glow-brand);
}

.switch:checked::before {
  transform: translateX(20px);
}

.switch:checked:active::before {
  transform: translateX(14px);
}

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

/* Campo de texto */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  padding: 0 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border: 0;
  border-radius: 16px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: inset 0 0 0 1px var(--glass-border), inset 0 1px 2px rgba(0, 0, 0, 0.12);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  line-height: 1.3;
  transition: box-shadow 250ms var(--ease-out), background-color 250ms;
}

.field textarea {
  padding: 12px 16px;
  min-height: 96px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--ink-3);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: none;
  background: var(--glass-hover);
  box-shadow: inset 0 0 0 1.5px var(--brand-1), 0 0 0 4px rgba(124, 92, 255, 0.22), 0 8px 24px -10px rgba(124, 92, 255, 0.6);
}

.field-hint,
.field > .footnote {
  padding: 0 6px;
  color: var(--ink-2);
}

/* --------------------------------------------------------------------------
   6. Clases compartidas v3
   -------------------------------------------------------------------------- */

/* Chip: píldora pequeña con icono + texto */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 0 0 1px var(--glass-border);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chip .icon {
  width: 16px;
  height: 16px;
}

.chip[data-tone="brand"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.3);
}

.chip[data-tone="good"] {
  background: color-mix(in srgb, var(--good) 16%, transparent);
  color: var(--good-text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--good) 35%, transparent);
}

.chip[data-tone="bad"] {
  background: color-mix(in srgb, var(--bad) 15%, transparent);
  color: var(--bad-text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 35%, transparent);
}

.chip[data-tone="gold"] {
  background: color-mix(in srgb, var(--gold) 18%, transparent);
  color: var(--gold-text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 40%, transparent);
}

.card-hero .chip {
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

/* KPI: cifra grande + etiqueta */
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
}

.card-hero .kpi-label {
  color: rgba(255, 255, 255, 0.82);
}

/* Icono dentro de cuadrado redondeado con degradado */
.icon-badge {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--grad-brand-deep);
  color: #FFFFFF;
  box-shadow: 0 8px 18px -8px rgba(124, 92, 255, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.icon-badge .icon {
  width: 22px;
  height: 22px;
}

.icon-badge[data-tone="warm"] { background: var(--grad-warm); box-shadow: 0 8px 18px -8px rgba(255, 122, 89, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.icon-badge[data-tone="cool"] { background: var(--grad-cool); box-shadow: 0 8px 18px -8px rgba(91, 140, 255, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.icon-badge[data-tone="gold"] { background: var(--grad-gold); color: #3A2000; box-shadow: var(--glow-gold), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.icon-badge[data-tone="good"] { background: var(--grad-good); color: #04291B; box-shadow: var(--glow-good), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.icon-badge[data-tone="bad"] { background: var(--grad-bad); box-shadow: 0 8px 18px -8px rgba(255, 77, 106, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.icon-badge[data-tone="muted"] { background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--glass-border); }

/* Anillo (motion.ring) */
.ring {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--ring-size, 120px);
  height: var(--ring-size, 120px);
  flex: none;
}

.ring > svg {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ring-track {
  stroke: var(--separator);
}

.ring-bar {
  filter: drop-shadow(0 0 6px rgba(193, 85, 255, 0.55));
}

.ring[data-tone="gold"] .ring-bar { filter: drop-shadow(0 0 6px rgba(255, 181, 71, 0.6)); }
.ring[data-tone="good"] .ring-bar { filter: drop-shadow(0 0 6px rgba(47, 220, 155, 0.55)); }
.ring[data-tone="bad"] .ring-bar { filter: drop-shadow(0 0 6px rgba(255, 77, 106, 0.55)); }

.ring-label {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  line-height: 1;
}

.ring-value {
  font-family: var(--font-display);
  font-size: calc(var(--ring-size, 120px) * 0.26);
  font-weight: 900;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.ring-sub {
  color: var(--ink-2);
  font-size: max(11px, calc(var(--ring-size, 120px) * 0.1));
  font-weight: 700;
  letter-spacing: 0.02em;
}

.card-hero .ring-track { stroke: rgba(255, 255, 255, 0.22); }
.card-hero .ring-sub { color: rgba(255, 255, 255, 0.85); }

/* Inclinación 3D (motion.tilt la mueve; aquí brillo que sigue al puntero) */
.tilt {
  transform-style: preserve-3d;
  transition: transform 600ms var(--ease-out-expo);
  will-change: transform;
}

.tilt.is-tilting {
  transition: transform 120ms linear;
}

.tilt.is-tilting::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.18), transparent 55%);
  pointer-events: none;
}

/* --- Animaciones de entrada y ambiente --- */
.anim-in {
  animation: anim-in 640ms var(--ease-out-expo) backwards;
  animation-delay: calc(min(var(--i, 0), 16) * 60ms);
}

.anim-pop {
  animation: anim-pop 620ms var(--ease-spring) backwards;
  animation-delay: calc(min(var(--i, 0), 16) * 60ms);
}

@keyframes anim-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes anim-pop {
  from {
    opacity: 0;
    transform: scale(0.82);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.float {
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.pulse-glow {
  animation: pulse-glow 2.4s ease-out infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: var(--glow-brand), 0 0 0 0 rgba(193, 85, 255, 0.5); }
  70% { box-shadow: var(--glow-brand), 0 0 0 16px rgba(193, 85, 255, 0); }
  100% { box-shadow: var(--glow-brand), 0 0 0 0 rgba(193, 85, 255, 0); }
}

.btn-gold.pulse-glow {
  animation-name: pulse-glow-gold;
}

@keyframes pulse-glow-gold {
  0% { box-shadow: var(--glow-gold), 0 0 0 0 rgba(255, 181, 71, 0.55); }
  70% { box-shadow: var(--glow-gold), 0 0 0 16px rgba(255, 181, 71, 0); }
  100% { box-shadow: var(--glow-gold), 0 0 0 0 rgba(255, 181, 71, 0); }
}

/* Barrido de brillo periódico */
.shine {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.shine::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, 0.35) 48%, transparent 62%);
  background-size: 250% 100%;
  background-position: 150% 0;
  pointer-events: none;
  animation: shine-sweep 3.6s var(--ease-out) 0.8s infinite;
}

@keyframes shine-sweep {
  0% { background-position: 150% 0; }
  45%, 100% { background-position: -60% 0; }
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* --------------------------------------------------------------------------
   7. Juego (base; play.css afina)
   -------------------------------------------------------------------------- */
.screen-play {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 2px;
}

.hud-progress {
  min-width: 2.2em;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hud-name {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.instruction {
  min-height: 2.6em;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
}

.stage {
  position: relative;
  width: 100%;
  max-width: min(100%, calc(100dvh - 310px));
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: var(--radius-xl);
  background: var(--bg);
  box-shadow: var(--shadow-2), 0 0 0 1px var(--glass-border), 0 0 40px -12px rgba(124, 92, 255, 0.45);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: box-shadow var(--dur);
}

@supports not (height: 100dvh) {
  .stage {
    max-width: min(100%, calc(100vh - 310px));
  }
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: crosshair;
  touch-action: none;
}

.stage:has(#canvas:focus-visible) {
  box-shadow: var(--shadow-2), 0 0 0 2px var(--brand-2), 0 0 40px -8px rgba(193, 85, 255, 0.6);
}

.hint {
  min-height: 1.5em;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.actions {
  margin-top: 8px;
}

.actions:not(:has(.btn:not([hidden]))) {
  display: none;
}

#btn-confirm,
#btn-next {
  width: 100%;
  min-height: 56px;
  font-size: 18px;
  font-weight: 800;
}

.reveal-panel {
  margin-top: 8px;
  animation: anim-in 420ms var(--ease-out-expo) backwards;
}

.reveal-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.reveal-error {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.3;
}

.reveal-score {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--accent-text);
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: anim-pop 520ms var(--ease-spring) backwards;
}

/* --------------------------------------------------------------------------
   8. Resultado (base; results.css afina)
   -------------------------------------------------------------------------- */
.score-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 0 10px;
  text-align: center;
}

.score-hero .score-big {
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 24vw, 8rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-text);
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 30px rgba(193, 85, 255, 0.35));
}

.score-max {
  color: var(--ink-2);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.score-context {
  min-height: 1.5em;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
}

.stars {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 34px;
  line-height: 1;
}

.star {
  display: inline-flex;
  color: var(--separator);
  transition: color var(--dur), filter var(--dur);
}

.star svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.star[data-on] {
  color: var(--gold);
  filter: drop-shadow(0 0 8px rgba(255, 190, 60, 0.65)) drop-shadow(0 2px 2px rgba(120, 60, 0, 0.3));
}

.stars .star[data-on] {
  animation: star-pop 700ms var(--ease-spring) backwards;
}

.stars .star:nth-child(2)[data-on] {
  animation-delay: 140ms;
}

.stars .star:nth-child(3)[data-on] {
  animation-delay: 280ms;
}

@keyframes star-pop {
  0% {
    transform: scale(0.2) rotate(-40deg);
    opacity: 0;
  }
  60% {
    opacity: 1;
  }
  100% {
    transform: none;
    opacity: 1;
  }
}

.breakdown {
  list-style: none;
  margin: 0;
  padding: 0 18px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border);
}

.breakdown li {
  display: grid;
  grid-template-columns: minmax(96px, 1.1fr) minmax(56px, 1fr) auto;
  grid-template-areas:
    "name   bar score"
    "detail bar score";
  align-items: center;
  column-gap: 14px;
  row-gap: 2px;
  padding: 14px 0;
  border-bottom: var(--hairline) solid var(--separator);
}

.breakdown li:last-child {
  border-bottom: 0;
}

.bd-name {
  grid-area: name;
  align-self: end;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.bd-detail {
  grid-area: detail;
  align-self: start;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.bd-bar {
  grid-area: bar;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--track-off);
  overflow: hidden;
}

.bd-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--grad-brand);
  box-shadow: 0 0 10px rgba(193, 85, 255, 0.55);
  transition: width 1s var(--ease-out-expo);
}

.bd-score {
  grid-area: score;
  min-width: 2.4em;
  font-size: 18px;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cta-row {
  display: flex;
  gap: 10px;
}

.cta-row > .btn {
  flex: 1 1 0;
  min-width: 0;
}

.cta-row + .cta-row {
  margin-top: 10px;
}

/* --------------------------------------------------------------------------
   9. Niveles, ranking y perfil (base; hojas de pantalla afinan)
   -------------------------------------------------------------------------- */
.series {
  margin: 0 0 32px;
}

.series:last-child {
  margin-bottom: 0;
}

.series-title {
  padding: 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.series-progress {
  margin: 2px 0 12px;
  padding: 0 4px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.level-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  aspect-ratio: 1;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  color: var(--ink);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border);
  text-decoration: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 480ms var(--ease-spring), box-shadow var(--dur);
}

.level-tile:active {
  transform: scale(0.94);
  transition-duration: 90ms;
}

.level-num {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.level-stars {
  display: inline-flex;
  gap: 2px;
  font-size: 12px;
  line-height: 1;
  min-height: 12px;
}

.level-best {
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
}

.level-tile[data-state="open"] {
  background: var(--grad-brand-deep);
  color: #FFFFFF;
  box-shadow: var(--glow-brand), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  animation: pulse-glow 2.4s ease-out infinite;
}

.level-tile[data-state="open"] .level-best {
  color: rgba(255, 255, 255, 0.85);
}

.level-tile[data-state="locked"] {
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  box-shadow: inset 0 0 0 1px var(--glass-border);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  cursor: default;
  pointer-events: none;
}

.level-tile[data-state="locked"] .level-num {
  color: var(--ink-3);
}

.level-tile[data-state="locked"] .level-stars,
.level-tile[data-state="locked"] .level-best {
  visibility: hidden;
}

.level-tile[data-state="locked"]::after {
  content: "";
  position: absolute;
  top: 9px;
  right: 9px;
  width: 14px;
  height: 14px;
  background: var(--ink-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V8a5 5 0 0 1 10 0v2h1a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zm2 0h6V8a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V8a5 5 0 0 1 10 0v2h1a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zm2 0h6V8a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border);
  overflow: hidden;
}

.rank-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 16px;
}

.rank-row::after {
  content: "";
  position: absolute;
  left: 64px;
  right: 16px;
  bottom: 0;
  height: var(--hairline);
  background: var(--separator);
}

.rank-row:last-child::after {
  display: none;
}

.rank-row[data-me] {
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.28), rgba(255, 94, 138, 0.12));
}

.rank-row[data-me]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--grad-brand);
  box-shadow: 0 0 12px rgba(193, 85, 255, 0.8);
}

.rank-row[data-me] .rank-name {
  color: var(--ink);
  font-weight: 800;
}

.rank-pos {
  flex: none;
  width: 30px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.rank-row .avatar {
  width: 38px;
  height: 38px;
}

.rank-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-score {
  flex: none;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rank-empty,
.rank-offline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 16px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
}

.rank-offline {
  color: var(--gold-text);
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 0 22px;
  text-align: center;
}

.profile-name {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.035em;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.profile-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.25);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 450ms var(--ease-spring);
}

.profile-edit:active {
  transform: scale(0.96);
  transition-duration: 90ms;
}

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

@media (min-width: 480px) {
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 84px;
  padding: 14px 10px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border);
  text-align: center;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--grad-warm);
  color: #2B1200;
  box-shadow: 0 8px 20px -8px rgba(255, 122, 89, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.streak .icon {
  width: 18px;
  height: 18px;
  color: currentColor;
}

/* --------------------------------------------------------------------------
   10. Otros
   -------------------------------------------------------------------------- */
.avatar {
  flex: none;
  display: inline-flex;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: 0 0 0 1.5px var(--glass-border);
  overflow: hidden;
}

.avatar svg {
  width: 100%;
  height: 100%;
}

.avatar-xl {
  width: 96px;
  height: 96px;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5.5px var(--brand-2), var(--glow-brand);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge .icon {
  width: 13px;
  height: 13px;
}

.badge[data-tone="good"] {
  background: color-mix(in srgb, var(--good) 18%, transparent);
  color: var(--good-text);
}

.badge[data-tone="warn"] {
  background: color-mix(in srgb, var(--warn) 20%, transparent);
  color: var(--gold-text);
}

.badge[data-tone="bad"] {
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  color: var(--bad-text);
}

.badge[data-tone="gold"] {
  background: var(--grad-gold);
  color: #2B1700;
}

.badge[data-tone="brand"] {
  background: var(--grad-brand-deep);
  color: #FFFFFF;
}

/* Barra de progreso: degradado con brillo que recorre */
.progress {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--track-off);
  overflow: hidden;
}

.progress-fill {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--grad-brand);
  box-shadow: 0 0 12px rgba(193, 85, 255, 0.6);
  transition: width 900ms var(--ease-out-expo);
  overflow: hidden;
}

.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: translateX(-100%);
  animation: shimmer 2.4s ease-in-out 0.6s infinite;
}

.progress[data-tone="gold"] .progress-fill { background: var(--grad-gold); box-shadow: 0 0 12px rgba(255, 181, 71, 0.6); }
.progress[data-tone="good"] .progress-fill { background: var(--grad-good); box-shadow: 0 0 12px rgba(47, 220, 155, 0.5); }

.card-hero .progress { background: rgba(255, 255, 255, 0.22); }
.card-hero .progress-fill { background: #FFFFFF; box-shadow: 0 0 12px rgba(255, 255, 255, 0.7); }

.banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(255, 94, 138, 0.14));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  box-shadow: var(--shadow-1), inset 0 0 0 1px rgba(124, 92, 255, 0.35), inset 0 1px 0 var(--glass-hi);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  animation: anim-in 520ms var(--ease-out-expo) backwards;
}

.banner > .icon {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 11px;
  background: var(--grad-brand-deep);
  color: #FFFFFF;
  box-shadow: 0 6px 14px -6px rgba(124, 92, 255, 0.8);
}

.banner > :not(.icon):not(.btn) {
  flex: 1 1 auto;
  min-width: 0;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 220px;
  padding: 40px 20px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.45;
  text-align: center;
}

.empty > .icon {
  width: 64px;
  height: 64px;
  padding: 16px;
  border-radius: 22px;
  background: var(--glass);
  color: var(--accent-text);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--glass-border), 0 0 30px -8px rgba(124, 92, 255, 0.5);
  animation: float 6s ease-in-out infinite;
}

.empty .headline {
  color: var(--ink);
}

.skeleton {
  position: relative;
  display: block;
  min-height: 1em;
  border-radius: 10px;
  background: var(--track-off);
  color: transparent;
  overflow: hidden;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, var(--shimmer) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

/* --------------------------------------------------------------------------
   11. Sheet, toast, consent
   -------------------------------------------------------------------------- */
.sheet {
  position: fixed;
  inset: 0;
  /* Con el teclado móvil abierto, main.js fija --vvh/--vvt (visualViewport): la hoja queda encima */
  top: var(--vvt, 0px);
  height: var(--vvh, 100%);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in 300ms var(--ease-out) both;
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: min(90dvh, calc(100dvh - var(--topbar-h) - var(--sat)));
  max-height: min(90dvh, calc(var(--vvh, 100dvh) - var(--sat) - 12px));
  display: flex;
  flex-direction: column;
  padding-bottom: var(--sab);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border-radius: 30px 30px 0 0;
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border);
  overflow: hidden;
  animation: sheet-in 560ms var(--ease-spring) both;
}

/* línea de luz superior */
.sheet-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(193, 85, 255, 0.8), transparent);
}

.sheet-grabber {
  flex: none;
  width: 40px;
  height: 5px;
  margin: 8px auto 4px;
  border-radius: 3px;
  background: var(--ink-3);
  opacity: 0.6;
}

.sheet-header {
  flex: none;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 52px;
  padding: 0 10px;
}

.sheet-title {
  grid-column: 2;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-close {
  grid-column: 3;
  width: 34px;
  height: 34px;
  justify-self: end;
  background: var(--track-off);
  color: var(--ink-2);
}

.sheet-close .icon {
  width: 18px;
  height: 18px;
}

/* Se ve de 34 px pero la zona táctil es de 44 × 44 */
.sheet-close::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
}

.sheet-content {
  flex: 1 1 auto;
  min-height: 0;
  padding: 4px 18px 26px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Cierre: el shell añade .is-closing antes de poner [hidden] */
.sheet.is-closing .sheet-panel {
  animation: sheet-out 240ms var(--ease-in) both;
}

.sheet.is-closing .sheet-scrim,
.sheet.is-dismissing .sheet-scrim {
  animation: fade-out 240ms var(--ease-in) both;
}

.sheet.is-closing,
.sheet.is-dismissing {
  pointer-events: none;
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}

@keyframes sheet-out {
  from {
    transform: none;
  }
  to {
    transform: translateY(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--sab) + 14px);
  z-index: 300;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  background: rgba(20, 18, 48, 0.9);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  box-shadow: var(--shadow-2), 0 0 0 1px rgba(193, 85, 255, 0.35), 0 10px 30px -10px rgba(124, 92, 255, 0.6);
  transform: translateX(-50%);
  animation: toast-in 560ms var(--ease-spring) both;
  pointer-events: none;
}

.toast.is-leaving {
  animation: toast-out 220ms var(--ease-in) both;
}

body[data-screen="play"] .toast {
  bottom: calc(var(--sab) + 24px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.96);
  }
}

.consent {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--sab) + 12px);
  z-index: 90;
  width: calc(100% - 24px);
  max-width: 560px;
  padding: 16px 18px;
  border-radius: var(--radius-xl);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border);
  transform: translateX(-50%);
  animation: consent-in 600ms var(--ease-spring) 400ms both;
}

body[data-screen="play"] .consent {
  bottom: calc(var(--sab) + 12px);
}

@keyframes consent-in {
  from {
    opacity: 0;
    transform: translate(-50%, 24px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.consent p {
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 1.45;
}

.consent-actions {
  display: flex;
  gap: 8px;
}

.consent-actions .btn {
  flex: 1 1 0;
}

/* --------------------------------------------------------------------------
   12. Páginas de texto (sobre, legal, cómo se puntúa, contacto, 404) y pie
   -------------------------------------------------------------------------- */
main:has(> .legal) {
  max-width: 800px;
}

.legal {
  position: relative;
  max-width: 760px;
  margin: 16px auto 0;
  padding: 28px 22px 32px;
  border-radius: var(--radius-2xl);
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border);
  font-size: 17px;
  line-height: 1.65;
  animation: anim-in 700ms var(--ease-out-expo) backwards;
}

.legal h1 {
  font-size: clamp(2rem, 6vw, 2.8rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin-bottom: 18px;
  text-wrap: balance;
  color: var(--accent-text);
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.legal h2 {
  position: relative;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin: 40px 0 12px;
  padding-left: 16px;
}

.legal h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.18em;
  bottom: 0.18em;
  width: 5px;
  border-radius: 4px;
  background: var(--grad-brand);
  box-shadow: 0 0 12px rgba(193, 85, 255, 0.6);
}

.legal h3 {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 24px 0 6px;
}

.legal p,
.legal ul,
.legal ol {
  margin: 0 0 14px;
}

.legal ul,
.legal ol {
  padding-left: 22px;
}

.legal li {
  margin: 5px 0;
}

.legal li::marker {
  color: var(--brand-2);
}

.legal a:not(.btn) {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent-text) 45%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
  transition: text-decoration-color var(--dur-fast);
}

.legal a:not(.btn):hover {
  text-decoration-color: currentColor;
}

.legal strong {
  font-weight: 700;
}

.legal .contact-mail {
  font-size: 1.15em;
  font-weight: 800;
}

.legal table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 8px 0 18px;
  font-size: 14px;
  line-height: 1.45;
  background: var(--glass);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--glass-border);
  overflow: hidden;
}

.legal th,
.legal td {
  padding: 10px 12px;
  border-bottom: var(--hairline) solid var(--separator);
  text-align: left;
  vertical-align: top;
}

.legal tr:last-child td {
  border-bottom: 0;
}

.legal th {
  background: var(--accent-soft);
  font-weight: 700;
}

/* Claves largas (aojo.progress, …) parten por donde haga falta: la tabla cabe en 360 px sin scroll lateral */
.legal td code {
  overflow-wrap: anywhere;
}

.legal code {
  font-size: 0.9em;
}

@media (max-width: 479px) {
  .legal {
    padding: 24px 18px 28px;
  }

  .legal th,
  .legal td {
    padding: 8px 8px;
  }

  .legal table {
    font-size: 13px;
  }
}

.legal .table-wrap,
.legal .scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Llamada a jugar en páginas de texto (topbar) */
.topbar .btn-small {
  min-height: 36px;
}

/* 404 dentro de la SPA (ruta desconocida): mismo tono que 404.html */
.shell-404 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
  padding: 24px 8px;
  text-align: center;
}

.shell-404-code {
  font-family: var(--font-display);
  font-size: clamp(5rem, 28vw, 8rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.05em;
}

.shell-404 .btn {
  margin-top: 6px;
}

/* 404 */
.page-404 {
  text-align: center;
}

.page-404 h1 {
  font-size: clamp(5rem, 28vw, 9rem);
  margin-bottom: 8px;
}

.page-404 .btn {
  margin-top: 12px;
  white-space: normal;
  text-align: center;
  padding-top: 10px;
  padding-bottom: 10px;
}

.foot {
  width: 100%;
  max-width: 760px;
  margin: 40px auto 0;
  padding: 0 16px calc(28px + var(--sab));
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.9;
  text-align: center;
}

.foot a {
  color: var(--ink-2);
  text-decoration: none;
  transition: color var(--dur-fast);
}

.foot a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Zona táctil cómoda (≥ 44 px de alto) sin agrandar el texto */
.foot-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 10px;
}

.foot a[aria-current="page"] {
  color: var(--ink);
  font-weight: 700;
}

.foot-copy {
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 12px;
}

body[data-screen="play"] .foot {
  display: none;
}

/* --------------------------------------------------------------------------
   13. Transiciones de pantalla
   El shell monta SIEMPRE de forma síncrona y pone #app.screen-enter (entrada CSS, retirada
   por setTimeout). Las reglas ::view-transition quedan listas por si una pantalla usa
   document.startViewTransition por su cuenta (topbar, tabbar y aurora tienen nombre propio).
   -------------------------------------------------------------------------- */
::view-transition-old(root) {
  animation: vt-out 180ms var(--ease-in) both;
}

::view-transition-new(root) {
  animation: vt-in 420ms var(--ease-out-expo) backwards;
}

::view-transition-group(topbar),
::view-transition-group(tabbar) {
  animation-duration: 380ms;
  animation-timing-function: var(--ease-out-expo);
}

@keyframes vt-out {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.99);
  }
}

@keyframes vt-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

#app {
  transition: opacity 140ms var(--ease-in), transform 140ms var(--ease-in);
}

#app.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
}

#app.screen-enter {
  animation: vt-in 420ms var(--ease-out-expo) backwards;
}

/* --------------------------------------------------------------------------
   14. Escritorio y preferencias del sistema
   -------------------------------------------------------------------------- */
@media (min-width: 520px) {
  .level-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
  }

  .level-num {
    font-size: 26px;
  }

  .legal {
    padding: 40px 44px 44px;
  }
}

@media (min-width: 720px) {
  /* Tableta: contenedor algo más ancho para todas las pantallas (antes 560 px salvo Inicio y Diario,
     que ya iban a ancho completo: al cambiar de pestaña el contenido cambiaba de ancho) */
  :root {
    --page-max: 760px;
  }

  .stage {
    max-width: min(520px, calc(100dvh - 310px));
  }

  .toast {
    bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--sab) + 18px);
  }
}

/* Solo con ratón: estados hover */
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) {
    transform: translateY(-1px);
  }

  .btn:active:not(:disabled) {
    transform: scale(0.97);
  }

  .btn-secondary:hover:not(:disabled),
  .btn-glass:hover:not(:disabled) {
    background: var(--glass-hover);
  }

  .btn-primary:hover:not(:disabled) {
    background-position: 100% 50%;
    box-shadow: 0 14px 36px -8px rgba(124, 92, 255, 0.85), 0 8px 22px -6px rgba(255, 94, 138, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }

  .btn-primary:hover:not(:disabled)::after,
  .btn-gold:hover:not(:disabled)::after {
    animation: shine-sweep 1.1s var(--ease-out) 1 both;
  }

  .btn-tinted:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent) 26%, transparent);
  }

  .btn-plain:hover:not(:disabled) {
    background: var(--accent-soft);
  }

  .icon-btn:hover {
    background: var(--accent-soft);
  }

  a.list-item:hover,
  button.list-item:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
  }

  a.list-item:hover .chevron,
  button.list-item:hover .chevron {
    transform: translateX(3px) rotate(-45deg);
  }

  a.card:hover,
  button.card:hover,
  a.glass:hover,
  button.glass:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-border), 0 0 0 1px rgba(124, 92, 255, 0.35);
  }

  .level-tile:not([data-state="locked"]):hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px rgba(124, 92, 255, 0.5);
  }

  .level-tile[data-state="open"]:hover {
    box-shadow: 0 16px 40px -10px rgba(124, 92, 255, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }

  .segmented-item:not([aria-pressed="true"]):hover {
    color: var(--ink);
  }
}

/* Escritorio: contenedor ancho para que las pantallas usen columnas */
@media (min-width: 1024px) {
  :root {
    --page-max: 1200px;
    --topbar-h: 64px;
    --tabbar-h: 68px;
    --tabbar-gap: 20px;
  }

  main {
    padding-left: 32px;
    padding-right: 32px;
  }

  body[data-screen="play"] main#app {
    max-width: 760px;
  }

  .large-title {
    font-size: 48px;
  }

  .title-1 {
    font-size: 34px;
  }

  .topbar {
    padding-left: 24px;
    padding-right: 24px;
  }

  .topbar-title,
  .brand {
    font-size: 18px;
  }

  .tabbar {
    width: 520px;
  }

  .tab {
    flex-direction: row;
    gap: 8px;
    font-size: 13px;
  }

  .tab .icon {
    width: 21px;
    height: 21px;
  }

  .grid-2 {
    gap: 16px;
  }

  .sheet {
    align-items: center;
  }

  .sheet-panel {
    max-width: 520px;
    max-height: min(84dvh, 760px, calc(var(--vvh, 100dvh) - 32px));
    padding-bottom: 0;
    border-radius: 30px;
    animation-name: sheet-pop;
  }

  .sheet.is-closing .sheet-panel {
    animation-name: sheet-pop-out;
  }

  .sheet-grabber {
    display: none;
  }

  .legal {
    font-size: 18px;
  }
}

@keyframes sheet-pop {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes sheet-pop-out {
  to {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}

/* Movimiento reducido: sin desplazamientos, rebotes ni bucles; estado final directo */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .sheet-panel,
  .sheet-scrim,
  .toast,
  .consent,
  .reveal-panel {
    animation: fade-in 150ms ease both !important;
  }

  .anim-in,
  .anim-pop,
  .banner,
  .legal,
  .aurora > span,
  .card-hero::before,
  .card-hero::after,
  .shine::after,
  .float,
  .pulse-glow,
  .grad-text,
  .level-tile[data-state="open"],
  .progress-fill::after,
  .empty > .icon {
    animation: none !important;
  }

  .skeleton::after {
    animation: none !important;
    transform: none;
    opacity: 0.5;
  }

  .btn:active,
  .btn:hover,
  .icon-btn:active,
  .tab:active .icon,
  .level-tile:active,
  .level-tile:hover,
  .segmented-item:active {
    transform: none !important;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }

  #app.is-leaving {
    opacity: 1;
    transform: none;
  }
}

/* Transparencia reducida: materiales sólidos, sin desenfoque */
@media (prefers-reduced-transparency: reduce) {
  :root {
    --glass: var(--surface);
    --glass-strong: var(--bg-elevated);
    --material: var(--bg-elevated);
  }

  .topbar,
  .tabbar,
  .glass,
  .card,
  .list,
  .btn-secondary,
  .btn-glass,
  .segmented,
  .field input,
  .field select,
  .field textarea,
  .chip,
  .breakdown,
  .level-tile,
  .rank-list,
  .stat,
  .banner,
  .sheet-panel,
  .sheet-scrim,
  .consent,
  .toast,
  .legal {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .banner {
    background: var(--surface);
  }

  .toast {
    background: #14122F;
  }

  .aurora > span {
    opacity: 0.5;
  }
}

/* Más contraste: bordes definidos, textos secundarios más oscuros, sin texto degradado */
@media (prefers-contrast: more) {
  :root {
    --separator: rgba(128, 128, 160, 0.6);
    --glass-border: rgba(160, 160, 200, 0.7);
  }

  :root:not([data-theme="light"]) {
    --ink-2: #D0CFEA;
    --ink-3: #A3A1C4;
  }

  :root[data-theme="light"] {
    --ink-2: #3E3B5E;
    --ink-3: #5E5B80;
  }

  .grad-text,
  .legal h1,
  .score-hero .score-big,
  .reveal-score {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--ink);
  }

  .card,
  .glass,
  .list,
  .rank-list,
  .breakdown,
  .stat,
  .level-tile,
  .consent,
  .sheet-panel,
  .legal {
    box-shadow: 0 0 0 1.5px var(--glass-border);
  }
}

@media (prefers-contrast: more) and (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ink-2: #3E3B5E;
    --ink-3: #5E5B80;
  }
}

@media (forced-colors: active) {
  .aurora,
  .noise {
    display: none;
  }

  .btn,
  .card,
  .glass,
  .tabbar {
    border: 1px solid CanvasText;
  }
}

/* Segmented dentro de una fila de lista: cabe en 375 px sin recortar etiquetas */
.list-item-trailing .segmented { max-width: 60vw; padding: 3px; }
.list-item-trailing .segmented-item { min-height: 32px; padding: 0 9px; font-size: 13px; white-space: nowrap; }

/* Lista anidada dentro de una tarjeta: sin sombra doble */
.card .list { box-shadow: inset 0 0 0 1px var(--glass-border); background: var(--track-off); margin: 8px 0 12px; -webkit-backdrop-filter: none; backdrop-filter: none; }
