/* ========================================
   LeakFinder – Poker Card Mini-Cards
   Visual card rendering for leak examples
   ======================================== */

/* ── Meta pills (compact tournament info) ── */
.lf-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 9999px;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--brm8-text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}
.lf-meta-pill--link {
  color: var(--brm8-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease-out;
}
.lf-meta-pill--link:hover {
  background: color-mix(in srgb, var(--brm8-primary) 12%, transparent);
  border-color: color-mix(in srgb, var(--brm8-primary) 30%, transparent);
}

/* ── Source range link – prominent rectangle button ── */
.lf-source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--brm8-primary);
  background: color-mix(in srgb, var(--brm8-primary) 10%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--brm8-primary) 25%, transparent);
  transition: all 0.15s ease-out;
  white-space: nowrap;
}

.lf-source-link:hover {
  background: color-mix(in srgb, var(--brm8-primary) 18%, transparent);
  border-color: color-mix(in srgb, var(--brm8-primary) 40%, transparent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--brm8-primary) 15%, transparent);
}

.lf-source-link:focus-visible {
  outline: 2px solid var(--brm8-primary, #8aebff);
  outline-offset: 2px;
}

.lf-source-link .material-symbols-outlined {
  font-size: 16px;
}

/* ── File input: selected state ── */
.lf-file-selected .rp-field {
  border-color: var(--brm8-primary);
}

/* The field's own icon only: the Analyser button sits in the same wrapper and
   its icon went cyan on cyan once a file was chosen. */
.lf-file-selected [data-file-input-target="icon"] {
  color: var(--brm8-primary);
  opacity: 1;
}

.lf-file-selected [data-filename] {
  color: var(--brm8-text-main);
  font-weight: 600;
}

/* ── Donut chart ── */
.lf-donut-segment {
  transition: opacity 0.15s ease-out, filter 0.15s ease-out;
}

.lf-donut-segment:hover {
  opacity: 0.85;
  filter: brightness(1.15);
}

.lf-legend-row {
  text-decoration: none;
}

.lf-legend-row:hover {
  background: color-mix(in srgb, var(--rb-surface, #1e293b) 80%, var(--brm8-primary, #8aebff));
}

/* ────────────────────────────────────────────────────────────
   HAND REPLAYER
   ──────────────────────────────────────────────────────────── */

/* ── Replay launch button – prominent rectangle matching source link ── */
.lf-replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.10);
  border: 1.5px solid rgba(251, 191, 36, 0.25);
  cursor: pointer;
  white-space: nowrap;
}
.lf-replay-btn:hover {
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.40);
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.15);
}

