/* ==========================================================================
   LA FICHA DE UN JUEGO — css/ficha.css
   ==========================================================================
   La ficha de un juego (juego.html, la del prototipo: prototipo/juego.html,
   specs/099-ideas-una-por-una, research D6). El viaje desde la tarjeta está en
   css/ficha-viaje.css, y la arma js/juego.js con js/ficha.js. Los colores de la ficha salen de la portada del juego: los
   scripts los ponen en --rb-ficha-luz, --rb-ficha-luz-2 y --rb-ficha-acento
   (desde el primer cuadro si se llegó tocando una tarjeta), que se registran
   para fundirse de un juego a otro. La noche de la ficha es la de Nay teñida
   con la luz del juego (--rb-ficha-noche): nunca un marrón.
   ========================================================================== */

@property --rb-ficha-luz {
  syntax: "<color>";
  inherits: true;
  initial-value: #8a4dff;
}

@property --rb-ficha-luz-2 {
  syntax: "<color>";
  inherits: true;
  initial-value: #e46cff;
}

@property --rb-ficha-acento {
  syntax: "<color>";
  inherits: true;
  initial-value: #dccaff;
}

/* ==========================================================================
   LA FICHA: sus piezas
   ========================================================================== */
@layer rb-piezas {
  .rb-ficha {
    --rb-ficha-radio: 18px;
    /* La noche violeta de Nay con un poco de la luz del juego, mezcladas en
       OKLCH: los naranjas dan ciruela, no marrón. */
    --rb-ficha-noche: color-mix(in oklch, var(--rb-ficha-luz) 30%, #1c1052);
    position: relative;
    isolation: isolate;
    transition:
      --rb-ficha-luz 1.1s ease,
      --rb-ficha-luz-2 1.1s ease,
      --rb-ficha-acento 1.1s ease;
  }

  /* La luz del juego, derramada por toda la ventana detrás de la página. */
  .rb-ficha-luz {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.5;
    background:
      radial-gradient(48% 46% at 24% 30%, color-mix(in srgb, var(--rb-ficha-luz) 46%, transparent), transparent 74%),
      radial-gradient(44% 40% at 84% 12%, color-mix(in srgb, var(--rb-ficha-luz-2) 36%, transparent), transparent 72%),
      radial-gradient(80% 46% at 50% 0%, color-mix(in srgb, var(--rb-ficha-noche) 90%, transparent), transparent 80%),
      radial-gradient(70% 50% at 50% 108%, color-mix(in srgb, var(--rb-ficha-noche) 80%, transparent), transparent 70%);
    transition: opacity 1.4s ease;
  }

  .rb-ficha[data-ficha-luz="lista"] .rb-ficha-luz {
    opacity: 1;
  }

  /* --- Volver --- */
  .rb-ficha-camino {
    display: flex;
    align-items: center;
  }

  .rb-ficha-volver {
    display: inline-flex;
    align-items: center;
    gap: var(--rb-e-2);
    min-height: 40px;
    padding: 6px var(--rb-e-4) 6px var(--rb-e-3);
    border: 1px solid var(--rb-borde-medio);
    border-radius: var(--rb-radio-pildora);
    background: rgb(9 13 54 / 0.72);
    font-weight: 600;
    font-size: var(--rb-t-14);
    color: var(--rb-texto-suave);
    -webkit-tap-highlight-color: transparent;
    transition: color var(--rb-transicion), border-color var(--rb-transicion), background var(--rb-transicion), scale 120ms ease;
  }

  /* Con el dedo, sin el velo gris del sistema: se hunde un poco al tocarlo. */
  .rb-ficha-volver:active {
    scale: 0.97;
    border-color: var(--rb-acento-claro);
  }

  .rb-ficha-volver .rb-icono {
    transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.3, 1.3);
  }

  @media (hover: hover) {
    .rb-ficha-volver:hover {
      border-color: var(--rb-acento-claro);
      background: rgb(84 37 215 / 0.24);
      color: var(--rb-texto);
    }
  }

  @media (hover: hover) {
    .rb-ficha-volver:hover .rb-icono {
      transform: translateX(-3px);
    }
  }

  /* --- El héroe: la portada grande y su luz, y el texto --- */
  .rb-ficha-heroe {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(var(--rb-e-6), 3.6vw, 56px);
    padding: clamp(var(--rb-e-5), 2.8vw, 44px);
    border-color: color-mix(in srgb, var(--rb-ficha-luz) 42%, var(--rb-borde));
    background: rgb(1 10 39 / 0.92);
    box-shadow: var(--rb-sombra-panel), 0 30px 80px -40px color-mix(in srgb, var(--rb-ficha-luz) 70%, transparent);
  }

  /* La luz del juego en el héroe: degradados limpios con sus dos tonos, sobre
     su noche, que se apaga hacia el texto para que se lea. */
  .rb-ficha-ambiente {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
    background:
      radial-gradient(46% 70% at 27% 50%, color-mix(in oklch, var(--rb-ficha-luz) 34%, transparent), transparent 72%),
      radial-gradient(38% 56% at 3% 100%, color-mix(in oklch, var(--rb-ficha-luz-2) 22%, transparent), transparent 70%),
      radial-gradient(40% 60% at 97% 0%, color-mix(in oklch, var(--rb-ficha-luz-2) 16%, transparent), transparent 70%),
      linear-gradient(105deg, var(--rb-ficha-noche) 0%, color-mix(in oklch, var(--rb-ficha-noche) 55%, #010822) 50%, rgb(1 8 34 / 0.94) 74%);
  }

  /* Una viñeta suave alrededor. */
  .rb-ficha-ambiente::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(150% 130% at 30% 50%, transparent 55%, rgb(1 8 34 / 0.5));
  }

  /* La portada mide 480 x 270: a lo sumo 560 de ancho (con su marco), para
     que no se vea estirada. */
  .rb-ficha-portada-zona {
    position: relative;
    z-index: 1;
    justify-self: center;
    width: min(100%, 560px);
    perspective: 900px;
  }

  /* El contraluz del color del juego, detrás de la portada: asoma alrededor de
     ella, más fuerte abajo, y crece un poco con el ratón encima. */
  .rb-ficha-portada-zona::before {
    content: "";
    position: absolute;
    inset: -7% -5% -14%;
    z-index: -1;
    border-radius: 48px;
    background:
      radial-gradient(60% 52% at 50% 64%, color-mix(in srgb, var(--rb-ficha-luz) 80%, transparent), transparent 100%),
      radial-gradient(70% 60% at 50% 40%, color-mix(in srgb, var(--rb-ficha-luz-2) 42%, transparent), transparent 100%);
    filter: blur(34px);
    opacity: 0.72;
    transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  @media (hover: hover) and (pointer: fine) {
    .rb-ficha-portada-zona:hover::before {
      opacity: 0.95;
      transform: scale(1.04);
    }
  }

  /* La portada es un objeto: en un marco de la luz de su juego (como el metal
     de las cartas del podio, que corre por el canto al inclinarla), con una
     sombra que se va al lado contrario de la inclinación y crece cuando se
     levanta. Con el ratón encima se inclina hacia él (hasta 8°) y se levanta un
     poco hacia quien mira. */
  .rb-ficha-portada {
    --rb-ficha-rx: 0deg;
    --rb-ficha-ry: 0deg;
    --rb-ficha-gx: 30%;
    --rb-ficha-gy: 20%;
    --rb-ficha-brillo: 0;
    --rb-ficha-sx: 0px;
    --rb-ficha-sy: 0px;
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    padding: 5px;
    border-radius: var(--rb-ficha-radio);
    box-shadow:
      var(--rb-ficha-sx) calc(18px + var(--rb-ficha-sy) + var(--rb-ficha-brillo) * 8px) calc(36px + var(--rb-ficha-brillo) * 14px) rgb(0 0 0 / 0.55),
      0 0 calc(var(--rb-ficha-brillo) * 40px) color-mix(in srgb, var(--rb-ficha-luz) 45%, transparent);
    transform: rotateX(var(--rb-ficha-rx)) rotateY(var(--rb-ficha-ry)) scale(calc(1 + var(--rb-ficha-brillo) * 0.02));
  }

  /* El marco: un aro de 5 px encima de todo, con el centro vacío (si la imagen
     tarda en llegar, se ve lo de detrás, y en el viaje, la portada que vuela). */
  .rb-ficha-portada::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    padding: 5px;
    border-radius: inherit;
    background: conic-gradient(from calc(210deg + var(--rb-ficha-ry) * 2.5), var(--rb-ficha-acento), var(--rb-ficha-luz), color-mix(in oklch, var(--rb-ficha-luz) 38%, #10082c), var(--rb-ficha-luz), var(--rb-ficha-acento));
    mask:
      linear-gradient(#000 0 0) content-box,
      linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
  }

  .rb-ficha-portada-vacia::after {
    content: none;
  }

  .rb-ficha-portada-img {
    width: 100%;
    height: 100%;
    border-radius: calc(var(--rb-ficha-radio) - 5px);
    object-fit: cover;
  }

  /* El canto de luz de la imagen (más claro arriba, de donde viene la luz). */
  .rb-ficha-portada-brillo {
    position: absolute;
    inset: 5px;
    border-radius: calc(var(--rb-ficha-radio) - 5px);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.42), inset 0 0 0 1px rgb(255 255 255 / 0.1);
    pointer-events: none;
  }

  /* El brillo que sigue al ratón: luz suave sobre la imagen, que aclara lo
     claro sin lavar lo oscuro. */
  .rb-ficha-portada-brillo::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
      radial-gradient(25% 40% at var(--rb-ficha-gx) var(--rb-ficha-gy), rgb(255 255 255 / calc(var(--rb-ficha-brillo) * 0.55)), transparent 72%),
      radial-gradient(80% 110% at var(--rb-ficha-gx) var(--rb-ficha-gy), rgb(255 255 255 / calc(var(--rb-ficha-brillo) * 0.18)), transparent 70%);
    mix-blend-mode: soft-light;
  }

  /* Un destello cruza la portada una sola vez, cuando se posa. */
  .rb-ficha-portada-brillo::after {
    content: "";
    position: absolute;
    inset: -30% -60%;
    background: linear-gradient(105deg, transparent 38%, rgb(255 255 255 / 0.16) 44%, rgb(255 255 255 / 0.62) 49%, rgb(255 255 255 / 0.16) 54%, transparent 62%);
    transform: translateX(-70%);
    opacity: 0;
  }

  /* Sin juego (o sin JavaScript): un cartucho con una pregunta, del mundo del
     prototipo, en vez de una caja de maqueta. */
  .rb-ficha-sin-portada {
    display: grid;
    place-items: center;
    align-content: center;
    gap: var(--rb-e-3);
    width: 100%;
    height: 100%;
    border-radius: calc(var(--rb-ficha-radio) - 5px);
    background:
      radial-gradient(56% 64% at 50% 42%, rgb(138 77 255 / 0.24), transparent 72%),
      rgb(13 20 64 / 0.6);
    box-shadow: inset 0 0 0 1px rgb(167 133 255 / 0.25);
    color: var(--rb-texto-suave);
    font-size: var(--rb-t-14);
    font-weight: 600;
    text-align: center;
  }

  .rb-ficha-cartucho {
    width: clamp(56px, 22%, 112px);
    height: auto;
    filter: drop-shadow(0 10px 16px rgb(0 0 0 / 0.45)) drop-shadow(0 0 22px rgb(138 77 255 / 0.35));
    rotate: -6deg;
  }

  .rb-ficha-texto {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: start;
    align-content: center;
    gap: var(--rb-e-4);
    min-width: 0;
  }

  .rb-ficha-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--rb-e-2) var(--rb-e-3);
  }

  .rb-ficha-categoria {
    --rb-ficha-cat: var(--rb-acento-claro);
    border-color: color-mix(in srgb, var(--rb-ficha-cat) 62%, transparent);
    background: color-mix(in srgb, var(--rb-ficha-cat) 14%, rgb(9 13 54 / 0.9));
  }

  .rb-ficha-categoria .rb-icono {
    color: var(--rb-ficha-cat);
  }

  [data-categoria="accion"] { --rb-ficha-cat: var(--rb-cat-accion); }
  [data-categoria="aventura"] { --rb-ficha-cat: var(--rb-cat-aventura); }
  [data-categoria="rpg"] { --rb-ficha-cat: var(--rb-cat-rpg); }
  [data-categoria="simulacion"] { --rb-ficha-cat: var(--rb-cat-simulacion); }
  [data-categoria="plataformas"] { --rb-ficha-cat: var(--rb-cat-plataformas); }
  [data-categoria="deportes"] { --rb-ficha-cat: var(--rb-cat-deportes); }
  [data-categoria="lucha"] { --rb-ficha-cat: var(--rb-cat-lucha); }
  [data-categoria="puzzles"] { --rb-ficha-cat: var(--rb-cat-puzzles); }
  [data-categoria="terror"] { --rb-ficha-cat: var(--rb-cat-terror); }
  [data-categoria="arcade"] { --rb-ficha-cat: var(--rb-cat-arcade); }
  [data-categoria="estrategia"] { --rb-ficha-cat: var(--rb-cat-estrategia); }
  [data-categoria="casual"] { --rb-ficha-cat: var(--rb-cat-casual); }
  [data-categoria="cooperativo"] { --rb-ficha-cat: var(--rb-cat-cooperativo); }

  /* «Más de» su categoría, con el icono del color de la categoría. */
  .rb-ficha[data-categoria] [data-ficha-seccion="mas"] .rb-icono-titulo {
    --rb-color-titulo: var(--rb-ficha-cat);
  }

  .rb-ficha-jugadores {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: var(--rb-t-13);
    color: var(--rb-texto-suave);
  }

  .rb-ficha-jugadores .rb-icono {
    color: var(--rb-ficha-acento);
  }

  .rb-ficha-titulo {
    width: fit-content;
    max-width: 100%;
    padding-right: 0.08em;
    font-family: var(--rb-letra-titular);
    font-style: italic;
    font-weight: 900;
    font-size: clamp(2.2rem, 4.4vw, 4rem);
    line-height: 0.98;
    letter-spacing: -0.01em;
    text-transform: uppercase;
    overflow-wrap: anywhere;
    background: linear-gradient(180deg, #ffffff 34%, var(--rb-ficha-acento) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 0 rgb(0 0 0 / 0.4)) drop-shadow(0 0 24px color-mix(in srgb, var(--rb-ficha-luz) 42%, transparent));
  }

  .rb-ficha-titulo[data-largo="medio"] {
    font-size: clamp(1.9rem, 3.3vw, 3rem);
  }

  .rb-ficha-titulo[data-largo="largo"] {
    font-size: clamp(1.6rem, 2.5vw, 2.35rem);
    line-height: 1.04;
  }

  .rb-ficha-valoracion {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--rb-e-2) var(--rb-e-3);
    font-size: var(--rb-t-14);
    color: var(--rb-texto-suave);
  }

  .rb-ficha-valoracion > strong {
    font-family: var(--rb-letra-titulo);
    font-size: var(--rb-t-20);
    color: var(--rb-texto);
  }

  /* Las estrellas: una fila apagada y, encima, la llena hasta su valor. La
     caja mide lo que su fila (no se estira en una rejilla), y lo lleno se
     cuenta por estrellas: las enteras con sus huecos y un trozo de la
     siguiente (el script pone cuántas enteras y la fracción). */
  .rb-ficha-estrellas {
    --rb-ficha-estrella: 20px;
    --rb-ficha-hueco: 3px;
    position: relative;
    display: inline-flex;
    flex: none;
    justify-self: start;
  }

  .rb-ficha-estrellas-chicas {
    --rb-ficha-estrella: 14px;
  }

  .rb-ficha-estrellas-fila {
    display: inline-flex;
    gap: var(--rb-ficha-hueco);
    color: rgb(214 200 255 / 0.2);
  }

  /* Sin el max-width: 100% de las imágenes (rb-base.css): en la capa de las llenas, que crece desde 0, las estrellas se
     aplastaban y se corrían en vez de descubrirse enteras (spec 100, T016). */
  .rb-ficha-estrellas-fila .rb-icono {
    flex: none;
    width: var(--rb-ficha-estrella);
    max-width: none;
    height: var(--rb-ficha-estrella);
  }

  .rb-ficha-estrellas-llenas {
    --rb-ficha-llenas: calc(var(--rb-ficha-enteras, 0) * (var(--rb-ficha-estrella) + var(--rb-ficha-hueco)) + var(--rb-ficha-fraccion, 0) * var(--rb-ficha-estrella));
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0;
    overflow: hidden;
    color: var(--rb-dorado);
    filter: drop-shadow(0 0 6px rgb(255 190 60 / 0.6));
    transition: width 1s cubic-bezier(0.3, 0.7, 0.2, 1);
  }

  [data-ficha-estrellas="llenas"] .rb-ficha-estrellas-llenas {
    width: var(--rb-ficha-llenas, 0%);
  }

  /* Los 52 caracteres de siempre, en em (52 «0» de Inter, de 0,631 em): con ch, el ancho dependía de la letra que
     hubiera, y al llegar Inter la descripción cambiaba de líneas y movía todo lo de abajo (spec 100, T016). */
  .rb-ficha-descripcion {
    max-width: 32.8em;
    font-size: var(--rb-t-16);
    line-height: 1.6;
    color: var(--rb-texto-suave);
  }

  .rb-ficha-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: var(--rb-e-3);
    margin-top: var(--rb-e-1);
  }

  .rb-ficha-jugar {
    min-height: 56px;
    padding-inline: 34px 38px;
    font-size: var(--rb-t-18);
    box-shadow: var(--rb-brillo-activo), 0 16px 36px -12px color-mix(in srgb, var(--rb-ficha-luz) 80%, transparent);
    transition: filter var(--rb-transicion), box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.3, 0.7, 0.3, 1.3);
  }

  .rb-ficha-jugar .rb-icono {
    width: 1.3em;
    height: 1.3em;
    transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.3, 1.4);
  }

  @media (hover: hover) {
    .rb-ficha-jugar:hover {
      transform: translateY(-2px);
      box-shadow: var(--rb-brillo-activo), 0 22px 44px -12px color-mix(in srgb, var(--rb-ficha-luz) 95%, transparent);
    }
  }

  @media (hover: hover) {
    .rb-ficha-jugar:hover .rb-icono {
      transform: scale(1.15);
    }
  }

  .rb-ficha-jugar:active {
    transform: translateY(1px) scale(0.98);
  }

  .rb-ficha-guardar {
    min-height: 56px;
  }

  .rb-ficha-guardar .rb-icono {
    color: var(--rb-texto-suave);
    transition: color var(--rb-transicion);
  }

  .rb-ficha-guardar[aria-pressed="true"] {
    border-color: rgb(255 111 168 / 0.7);
    background: rgb(255 77 140 / 0.16);
  }

  .rb-ficha-guardar[aria-pressed="true"] .rb-icono {
    color: #ff6fa8;
    filter: drop-shadow(0 0 8px rgb(255 90 150 / 0.7));
  }

  .rb-ficha-progreso {
    display: grid;
    gap: 6px;
    width: min(100%, 330px);
    font-size: var(--rb-t-13);
    color: var(--rb-texto-suave);
  }

  .rb-ficha-progreso strong {
    color: var(--rb-texto);
  }

  /* --- Sus números --- */
  .rb-ficha-cifras {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--rb-e-3);
    margin: 0;
  }

  .rb-ficha-cifra {
    position: relative;
    display: grid;
    align-content: start;
    gap: var(--rb-e-2);
    min-width: 0;
    overflow: hidden;
    padding: var(--rb-e-4) var(--rb-e-5);
    border: 1px solid var(--rb-borde-medio);
    border-radius: var(--rb-radio-mediano);
    background:
      radial-gradient(90% 120% at 0% 0%, color-mix(in srgb, var(--rb-ficha-luz) 13%, transparent), transparent 65%),
      rgb(13 20 64 / 0.55);
  }

  .rb-ficha-cifra::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 2px;
    background: linear-gradient(90deg, var(--rb-ficha-luz), var(--rb-ficha-luz-2), transparent);
    opacity: 0.85;
  }

  .rb-ficha-cifra dt {
    display: flex;
    align-items: center;
    gap: var(--rb-e-2);
    font-size: var(--rb-t-12);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--rb-texto-suave);
  }

  .rb-ficha-cifra dt .rb-icono {
    width: 18px;
    height: 18px;
    color: var(--rb-ficha-acento);
  }

  .rb-ficha-cifra dd {
    display: grid;
    gap: 6px;
    margin: 0;
  }

  .rb-ficha-cifra dd > strong {
    font-family: var(--rb-letra-titulo);
    font-size: var(--rb-t-32);
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }

  .rb-ficha-cifra-detalle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px var(--rb-e-2);
    font-size: var(--rb-t-13);
    color: var(--rb-texto-suave);
  }

  .rb-ficha-recordista {
    flex-wrap: nowrap;
  }

  .rb-ficha-recordista strong {
    color: var(--rb-texto);
  }

  /* La valoración: el número y sus estrellas, y al lado cómo se reparte. */
  .rb-ficha-cifra-reparto dd {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: var(--rb-e-5);
  }

  .rb-ficha-cifra-reparto dd > strong {
    grid-column: 1;
    grid-row: 1;
  }

  .rb-ficha-cifra-valoracion {
    display: contents;
  }

  .rb-ficha-cifra-valoracion > span {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    gap: 4px;
  }

  .rb-ficha-reparto {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: grid;
    gap: 3px;
  }

  .rb-ficha-reparto li {
    display: grid;
    grid-template-columns: 0.7em minmax(0, 1fr);
    align-items: center;
    gap: var(--rb-e-2);
    font-size: var(--rb-t-11);
    font-weight: 700;
    line-height: 1.1;
    color: var(--rb-texto-suave);
  }

  .rb-ficha-reparto-barra {
    height: 5px;
    overflow: hidden;
    border-radius: var(--rb-radio-pildora);
    background: rgb(214 200 255 / 0.12);
  }

  .rb-ficha-reparto-barra i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ffd56a, var(--rb-dorado-boton));
    transition: width 0.9s cubic-bezier(0.3, 0.7, 0.2, 1);
  }

  [data-ficha-estrellas="llenas"] .rb-ficha-reparto-barra i {
    width: var(--rb-ficha-parte, 0%);
  }

  /* Con alto contraste los fondos desaparecen, y con ellos las barras. */
  @media (forced-colors: active) {
    .rb-ficha-reparto-barra {
      border: 1px solid CanvasText;
    }

    .rb-ficha-reparto-barra i {
      forced-color-adjust: none;
      background: Highlight;
    }
  }

  .rb-ficha-reparto li:nth-child(2) i { transition-delay: 60ms; }
  .rb-ficha-reparto li:nth-child(3) i { transition-delay: 120ms; }
  .rb-ficha-reparto li:nth-child(4) i { transition-delay: 180ms; }
  .rb-ficha-reparto li:nth-child(5) i { transition-delay: 240ms; }

  /* De vuelta a una ficha ya vista, sus estrellas y sus barras están llenas desde el principio. */
  html[data-ficha-llegada="vuelta"] .rb-ficha-estrellas-llenas,
  html[data-ficha-de-vuelta] .rb-ficha-estrellas-llenas {
    width: var(--rb-ficha-llenas, 0%);
    transition: none;
  }

  html[data-ficha-llegada="vuelta"] .rb-ficha-reparto-barra i,
  html[data-ficha-de-vuelta] .rb-ficha-reparto-barra i {
    width: var(--rb-ficha-parte, 0%);
    transition: none;
  }

  /* --- La entrada sin viaje: sobria, con CSS. Si llegó viajando
     (data-ficha-llegada, que no se quita), el héroe, su portada y su título no
     la hacen: la hizo el viaje; el resto del texto llega escalonado alrededor
     de la portada ya posada. --- */
  @media (prefers-reduced-motion: no-preference) {
    .rb-ficha-texto > * {
      animation: rb-ficha-subir 640ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    }

    .rb-ficha-texto > :nth-child(1) { animation-delay: 120ms; }
    .rb-ficha-texto > :nth-child(2) { animation-delay: 170ms; }
    .rb-ficha-texto > :nth-child(3) { animation-delay: 230ms; }
    .rb-ficha-texto > :nth-child(4) { animation-delay: 290ms; }
    .rb-ficha-texto > :nth-child(5) { animation-delay: 350ms; }
    .rb-ficha-texto > :nth-child(6) { animation-delay: 410ms; }

    /* Llegando con el viaje (650 ms): el texto llega escalonado mientras la
       portada se asienta, del 240 al 480. */
    html[data-ficha-llegada] .rb-ficha-texto > * { animation-duration: 520ms; }
    html[data-ficha-llegada] .rb-ficha-texto > :nth-child(1) { animation-delay: 240ms; }
    html[data-ficha-llegada] .rb-ficha-texto > :nth-child(3) { animation-delay: 300ms; }
    html[data-ficha-llegada] .rb-ficha-texto > :nth-child(4) { animation-delay: 360ms; }
    html[data-ficha-llegada] .rb-ficha-texto > :nth-child(5) { animation-delay: 420ms; }
    html[data-ficha-llegada] .rb-ficha-texto > :nth-child(6) { animation-delay: 480ms; }

    /* Y lo de debajo (sus números, sus logros) no entra mientras la portada
       vuela: si el motor lo marca visto en pleno viaje, espera a que se pose. */
    html[data-ficha-viajando="ida"] .rb-ficha [data-ficha-seccion][data-aparecer] {
      transition-delay: 420ms;
    }

    html[data-ficha-llegada] .rb-ficha-titulo,
    html[data-ficha-llegada] .rb-ficha-heroe[data-aparecer="entrada"] {
      animation: none;
    }

    .rb-ficha-portada:not(.rb-ficha-portada-vacia) {
      animation: rb-ficha-posarse 760ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    }

    html[data-ficha-llegada] .rb-ficha-portada {
      animation: none;
    }

    .rb-ficha-portada:not(.rb-ficha-portada-vacia) .rb-ficha-portada-brillo::after {
      animation: rb-ficha-destello 1.1s 420ms cubic-bezier(0.35, 0.6, 0.25, 1) both;
    }

    html[data-ficha-llegada] .rb-ficha-portada .rb-ficha-portada-brillo::after {
      animation-delay: 520ms;
    }

    /* Con el viaje de reserva (una copia vuela la portada), el título no viaja:
       sube con el texto; y el destello espera a que la copia se pose. */
    html[data-ficha-reserva] .rb-ficha-titulo {
      animation: rb-ficha-subir 520ms 200ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    }

    html[data-ficha-reserva] .rb-ficha-portada .rb-ficha-portada-brillo::after {
      animation-delay: 660ms;
    }

    .rb-ficha-ambiente {
      animation: rb-ficha-encenderse 1.2s 120ms ease backwards;
    }

    .rb-ficha-portada-zona::before {
      animation: rb-ficha-encenderse 1.2s 300ms ease backwards;
    }

    /* De vuelta con la historia (la página se carga otra vez), la ficha está
       como se dejó: nada entra de nuevo. */
    html[data-ficha-de-vuelta] .rb-ficha-texto > *,
    html[data-ficha-de-vuelta] .rb-ficha-portada,
    html[data-ficha-de-vuelta] .rb-ficha-portada .rb-ficha-portada-brillo::after,
    html[data-ficha-de-vuelta] .rb-ficha-ambiente,
    html[data-ficha-de-vuelta] .rb-ficha-portada-zona::before {
      animation: none;
    }
  }

  @keyframes rb-ficha-subir {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
  }

  @keyframes rb-ficha-posarse {
    from {
      opacity: 0;
      transform: translateY(12px) scale(0.965);
    }
  }

  @keyframes rb-ficha-destello {
    0% {
      opacity: 1;
      transform: translateX(-70%);
    }
    100% {
      opacity: 1;
      transform: translateX(70%);
    }
  }

  @keyframes rb-ficha-encenderse {
    from {
      opacity: 0;
    }
  }
}

