/* Estadísticas con la composición de Últimas partidas: cabecera sobre madera,
   las secciones como fichas de latón y el ranking en una hoja de pergamino
   compacta. Las plantillas cargan antes home.css, recent_games.css (recent-hero,
   recent-home, recent-mode y la franja de líderes) y decks.css (la página de
   listas de cada líder usa las cartas del editor). */

/* --- Cabecera: accesos y pestañas --- */
.statistics-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-self: flex-end;
  gap: 0.5rem;
}

.statistics-links .recent-home {
  position: static;
}

/* Enlaces a informes completos; funcionan también sin JavaScript. */
.statistics-tabs .statistics-tab {
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.statistics-tabs .statistics-tab.is-active {
  border-color: rgba(90, 58, 34, 0.55);
  background: var(--recent-parchment);
  box-shadow:
    0 22px 40px -22px rgba(0, 0, 0, 0.92),
    inset 0 0 40px rgba(90, 58, 34, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  color: var(--ink-950);
}

.statistics-tabs .statistics-tab.is-active:hover {
  filter: none;
  color: var(--ink-950);
}

.statistics-tabs .statistics-tab.is-active .recent-mode-mark {
  border-color: var(--lacquer);
  background: radial-gradient(circle, var(--lacquer) 0 40%, rgba(0, 0, 0, 0) 45%);
}

.statistics-tabs .statistics-tab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.statistics-kicker {
  margin: 0 0 0.35rem;
  color: var(--lacquer);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* --- Hoja del ranking --- */
.statistics-sheet {
  min-height: 24rem;
  padding: clamp(1.4rem, 3vw, 2.2rem) clamp(1.1rem, 3vw, 2.4rem) clamp(1.2rem, 2.5vw, 1.8rem);
  border: 1px solid rgba(90, 58, 34, 0.55);
  border-radius: 14px;
  background: var(--recent-parchment);
  box-shadow:
    0 34px 64px -28px rgba(0, 0, 0, 0.92),
    inset 0 0 90px rgba(90, 58, 34, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  color: var(--ink-950);
}

.statistics-loading {
  display: flex;
  min-height: 18rem;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  color: var(--ink-600);
  font-size: 0.82rem;
  font-weight: 700;
}

.statistics-loading span {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(90, 58, 34, 0.24);
  border-top-color: var(--lacquer);
  border-radius: 50%;
  animation: statistics-spin 0.8s linear infinite;
}

.statistics-sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.3rem 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid rgba(90, 58, 34, 0.35);
}

.statistics-sheet-head h2 {
  margin: 0;
  color: var(--ink-950);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.1;
}

.statistics-sheet-head time {
  color: var(--ink-600);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Registro compacto: tres columnas desde 1024 px, dos en tablet y una en móvil.
   Se lee por filas (1, 2 y 3 arriba); en móvil, del 1 al 21. */
.statistics-ledger {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 2.4rem;
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}

.statistics-leader-row {
  display: grid;
  grid-template-columns: 2rem 2.3rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  padding: 0.6rem 0;
  border-bottom: 1px dashed rgba(90, 58, 34, 0.3);
}

.statistics-ledger--plain .statistics-leader-row {
  grid-template-columns: 2rem 2.3rem minmax(0, 1fr);
}

.statistics-leader-rank {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  color: var(--lacquer);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1;
}

/* Medallas de oro, plata y bronce para los tres primeros. */
.statistics-leader-rank--1,
.statistics-leader-rank--2,
.statistics-leader-rank--3 {
  color: #22170c;
  box-shadow: 0 6px 12px -6px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.statistics-leader-rank--1 {
  border: 1px solid #8f6a1f;
  background: radial-gradient(circle at 35% 30%, #f6de8d, #c49a3a 72%);
}

.statistics-leader-rank--2 {
  border: 1px solid #77736a;
  background: radial-gradient(circle at 35% 30%, #f1efe9, #a8a49a 72%);
}

.statistics-leader-rank--3 {
  border: 1px solid #7a4a26;
  background: radial-gradient(circle at 35% 30%, #efc29a, #a8683a 72%);
}

.statistics-leader-portrait {
  display: block;
  width: 2.3rem;
}

.statistics-leader-portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 120 / 167;
  object-fit: fill;
  border-radius: 3px;
  box-shadow: 0 4px 8px -4px rgba(0, 0, 0, 0.6);
}

.statistics-leader-identity {
  display: grid;
  min-width: 0;
  gap: 0.15rem;
}

.statistics-leader-identity strong {
  color: var(--ink-950);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: break-word;
}

.statistics-leader-identity small {
  color: var(--ink-600);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.statistics-view-lists {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  padding: 0 0.1rem;
  border: 0;
  background: none;
  color: var(--wood-700);
  font: 700 0.85rem/1.2 var(--font-body);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
  cursor: pointer;
}

.statistics-view-lists:hover {
  color: var(--ink-950);
}

.statistics-view-lists:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--wood-700);
  outline-offset: 2px;
}

.statistics-view-lists[aria-disabled="true"] {
  opacity: 0.48;
  text-decoration: none;
  cursor: not-allowed;
}

.statistics-view-lists-short {
  display: none;
}

/* Vacío: la línea de rumbo de Partidas, sin tarjeta propia dentro de la hoja. */
.statistics-empty {
  display: grid;
  min-height: 17rem;
  align-content: center;
  justify-items: center;
  padding: 2rem 1rem;
  text-align: center;
}

.statistics-empty .statistics-empty-course {
  width: min(16rem, 70%);
  margin: 0 auto 1.4rem;
}

.statistics-empty .home-x {
  color: var(--lacquer);
}

.statistics-empty h3 {
  margin: 0 0 0.6rem;
  color: var(--ink-950);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.15;
  text-wrap: balance;
}

.statistics-empty p {
  max-width: 50ch;
  margin: 0 auto;
  color: var(--ink-600);
  font-size: 0.98rem;
  line-height: 1.65;
}

/* --- Página de listas de un líder --- */
/* Escritorio: el TOP 21 en una columna de pergamino. Hasta 900 px, la franja de
   latón de «Más jugados» de Últimas partidas, solo con las cartas. */
.statistics-lists-strip {
  display: none;
  margin-bottom: 1rem;
}

.statistics-lists-strip .recent-leader.is-unavailable {
  opacity: 0.45;
}

.statistics-lists-strip .recent-leader.is-unavailable:hover {
  border-color: transparent;
  background: none;
  transform: none;
}

.statistics-lists-layout {
  display: grid;
  grid-template-columns: minmax(15rem, 18.5rem) minmax(0, 1fr);
  align-items: start;
  gap: clamp(1rem, 2vw, 1.5rem);
}

.statistics-lists-layout--single {
  grid-template-columns: minmax(0, 1fr);
}

.statistics-lists-layout .statistics-sheet {
  min-height: 0;
}

.statistics-lists-leaders {
  padding: 1.1rem 1.1rem 0.6rem;
}

.statistics-lists-leaders .statistics-sheet-head {
  padding-bottom: 0.6rem;
}

.statistics-lists-leaders .statistics-sheet-head h2 {
  font-size: 1.15rem;
}

.statistics-ledger.statistics-lists-ledger {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 0.2rem;
}

.statistics-lists-ledger .statistics-leader-row {
  grid-template-columns: 2rem 2.3rem minmax(0, 1fr);
  padding-inline: 0.35rem;
  color: inherit;
  text-decoration: none;
}

.statistics-lists-ledger a.statistics-leader-row:hover strong {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.statistics-lists-ledger a.statistics-leader-row:focus-visible {
  border-radius: 6px;
  outline: 2px solid var(--wood-700);
  outline-offset: 2px;
}

.statistics-lists-ledger [aria-disabled="true"] {
  opacity: 0.48;
}

/* El líder que se ve va primero, resaltado y separado del resto. */
.statistics-lists-current {
  margin-bottom: 0.25rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid rgba(90, 58, 34, 0.35);
}

.statistics-lists-ledger [aria-current="page"] {
  border-bottom-color: transparent;
  border-radius: 6px;
  background: rgba(196, 154, 58, 0.16);
}

.statistics-lists-sheet {
  padding: clamp(1rem, 2.4vw, 1.8rem) clamp(0.75rem, 2.4vw, 2rem);
}

.statistics-lists-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.3rem 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid rgba(90, 58, 34, 0.35);
}

.statistics-lists-head h2 {
  margin: 0;
  color: var(--ink-950);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: break-word;
}

.statistics-lists-head h2 small {
  margin-left: 0.4rem;
  color: var(--ink-600);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.statistics-lists-head time {
  color: var(--ink-600);
  font-size: 0.85rem;
  font-weight: 600;
}

.statistics-lists {
  display: grid;
  gap: 1rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.statistics-lists-notes {
  margin: 1rem 0 0;
  color: var(--ink-600);
  font-size: 0.72rem;
  line-height: 1.45;
}

/* Cada lista decide su disposición por su propio ancho, no por la ventana:
   con la columna del TOP 21 el panel es más estrecho que la pantalla. */
.statistics-deck-entry {
  min-width: 0;
  container-type: inline-size;
}

.statistics-deck-frame {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(90, 58, 34, 0.35);
  border-radius: 6px;
  background: rgba(255, 250, 235, 0.5);
}

.statistics-group-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(90, 58, 34, 0.24);
  background: rgba(255, 252, 242, 0.72);
}

.statistics-group-stats > div {
  min-width: 0;
  padding: 0 0.8rem;
}

.statistics-group-stats > div + div {
  border-left: 1px solid rgba(90, 58, 34, 0.2);
}

.statistics-group-stats dt {
  color: var(--ink-600);
  font-size: 0.72rem;
  font-weight: 700;
}

.statistics-group-stats dd {
  margin: 0.25rem 0 0;
  color: var(--ink-950);
  font-size: 1.3rem;
  font-weight: 800;
}

.statistics-wr-value {
  white-space: nowrap;
}

.statistics-group-stats small {
  display: block;
  margin-top: 0.2rem;
  color: var(--ink-600);
  font-size: 0.68rem;
  font-weight: 500;
}

/* Compartir e importar, justo después de la franja de cifras. */
.statistics-deck-footer {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid rgba(90, 58, 34, 0.24);
  background: rgba(255, 252, 242, 0.72);
}

.statistics-deck-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.statistics-deck-actions .btn {
  display: inline-flex;
  min-height: 2.55rem;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  border-width: 1px;
  border-style: solid;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.statistics-deck-actions .btn svg {
  width: 1rem;
  height: 1rem;
  flex: none;
}

/* El secundario con la madera que usa Mazos sobre pergamino. */
.statistics-deck-actions .btn-ghost {
  border-color: rgba(90, 58, 34, 0.4);
  background: rgba(90, 58, 34, 0.1);
  color: var(--wood-700);
}

.statistics-deck-actions .btn-ghost:hover:not(:disabled) {
  border-color: var(--wood-700);
  background: rgba(90, 58, 34, 0.18);
  color: var(--ink-950);
}

.statistics-action-status {
  min-height: 1.3em;
  margin: 0;
  color: var(--ink-600);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.statistics-action-status:empty {
  display: none;
}

/* Estrecho: cuatro cartas por fila y sin nombre debajo (sale en el zoom). */
.statistics-deck-grid {
  min-height: 0;
  max-height: none;
  overflow: visible;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem 0.55rem;
  padding: 0.75rem 0.85rem 0.85rem 0.6rem;
  border: 0;
  border-radius: 0;
}

.statistics-deck-grid .deck-builder-card {
  width: 100%;
  height: auto;
}

.statistics-deck-grid .deck-builder-card-img {
  width: 100%;
  height: auto;
  aspect-ratio: 480 / 671;
}

.statistics-deck-grid .deck-builder-card-name {
  display: none;
}

.statistics-deck-grid .deck-card-zoom {
  right: 0.25rem;
  left: auto;
}

.statistics-deck-grid .deck-builder-card .deck-copy-badge {
  right: -0.25rem;
  bottom: -0.3rem;
}

@container (min-width: 34rem) {
  .statistics-group-stats {
    grid-template-columns: max-content repeat(2, minmax(0, 1fr));
  }

  .statistics-group-rate {
    display: grid;
    grid-template-columns: minmax(0, max-content) max-content;
    gap: 0.15rem 0.75rem;
    justify-content: start;
    align-content: center;
  }

  .statistics-group-rate dt {
    grid-column: 1;
    grid-row: 1;
  }

  .statistics-group-rate dd {
    display: contents;
  }

  .statistics-group-rate .statistics-wr-value {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    font-size: 1.75rem;
    line-height: 1;
  }

  .statistics-group-rate small {
    grid-column: 1;
    grid-row: 2;
    margin-top: 0;
  }

  .statistics-deck-footer {
    align-items: flex-end;
  }

  .statistics-deck-actions {
    display: flex;
  }

  /* Con sitio, las cartas del editor con su nombre. */
  .statistics-deck-grid {
    --deck-builder-card-w: 5rem;
    --deck-builder-card-h: 7rem;
    grid-template-columns: repeat(auto-fill, minmax(calc(var(--deck-builder-card-w) + 1.35rem), 1fr));
    gap: 0.9rem 0.7rem;
    padding: 0.8rem;
  }

  .statistics-deck-grid .deck-builder-card {
    width: calc(var(--deck-builder-card-w) + 1.35rem);
    height: calc(var(--deck-builder-card-h) + 2.35rem);
  }

  .statistics-deck-grid .deck-builder-card-img {
    width: var(--deck-builder-card-w);
    height: var(--deck-builder-card-h);
    aspect-ratio: auto;
  }

  .statistics-deck-grid .deck-builder-card-name {
    display: -webkit-box;
  }

  .statistics-deck-grid .deck-card-zoom {
    right: auto;
    left: calc(var(--deck-builder-card-w) - 1.65rem);
  }

  .statistics-deck-grid .deck-builder-card .deck-copy-badge {
    right: 1.1rem;
    bottom: 2.05rem;
  }
}

/* Ancho: los botones entran en la franja blanca, a la derecha de las cifras. */
@container (min-width: 46rem) {
  .statistics-deck-frame {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .statistics-group-stats {
    grid-column: 1;
    grid-row: 1;
    border-bottom: 0;
  }

  .statistics-deck-footer {
    grid-column: 2;
    grid-row: 1;
    max-width: 21rem;
    justify-content: center;
    border-bottom: 0;
  }

  .statistics-action-status {
    order: 1;
    min-height: 0;
    text-align: right;
  }

  .statistics-deck-grid {
    grid-column: 1 / -1;
    grid-row: 2;
    border-top: 1px solid rgba(90, 58, 34, 0.24);
  }
}

.statistics-card-visual {
  cursor: zoom-in;
}

.statistics-card-visual:disabled {
  cursor: default;
}

.statistics-card-preview {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  background: transparent;
}

.statistics-card-preview::backdrop {
  background: transparent;
}

@keyframes statistics-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 900px) {
  .statistics-lists-strip {
    display: block;
  }

  .statistics-lists-leaders {
    display: none;
  }

  .statistics-lists-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1023px) {
  .statistics-ledger {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 2rem;
  }
}

/* Como en Partidas, «Inicio» y «Mazos» suben junto al antetítulo. */
@media (max-width: 1080px) {
  .statistics-links {
    position: absolute;
    top: clamp(2rem, 4.5vw, 3.25rem);
    right: 0;
  }
}

/* En el móvil no caben junto al antetítulo en todos los idiomas: pasan a su
   propia fila, delante de las fichas, como «Inicio» en Configuración. */
@media (max-width: 700px) {
  .statistics-links {
    position: static;
    align-self: flex-start;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .statistics-ledger {
    grid-template-columns: minmax(0, 1fr);
  }

  .statistics-sheet-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }

  .statistics-sheet-head h2 {
    font-size: 1.3rem;
  }

  .statistics-leader-row {
    grid-template-columns: 1.9rem 2.2rem minmax(0, 1fr) auto;
    gap: 0.6rem;
  }

  .statistics-ledger--plain .statistics-leader-row {
    grid-template-columns: 1.9rem 2.2rem minmax(0, 1fr);
  }

  .statistics-leader-portrait {
    width: 2.2rem;
  }

  .statistics-view-lists {
    min-width: 2.75rem;
    justify-content: flex-end;
  }

  .statistics-view-lists-full {
    display: none;
  }

  .statistics-view-lists-short {
    display: inline;
  }

}

@media (prefers-reduced-motion: reduce) {
  .statistics-loading span {
    animation: none;
  }
}


/* --- Matriz de matchups --- */
/* Mapa de calor sobre el pergamino: el verde de ganador de Partidas
   (--recent-winner) si gana la fila y la laca si pierde, más intenso cuanto más
   se aleja del 50 % (MATCHUP_FULL_TINT). Solo desde la muestra normal; la
   pequeña va sin tinte y con asterisco. El tinte máximo deja el texto oscuro
   por encima de 4,5:1. En el móvil la columna fija se queda en retrato y
   código, y los nombres se leen en el detalle de la casilla tocada. */
.statistics-sheet {
  --matchups-good: 45 115 87;
  --matchups-bad: 166 58 46;
  --matchups-row-head: 12rem;
  --matchups-cell: 4.4rem;
  --matchups-sticky: #ede0c0;
}

.statistics-matchups-intro {
  max-width: 78ch;
  margin: 0.9rem 0 0;
  color: var(--ink-600);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* Leyenda */
.statistics-matchups-key {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.6rem;
  margin: 1.1rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 1px dashed rgba(90, 58, 34, 0.32);
  border-radius: 8px;
  list-style: none;
  color: var(--ink-600);
  font-size: 0.76rem;
  line-height: 1.4;
}

.statistics-matchups-key li {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.6rem;
}

.statistics-matchups-scale {
  display: grid;
  flex: 0 0 10rem;
  gap: 0.2rem;
}

.statistics-matchups-scale-bar {
  height: 0.6rem;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgb(var(--matchups-bad) / 0.66) 0%,
    rgb(var(--matchups-bad) / 0.06) 48%,
    rgb(var(--matchups-good) / 0.06) 52%,
    rgb(var(--matchups-good) / 0.66) 100%
  );
  box-shadow: inset 0 0 0 1px rgba(90, 58, 34, 0.2);
}

.statistics-matchups-scale-labels {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  color: var(--ink-950);
  font-size: 0.62rem;
  font-weight: 700;
  white-space: nowrap;
}

.statistics-matchups-swatch {
  display: inline-grid;
  flex: none;
  width: 2.2rem;
  height: 1.55rem;
  place-items: center;
  border: 1px dashed rgba(90, 58, 34, 0.3);
  border-radius: 5px;
  color: var(--ink-600);
  font-size: 0.72rem;
  font-weight: 800;
}

.statistics-matchups-swatch--small {
  border-style: solid;
  background: rgba(255, 250, 235, 0.55);
}

.statistics-matchups-swatch--mirror {
  border-style: solid;
  background: repeating-linear-gradient(135deg, rgba(90, 58, 34, 0.2) 0 2px, rgba(0, 0, 0, 0) 2px 7px);
}

.statistics-matchups-reading {
  max-width: 78ch;
  margin: 1.2rem 0 0;
  color: var(--ink-950);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.5;
}

/* Ejes: «Juega segundo» sobre las columnas, «Juega primero» en la esquina. */
.statistics-matchups-second,
.statistics-matchups-table .statistics-matchups-corner {
  color: var(--lacquer);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.statistics-matchups-second {
  margin: 0.9rem 0 0.35rem;
  padding-left: calc(var(--matchups-row-head) + 0.4rem);
}

/* Tabla. El marco es el contenedor de los nombres que el móvil oculta con
   position: absolute: sin él escapan del scroll y ensanchan la página. */
.statistics-matchups-scroll {
  position: relative;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid rgba(90, 58, 34, 0.28);
  border-radius: 10px;
  background: rgba(255, 250, 235, 0.32);
  scrollbar-color: rgba(90, 58, 34, 0.45) transparent;
}

.statistics-matchups-scroll:focus-visible {
  outline: 2px solid var(--wood-700);
  outline-offset: 3px;
}

.statistics-matchups-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.statistics-matchups-table th,
.statistics-matchups-table td {
  padding: 2px;
  font-weight: inherit;
}

.statistics-matchups-table thead th {
  padding-top: 0.6rem;
  padding-bottom: 0.45rem;
  vertical-align: bottom;
}

.statistics-matchups-table small {
  display: block;
  color: var(--ink-600);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

/* Columna fija: identidad de la fila al recorrer las columnas. */
.statistics-matchups-table .statistics-matchups-corner,
.statistics-matchups-row {
  position: sticky;
  left: 0;
  z-index: 1;
  width: var(--matchups-row-head);
  min-width: var(--matchups-row-head);
  max-width: var(--matchups-row-head);
  padding-right: 0.6rem;
  padding-left: 0.6rem;
  background: var(--matchups-sticky);
  box-shadow: 1px 0 0 rgba(90, 58, 34, 0.28);
  text-align: left;
}

.statistics-matchups-table .statistics-matchups-corner {
  z-index: 2;
  border-top-left-radius: 9px;
}

.statistics-matchups-table .statistics-matchups-column {
  min-width: var(--matchups-cell);
  vertical-align: top;
  text-align: center;
}

.statistics-matchups-column img,
.statistics-matchups-leader img {
  display: block;
  object-fit: cover;
  object-position: center 22%;
  border-radius: 6px;
  box-shadow: 0 4px 8px -4px rgba(0, 0, 0, 0.6);
}

.statistics-matchups-column img {
  width: 2.6rem;
  height: 2.6rem;
  margin: 0 auto 0.3rem;
}

.statistics-matchups-column .statistics-matchups-name {
  display: -webkit-box;
  overflow: hidden;
  max-width: 5.6rem;
  margin: 0 auto 0.1rem;
  color: var(--ink-950);
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.statistics-matchups-leader {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.statistics-matchups-leader img {
  width: 2.4rem;
  height: 2.4rem;
  flex: none;
}

.statistics-matchups-leader-text {
  display: grid;
  min-width: 0;
  gap: 0.1rem;
}

.statistics-matchups-leader strong {
  color: var(--ink-950);
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.statistics-matchups-plays {
  font-weight: 500;
  letter-spacing: 0;
}

/* Casillas */
.statistics-matchup-cell {
  min-width: var(--matchups-cell);
}

.statistics-matchups-tile {
  display: flex;
  width: 100%;
  margin: 0;
  min-height: 3.3rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.2rem;
  border: 1px solid rgba(90, 58, 34, 0.14);
  border-radius: 6px;
  background-color: rgba(255, 250, 235, 0.55);
  color: var(--ink-950);
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.statistics-matchups-tile:focus-visible {
  outline: 2px solid var(--ink-950);
  outline-offset: 2px;
}

.statistics-matchup-replays {
  scroll-margin-top: 6rem;
}

.statistics-matchup-replays[hidden],
.statistics-matchup-replays [hidden] {
  display: none;
}

.statistics-matchup-replays-note,
.statistics-matchup-replays [role="status"] {
  color: var(--parchment-100);
}

.statistics-matchup-replays-actions {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.statistics-matchups-rate {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.statistics-matchups-tile small {
  margin-top: 0.1rem;
  font-weight: 600;
}

.statistics-matchups-favorable .statistics-matchups-tile,
.statistics-matchups-unfavorable .statistics-matchups-tile {
  border-color: rgba(21, 14, 8, 0.08);
}

.statistics-matchups-favorable .statistics-matchups-tile {
  background-color: rgb(var(--matchups-good) / calc(0.06 + 0.6 * var(--matchup-strength)));
}

.statistics-matchups-unfavorable .statistics-matchups-tile {
  background-color: rgb(var(--matchups-bad) / calc(0.06 + 0.6 * var(--matchup-strength)));
}

.statistics-matchups-strong .statistics-matchups-tile small {
  color: var(--ink-900);
}

.statistics-matchups-small .statistics-matchups-tile {
  color: var(--ink-600);
}

/* El asterisco no descentra el porcentaje. */
.statistics-matchups-value {
  position: relative;
}

.statistics-matchup-cell abbr {
  position: absolute;
  top: -0.15rem;
  left: 100%;
  margin-left: 0.05rem;
  color: #885400;
  font-size: 0.85rem;
  font-weight: 800;
  text-decoration: none;
}

.statistics-matchups-insufficient .statistics-matchups-tile {
  border-style: dashed;
  background-color: transparent;
  color: var(--ink-600);
}

/* Espejo: la diagonal rayada sobre su tinte. */
.statistics-matchups-mirror .statistics-matchups-tile {
  background-image: repeating-linear-gradient(135deg, rgba(90, 58, 34, 0.16) 0 2px, rgba(0, 0, 0, 0) 2px 7px);
}

/* Casilla señalada y sus ejes; el resaltado se fija al tocarla. */
.statistics-matchups.is-interactive .statistics-matchup-cell {
  cursor: pointer;
}

.statistics-matchup-cell.is-active .statistics-matchups-tile {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--ink-950), 0 6px 14px -8px rgba(0, 0, 0, 0.7);
}

.statistics-matchups-column.is-axis img,
.statistics-matchups-row.is-axis img {
  box-shadow: 0 0 0 2px var(--lacquer), 0 4px 8px -4px rgba(0, 0, 0, 0.6);
}

.statistics-matchups-row.is-axis {
  box-shadow: inset 3px 0 0 var(--lacquer), 1px 0 0 rgba(90, 58, 34, 0.28);
}

/* Móvil: retrato y código en la columna fija; los nombres siguen disponibles
   para lectores de pantalla. */
@media (max-width: 640px) {
  .statistics-sheet {
    --matchups-row-head: 3.6rem;
    --matchups-cell: 3.3rem;
  }

  .statistics-matchups-key {
    display: grid;
    gap: 0.6rem;
  }

  .statistics-matchups-key .statistics-matchups-key-scale {
    flex-direction: column;
    align-items: stretch;
  }

  .statistics-matchups-scale {
    flex-basis: auto;
    max-width: 16rem;
  }

  .statistics-matchups-second {
    padding-left: calc(var(--matchups-row-head) + 0.2rem);
  }

  .statistics-matchups-table .statistics-matchups-corner,
  .statistics-matchups-row {
    padding-right: 0.3rem;
    padding-left: 0.3rem;
    text-align: center;
  }

  .statistics-matchups-table .statistics-matchups-corner {
    font-size: 0.56rem;
    letter-spacing: 0.04em;
  }

  .statistics-matchups-leader {
    display: grid;
    justify-items: center;
    gap: 0.2rem;
  }

  .statistics-matchups-leader img,
  .statistics-matchups-column img {
    width: 2.25rem;
    height: 2.25rem;
  }

  .statistics-matchups-name,
  .statistics-matchups-column .statistics-matchups-name,
  .statistics-matchups-plays {
    position: absolute;
    overflow: hidden;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .statistics-matchups-table small {
    font-size: 0.52rem;
    letter-spacing: 0;
  }

  .statistics-matchups-tile {
    min-height: 2.9rem;
    padding: 0.25rem 0.1rem;
  }

  .statistics-matchups-rate {
    font-size: 0.9rem;
  }
}