.lf-replay-btn:focus-visible {
  outline: 2px solid var(--replayer-gold);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   HAND REPLAYER – the stage
   A full-viewport dialog: a heading, the scene (table, seats, board), then
   the caption, the progress bar and the controls. Everything inside the scene
   is sized in --u, a fraction of the scene's width (container query units),
   so the table, the cards and the numbers grow and shrink together.

   Flat on purpose: solid surfaces, rings instead of glows, one neutral shadow
   under the table. Only transform and opacity ever animate. Every colour and
   both typefaces are named once, in the block below.

   Markup: app/views/leak_analyses/_hand_replayer.html.erb.
   Behaviour: app/javascript/controllers/hand_replayer_controller.js.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --replayer-font: "Inter", ui-sans-serif, system-ui, sans-serif;
  --replayer-font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;

  --replayer-night: #070d1a;         /* the stage */
  --replayer-plate: #0d1830;         /* seat plates, buttons, panels */
  --replayer-plate-hover: #1c2a4a;
  --replayer-rail: #1d2a45;          /* the table's rim */
  --replayer-felt: #0f3d52;
  --replayer-ink: #f4f7ff;           /* text */
  --replayer-ink-soft: #c5d0e6;      /* secondary text */
  --replayer-primary: var(--brm8-primary, #8aebff);
  --replayer-on-primary: #03131d;
  --replayer-gold: #ffd166;          /* stacks, pot, bets, the winner */
  --replayer-on-gold: #1c1400;
  --replayer-chip-edge: #a8720c;
  --replayer-dealer: #e8eefb;

  /* What a player did, as text on the plate colour (each 4.5:1 or better) */
  --replayer-fold: #9aa6bd;
  --replayer-call: #2fe0c6;
  --replayer-raise: #ff8a5c;
  --replayer-allin: #c3adff;
  --replayer-ko: #ff7a9c;

  /* Four-colour deck, light text on each */
  --replayer-spade: #33415a;
  --replayer-heart: #b3261e;
  --replayer-diamond: #104f9e;
  --replayer-club: #14652f;
  --replayer-card-back: #1a2b4d;

  /* The same suits as text on the stage, in captions and the history */
  --replayer-spade-text: #dfe7f5;
  --replayer-heart-text: #ff9a9a;
  --replayer-diamond-text: #8cc4ff;
  --replayer-club-text: #86e3a4;
}

/* Custom display values beat Tailwind's .hidden, and [hidden] loses to them too. */
[class*="replayer"].hidden,
[class*="replayer"][hidden] { display: none !important; }

.replayer {
  --rp-rate: 1;
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: clip;
  color: var(--replayer-ink);
  font-family: var(--replayer-font);
  background: var(--replayer-night);
  scrollbar-color: var(--replayer-ink-soft) transparent;
  caret-color: var(--replayer-primary);
}
.replayer ::selection { background: var(--replayer-primary); color: var(--replayer-on-primary); }

/* ── Background: RangerPro's 13 × 13 range matrix as the floor the table
   stands on. Flat tints of the action colours, fading out before the edges
   so the heading and the controls sit on the plain stage colour. ── */
.replayer-matrix {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 66% 56% at 50% 46%, black 30%, transparent 82%);
  mask-image: radial-gradient(ellipse 66% 56% at 50% 46%, black 30%, transparent 82%);
}
.replayer-matrix rect { fill: color-mix(in srgb, var(--replayer-ink-soft) 7%, transparent); }
.replayer-matrix .is-call { fill: color-mix(in srgb, var(--rb-call) 16%, transparent); }
.replayer-matrix .is-raise { fill: color-mix(in srgb, var(--rb-raise) 17%, transparent); }
.replayer-matrix .is-3bet { fill: color-mix(in srgb, var(--rb-3bet) 18%, transparent); }
.replayer-matrix .is-allin { fill: color-mix(in srgb, var(--rb-allin) 24%, transparent); }

/* ── Controls ── */
.replayer-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--replayer-ink-soft) 45%, transparent);
  background: var(--replayer-plate);
  color: var(--replayer-ink);
  font: 700 14px/1 var(--replayer-font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.1s ease-out;
  -webkit-tap-highlight-color: transparent;
}
.replayer-btn svg { width: 24px; height: 24px; flex: none; }
.replayer-btn:hover { background: var(--replayer-plate-hover); border-color: var(--replayer-primary); }
.replayer-btn:active { transform: scale(0.94); }
.replayer-btn:focus-visible,
.replayer-link:focus-visible {
  outline: 3px solid var(--replayer-primary);
  outline-offset: 2px;
}
.replayer-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.replayer-btn:disabled:hover { background: var(--replayer-plate); border-color: color-mix(in srgb, var(--replayer-ink-soft) 45%, transparent); }
.replayer-btn:disabled:active { transform: none; }
.replayer-btn[aria-expanded="true"] { border-color: var(--replayer-primary); background: var(--replayer-plate-hover); }
.replayer-btn--play {
  min-width: 64px;
  height: 56px;
  border-radius: 16px;
  border-color: var(--replayer-primary);
  background: var(--replayer-primary);
  color: var(--replayer-on-primary);
}
.replayer-btn--play svg { width: 32px; height: 32px; }
.replayer-btn--play:hover { background: var(--replayer-ink); border-color: var(--replayer-ink); }
.replayer-btn--play:focus-visible { outline-color: var(--replayer-ink); }
.replayer-btn--play[data-state="playing"] .replayer-icon-play,
.replayer-btn--play:not([data-state="playing"]) .replayer-icon-pause { display: none; }
.replayer-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--replayer-primary);
  background: var(--replayer-plate);
  color: var(--replayer-primary);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
}
.replayer-link:hover { background: var(--replayer-plate-hover); }
.replayer-link:active { transform: scale(0.97); }