/* ==========================================================================
   LA FICHA EN SU PÁGINA
   ========================================================================== */
@layer rb-pantallas {
  .rb-ficha {
    width: min(100%, 1320px + 2 * var(--rb-calle));
    padding-top: var(--rb-e-4);
  }

  /* Sin JavaScript, la ficha no sabe qué juego enseñar: solo su explicación. */
  @media (scripting: none) {
    .rb-ficha [data-ficha-seccion] {
      display: none;
    }
  }

  @media (max-width: 1023px) {
    .rb-ficha-heroe {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .rb-ficha-cifras {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (max-width: 767px) {
    /* En el móvil, la portada va de borde a borde justo debajo de la barra,
       como una tarjeta que se abre, con el título encima de su degradado;
       «Volver» flota sobre ella, y el resto del texto sigue debajo. */
    .rb-ficha {
      padding-top: 0;
    }

    .rb-ficha-camino {
      position: absolute;
      top: var(--rb-e-3);
      left: var(--rb-e-3);
      z-index: 3;
    }

    .rb-ficha-volver {
      min-height: 44px;
      backdrop-filter: blur(8px);
    }

    /* La página tiene 12 px de margen a los lados en el móvil (rb-piezas.css):
       el héroe los recupera, justo, para no salirse de la pantalla (si se sale,
       el móvil agranda la página y el navegador corta el viaje). */
    .rb-ficha-heroe {
      grid-template-columns: minmax(0, 1fr);
      gap: var(--rb-e-4);
      margin-inline: calc(-1 * var(--rb-e-3));
      padding: 0 var(--rb-e-4) var(--rb-e-5);
      border-width: 0 0 1px;
      border-radius: 0 0 22px 22px;
    }

    /* El borde de luz de los paneles se pinta un píxel por fuera: de borde a
       borde, se saldría de la pantalla. */
    .rb-ficha-heroe::before {
      content: none;
    }

    /* El texto deja de ser una caja: sus partes van a la rejilla del héroe (el
       título, encima de la portada), siempre por encima de la luz de fondo. */
    .rb-ficha-texto {
      display: contents;
    }

    .rb-ficha-texto > * {
      position: relative;
      z-index: 1;
    }

    /* A lo ancho de su rejilla (stretch, no el center de siempre): ajustada a su contenido, la zona medía 0 hasta que
       llegaba la imagen, la portada (16:9) no tenía alto, y al llegar empujaba todo el texto 164 px hacia abajo
       (0,17 de salto en la web real con la red lenta, spec 100, T016). Así su alto existe desde el primer cuadro. */
    .rb-ficha-portada-zona {
      grid-row: 1;
      grid-column: 1;
      justify-self: stretch;
      width: auto;
      margin-inline: calc(-1 * var(--rb-e-4));
    }

    /* La luz de detrás de la portada, que en el ancho entero se saldría de la pantalla. */
    .rb-ficha-portada-zona::before {
      content: none;
    }

    .rb-ficha-portada,
    .rb-ficha-portada-img,
    .rb-ficha-portada-brillo,
    .rb-ficha-sin-portada {
      border-radius: 0;
    }

    .rb-ficha-portada {
      padding: 0;
      box-shadow: none;
    }

    .rb-ficha-portada-brillo {
      inset: 0;
    }

    /* Sin marco: en su lugar, el degradado de la noche sobre el pie de la
       portada, donde se lee el título. Va dentro de la portada, así viaja con
       ella. */
    .rb-ficha-portada::after {
      inset: 38% 0 0;
      z-index: 1;
      padding: 0;
      border-radius: 0;
      background: linear-gradient(180deg, rgb(1 10 39 / 0), rgb(1 10 39 / 0.55) 45%, rgb(1 10 39 / 0.94));
      mask: none;
    }

    .rb-ficha-portada-vacia::after {
      content: none;
    }

    .rb-ficha-titulo {
      grid-row: 1;
      grid-column: 1;
      z-index: 2;
      align-self: end;
      margin-bottom: var(--rb-e-3);
    }

    /* En el móvil la portada va arriba y el texto debajo: la luz, detrás de la
       portada, y la noche se cierra hacia el texto. */
    .rb-ficha-ambiente {
      background:
        radial-gradient(90% 44% at 50% 20%, color-mix(in oklch, var(--rb-ficha-luz) 34%, transparent), transparent 72%),
        radial-gradient(60% 30% at 100% 0%, color-mix(in oklch, var(--rb-ficha-luz-2) 18%, transparent), transparent 70%),
        linear-gradient(180deg, var(--rb-ficha-noche) 0%, color-mix(in oklch, var(--rb-ficha-noche) 55%, #010822) 42%, rgb(1 8 34 / 0.95) 66%);
    }

    .rb-ficha-ambiente::after {
      background: radial-gradient(150% 120% at 50% 30%, transparent 55%, rgb(1 8 34 / 0.5));
    }

    .rb-ficha {
      --rb-ficha-radio: 14px;
    }

    .rb-ficha-titulo {
      font-size: clamp(1.9rem, 9vw, 2.6rem);
    }

    .rb-ficha-titulo[data-largo="medio"] {
      font-size: clamp(1.6rem, 7.4vw, 2.2rem);
    }

    .rb-ficha-titulo[data-largo="largo"] {
      font-size: clamp(1.35rem, 6vw, 1.8rem);
    }

    .rb-ficha-descripcion {
      font-size: var(--rb-t-14);
    }

    .rb-ficha-acciones {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      width: 100%;
    }

    .rb-ficha-jugar {
      padding-inline: var(--rb-e-5);
    }

    /* «Guardar», solo con su corazón: su nombre sigue ahí para quien lee en voz alta. */
    .rb-ficha-guardar {
      width: 56px;
      padding: 0;
    }

    .rb-ficha-guardar-texto {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip: rect(0 0 0 0);
      white-space: nowrap;
    }

    .rb-ficha-progreso {
      width: 100%;
    }

    .rb-ficha-cifra {
      padding: var(--rb-e-3) var(--rb-e-4);
    }

    .rb-ficha-cifra dd > strong {
      font-size: var(--rb-t-24);
    }

    .rb-ficha-cifra-reparto,
    .rb-ficha-cifra-record,
    .rb-ficha-cifra:last-child:nth-child(4) {
      grid-column: 1 / -1;
    }

    .rb-ficha .rb-panel-cabeza {
      flex-wrap: wrap;
    }
  }
}

/* ==========================================================================
   LO DE LA WEB: las opiniones, los amigos, las reseñas y el camino
   ========================================================================== */
@layer rb-pantallas {
  .rb-ficha [data-estrellas] {
    display: inline-flex;
  }

  /* Lo que dice de sí: nuevo, en tendencia, popular. */
  .rb-ficha-etiquetas {
    display: flex;
    flex-wrap: wrap;
    gap: var(--rb-e-2);
  }

  .rb-ficha-etiquetas:not(:has(span:not(:empty))) {
    display: none;
  }

  .rb-ficha-etiquetas span:empty {
    display: none;
  }

  .rb-ficha-etiquetas > .estado-juego,
  .rb-ficha-etiquetas .rb-ficha-etiqueta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border: 1px solid rgb(190 140 255 / 0.5);
    border-radius: var(--rb-radio-pildora);
    background: rgb(84 37 215 / 0.3);
    font-weight: 700;
    font-size: var(--rb-t-12);
  }

  .rb-ficha-etiqueta .rb-icono {
    width: 14px;
    height: 14px;
    color: var(--rb-ficha-acento);
  }

  @media (hover: hover) {
    .rb-ficha a.rb-ficha-categoria:hover {
      filter: brightness(1.2);
    }
  }

  .rb-ficha-nota {
    font-size: var(--rb-t-13);
    color: var(--rb-texto-suave);
  }

  .rb-ficha-jugar[aria-busy="true"] {
    opacity: 0.75;
  }

  .rb-ficha-guardar:disabled {
    opacity: 1;
    color: var(--rb-texto-suave);
  }

  /* --- El cuerpo: las reseñas y, al lado, tu opinión y tus amigos --- */
  .rb-ficha-cuerpo {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    align-items: start;
    gap: var(--rb-calle);
  }

  .rb-ficha-lado {
    display: grid;
    gap: var(--rb-calle);
    min-width: 0;
  }

  /* --- Tu opinión: las estrellas y el pulgar --- */
  .rb-ficha-opinion {
    display: grid;
    gap: var(--rb-e-4);
  }

  .rb-ficha-opinion .rb-panel-cabeza {
    margin-bottom: 0;
  }

  .rb-ficha-opinion > div:not(.rb-panel-cabeza) {
    display: grid;
    justify-items: start;
    gap: var(--rb-e-2);
  }

  .rb-ficha-opinion .rb-ficha-voto {
    margin-left: -8px;
  }

  .rb-ficha-opinion .rb-ficha-pulgares {
    width: 100%;
  }

  .rb-ficha-opinion h3 {
    font: 700 var(--rb-t-14) / 1.3 var(--rb-letra-titulo);
    color: var(--rb-texto-suave);
  }

  .rb-ficha-voto {
    display: inline-flex;
    gap: 2px;
  }

  .rb-ficha-voto .estrella {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: var(--rb-radio-tarjeta);
    background: none;
    color: rgb(214 200 255 / 0.28);
    transition: color var(--rb-transicion), transform var(--rb-transicion);
  }

  .rb-ficha-voto .estrella .rb-icono {
    width: 28px;
    height: 28px;
    transition: filter var(--rb-transicion);
  }

  @media (hover: hover) {
    .rb-ficha-voto .estrella:hover {
      transform: scale(1.14);
    }
  }

  .rb-ficha-voto .estrella.activa,
  .rb-ficha-voto .estrella.preview {
    color: var(--rb-dorado);
  }

  .rb-ficha-voto .estrella.activa .rb-icono,
  .rb-ficha-voto .estrella.preview .rb-icono {
    filter: drop-shadow(0 0 7px rgb(255 190 60 / 0.6));
  }

  .rb-ficha-pulgares {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--rb-e-2);
  }

  .rb-ficha-pulgares .rb-boton {
    justify-content: center;
    min-height: 46px;
    padding-inline: var(--rb-e-2);
  }

  .rb-ficha-pulgares .reaccion-contador {
    font-variant-numeric: tabular-nums;
    color: var(--rb-texto-suave);
  }

  .rb-ficha-pulgares .boton-like.activo {
    border-color: rgb(140 251 204 / 0.7);
    background: rgb(33 194 107 / 0.2);
    color: var(--rb-verde);
  }

  .rb-ficha-pulgares .boton-dislike.activo {
    border-color: rgb(255 120 150 / 0.7);
    background: rgb(210 40 90 / 0.22);
    color: #ffb3c6;
  }

  /* --- Tus amigos --- */
  .rb-ficha-amigos:empty,
  .rb-ficha-amigos[hidden] {
    display: none;
  }

  .rb-ficha-amigos ul {
    display: grid;
    gap: var(--rb-e-2);
  }

  .rb-ficha-amigos .rb-retrato {
    --rb-tam-retrato: 40px;
  }

  .rb-ficha-amigos p {
    margin-bottom: var(--rb-e-3);
    font-size: var(--rb-t-14);
    color: var(--rb-texto-suave);
  }

  /* --- Las reseñas --- */
  .rb-ficha-resena-nueva {
    display: grid;
    gap: var(--rb-e-3);
    margin-bottom: var(--rb-e-5);
    padding: var(--rb-e-4);
    border: 1px solid var(--rb-borde-medio);
    border-radius: var(--rb-radio-mediano);
    background: rgb(13 20 64 / 0.5);
  }

  .rb-ficha-resena-nueva[hidden],
  .rb-ficha-resena-aviso[hidden] {
    display: none;
  }

  .rb-ficha-resena-nueva > p {
    font-weight: 600;
    font-size: var(--rb-t-14);
  }

  .rb-ficha-resena-nueva .rb-ficha-voto .estrella {
    width: 36px;
    height: 36px;
  }

  .rb-ficha-resena-nueva .rb-ficha-voto .estrella .rb-icono {
    width: 22px;
    height: 22px;
  }

  .rb-ficha-resena-aviso {
    margin-bottom: var(--rb-e-4);
    font-size: var(--rb-t-14);
    color: var(--rb-texto-suave);
  }

  .rb-ficha-resenas {
    display: grid;
    gap: var(--rb-e-3);
  }

  .rb-ficha-resenas .rb-comentario[data-propia] {
    border-color: rgb(190 140 255 / 0.55);
    background: rgb(84 37 215 / 0.14);
  }

  .resena-estrellas {
    display: inline-flex;
    gap: 2px;
  }

  .resena-estrella {
    color: rgb(214 200 255 / 0.2);
  }

  .resena-estrella.llena {
    color: var(--rb-dorado);
  }

  .resena-estrella .rb-icono {
    width: 15px;
    height: 15px;
  }

  /* --- El camino: el anterior, la categoría y el siguiente --- */
  .rb-ficha-flujo {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--rb-e-3);
    margin-top: var(--rb-e-4);
  }

  .rb-ficha-flujo .rb-boton {
    justify-content: center;
    min-width: 0;
  }

  .rb-ficha-flujo .rb-boton > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .rb-ficha-flujo [hidden] {
    display: none;
  }

  @media (max-width: 1023px) {
    .rb-ficha-cuerpo {
      grid-template-columns: minmax(0, 1fr);
    }

    /* Tu opinión, antes que las reseñas. */
    .rb-ficha-lado {
      order: -1;
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (max-width: 767px) {
    .rb-ficha-lado {
      grid-template-columns: minmax(0, 1fr);
    }

    .rb-ficha-flujo {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rb-ficha-flujo #juegoCategoria {
      grid-column: 1 / -1;
      grid-row: 1;
    }
  }
}
