/* Eye-strip cut-in -> poster slam -> held portrait -> whip to the next player -> squad line-up.
   All movement is finite transform/opacity. Fields remain opaque through the handoff; scene
   visibility bounds painting to the current cut. Speed lines are one static texture per shot
   that jumps between three angles; lite mode drops them. No animated filters or masks. */
.cast-intro {
  --ink: #1a0d2b; --night: #120a1f; --lime: #d8ff36; --paper: #fff9ee;
  position: fixed; inset: 0; z-index: 9100; overflow: hidden; isolation: isolate; background: var(--night); color: var(--paper); cursor: pointer; outline: none;
  font-family: "Bangers", "Bricolage Grotesque", "Figtree", sans-serif; user-select: none; -webkit-tap-highlight-color: transparent;
  animation: cast-out var(--out) ease-in calc(var(--end) - var(--out) - var(--elapsed)) forwards;
}
.cast-intro *, .cast-intro *::before, .cast-intro *::after { box-sizing: border-box; }
@keyframes cast-out { to { opacity: 0; } }
.cast-backdrop { position: absolute; inset: 0; background: linear-gradient(112deg, #2b1941 0 36%, var(--night) 36%); }

/* Opaque fields overlap for exactly the wipe, never exposing a blank frame. Hidden stations
   cannot paint or retain oversized moving layers while another player is introduced. */
.cast-station {
  --at: calc(var(--open) + var(--i) * var(--beat) - var(--elapsed));
  position: absolute; inset: 0; visibility: hidden; pointer-events: none; contain: layout paint;
  animation: cast-show 1ms steps(1, start) var(--at) forwards,
    cast-hide 1ms steps(1, start) calc(var(--at) + var(--beat) + var(--wipe)) forwards;
}
/* Separate one-shot gates avoid recalculating a visibility animation throughout every hold. */
@keyframes cast-show { to { visibility: visible; } }
@keyframes cast-hide { to { visibility: hidden; } }
.cast-band-group { position: absolute; inset: 0; overflow: hidden;
  animation: cast-field-in var(--wipe) cubic-bezier(.16,.8,.25,1) var(--at) both; }
@keyframes cast-field-in { from { transform: translateX(105%); } to { transform: none; } }
.cast-band { position: absolute; inset: 0; background: var(--band); }
.cast-band-slash { position: absolute; inset: 0; background: var(--c); clip-path: polygon(18% 0, 44% 0, 25% 100%, 0 100%); opacity: .8; }
.cast-band-group::after { content: ""; position: absolute; inset: 0; background: var(--paper); clip-path: polygon(44% 0, 45% 0, 26% 100%, 25% 100%); opacity: .7; }
.cast-halftone { position: absolute; right: -2%; top: 0; width: 31%; height: 100%; transform: skewX(-12deg);
  background: radial-gradient(circle, #ffffff55 1px, transparent 1.5px) 0 0 / 10px 10px; opacity: .3; }
.cast-index { position: absolute; right: 3vw; bottom: 4vh; font-size: clamp(130px, 46vmin, 460px); line-height: .85; letter-spacing: -.03em; color: #ffffff12; transform: rotate(-6deg); }

/* Radial speed lines: uneven wedges that leave the middle clear for the face and name. The
   texture is painted once; it jumps between three angles (about 12 per second) for a counted
   number of steps, so nothing loops forever. It bursts bright at the slam, then rests faint. */
.cast-speed { position: absolute; left: 50%; top: 50%; width: 160vmax; height: 160vmax; margin: -80vmax 0 0 -80vmax; pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(from 0deg, transparent 0 2.2deg, var(--paper) 2.2deg 2.9deg, transparent 2.9deg 6deg, var(--paper) 6deg 6.3deg, transparent 6.3deg 9.4deg, var(--paper) 9.4deg 10.4deg, transparent 10.4deg 13deg);
  -webkit-mask-image: radial-gradient(closest-side, transparent 0 30%, #000 58%); mask-image: radial-gradient(closest-side, transparent 0 30%, #000 58%);
  animation: cast-speed-step 240ms step-end calc(var(--at) + var(--slam)) var(--speed-n),
    cast-speed-pop var(--speed-ms) ease-out calc(var(--at) + var(--slam)) forwards; }
@keyframes cast-speed-step { 0% { transform: none; } 33.3% { transform: rotate(4.6deg); } 66.6% { transform: rotate(-3.4deg); } }
@keyframes cast-speed-pop { from { opacity: .75; } to { opacity: var(--speed-rest, .17); } }

/* A 70 ms paper flash on the cut: one flash per shot, well under three flashes a second. */
.cast-flash { position: absolute; inset: 0; background: var(--paper); pointer-events: none;
  animation: cast-flash var(--flash-ms) steps(2, end) var(--at) both; }
@keyframes cast-flash { from { opacity: .8; } to { opacity: 0; visibility: hidden; } }

/* The close-up. A tilted ink strip snaps open, the face runs in fast, drifts for a moment,
   then the strip leaves sideways as the poster lands. Pairs and trios stack one strip each. */
.cast-strips { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 2.4vh; transform: rotate(-7deg); pointer-events: none; }
.cast-station.is-group-1 { --strip-h: min(30vh, 48vw); }
.cast-station.is-group-2 { --strip-h: min(23vh, 40vw); }
.cast-station.is-group-3 { --strip-h: min(17vh, 34vw); }
.cast-strip { position: relative; flex: none; height: var(--strip-h); width: 140%; margin-left: -20%; overflow: hidden; background: var(--ink);
  border-top: max(4px, .9vmin) solid var(--paper); border-bottom: max(4px, .9vmin) solid var(--c);
  animation: cast-strip-in var(--strip-ms) cubic-bezier(.2,.9,.3,1.25) calc(var(--at) + var(--strip-at) + var(--j) * 40ms) both,
    cast-strip-out var(--strip-out) ease-in calc(var(--at) + var(--slam)) forwards; }
@keyframes cast-strip-in { from { transform: scaleY(0); } to { transform: none; } }
@keyframes cast-strip-out { to { transform: translateX(calc(var(--dir) * -115%)); visibility: hidden; } }
/* Finite streaks in the player's colour and paper; they run against the face's travel. */
.cast-strip-lines { position: absolute; inset: 0 -40%; opacity: .9;
  background:
    linear-gradient(90deg, transparent, var(--c) 35%, var(--c) 65%, transparent) 0 10% / 34% 7% repeat-x,
    linear-gradient(90deg, transparent, var(--paper) 50%, transparent) 18% 27% / 47% 2.5% repeat-x,
    linear-gradient(90deg, transparent, var(--c) 50%, transparent) 9% 46% / 26% 4% repeat-x,
    linear-gradient(90deg, transparent, var(--paper) 50%, transparent) 30% 66% / 39% 3% repeat-x,
    linear-gradient(90deg, transparent, var(--c) 35%, var(--c) 65%, transparent) 14% 86% / 43% 8% repeat-x;
  animation: cast-lines var(--run-ms) linear calc(var(--at) + var(--strip-at)) both; }
@keyframes cast-lines { from { transform: translateX(calc(var(--dir) * -14%)); } to { transform: translateX(calc(var(--dir) * 14%)); } }
.cast-strip-face { --face: calc(var(--strip-h) * 1.9); position: absolute; left: 50%; top: 50%; width: var(--face); height: var(--face);
  margin: calc(var(--face) * -.56) 0 0 calc(var(--face) * -.5);
  animation: cast-face-run var(--run-ms) linear calc(var(--at) + var(--strip-at)) both; }
.cast-strip-face .cast-avatar { transform: rotate(7deg); }
@keyframes cast-face-run {
  0% { transform: translateX(calc(var(--dir) * 190%)); animation-timing-function: cubic-bezier(.1,.8,.2,1); }
  42% { transform: translateX(calc(var(--dir) * 7%)); animation-timing-function: linear; }
  100% { transform: translateX(calc(var(--dir) * -7%)); }
}

/* The poster slams in at --slam and is still by --push-at; only then does the slow push-in
   start, on the wrapper, so each portrait and plate keeps an identity transform for the hold. */
.cast-cards { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 3.5vmin; padding: 8vh 6vw;
  animation: cast-push var(--push-ms) linear calc(var(--at) + var(--push-at)) forwards,
    cast-cards-out var(--wipe) ease-in calc(var(--at) + var(--beat)) forwards; }
@keyframes cast-push { to { transform: scale(1.035); } }
@keyframes cast-cards-out { to { opacity: 0; transform: translateX(-38%) skewX(-12deg); } }
.cast-card { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; max-width: 100%; }
.cast-station.is-group-1 { --size: min(62vw, 43vh, 420px); --name: clamp(44px, 16vmin, 112px); --plate-max: min(82vw, 660px); }
.cast-station.is-group-2 { --size: min(37vw, 31vh, 310px); --name: clamp(23px, 6.4vmin, 72px); --plate-max: 40vw; }
.cast-station.is-group-3 { --size: min(25vw, 26vh, 240px); --name: clamp(19px, 4.6vmin, 52px); --plate-max: 27vw; }
.cast-avatar-wrap { position: relative; width: var(--size); aspect-ratio: 1; flex: none; transform-origin: 50% 70%;
  animation: cast-avatar-in var(--portrait-ms) cubic-bezier(.2,.8,.2,1) calc(var(--at) + var(--slam)) both; }
.cast-avatar-wrap::before { content: ""; position: absolute; inset: 9% -2% -2% 4%; background: var(--paper); transform: rotate(-8deg);
  clip-path: polygon(8% 8%, 90% 0, 100% 86%, 0 100%); }
@keyframes cast-avatar-in { 0% { opacity: 0; transform: scale(1.75) rotate(-9deg); } 35% { opacity: 1; } 68% { transform: scale(.95) rotate(1.5deg); } 100% { opacity: 1; transform: none; } }
.cast-avatar, .cast-avatar > svg { position: relative; display: block; width: 100%; height: 100%; }
.cast-intro .cast-avatar > svg { filter: none; }
/* Freeze the pose's own accessory loops too (halo, steam, etc.). */
.cast-intro .cast-avatar, .cast-intro .cast-avatar * { animation: none !important; transition: none !important; }
.cast-plate { position: relative; z-index: 1; margin-top: -2vmin; max-width: var(--plate-max);
  animation: cast-plate-in var(--plate-ms) cubic-bezier(.2,.8,.2,1) calc(var(--at) + var(--plate-at)) both; }
@keyframes cast-plate-in { 0% { opacity: 0; transform: scale(1.6) rotate(5deg); } 40% { opacity: 1; } 72% { transform: scale(.96) rotate(-1deg); } 100% { opacity: 1; transform: none; } }
.cast-plate-body { display: flex; flex-direction: column; align-items: flex-start; gap: .9vmin; padding: 1.5vmin 2.2vmin 1.6vmin;
  transform: rotate(-4deg); background: var(--ink); border-left: max(4px,.7vmin) solid var(--paper); box-shadow: .8vmin .8vmin 0 var(--c); max-width: 100%; }
/* Cut-out lettering: every character sits on its own tilted block of paper, colour or ink. */
.cast-name { display: block; font: 400 var(--name)/1.14 "Bangers", "Bricolage Grotesque", sans-serif; letter-spacing: 0; color: var(--ink); max-width: 100%; }
.cast-name.is-long { font-size: calc(var(--name) * .62); }
.cast-ch { display: inline-block; min-width: .55em; padding: 0 .1em .02em; margin: .03em .015em; text-align: center; background: var(--paper); color: var(--ink); transform: rotate(-3deg); }
.cast-ch:nth-child(3n+2) { background: var(--c); transform: rotate(2.5deg) translateY(.04em); }
.cast-ch:nth-child(4n+3) { background: var(--ink); color: var(--paper); box-shadow: inset 0 0 0 .045em var(--paper); transform: rotate(-1deg) scale(1.06); }
.cast-look { max-width: 100%; font: 800 clamp(10px, 2vmin, 19px)/1.3 "Figtree", sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--paper); opacity: .8; overflow-wrap: anywhere; }
.cast-tags { display: flex; gap: .7vmin; flex-wrap: wrap; }
.cast-tags span { font: 900 clamp(9px, 1.5vmin, 14px)/1 "Figtree", sans-serif; letter-spacing: .1em; text-transform: uppercase; padding: .4em .6em; background: var(--paper); color: var(--ink); }
.cast-tags span.is-you { background: var(--lime); }
@media (min-aspect-ratio: 5/4) {
  .cast-station.is-group-1 { --size: min(39vw, 58vh, 480px); --plate-max: 43vw; --name: clamp(40px, 10vmin, 112px); }
  .cast-station.is-group-1 .cast-card { flex-direction: row; gap: 3vmin; }
  .cast-station.is-group-1 .cast-plate { margin: 7vmin 0 0 -3vmin; }
}
/* Three phone portraits get their own rows instead of tiny faces and truncated names. */
@media (max-aspect-ratio: 5/4) {
  .cast-station.is-group-3 { --size: min(25vw, 18vh); --plate-max: 53vw; --name: clamp(24px, 7vmin, 44px); }
  .cast-station.is-group-3 .cast-cards { flex-direction: column; gap: 3vh; }
  .cast-station.is-group-3 .cast-card { flex-direction: row; gap: 3vw; width: 100%; justify-content: center; }
  .cast-station.is-group-3 .cast-plate { margin: 0; flex: 1; }
}

.cast-open { --at: calc(0ms - var(--elapsed)); --slam: 0ms; --speed-rest: .3; position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  animation: cast-open-out var(--wipe) ease-in calc(var(--open) - var(--elapsed)) forwards; }
@keyframes cast-open-out { to { opacity: 0; transform: translateX(-12%); visibility: hidden; } }
.cast-open-slash { position: absolute; inset: 0; background: var(--lime); clip-path: polygon(0 37%, 100% 28%, 100% 63%, 0 72%);
  animation: cast-title-slash .16s ease-out calc(0ms - var(--elapsed)) both; transform-origin: 0 50%; }
@keyframes cast-title-slash { from { transform: scaleX(0); } to { transform: none; } }
.cast-open-title { position: relative; display: flex; flex-direction: column; align-items: center; transform: rotate(-4deg);
  animation: cast-title-in .24s cubic-bezier(.2,.8,.2,1) calc(0ms - var(--elapsed)) both; }
@keyframes cast-title-in { 0% { opacity: 0; transform: rotate(-4deg) scale(2); } 40% { opacity: 1; } 70% { transform: rotate(-4deg) scale(.95); } 100% { opacity: 1; transform: rotate(-4deg); } }
.cast-open-title span { font-size: clamp(26px, 7vmin, 84px); line-height: .9; letter-spacing: .06em; color: var(--paper); padding: .1em .3em; background: var(--ink); }
.cast-open-title strong { font-weight: 400; font-size: clamp(66px, 20vmin, 230px); line-height: 1; letter-spacing: .02em; color: var(--ink); text-shadow: .04em .04em 0 var(--paper); }
.cast-bug { position: absolute; top: max(18px, env(safe-area-inset-top)); left: max(20px, env(safe-area-inset-left)); pointer-events: none;
  font: 800 clamp(11px, 1.8vmin, 18px)/1 "Figtree", sans-serif; text-transform: uppercase; letter-spacing: .18em; color: var(--paper);
  visibility: hidden; animation: cast-show 1ms steps(1,start) calc(var(--open) - var(--elapsed)) forwards,
    cast-hide 1ms steps(1,start) calc(var(--finale-at) - var(--elapsed)) forwards; }

/* Finale: every player's colour crosses the screen as a blade (0 to 250 ms), then the whole
   squad lands with names. All portraits are still within 540 ms, regardless of room size. */
.cast-finale { --at: calc(var(--finale-at) - var(--elapsed)); --slam: var(--lineup); --speed-rest: .22; position: absolute; inset: 0; pointer-events: none; visibility: hidden;
  animation: cast-finale-life 1ms steps(1,end) var(--at) forwards; }
@keyframes cast-finale-life { to { visibility: visible; } }
.cast-finale-band { position: absolute; inset: 0; overflow: hidden; background: var(--night);
  animation: cast-field-in var(--wipe) cubic-bezier(.16,.8,.25,1) var(--at) both; }
.cast-finale-band::after { content: ""; position: absolute; inset: 0; background: var(--lime); clip-path: polygon(0 43%, 100% 34%, 100% 78%, 0 87%); }
.cast-blades { position: absolute; inset: -22%; display: flex; flex-direction: column; transform: rotate(-7deg); }
.cast-blade { flex: 1; margin-bottom: -1px; background: var(--c);
  animation: cast-blade-in var(--blade-ms) cubic-bezier(.2,.8,.2,1) calc(var(--at) + var(--j) * var(--blade-stagger)) both,
    cast-blade-out var(--blade-ms) ease-in calc(var(--at) + var(--blades-out)) forwards; }
@keyframes cast-blade-in { from { transform: translateX(calc(var(--dir) * 105%)); } to { transform: none; } }
@keyframes cast-blade-out { to { transform: translateX(calc(var(--dir) * -105%)); visibility: hidden; } }
.cast-finale-title { position: absolute; left: 4%; right: 4%; top: 18%; text-align: center; font-size: clamp(54px, 15vmin, 180px); line-height: 1; letter-spacing: .03em;
  color: var(--paper); text-shadow: .04em .04em 0 var(--ink); transform: rotate(-4deg);
  animation: cast-title-in var(--finale-title-ms) cubic-bezier(.2,.8,.2,1) calc(var(--at) + var(--lineup)) both; }
.cast-finale-row { position: absolute; left: 50%; top: 61%; transform: translate(-50%,-50%); display: grid; grid-template-columns: repeat(var(--cols),minmax(0,1fr)); gap: 3vmin 2vmin;
  width: min(92vw, calc(var(--cols) * 150px)); }
.cast-finale-slot { min-width: 0;
  animation: cast-slot-in var(--slot-ms) cubic-bezier(.2,.8,.2,1) calc(var(--at) + var(--lineup) + var(--j) * var(--stagger)) both; }
.cast-finale-slot .cast-avatar { height: auto; aspect-ratio: 1; }
@keyframes cast-slot-in { 0% { opacity: 0; transform: translateY(45%) scale(.55); } 45% { opacity: 1; } 72% { transform: translateY(-4%) scale(1.06); } 100% { opacity: 1; transform: none; } }
.cast-finale-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; padding: .25em .25em 0; border-bottom: .25em solid var(--ink); text-align: center; font: 800 clamp(11px,3.3vmin,19px)/1.15 "Figtree",sans-serif; color: var(--paper); background: var(--ink); overflow-wrap: anywhere; }
@media (min-aspect-ratio: 5/4) { .cast-finale-row { grid-template-columns: repeat(var(--n),minmax(0,1fr)); width: min(92vw, calc(var(--n) * 170px)); } }
.cast-skip { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); right: max(20px, env(safe-area-inset-right)); font: 700 11px/1 "Figtree", sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--paper); opacity: .7; }

.perf-lite .cast-halftone, .perf-lite .cast-speed, .perf-lite .cast-strip-lines { display: none; }
.perf-lite .cast-finale-title, .perf-lite .cast-open-title strong { text-shadow: none; }
.cast-intro.is-reduced, .cast-intro.is-reduced * { animation: none !important; }
.cast-intro.is-reduced .cast-finale { visibility: visible; }