/* ── Heading: the hand's facts, kept apart by hairlines ── */
.replayer-facts { display: flex; margin: 0; padding: 0; list-style: none; }
.replayer-facts li { flex: none; padding: 0 12px; border-left: 1px solid color-mix(in srgb, var(--replayer-ink-soft) 40%, transparent); white-space: nowrap; }
.replayer-facts li:first-child { padding-left: 0; border-left: 0; }
/* The tournament's name is the one that gives when the line is too long */
.replayer-facts li[data-fact="tournament"] { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ── Stage and scene ── */
.replayer-stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}
/* The controller picks the orientation and sets --rp-aspect, between the two
   shapes each layout was drawn for: 16:9 to 2:1 lying down, 9:16 to 10:16
   standing up. A seat's plate is 15 --u wide either way. */
.replayer-scene {
  position: relative;
  flex: none;
  container-type: inline-size;
  aspect-ratio: var(--rp-aspect, 2);
  width: min(100cqw, 100cqh * var(--rp-aspect, 2));
  --u: 1cqw;
}
.replayer-scene[data-orient="portrait"] { --u: 2.3cqw; }
.replayer-scene[data-orient="portrait"][data-crowded="true"] { --u: 1.95cqw; }

/* ── Table: a flat rim with one line of light, flat felt, a betting line ── */
.replayer-table {
  position: absolute;
  left: 11%;
  right: 11%;
  top: 16%;
  bottom: 22%;
  border-radius: 9999px;
  padding: calc(var(--u) * 1.4);
  background: var(--replayer-rail);
  box-shadow: 0 calc(var(--u) * 2) calc(var(--u) * 4) color-mix(in srgb, var(--replayer-night) 80%, transparent);
}
.replayer-scene[data-orient="portrait"] .replayer-table { left: 9%; right: 9%; top: 12%; bottom: 17.5%; }
.replayer-felt {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  background: var(--replayer-felt);
  border: calc(var(--u) * 0.18) solid var(--replayer-primary);
}
.replayer-felt::before {
  content: "";
  position: absolute;
  inset: calc(var(--u) * 5.5);
  border-radius: 9999px;
  border: 1px solid color-mix(in srgb, var(--replayer-ink-soft) 22%, transparent);
}
/* One flash of the rim when a player moves all in or is knocked out: a solid
   ring whose opacity the controller animates */
.replayer-flash {
  position: absolute;
  inset: calc(var(--u) * -0.5);
  border-radius: 9999px;
  border: calc(var(--u) * 0.7) solid var(--rp-flash, var(--replayer-allin));
  opacity: 0;
  pointer-events: none;
}

/* ── Centre: board, pot ── */
.replayer-board {
  position: absolute;
  left: 50%;
  top: 41.6%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: calc(var(--u) * 0.8);
  z-index: 2;
}
.replayer-scene[data-orient="portrait"] .replayer-board { top: 42.7%; }
.replayer-scene[data-orient="portrait"][data-crowded="true"] .replayer-board { top: 50%; }
.replayer-pot {
  position: absolute;
  left: 50%;
  top: 54.8%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 2;
  display: inline-flex;
  align-items: baseline;
  gap: calc(var(--u) * 0.7);
  white-space: nowrap;
  font-family: var(--replayer-font-display);
  font-weight: 700;
  color: var(--replayer-gold);
}
.replayer-scene[data-orient="portrait"] .replayer-pot { top: 51.4%; }
.replayer-scene[data-orient="portrait"][data-crowded="true"] .replayer-pot { top: 58%; }
.replayer-pot__label { font-size: max(13px, calc(var(--u) * 1.7)); color: var(--replayer-ink); }
.replayer-pot__value { font-size: max(19px, calc(var(--u) * 3)); font-variant-numeric: tabular-nums; }

/* ── Cards: four colours, each with its suit drawn, never colour alone ── */
.replayer-card {
  --cw: calc(var(--u) * 4.6);
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  border-radius: calc(var(--cw) * 0.13);
  border: 1px solid color-mix(in srgb, var(--replayer-ink) 45%, transparent);
  color: var(--replayer-ink);
  box-shadow: 0 calc(var(--cw) * 0.06) calc(var(--cw) * 0.16) color-mix(in srgb, var(--replayer-night) 70%, transparent);
  transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}
.replayer-card__rank {
  font: 700 calc(var(--cw) * 0.62)/0.95 var(--replayer-font-display);
  font-variant-numeric: tabular-nums;
}
.replayer-card__suit { width: calc(var(--cw) * 0.44); height: calc(var(--cw) * 0.44); fill: currentColor; }
.replayer-card--s { background: var(--replayer-spade); color: var(--replayer-ink); }
.replayer-card--h { background: var(--replayer-heart); color: var(--replayer-ink); }
.replayer-card--d { background: var(--replayer-diamond); color: var(--replayer-ink); }
.replayer-card--c { background: var(--replayer-club); color: var(--replayer-ink); }
.replayer-card.is-back { background: var(--replayer-card-back); color: var(--replayer-ink); border-color: var(--replayer-primary); }
.replayer-card.is-back::after {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: calc(var(--cw) * 0.07);
  border: 1px solid color-mix(in srgb, var(--replayer-primary) 60%, transparent);
}
.replayer-card.is-slot {
  border: 1px dashed color-mix(in srgb, var(--replayer-ink-soft) 30%, transparent);
  background: transparent;
  box-shadow: none;
}
/* Dimmed, not hidden: a losing card keeps 4.5:1 between its rank and its face */
.replayer-card.is-dim { opacity: 0.75; }
.replayer-card.is-best {
  transform: translateY(calc(var(--cw) * -0.1));
  outline: calc(var(--cw) * 0.045) solid var(--replayer-gold);
  outline-offset: 0;
}
.replayer-board .replayer-card { --cw: calc(var(--u) * 6); }
.replayer-scene[data-crowded="true"] .replayer-board .replayer-card { --cw: calc(var(--u) * 4.5); }
.replayer-seat--hero .replayer-card { --cw: calc(var(--u) * 5.6); }
/* Other players' cards show their top part above the plate: rank and suit
   are set at the top so both stay in view */
.replayer-seat:not(.replayer-seat--hero) .replayer-card { justify-content: flex-start; padding-top: calc(var(--cw) * 0.06); }
.replayer-seat:not(.replayer-seat--hero) .replayer-card__rank { font-size: calc(var(--cw) * 0.5); }
.replayer-seat:not(.replayer-seat--hero) .replayer-card__suit { width: calc(var(--cw) * 0.34); height: calc(var(--cw) * 0.34); }

/* ── Seats: cards, then the plate (position, name, stack), then the last action ── */
.replayer-seat {
  position: absolute;
  z-index: 4;
  width: calc(var(--u) * 15);
  height: calc(var(--u) * 5.2);
  transform: translate(-50%, -50%);
}
.replayer-scene[data-crowded="true"] .replayer-seat { width: calc(var(--u) * 12.2); }
.replayer-seat__cards {
  position: absolute;
  left: 50%;
  bottom: calc(100% - var(--u) * 2.44);
  transform: translateX(-50%);
  display: flex;
  gap: calc(var(--u) * 0.4);
  transition: opacity 0.3s ease-out;
}
.replayer-seat__plate {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: calc(var(--u) * 0.6);
  padding: calc(var(--u) * 0.5) calc(var(--u) * 0.9);
  border-radius: calc(var(--u) * 1.1);
  border: 1px solid color-mix(in srgb, var(--replayer-ink-soft) 40%, transparent);
  background: var(--replayer-plate);
  box-shadow: 0 calc(var(--u) * 0.5) calc(var(--u) * 1.2) color-mix(in srgb, var(--replayer-night) 70%, transparent);
  transition: opacity 0.3s ease-out;
}
.replayer-seat__pos {
  grid-row: 1;
  grid-column: 1;
  padding: calc(var(--u) * 0.1) calc(var(--u) * 0.5);
  border-radius: calc(var(--u) * 0.4);
  background: color-mix(in srgb, var(--replayer-ink-soft) 22%, var(--replayer-plate));
  color: var(--replayer-ink);
  font-size: max(11px, calc(var(--u) * 1.05));
  font-weight: 800;
  line-height: 1.3;
}
.replayer-seat__name {
  grid-row: 1;
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--replayer-ink);
  font-size: max(12px, calc(var(--u) * 1.3));
  font-weight: 600;
  line-height: 1.3;
}
.replayer-seat__stack {
  grid-row: 2;
  grid-column: 1 / 3;
  min-width: 0;
  color: var(--replayer-gold);
  font: 700 max(16px, calc(var(--u) * 2.3))/1.15 var(--replayer-font-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform-origin: left center;
}
.replayer-seat__you { font-weight: 800; color: var(--replayer-primary); }
.replayer-seat__bounty {
  position: absolute;
  z-index: 2;
  right: calc(var(--u) * -0.7);
  top: calc(var(--u) * -1.9);
  display: inline-flex;
  align-items: center;
  gap: calc(var(--u) * 0.3);
  padding: calc(var(--u) * 0.1) calc(var(--u) * 0.5);
  border-radius: 9999px;
  border: 1px solid var(--replayer-ko);
  background: var(--replayer-plate);
  color: var(--replayer-ko);
  font-size: max(11px, calc(var(--u) * 1.05));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.replayer-scene[data-crowded="true"] .replayer-seat__bounty { right: 0; }
.replayer-seat__bounty svg { width: max(10px, calc(var(--u) * 1.1)); height: max(10px, calc(var(--u) * 1.1)); fill: none; stroke: currentColor; stroke-width: 2.4; }
.replayer-seat__action {
  position: absolute;
  left: 50%;
  top: calc(100% + var(--u) * 0.35);
  transform: translateX(-50%);
  padding: calc(var(--u) * 0.2) calc(var(--u) * 0.8);
  border-radius: calc(var(--u) * 0.6);
  border: 1px solid currentColor;
  background: var(--replayer-night);
  color: var(--replayer-ink);
  font-size: max(12px, calc(var(--u) * 1.3));
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
}
.replayer-seat__action:empty { display: none; }
.replayer-seat__action[data-tone="fold"] { color: var(--replayer-fold); }
.replayer-seat__action[data-tone="call"] { color: var(--replayer-call); }
.replayer-seat__action[data-tone="raise"] { color: var(--replayer-raise); }
.replayer-seat__action[data-tone="allin"] { color: var(--replayer-allin); }
.replayer-seat__action[data-tone="win"] { color: var(--replayer-on-gold); background: var(--replayer-gold); border-color: var(--replayer-gold); }
/* "Two pair, wins 16.5 BB" is longer than a plate: beside the table it may
   take two lines, under the hero there is the room for one */
.replayer-seat:not(.replayer-seat--hero) .replayer-seat__action[data-tone="win"] {
  width: max-content;
  max-width: calc(var(--u) * 16);
  white-space: normal;
  text-align: center;
  text-wrap: balance;
}
.replayer-seat__action[data-tone="ko"] { color: var(--replayer-ko); }

.replayer-seat--hero .replayer-seat__cards { bottom: calc(100% - var(--u) * 1); }
.replayer-seat--hero .replayer-seat__plate { border-color: var(--replayer-primary); }
.replayer-seat--hero .replayer-seat__pos { background: var(--replayer-primary); color: var(--replayer-on-primary); }
.replayer-seat--acting .replayer-seat__plate { outline: calc(var(--u) * 0.28) solid var(--replayer-ink); outline-offset: 0; }
/* The player to act is also marked by a pointer, for those who cannot tell a ring's colour */
.replayer-seat--acting .replayer-seat__plate::before {
  content: "";
  position: absolute;
  left: calc(var(--u) * -1.7);
  top: 50%;
  border: calc(var(--u) * 0.65) solid transparent;
  border-left-color: var(--replayer-ink);
  transform: translateY(-50%);
}
.replayer-seat--folded .replayer-seat__plate { opacity: 0.6; }
.replayer-seat--folded .replayer-seat__cards { opacity: 0; }
.replayer-seat--winner .replayer-seat__plate { outline: calc(var(--u) * 0.32) solid var(--replayer-gold); outline-offset: 0; }
.replayer-seat--busted .replayer-seat__plate { opacity: 0.6; border-color: var(--replayer-ko); }
.replayer-seat__ko {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 76%;
  transform: translate(-50%, -50%) rotate(-9deg);
  padding: 0 calc(var(--u) * 1.1);
  border: calc(var(--u) * 0.32) solid var(--replayer-ko);
  border-radius: calc(var(--u) * 0.7);
  background: var(--replayer-night);
  color: var(--replayer-ko);
  font: 700 max(20px, calc(var(--u) * 3.3))/1.1 var(--replayer-font-display);
}

/* ── The short table (a phone held sideways): no room for two lines in a
   plate, so the name goes (it stays in the caption and the history) and the
   pot moves to the corner, off the middle of the table ── */
.replayer-scene[data-short="true"] .replayer-table { top: 18%; bottom: 24%; }
.replayer-scene[data-short="true"] .replayer-board { top: 46.75%; }
.replayer-scene[data-short="true"] .replayer-pot { left: 0.5%; top: 2%; transform: none; flex-direction: column; align-items: flex-start; gap: 0; }
.replayer-scene[data-short="true"] .replayer-seat { height: calc(var(--u) * 3.8); }
.replayer-scene[data-short="true"] .replayer-seat__plate { grid-template-rows: auto; }
.replayer-scene[data-short="true"] .replayer-seat__name { display: none; }
.replayer-scene[data-short="true"] .replayer-seat__stack { grid-row: 1; grid-column: 2; }
.replayer-scene[data-short="true"] .replayer-seat__bounty { display: none; }
.replayer-scene[data-short="true"] .replayer-seat__action { font-size: max(11px, calc(var(--u) * 1.3)); }

/* ── Bets in front of the seats, dealer button ── */
.replayer-bet {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: calc(var(--u) * 0.5);
  padding: calc(var(--u) * 0.2) calc(var(--u) * 0.8) calc(var(--u) * 0.2) calc(var(--u) * 0.3);
  border-radius: 9999px;
  background: var(--replayer-night);
  color: var(--replayer-gold);
  font: 700 max(14px, calc(var(--u) * 1.9))/1.2 var(--replayer-font-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.replayer-chip {
  flex: none;
  width: max(13px, calc(var(--u) * 1.7));
  height: max(13px, calc(var(--u) * 1.7));
  border-radius: 50%;
  border: max(2px, calc(var(--u) * 0.3)) dashed var(--replayer-on-gold);
  background: var(--replayer-gold);
  outline: 1px solid var(--replayer-chip-edge);
}
.replayer-dealer {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: max(20px, calc(var(--u) * 2.5));
  height: max(20px, calc(var(--u) * 2.5));
  border-radius: 50%;
  background: var(--replayer-dealer);
  color: var(--replayer-night);
  font: 800 max(11px, calc(var(--u) * 1.3))/1 var(--replayer-font);
}

/* ── Effects layer: chips and cards in flight, rings ── */
.replayer-fx { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.replayer-fx > * { position: absolute; margin: 0; }
.replayer-ring {
  border-radius: 9999px;
  border: calc(var(--u) * 0.4) solid var(--rp-flash, var(--replayer-allin));
  opacity: 0;
}

/* ── Loading, error ── */
.replayer-status {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--replayer-ink);
  background: var(--replayer-night);
}
.replayer-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--replayer-primary) 25%, transparent);
  border-top-color: var(--replayer-primary);
  animation: replayer-spin 0.8s linear infinite;
}
@keyframes replayer-spin { to { transform: rotate(360deg); } }

/* ── Panels: history, shortcuts ── */
.replayer-panel {
  position: absolute;
  z-index: 9;
  top: 8px;
  right: 8px;
  bottom: 8px;
  width: min(360px, calc(100% - 16px));
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--replayer-primary);
  background: var(--replayer-plate);
  color: var(--replayer-ink);
}
.replayer-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--replayer-ink-soft) 30%, transparent);
}
.replayer-panel__title { margin: 0; font: 700 16px/1.3 var(--replayer-font-display); color: var(--replayer-ink); }
.replayer-panel__body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }
.replayer-log { list-style: none; margin: 0; padding: 0; }
.replayer-log__street { margin: 12px 8px 4px; font-size: 13px; font-weight: 800; color: var(--replayer-primary); }
.replayer-log__step {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--replayer-ink-soft);
  font: 500 14px/1.4 var(--replayer-font);
  text-align: left;
  cursor: pointer;
}
.replayer-log__step:hover { background: var(--replayer-plate-hover); color: var(--replayer-ink); }
.replayer-log__step:active { transform: scale(0.99); }
.replayer-log__step:focus-visible { outline: 3px solid var(--replayer-primary); outline-offset: -3px; }
.replayer-log__step[aria-current="step"] { background: var(--replayer-plate-hover); color: var(--replayer-ink); font-weight: 700; }
.replayer-keys { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; align-items: center; padding: 8px; }
.replayer-keys dt { display: flex; gap: 4px; }
.replayer-keys dd { margin: 0; font-size: 14px; color: var(--replayer-ink-soft); }
.replayer-kbd {
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--replayer-ink-soft);
  border-bottom-width: 2px;
  background: var(--replayer-night);
  color: var(--replayer-ink);
  font: 700 13px/1.3 var(--replayer-font);
  text-align: center;
}

/* ── Caption (what just happened), card names inside text ── */
.replayer-caption {
  margin: 0;
  min-height: 2lh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(15px, 1.7vw, 22px);
  font-weight: 700;
  line-height: 1.35;
  color: var(--replayer-ink);
  text-wrap: balance;
}
@media (min-width: 1024px) {
  .replayer-caption { min-height: 1lh; }
}
.replayer-cardref { font-weight: 800; white-space: nowrap; }
.replayer-cardref--s { color: var(--replayer-spade-text); }
.replayer-cardref--h { color: var(--replayer-heart-text); }
.replayer-cardref--d { color: var(--replayer-diamond-text); }
.replayer-cardref--c { color: var(--replayer-club-text); }
.replayer-cardref svg { display: inline-block; width: 0.85em; height: 0.85em; margin-left: 1px; vertical-align: -0.08em; fill: currentColor; }

/* ── Progress: one segment per step, grouped by street. The slider inside is
   the control; the segments are its track. ── */
.replayer-progress { position: relative; display: flex; gap: 8px; border-radius: 8px; cursor: pointer; }
.replayer-progress:has(.replayer-scrub:focus-visible) { outline: 3px solid var(--replayer-primary); outline-offset: 4px; }
.replayer-scrub { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.replayer-count { align-self: flex-end; font-size: 14px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--replayer-ink); white-space: nowrap; }
.replayer-seg-group { display: flex; flex-direction: column; gap: 4px; min-width: max-content; }
.replayer-seg-group__label { font-size: 12px; font-weight: 700; line-height: 1.3; color: var(--replayer-ink-soft); white-space: nowrap; }
.replayer-seg-group.is-current .replayer-seg-group__label { color: var(--replayer-ink); }
.replayer-seg-row { display: flex; gap: 4px; }
.replayer-seg { flex: 1 1 0; min-width: 6px; padding: 4px 0; }
.replayer-seg::before {
  content: "";
  display: block;
  height: 6px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--replayer-ink-soft) 48%, transparent);
  transition: transform 0.15s ease-out;
}
.replayer-seg.is-done::before { background: var(--replayer-primary); }
.replayer-seg.is-current::before { background: var(--replayer-ink); transform: scaleY(1.7); }
.replayer-seg:hover::before { background: var(--replayer-ink); }

/* ── Phones and short windows: tighter chrome, the scene keeps the room ── */
@media (max-width: 639px) {
  .replayer-btn { min-width: 40px; padding: 0 8px; }
  .replayer-btn--play { min-width: 56px; height: 52px; }
  /* The leak card behind has the same link; the tournament's name and level give way to the table */
  .replayer-link { display: none; }
  .replayer-facts li[data-fact="tournament"],
  .replayer-facts li[data-fact="level"] { display: none; }
  .replayer-facts li[data-fact="blinds"] { padding-left: 0; border-left: 0; }
}
/* No keyboard to list shortcuts for */
@media (hover: none) {
  .replayer-btn--keys { display: none; }
}
@media (max-height: 520px) {
  .replayer-btn { height: 36px; }
  .replayer-btn--play { height: 36px; min-width: 52px; }
  .replayer-caption { font-size: 14px; min-height: 1lh; }
  .replayer-seg-group__label { display: none; }
  .replayer-count { align-self: center; }
  /* The table needs every pixel of height: the close button moves over the
     stage's corner, the heading stays for screen readers only, and the
     explanation and the hand's facts are on the leak card behind */
  .replayer-head { position: absolute; top: 0; right: 0; left: auto; padding: 8px; }
  .replayer-head__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .replayer-link { display: none; }
}

/* ── Reduced motion: the state still changes, nothing moves. The controller
   skips its own animations on the same media query. ── */
@media (prefers-reduced-motion: reduce) {
  .replayer *,
  .replayer *::before,
  .replayer *::after {
    animation: none !important;
    transition: none !important;
  }
  .replayer-card.is-best { transform: none; }
  .replayer-btn:active,
  .replayer-link:active,
  .replayer-log__step:active { transform: none; }
  .replayer-spinner { border-top-color: color-mix(in srgb, var(--replayer-primary) 25%, transparent); border-right-color: var(--replayer-primary); }
}
