/* Ultra Beam Blasters — game screen glue on top of the Face-Off kit.
   Colors and sizes come from theme.css tokens and assets/ui/kit.css recipes (Artist-owned).
   Only layout glue lives here: setup screen, hand overlap, overlays, HUD drawers. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--arena-3);
  color: var(--hud-ink);
  font: var(--fw-body) var(--fs-md) / 1.35 var(--font-body);
  -webkit-text-size-adjust: 100%;
}
/* Tablet feel (#203): no double-tap zoom, no long-press select or callout, no tap flash, no rubber-band.
   Text inputs (seed, room code) stay selectable. */
html, body { touch-action: manipulation; overscroll-behavior: none; }
body, #game {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
img { -webkit-user-drag: none; }
input, textarea, select, [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
[hidden] { display: none !important; }
.error { color: var(--bad); font-weight: var(--fw-bold); }
.hint { font-size: var(--fs-sm); color: var(--hud-soft); }

/* ---------- Start screen ---------- */
.setup {
  min-height: 100dvh; padding: 28px 32px 40px;
  background: linear-gradient(var(--arena-2), var(--arena-3));
}
.setup__title { margin: 0 0 18px; font: var(--fw-display) var(--fs-xl) / 1.1 var(--font-display); }
.setup__title small { font: var(--fw-body) var(--fs-sm) var(--font-body); color: var(--hud-soft); }
.setup h2 { margin: 0 0 12px; }
.hero-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; margin-bottom: 22px; }
.hero-choice {
  -webkit-appearance: none; appearance: none; font: inherit; color: inherit; cursor: pointer;
  display: grid; justify-items: center; gap: 10px; padding: 26px 8px 14px;
  border: 0; border-radius: var(--radius-lg);
  background: var(--hud); box-shadow: inset 0 0 0 2px var(--hud-line);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.hero-choice .ui-medal { --size: 96px; margin-bottom: 10px; }
/* CLS (#207): the hero row fills in from JS; keep the Play row out until it has, so nothing below shifts. */
.hero-choices:empty ~ p { display: none; }
.hero-choice b { font: var(--fw-display) var(--fs-md) / 1.1 var(--font-display); }
.hero-choice small { color: var(--hud-soft); font-size: var(--fs-xs); text-align: center; }
.hero-choice.chosen { box-shadow: inset 0 0 0 3px var(--spark), var(--glow-gold); }
.setup__row { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-bottom: 14px; }
.field { display: inline-flex; align-items: center; gap: 8px; }
.setup select, .setup input[type="text"], .setup input[type="number"], .drawer input[type="number"] {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 2px solid var(--edge); border-radius: var(--radius-sm); padding: 4px 8px; min-height: 36px;
}
.setup__debug { margin: 8px 0 18px; color: var(--hud-soft); }
.setup__debug summary { cursor: pointer; }

/* ---------- Arena glue ---------- */
#game { position: relative; height: 100dvh; overflow: hidden; }
[data-act], [data-sel] { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.ui-at-you-boosts, .ui-at-foe-boosts { display: grid; gap: 8px; align-content: start; }
.ui-at-foe-boosts { justify-items: end; }
.ui-at-turn { position: relative; z-index: 2; } /* over the beam glare */
.boost-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ui-at-foe-boosts .boost-chips { justify-content: flex-end; }
.tools-btns { display: flex; gap: 10px; margin-top: 6px; }
.ui-at-tools .ui-chip { white-space: normal; height: auto; min-height: 32px; padding-block: 6px; line-height: 1.15; }

/* Rival hand in the plate: backs, plus face-up cards the rival took from the Wilds */
.rival-hand { display: flex; align-items: center; margin-right: auto; }
.rival-hand > * + * { margin-left: -20px; }
.rival-hand .uc, .rival-hand .ui-card-back { --w: 34px; }
.rival-hand .uc { box-shadow: 0 0 0 2px var(--edge); }

/* Hand: cards overlap more as the hand grows (--ov set per hand size) */
/* Design G cards (.uc, web/assets/frames/card.css) in the kit's slots: the same sizes, fan and states .ui-card had */
.ui-hand > .uc { --w: var(--hand-w, 180px); margin: 0 calc(var(--hand-w, 180px) * var(--ov, -0.025)); }
.ui-hand > .uc:first-child:not(:last-child) { --r: -6deg; --lift: 0.6em; }
.ui-hand > .uc:last-child:not(:first-child)  { --r: 6deg;  --lift: 0.6em; }
.ui-hand > .uc.is-selected:nth-child(n) { --r: 0deg; --lift: -0.9em; }
.ui-hand > .uc.has-preview { overflow: visible; } /* the live push pill may poke past the corner */
.ui-table .uc { --w: var(--small-w, 96px); }
.ui-table__last .uc { --r: 7deg; }
.uc { -webkit-tap-highlight-color: transparent; }
.uc.is-legal { box-shadow: 0 0 0 var(--card-keyline) var(--edge), 0 0 0 0.3em var(--spark), var(--card-drop); animation: ui-legal 1.4s var(--ease-out) infinite; }
.uc.is-dim { filter: saturate(0.35) brightness(0.7); }
.uc-win { margin-left: 0.2em; padding: 0 0.35em; border-radius: 0.5em; background: var(--good); color: var(--surface); font: var(--fw-display) 0.8em / 1.5 var(--font-display); }
.ui-hand-wrap > .ui-math { min-height: 38px; }
.ui-math .win-tag { margin-left: 4px; padding: 0 8px; border-radius: 10px; background: var(--good); color: var(--surface); font-size: 16px; line-height: 26px; }
.hand-empty { color: var(--hud-soft); padding-bottom: 40px; }

/* Wilds / Last move placeholders */
.slot-empty {
  width: var(--small-w, 96px); height: calc(var(--small-w, 96px) * 1.4); border-radius: 10px;
  outline: 2px dashed var(--hud-line); outline-offset: -2px;
}
.ui-card-back.is-legal { box-shadow: 0 0 0 3px var(--edge), 0 0 0 0.3em var(--spark), var(--glow-gold); }
.deck-count { font: var(--fw-display) var(--fs-sm) / 1 var(--font-display); color: var(--hud-soft); justify-self: center; }

/* Action buttons: Boost / Pass / Later sit in one column with Blast / Super */
.ui-action .ui-icon + span:empty { display: none; }

/* ---------- Choose-a-card overlay ---------- */
.picker { z-index: 30; padding: 24px; }
.picker__box {
  display: grid; justify-items: center; gap: 22px; max-width: 96vw;
  padding: 26px 30px 30px; border-radius: var(--radius-lg);
  background: var(--hud); box-shadow: inset 0 0 0 2px var(--hud-line), var(--shadow-lg);
}
.picker__cards { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 22px; }
.picker__cards .uc { --w: clamp(130px, 17vw, 200px); }
.picker__aside { display: grid; justify-items: center; gap: 8px; padding-left: 22px; border-left: 2px dashed var(--hud-line); }
.picker__aside .uc { --w: clamp(100px, 12vw, 150px); }
.picker__new { font-size: 26px; color: var(--spark); }

/* ---------- Table layout v2 (?layout=v2; Silas #292 msg #516, mockups A/B/C msg #486) ----------
   1 the battle (both heroes + the beam) in the middle, biggest; a subtle tick ruler under the beam.
   2 your hand, clearly smaller, at the bottom.  3 the Wilds + deck, smaller again, in a slim top tray.
   4 everything else small in the corners: names, turn, Boosts, menu, log, Blast/Boost.
   Placement only: the parts are the same as v1. When Silas picks, adjust here and make it the default. */
.ui-arena[data-layout="v2"] {
  /* side columns hold the medallions: the medallion never grows past its column (it would be clipped) */
  --medal: clamp(140px, min(20cqw, 40cqh), 340px);
  --hand-w: clamp(100px, max(11cqw, 16cqh), 186px);
  --small-w: clamp(50px, 5.2cqw, 74px);
  --track-w: calc(56cqw - 72px);
  grid-template-columns: minmax(0, 22cqw) minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 22cqw);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "you-plate  you-plate table foe-plate foe-plate"
    "you-hero   beam      beam  beam      foe-hero"
    "you-boosts .         .     .         foe-boosts"
    "tools      hand      hand  hand      actions";
  gap: 6px 16px; padding: 12px 20px;
}
.ui-arena[data-layout="v2"] .ui-at-you-plate { justify-self: start; max-width: 100%; }
.ui-arena[data-layout="v2"] .ui-at-foe-plate { justify-self: end; max-width: 100%; }
.ui-arena[data-layout="v2"] .ui-at-table { align-self: start; justify-self: center; }
.ui-arena[data-layout="v2"] .ui-at-you-plate, .ui-arena[data-layout="v2"] .ui-at-foe-plate { align-self: start; min-width: min(100%, 300px); }
.ui-arena[data-layout="v2"] .ui-table { gap: 8px; padding: 6px 10px; border-radius: var(--radius-lg); background: var(--hud); box-shadow: inset 0 0 0 2px var(--hud-line); }
.ui-arena[data-layout="v2"] .ui-at-you-hero, .ui-arena[data-layout="v2"] .ui-at-foe-hero { padding: 0; }
.ui-arena[data-layout="v2"] .ui-at-beam { align-self: center; position: relative; }
.ui-arena[data-layout="v2"] .ui-beam { width: var(--track-w); height: 92px; margin: 0 auto; }
.ui-arena[data-layout="v2"] .ui-beam__cells { display: none; } /* the ruler under the beam carries the spaces */
.ui-arena[data-layout="v2"] .bt { position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); --tick-h: clamp(12px, 1.5cqw, 20px); }
.ui-arena[data-layout="v2"] .ui-at-turn { position: absolute; left: 50%; top: calc(12px + var(--small-w) * 1.4 + 28px); transform: translateX(-50%); grid-area: auto; }
.ui-arena[data-layout="v2"] .ui-at-hand { align-self: end; }
.ui-arena[data-layout="v2"] .ui-action { --size: clamp(84px, 14cqh, 112px); }
.ui-arena[data-layout="v2"] .ui-at-actions { gap: 10px; }

/* ---------- Table layout variants A/B/C (?layout=a|b|c; #292 msg #583) ----------
   The v2 base above plus one mockup placement each (scratchpad ref A/B/C-ticks). Placement only: same parts.
   A Center Stage: standing heroes at the edges, beam + ruler across the middle, slim tray top, hand bottom.
   B Battle Bridge: round medallions, long ruler under both, Wilds tray beside the hand, Boost/Blast bottom left.
   C All Battle: the biggest standing heroes, short ruler under the clash, hand peeking up, tiny tray top.
   The beam (web/beam/beam.js) runs between the hero cell centers and its clash follows .ui-beam, so the
   .ui-beam box is always as wide as the ruler (--track-w): the token on the ruler sits under the clash. */

/* A + C: the hero stands. The Home cut-out art (the Good Game heroes use it too) replaces the painted
   square, no disc, no rim; an element glow instead of the ring. No evolved cut-outs yet: an evolved
   hero keeps the round medallion. */
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) {
  --medal: calc(var(--hero-w) * 0.74); /* evolved fallback medallion */
}
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal:not(:has(> img[src*="-evolved"])) {
  --size: var(--hero-w);
  width: var(--hero-w); height: var(--hero-h); border-radius: 0;
  background: none; box-shadow: none; animation: none;
  filter: drop-shadow(0 0 calc(var(--hero-w) * 0.05) var(--m));
}
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal.is-active:not(:has(> img[src*="-evolved"])) {
  filter: drop-shadow(0 0 3px var(--edge)) drop-shadow(0 0 calc(var(--hero-w) * 0.08) var(--m));
}
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal.is-shielded:not(:has(> img[src*="-evolved"])) {
  filter: drop-shadow(0 0 4px var(--hud-ink)) drop-shadow(0 0 calc(var(--hero-w) * 0.07) var(--m));
}
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal.is-frozen:not(:has(> img[src*="-evolved"]))::before {
  inset: 18% 8% 0; border-radius: 50%; opacity: 0.6; box-shadow: none;
}
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal > img:not([src*="-evolved"]) {
  border-radius: 0; object-fit: contain; object-position: 50% 100%;
}
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal__badge { top: 4%; width: calc(var(--hero-w) * 0.17); font-size: calc(var(--hero-w) * 0.1); }
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal[data-el="fire"] > img:not([src*="-evolved"])     { content: url("assets/ui/home-hero-fire.webp"); }
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal[data-el="ice"] > img:not([src*="-evolved"])      { content: url("assets/ui/home-hero-ice.webp"); }
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal[data-el="leaf"] > img:not([src*="-evolved"])     { content: url("assets/ui/home-hero-leaf.webp"); }
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal[data-el="electric"] > img:not([src*="-evolved"]) { content: url("assets/ui/home-hero-electric.webp"); }
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal[data-el="water"] > img:not([src*="-evolved"])    { content: url("assets/ui/home-hero-water.webp"); }
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal[data-el="rock"] > img:not([src*="-evolved"])     { content: url("assets/ui/home-hero-rock.webp"); }
/* ruler as wide as the beam's clash range; the .ui-beam box overhangs its cell evenly */
.ui-arena[data-layout="v2"][data-variant] .ui-beam { margin: 0 calc((100% - var(--track-w)) / 2); }
/* the turn chip under your name plate (top left) */
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-at-turn {
  left: 20px; top: calc(12px + 66px + 8px); transform: none; justify-items: start; z-index: 3;
}
/* Boost / Blast side by side */
.ui-arena[data-layout="v2"][data-variant] .ui-at-actions { grid-auto-flow: column; align-items: end; justify-content: end; }

/* A · Center Stage */
.ui-arena[data-layout="v2"][data-variant="a"] {
  --hero-w: clamp(150px, min(25cqw, 46cqh), 400px);
  --hero-h: calc(var(--hero-w) * 1.08);
  --small-w: clamp(44px, 4.4cqw, 64px);
  --track-w: calc(100cqw - 40px - var(--hero-w) * 1.6);
  grid-template-columns: minmax(0, var(--hero-w)) minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, var(--hero-w));
}
.ui-arena[data-layout="v2"][data-variant="a"] .ui-action { --size: clamp(72px, 12cqh, 100px); }

/* B · Battle Bridge */
.ui-arena[data-layout="v2"][data-variant="b"] {
  --medal: clamp(140px, min(20cqw, 40cqh), 330px);
  --hand-w: clamp(96px, max(10cqw, 15cqh), 172px);
  --small-w: clamp(44px, 4.6cqw, 66px);
  --act: clamp(72px, 12cqh, 100px);
  --tray-w: calc(var(--small-w) * 5 + 60px);
  --track-w: calc(100cqw - 40px - 23cqw); /* medallion center to medallion center */
  grid-template-columns: minmax(0, 23cqw) minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 23cqw);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "you-plate you-plate turn   foe-plate foe-plate"
    "you-hero  beam      beam   beam      foe-hero"
    "bottom    bottom    bottom bottom    bottom";
}
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-you-plate { margin-left: 64px; max-width: calc(100% - 64px); }
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-turn { top: 12px; }
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-tools {
  position: absolute; left: 20px; top: 19px; z-index: 3;
  flex-direction: column-reverse; justify-content: flex-start;
}
.ui-arena[data-layout="v2"][data-variant="b"] .tools-btns { margin-top: 0; }
/* Boosts tuck under the medallion rim */
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-you-boosts { grid-area: you-hero; }
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-foe-boosts { grid-area: foe-hero; }
.ui-arena[data-layout="v2"][data-variant="b"] :is(.ui-at-you-boosts, .ui-at-foe-boosts) {
  align-self: center; justify-self: center; z-index: 2; margin-top: calc(var(--medal) + 8px);
}
.ui-arena[data-layout="v2"][data-variant="b"] .ui-boost { --size: clamp(30px, 3.2cqw, 44px); }
.ui-arena[data-layout="v2"][data-variant="b"] .bt { top: calc(50% + var(--medal) / 2 + clamp(30px, 3.2cqw, 44px) + 22px); }
/* bottom row: Boost/Blast left, hand in the middle, the Wilds tray right */
.ui-arena[data-layout="v2"][data-variant="b"] :is(.ui-at-actions, .ui-at-hand, .ui-at-table) { grid-area: bottom; align-self: end; }
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-actions { justify-self: start; }
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-table { justify-self: end; }
/* the hand sits dead centre on screen (Silas #292 msg 682): equal room both sides for the wider of tray / buttons */
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-hand { padding-inline: max(var(--tray-w) + 16px, var(--act) * 2 + 26px); }
.ui-arena[data-layout="v2"][data-variant="b"] .ui-action { --size: var(--act); }
/* the hand box spans the whole bottom row (its padding clears the tray and Boost/Blast): let taps through
   its padding to the Wilds tray and the buttons under it; the hand itself and the push pill still take them */
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-hand { pointer-events: none; }
.ui-arena[data-layout="v2"][data-variant="b"] .ui-at-hand > * { pointer-events: auto; }

/* B · bigger Wilds (?commons=big; #292 msg 642)
   The Wilds cards grow to 0.8 of a hand card so you can read them before you pick; the deck and the
   last move stay a step smaller beside them. Boost / Blast stack in a column bottom left (pinned to the
   bottom row, so a third button never pushes the battle up) to free the width; the hand sits between them.
   Order stays: battle biggest, your hand 2nd, the Wilds 3rd. */
.ui-arena[data-layout="v2"][data-variant="b"][data-commons="big"] {
  --wild-w: calc(var(--hand-w) * 0.8);
  --side-w: max(52px, calc(var(--wild-w) * 0.7)); /* deck + last move; the deck stays a 48px+ target */
  --act: clamp(72px, 10.5cqh, 92px); /* 72px keeps "Blast 3" on one line */
  --tray-w: calc(var(--side-w) * 2 + var(--wild-w) * 3 + 56px); /* 2 zone gaps + 2 card gaps + padding */
}
.ui-arena[data-layout="v2"][data-variant="b"][data-commons="big"] .ui-table { --small-w: var(--wild-w); }
.ui-arena[data-layout="v2"][data-variant="b"][data-commons="big"] :is(.ui-table__zone:first-child, .ui-table__last) { --small-w: var(--side-w); }
.ui-arena[data-layout="v2"][data-variant="b"][data-commons="big"] .ui-at-actions {
  position: absolute; left: 0; bottom: 0;
  grid-auto-flow: row; justify-items: start; justify-content: start; gap: 10px;
}
/* chain turn (Done + Boost + Blast): a smaller Done on top keeps the column clear of your Boost slots */
.ui-arena[data-layout="v2"][data-variant="b"][data-commons="big"] .ui-at-actions:has(> :nth-child(3)) { gap: 8px; }
.ui-arena[data-layout="v2"][data-variant="b"][data-commons="big"] .ui-at-actions > .ui-action:nth-last-child(3) { --size: max(58px, calc(var(--act) * 0.8)); }
.ui-arena[data-layout="v2"][data-variant="b"][data-commons="big"] .ui-at-hand { padding: 0 calc(var(--tray-w) + 16px) 0 calc(var(--act) + 26px); }

/* C · All Battle */
.ui-arena[data-layout="v2"][data-variant="c"] {
  --hero-w: clamp(180px, min(32cqw, 58cqh), 520px);
  --hero-h: calc(var(--hero-w) * 1.06);
  --small-w: clamp(38px, 3.8cqw, 54px);
  --hand-w: clamp(104px, max(11cqw, 17cqh), 196px);
  --peek: calc(var(--hand-w) * 0.42); /* how much of the hand hides under the bottom edge */
  --track-w: calc(100cqw - 40px - var(--hero-w) * 1.9);
  grid-template-columns: minmax(0, var(--hero-w)) minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, var(--hero-w));
}
.ui-arena[data-layout="v2"][data-variant="c"] .ui-boost { --size: clamp(32px, 3.4cqw, 46px); }
.ui-arena[data-layout="v2"][data-variant="c"] .ui-at-hand { margin-bottom: calc(var(--peek) * -1); }
.ui-arena[data-layout="v2"][data-variant="c"] .ui-hand { transition: transform var(--dur-med) var(--ease-out); }
.ui-arena[data-layout="v2"][data-variant="c"] .ui-hand:has(> .is-selected) { transform: translateY(calc(var(--peek) * -1)); }
.ui-arena[data-layout="v2"][data-variant="c"] .ui-action { --size: clamp(64px, 10cqh, 88px); }

/* ---------- Big moments ---------- */
.moment-layer { position: fixed; inset: 0; z-index: 50; cursor: pointer; } /* tap to skip */
.moment-pop { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 4px; background: var(--scrim); }
.moment-pop__inner { display: grid; justify-items: center; gap: 0; color: var(--ink); }
.moment-pop__inner > .ui-icon { font-size: 15cqw; }
.moment-pop .ui-moment .ui-shout { font-size: 8cqw; }
.beat-mark { color: var(--m); }
.hero-choice small { display: inline-flex; align-items: center; gap: 4px; font-size: 18px; }

/* Super effective (#19 mockup msg #163; parts board #19 msg #322, reference art/ui/fx/preview.html?m=se).
   The kit's .ui-versus split on the element halves; attacker lunges, impact flash on the seam, defender
   knocked back dizzy; diagonal SUPER EFFECTIVE! ribbon with a "Fire beats Ice" chip; foot = who + math. */
.se { --k: 1; }
.se.ui-versus--flip { --k: -1; }
:is(.se, .mo-super)[data-a="fire"] { --a-img: url(assets/ui/versus-bg-fire.webp); --super-charge: url(assets/ui/fx-super-fire-charge.webp); --super-wave: url(assets/ui/fx-super-fire-wave.webp); --super-spark: url(assets/ui/fx-super-fire-spark.svg); --beam-core: url(assets/ui/fx-beam-fire-core.webp); --beam-glow: url(assets/ui/fx-beam-fire-glow.webp); --beam-hit: url(assets/ui/fx-beam-fire-impact.webp); }
:is(.se, .mo-super)[data-d="fire"] { --d-img: url(assets/ui/versus-bg-fire.webp); }
:is(.se, .mo-super)[data-a="ice"] { --a-img: url(assets/ui/versus-bg-ice.webp); --super-charge: url(assets/ui/fx-super-ice-charge.webp); --super-wave: url(assets/ui/fx-super-ice-wave.webp); --super-spark: url(assets/ui/fx-super-ice-spark.svg); --beam-core: url(assets/ui/fx-beam-ice-core.webp); --beam-glow: url(assets/ui/fx-beam-ice-glow.webp); --beam-hit: url(assets/ui/fx-beam-ice-impact.webp); }
:is(.se, .mo-super)[data-d="ice"] { --d-img: url(assets/ui/versus-bg-ice.webp); }
:is(.se, .mo-super)[data-a="leaf"] { --a-img: url(assets/ui/versus-bg-leaf.webp); --super-charge: url(assets/ui/fx-super-leaf-charge.webp); --super-wave: url(assets/ui/fx-super-leaf-wave.webp); --super-spark: url(assets/ui/fx-super-leaf-spark.svg); --beam-core: url(assets/ui/fx-beam-leaf-core.webp); --beam-glow: url(assets/ui/fx-beam-leaf-glow.webp); --beam-hit: url(assets/ui/fx-beam-leaf-impact.webp); }
:is(.se, .mo-super)[data-d="leaf"] { --d-img: url(assets/ui/versus-bg-leaf.webp); }
:is(.se, .mo-super)[data-a="electric"] { --a-img: url(assets/ui/versus-bg-electric.webp); --super-charge: url(assets/ui/fx-super-electric-charge.webp); --super-wave: url(assets/ui/fx-super-electric-wave.webp); --super-spark: url(assets/ui/fx-super-electric-spark.svg); --beam-core: url(assets/ui/fx-beam-electric-core.webp); --beam-glow: url(assets/ui/fx-beam-electric-glow.webp); --beam-hit: url(assets/ui/fx-beam-electric-impact.webp); }
:is(.se, .mo-super)[data-d="electric"] { --d-img: url(assets/ui/versus-bg-electric.webp); }
:is(.se, .mo-super)[data-a="water"] { --a-img: url(assets/ui/versus-bg-water.webp); --super-charge: url(assets/ui/fx-super-water-charge.webp); --super-wave: url(assets/ui/fx-super-water-wave.webp); --super-spark: url(assets/ui/fx-super-water-spark.svg); --beam-core: url(assets/ui/fx-beam-water-core.webp); --beam-glow: url(assets/ui/fx-beam-water-glow.webp); --beam-hit: url(assets/ui/fx-beam-water-impact.webp); }
:is(.se, .mo-super)[data-d="water"] { --d-img: url(assets/ui/versus-bg-water.webp); }
:is(.se, .mo-super)[data-a="rock"] { --a-img: url(assets/ui/versus-bg-rock.webp); --super-charge: url(assets/ui/fx-super-rock-charge.webp); --super-wave: url(assets/ui/fx-super-rock-wave.webp); --super-spark: url(assets/ui/fx-super-rock-spark.svg); --beam-core: url(assets/ui/fx-beam-rock-core.webp); --beam-glow: url(assets/ui/fx-beam-rock-glow.webp); --beam-hit: url(assets/ui/fx-beam-rock-impact.webp); }
:is(.se, .mo-super)[data-d="rock"] { --d-img: url(assets/ui/versus-bg-rock.webp); }
.ui-versus:is(.se, .mo-super)::before { background: var(--a-img, none) 50% 40% / cover no-repeat, var(--a); }   /* missing art: the element color */
.ui-versus:is(.se, .mo-super)::after  { background: var(--d-img, none) 50% 40% / cover no-repeat, var(--d); filter: saturate(0.75) brightness(0.85); }
.se .ui-versus__a { top: 17cqh; width: 52cqw; }
.se .ui-versus__d { top: 22cqh; width: 40cqw; }
.se.is-in .ui-versus__a { animation: ui-vs-l var(--dur-slow) var(--ease-pop) both, se-lunge 420ms var(--ease-out) var(--dur-slow); }
.se.is-in .ui-versus__d { animation: ui-vs-r var(--dur-slow) var(--ease-pop) both, se-knock 640ms var(--ease-out) 560ms forwards; }
.se.ui-versus--flip.is-in .ui-versus__a { animation-name: ui-vs-r, se-lunge; }
.se.ui-versus--flip.is-in .ui-versus__d { animation-name: ui-vs-l, se-knock; }
.se__lines { inset: 0; z-index: 2; pointer-events: none; background: url(assets/ui/fx-speedlines.svg) center / cover no-repeat;
  opacity: 0.5; animation: se-flicker 180ms steps(2, jump-none) infinite alternate; }
.se__hit { left: 37cqw; top: 26cqh; width: 26cqw; aspect-ratio: 1; z-index: 4; pointer-events: none;
  background: url(assets/ui/fx-impact.svg) center / contain no-repeat; animation: se-hit 900ms var(--ease-out) 520ms both; }
.se.ui-versus--flip .se__hit { left: 35cqw; }
.se__dizzy { right: 11cqw; top: 25cqh; width: 20cqw; aspect-ratio: 2; z-index: 4; pointer-events: none;
  background: url(assets/ui/fx-dizzy.svg) center / contain no-repeat; animation: se-dizzy 1100ms var(--ease-out) 760ms both; }
.se.ui-versus--flip .se__dizzy { right: auto; left: 9cqw; }
.se__stand { position: absolute; left: 50%; top: 50%; translate: -50% -50%; display: grid; place-items: center; width: 1.7em; aspect-ratio: 1;
  border-radius: 50%; background: var(--surface); color: var(--m); font-size: 11cqw;
  box-shadow: 0 0 0 0.7cqw var(--ink), 0 1cqw 0 0.7cqw var(--ink); }   /* no creature art: the element token */
.ui-versus__a > .se__stand { font-size: 14cqw; }
:is(.ui-versus__a, .ui-versus__d):has(> img:not([hidden])) > .se__stand { display: none; }
.se__ribbon { left: 7cqw; top: 3cqh; width: 84cqw; aspect-ratio: 1000 / 240; z-index: 5;
  display: grid; place-items: center; padding: 0 8% 0 19%; transform: rotate(-5deg);
  animation: se-ribbon 560ms var(--ease-bounce) 140ms both; }
.se__ribbon::before { content: ""; position: absolute; inset: 0; z-index: -1; background: url(assets/ui/ribbon-super-effective.svg) center / contain no-repeat; }
.se.ui-versus--flip .se__ribbon { left: 9cqw; padding: 0 19% 0 8%; }
.se.ui-versus--flip .se__ribbon::before { transform: scaleX(-1); } /* the arrow points at the defender */
.se__shout { font: var(--fw-display, 700) 6.4cqw / 1 var(--font-display); color: var(--surface); white-space: nowrap; text-transform: uppercase;
  letter-spacing: 0.04em; font-kerning: none; -webkit-text-stroke: 0.7cqw var(--ink); paint-order: stroke fill; text-shadow: 0 0.5cqw 0 var(--ink); }
.se__chip { position: absolute; top: 1cqw; left: 34%; display: inline-flex; align-items: center; gap: 0.5cqw; padding: 0.5cqw 2cqw 0.6cqw;
  border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); box-shadow: 0 0 0 0.45cqw var(--ink);
  font: var(--fw-display, 700) 2.7cqw / 1.1 var(--font-display); white-space: nowrap; }
.se__chip [data-el] { display: inline-flex; color: var(--m); font-size: 3.1cqw; }
.se__chip [data-el] + [data-el], .se__chip [data-el]:not(:first-child) { margin-left: 0.3cqw; }
.se .ui-versus__foot { z-index: 6; animation: mo-drop 420ms var(--ease-pop) 700ms both; }
.se .ui-versus__foot > .ui-math--lg { flex: none; }
.se-plate { flex: 0 1 300px; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 20px 12px 14px;
  border-radius: 22px; background: var(--hud); color: var(--hud-ink); box-shadow: 0 0 0 3px var(--edge), inset 0 0 0 2px var(--hud-line); }
.se-plate__el { flex: none; display: inline-flex; color: var(--m); font-size: 40px; }
.se-plate__who { display: grid; gap: 4px; min-width: 0; }
.se-plate__who small { font: 900 12px / 1 var(--font-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--spark); }
.se-plate__who b { font: 700 26px / 1 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes se-lunge   { 40% { translate: calc(var(--k) * 4cqw) -1cqh; } }
@keyframes se-knock   { 0% { translate: 0 0; rotate: 0deg; } 22% { translate: calc(var(--k) * 7cqw) -3cqh; rotate: calc(var(--k) * 16deg); }
                        45% { translate: calc(var(--k) * 4cqw) -1cqh; rotate: calc(var(--k) * 6deg); } 100% { translate: calc(var(--k) * 5cqw) -1.5cqh; rotate: calc(var(--k) * 10deg); } }
@keyframes se-hit     { 0% { opacity: 0; scale: 0.1; } 25% { opacity: 1; scale: 1.2; } 50% { scale: 0.95; } 100% { opacity: 0.85; scale: 1; } }
@keyframes se-dizzy   { 0% { opacity: 0; scale: 0.4; rotate: -30deg; } 40% { opacity: 1; scale: 1.05; } 100% { opacity: 1; scale: 1; rotate: 12deg; } }
@keyframes se-ribbon  { from { opacity: 0; scale: 1.7; } 60% { opacity: 1; scale: 0.94; } to { opacity: 1; scale: 1; } }
@keyframes se-flicker { from { opacity: 0.35; } to { opacity: 0.6; } }

/* ---------- End of game ---------- */

/* ---------- HUD drawers: menu (left) and log (right) ---------- */
.drawer {
  position: fixed; top: 12px; bottom: 12px; z-index: 35; width: min(380px, 86vw);
  display: flex; flex-direction: column; gap: 12px; padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--hud); color: var(--hud-ink);
  box-shadow: inset 0 0 0 2px var(--hud-line), var(--shadow-lg);
}
.drawer--left { left: 12px; }
.drawer--right { right: 12px; }
.drawer__head { display: flex; align-items: center; gap: 8px; }
.drawer__head b { font: var(--fw-display) var(--fs-lg) / 1 var(--font-display); }
.drawer__head small { color: var(--hud-soft); }
.drawer__head .ui-btn--hud { margin-left: auto; width: 44px; height: 44px; font-size: 20px; }
.drawer__info { margin: 0; color: var(--hud-soft); font-size: var(--fs-sm); }
.drawer__info code { color: var(--hud-ink); }
.drawer__opt { display: flex; align-items: center; gap: 8px; }
.drawer .ui-btn--sm { align-self: flex-start; }
.drawer h3 { margin: 8px 0 0; }

.log { flex: 1; overflow: auto; margin: 0; padding: 0 4px 0 30px; font-size: var(--fs-sm); }
.log li { margin: 3px 0; }
.log li .small { color: var(--hud-soft); font-size: var(--fs-xs); }
.log li.turn-line { margin-top: 10px; padding-top: 6px; border-top: 1px dashed var(--hud-line); font-weight: var(--fw-bold); }
.log li.end-line { font-weight: 800; color: var(--spark); }

/* ---------- WebGL beam (web/beam/beam.js) ----------
   An absolutely placed overlay under every arena child, so it never moves the layout or takes a touch.
   The CSS beam (kit.css .ui-beam) stays as the fallback: its rail, rays and token hide only while the
   shader is drawing (.beam-fx-on). Track cells, Rally zones and labels stay CSS. */
.ui-arena > .beam-fx { position: absolute; z-index: 0; pointer-events: none; contain: strict; }
.beam-fx canvas { display: block; width: 100%; height: 100%; }
.ui-arena:not(.beam-fx-on) > .beam-fx { opacity: 0; }
.ui-arena.beam-fx-on .ui-beam::before, .ui-arena.beam-fx-on .ui-beam::after,
.ui-arena.beam-fx-on .ui-beam__rail, .ui-arena.beam-fx-on .ui-beam__token { display: none; }

/* Drag a hand card: Boost on your hero, Blast on the beam or the rival */
.ui-hand > .uc[data-sel] { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab; }
.uc.is-dragging { position: relative; z-index: 40; pointer-events: none; cursor: grabbing; transition: none; box-shadow: var(--glow-gold); will-change: transform; }
.uc.is-returning { transition: transform 0.22s ease-out; }
.is-card-dragging, .is-card-dragging * { user-select: none; -webkit-user-select: none; }
.is-drop-ok { outline: 3px dashed var(--spark); outline-offset: 4px; border-radius: var(--radius-sm); }
.is-drop-ok.is-drop-hot { outline-style: solid; box-shadow: var(--glow-gold); }

/* ---------- Table polish (#16) ---------- */
/* Hint chip: a solid HUD chip under "Your turn", so it reads over the beam glare */
.turn-hint {
  height: auto; min-height: 34px; padding: 4px 14px;
  font-size: 20px; color: var(--hud-ink); background: var(--arena-3);
  box-shadow: inset 0 0 0 2px var(--hud-line), 0 0 0 3px var(--edge), var(--shadow-md);
  animation: hint-in var(--dur-med) var(--ease-pop) both;
}
.turn-hint .ui-icon { font-size: 20px; }
@keyframes hint-in { from { opacity: 0; transform: translateY(-6px) scale(0.9); } to { opacity: 1; transform: none; } }

/* Long names shrink to fit (--n = name length, set in app.js fitName); ellipsis stays as the last resort. */
/* Plate names get the room the pips and rival hand leave, and size to it (1 char ~ 0.6em) */
.ui-plate__who { flex: 1 1 0; min-width: 0; container-type: inline-size; }
.ui-plate__who b { font-size: clamp(13px, calc(100cqw * 1.65 / var(--n, 1)), 24px); overflow: hidden; text-overflow: ellipsis; }
.ui-plate > .ui-pips, .ui-plate > .ui-chip, .ui-plate > .rival-hand { flex: none; }
.ui-plate--foe .rival-hand { margin-right: 0; }

/* Icon-only zone labels and chips */
.ui-at-you-boosts::before, .ui-at-foe-boosts::before { content: none; }
.beat-mark .ui-icon { color: var(--m); }

/* Mirror match: the rival medallion gets a darker rim (its --m drives the kit ring and glow)
   and leans the other way, so two of the same hero never look alike. */
.ui-arena[data-mirror] .ui-medal--foe {
  --m: color-mix(in srgb, var(--you) 28%, var(--rival-lip));
  --l: color-mix(in srgb, var(--you) 30%, var(--arena-3));
  transform: rotate(-6deg);
}
.ui-arena[data-mirror] .ui-medal--foe > img { filter: brightness(0.78) saturate(0.8); }
.ui-arena[data-mirror] .ui-medal:not(.ui-medal--foe) { transform: rotate(4deg); }

@media (prefers-reduced-motion: reduce) {
  .turn-hint { animation: none; }
}

/* ---------- Hero moments (#19): Evolve and Super Move ----------
   Transform/opacity only. Timeline (hold = 1.8 x --dur-moment): the normal hero pops in, flips
   edge-on, a gold ring bursts, the evolved hero flips in, then the EVOLVED! ribbon drops. */
.mo-evolve {
  position: absolute; inset: 0; overflow: hidden; container-type: size;
  background:
    radial-gradient(circle at 50% 44%, var(--gold-hi) 0, color-mix(in srgb, var(--gold) 85%, transparent) 18%, color-mix(in srgb, var(--m) 35%, transparent) 46%, transparent 72%),
    var(--scrim);
  animation: mo-fade var(--dur-med) var(--ease-out) both;
}
.mo-evolve > * { position: absolute; }
.mo-evolve__rays {
  left: 50%; top: 44%; width: 170cqmax; aspect-ratio: 1; margin: -85cqmax 0 0 -85cqmax; border-radius: 50%;
  background: var(--sunburst-gold); opacity: 0.8;
  -webkit-mask: radial-gradient(circle, #000 4%, transparent 44%); mask: radial-gradient(circle, #000 4%, transparent 44%);
  animation: mo-spin 14s linear infinite, mo-grow 700ms var(--ease-out) both;
}
.mo-evolve__ring {
  left: 50%; top: 44%; width: 50cqh; aspect-ratio: 1; margin: -25cqh 0 0 -25cqh; border-radius: 50%;
  box-shadow: 0 0 0 10px var(--gold-hi), 0 0 0 18px var(--gold), 0 0 60px 30px var(--gold);
  opacity: 0; animation: mo-ring 760ms var(--ease-out) 900ms both;
}
.mo-evolve::after { /* the flash at the swap */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 44%, var(--surface) 0, var(--gold-hi) 30%, transparent 70%);
  opacity: 0; animation: mo-flash 560ms var(--ease-out) 860ms both;
}
.mo-evolve__hero {
  left: 50%; top: 44%; aspect-ratio: 1; border-radius: 50%;
  -webkit-mask: radial-gradient(circle, #000 60%, transparent 71%); mask: radial-gradient(circle, #000 60%, transparent 71%);
  background: radial-gradient(circle, var(--l) 0, var(--m) 62%); /* missing-art fallback: hidden under the opaque art */
}
.mo-evolve__hero img { position: relative; width: 100%; height: 100%; object-fit: cover; display: block; }
.mo-evolve__hero img[hidden] { display: none; }
.mo-evolve__hero > .ui-icon { position: absolute; left: 50%; top: 50%; translate: -50% -50%; color: var(--on); }
.mo-evolve__from > .ui-icon { font-size: 20cqh; }
.mo-evolve__to > .ui-icon { font-size: 30cqh; }
.mo--flip .mo-evolve__hero img { transform: scaleX(-1); } /* the rival faces left */
.mo-evolve__from { width: 46cqh; margin: -23cqh 0 0 -23cqh; animation: mo-from 1000ms var(--ease-out) both; }
.mo-evolve__to   { width: 70cqh; margin: -35cqh 0 0 -35cqh; opacity: 0;
  animation: mo-to 620ms var(--ease-pop) 940ms both, mo-float 2.4s ease-in-out 1600ms infinite; }
.mo-spark {
  left: var(--x); top: var(--y); width: 3.2cqh; aspect-ratio: 1; z-index: 2;
  background: var(--surface);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  opacity: 0; animation: mo-twinkle 1.1s ease-in-out calc(var(--d) + 900ms) infinite both;
}
.mo-evolve__foot { left: 0; right: 0; bottom: 5cqh; z-index: 3; display: grid; justify-items: center; gap: 6px;
  animation: mo-drop 560ms var(--ease-bounce) 1150ms both; }
.mo-evolve__foot .ui-ribbon { min-width: 460px; height: 136px; }
.mo-evolve__foot .ui-shout { font-size: clamp(56px, 9cqh, 84px); }
.mo-sub {
  margin: -18px 0 0; padding: 8px 22px; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--hud); color: var(--hud-ink); box-shadow: inset 0 0 0 2px var(--hud-line), 0 0 0 3px var(--edge);
  font: var(--fw-display) var(--fs-lg) / 1.1 var(--font-display);
}
.mo-sub .ui-icon { font-size: 26px; color: var(--gold); }

@keyframes mo-fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes mo-spin  { to { rotate: 360deg; } }
@keyframes mo-grow  { from { scale: 0.2; opacity: 0; } to { scale: 1; opacity: 0.8; } }
@keyframes mo-ring  { 0% { opacity: 1; transform: scale(0.3); } 100% { opacity: 0; transform: scale(2.6); } }
@keyframes mo-flash { 0% { opacity: 0; } 35% { opacity: 0.95; } 100% { opacity: 0; } }
@keyframes mo-from {
  0%   { opacity: 0; transform: perspective(900px) scale(0.6); }
  28%  { opacity: 1; transform: perspective(900px) scale(1); }
  60%  { opacity: 1; transform: perspective(900px) rotateY(0) scale(1.04); }
  94%  { opacity: 1; transform: perspective(900px) rotateY(90deg) scale(1.12); }
  100% { opacity: 0; transform: perspective(900px) rotateY(90deg) scale(1.12); }
}
@keyframes mo-to {
  from { opacity: 1; transform: perspective(900px) rotateY(-90deg) scale(0.9); }
  to   { opacity: 1; transform: perspective(900px) rotateY(0) scale(1); }
}
@keyframes mo-float   { 0%, 100% { translate: 0 0; } 50% { translate: 0 -1.6cqh; } }
@keyframes mo-twinkle { 0%, 100% { opacity: 0; transform: scale(0.2) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
@keyframes mo-drop    { from { opacity: 0; transform: translateY(14cqh) scale(0.6); } to { opacity: 1; transform: none; } }

/* Super Move: the versus frame with the evolved hero full bleed, a bolt, and the move name on a ribbon */
.mo-super .ui-versus__a { width: 64cqw; top: 0; left: -7cqw; }
.mo-super.ui-versus--flip .ui-versus__a { left: auto; right: -7cqw; }
.mo-super .ui-versus__d { width: 38cqw; top: 14cqh; }
.mo-super.is-in .ui-versus__d { animation: ui-vs-r var(--dur-slow) var(--ease-pop) both, mo-hit 460ms ease-out 760ms forwards; }
/* Super Move hit (look B, Silas #187 msg #555): the hero charges up on its own side; a shockwave and the
   element burst land on the rival's side. Nothing crosses the seam. */
.mo-super__charge { left: 2cqw; top: 4cqh; width: 50cqw; aspect-ratio: 1; z-index: 3; pointer-events: none; mix-blend-mode: screen;
  background: var(--super-charge, var(--beam-hit)) center / contain no-repeat; animation: mo-charge 1300ms var(--ease-out) 150ms both; }
.ui-versus--flip .mo-super__charge { left: auto; right: 2cqw; }
.mo-super__spark { left: calc(10cqw + var(--i) * 9cqw); top: 44cqh; width: 6cqw; aspect-ratio: 1; z-index: 3; pointer-events: none;
  background: var(--super-spark) center / contain no-repeat; animation: mo-spark 900ms var(--ease-out) calc(200ms + var(--i) * 110ms) both; }
.ui-versus--flip .mo-super__spark { left: auto; right: calc(10cqw + var(--i) * 9cqw); }
.mo-super__wave { right: 4cqw; top: 10cqh; width: 44cqw; aspect-ratio: 1; z-index: 3; pointer-events: none; mix-blend-mode: screen;
  background: var(--super-wave) center / contain no-repeat; animation: mo-wave 760ms var(--ease-out) 700ms both; }
.ui-versus--flip .mo-super__wave { right: auto; left: 4cqw; }
.mo-super__impact { right: 13cqw; top: 18cqh; width: 32cqw; aspect-ratio: 1; z-index: 4; pointer-events: none;
  background: var(--beam-hit) center / contain no-repeat; animation: mo-impact 800ms var(--ease-out) 760ms both; }
.ui-versus--flip .mo-super__impact { right: auto; left: 13cqw; transform: scaleX(-1); }
.mo-super__name {
  left: -4cqw; right: -4cqw; bottom: 9cqh; z-index: 5;
  display: grid; justify-items: center; padding: 2cqh 0 2.4cqh;
  background: var(--cel-gold);
  box-shadow: 0 0 0 6px var(--edge), 0 12px 0 var(--edge);
  transform: rotate(-5deg);
  animation: mo-slide 560ms var(--ease-pop) 260ms both;
}
.ui-versus--flip .mo-super__name { transform: rotate(5deg); animation-name: mo-slide-r; }
.mo-super__name .ui-shout { font-size: clamp(56px, 10cqw, 140px); white-space: nowrap; text-transform: uppercase; }
.mo-super__tag {
  position: absolute; top: -3.6cqh; left: 30%;
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 18px; border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: 0 0 0 4px var(--edge);
  font: var(--fw-display) clamp(22px, 3cqw, 40px) / 1 var(--font-display);
  transform: rotate(-3deg);
}
.mo-super__tag .ui-icon { color: var(--gold-lip); }
.ui-versus--flip .mo-super__tag { left: auto; right: 30%; transform: rotate(3deg); }
/* Thunder Dive is the hero moment (production plan §3.6): same look B parts, a touch more. The charge
   throbs twice (the dive) and brighter, and 2 more lightning sparks rise higher up the hero's side. */
.mo-super[data-a="electric"] .mo-super__charge { animation-name: mo-super-throb; animation-duration: 1400ms; }
.mo-super__spark--hi { top: 30cqh; width: 5cqw; }
@media (prefers-reduced-motion: reduce) { .mo-super__wave { opacity: 0.45; } } /* still frame: the shock ring stays light over the rival */
@keyframes mo-super-throb {
  0% { opacity: 0; scale: 0.3; rotate: 0deg; } 20% { opacity: 1; scale: 1.05; } 34% { opacity: 0.75; scale: 0.9; }
  48% { opacity: 1; scale: 1.06; rotate: 24deg; } 64% { opacity: 0.85; scale: 0.96; } 100% { opacity: 0.3; scale: 1.08; rotate: 60deg; }
}
@keyframes mo-charge { 0% { opacity: 0; scale: 0.3; rotate: 0deg; } 30% { opacity: 0.9; scale: 1.05; } 50% { opacity: 0.9; scale: 0.95; } 70% { opacity: 0.5; } 100% { opacity: 0.25; scale: 1.1; rotate: 50deg; } }
@keyframes mo-wave { 0% { opacity: 1; scale: 0.3; } 100% { opacity: 0; scale: 1.3; } }
@keyframes mo-spark { 0% { opacity: 0; transform: translateY(0) scale(0.4); } 30% { opacity: 1; transform: translateY(-8cqh) scale(1); } 100% { opacity: 0; transform: translateY(-30cqh) scale(0.7) rotate(90deg); } }
@keyframes mo-impact { 0% { opacity: 0; scale: 0.2; rotate: -20deg; } 30% { opacity: 1; scale: 1.25; } 60% { scale: 0.95; } 100% { opacity: 0.9; scale: 1; rotate: 0deg; } }
@keyframes mo-hit { 0% { translate: 0 0; } 20% { translate: 3cqw -1cqh; } 45% { translate: -1.5cqw 0.5cqh; } 70% { translate: 1cqw 0; } 100% { translate: 0 0; } }
@keyframes mo-slide   { from { translate: -110% 0; } to { translate: 0 0; } }
@keyframes mo-slide-r { from { translate: 110% 0; } to { translate: 0 0; } }

/* ---------- Good Game! (look C "curtain call" in the Temple: Silas #188 msg #562; mockup msg #531) ----------
   0-0.5 s the stage lights come up; 0.15 s the heroes walk in from the sides; 0.55 s the banner swings down;
   1.0 s they bow to each other; 1.3 s a star glows between them; 1.5 s the buttons slide up.
   Rest: the heroes breathe and bow now and then, element confetti falls. Winner: a small gold star. */
.banner { position: fixed; inset: 0; z-index: 40; overflow: hidden; }
.gg { position: absolute; inset: 0; overflow: hidden; container-type: size;
  background: var(--table) url(assets/ui/goodgame-bg.webp) center / cover no-repeat; }
.gg > * { position: absolute; }
.gg__rays { left: 50%; top: 50%; width: 150cqw; aspect-ratio: 1; margin: -75cqw 0 0 -75cqw; opacity: 0.35;
  background: url(assets/ui/fx-rays.svg) center / contain no-repeat;
  animation: mo-fade 900ms ease-out 300ms both; } /* still after the fade (ops #869: a 1770 px layer spinning forever cost frames) */
.gg__lights { inset: 0; z-index: 6; pointer-events: none; background: var(--table); animation: gg-lights 700ms ease-out both; } /* house lights down -> stage up */
.gg__fall { inset: 0; z-index: 1; pointer-events: none; }
/* One animation per element (ops #869: stacked transform animations would not composite):
   walk-in on .gg__hero, the first bow on .gg__bow, the idle bow on .gg__rest; pop on the star, sway on its <i>. */
.gg__hero { --hb: 19cqh; --hh: 46cqh; bottom: var(--hb); z-index: 2; height: var(--hh); aspect-ratio: 809 / 900; --k: 1; transform-origin: 50% 100%; }
/* The winner stands about 18% bigger than the loser (Silas #1053 msg 1081): the winner keeps the full hero size, so it
   never grows up into the ribbon, and the loser steps back to 0.85 with the separate `scale` property (anchored at the
   feet; it composes with the walk/bow transform animations instead of fighting them). A draw keeps both equal. */
.gg__hero.is-winner { z-index: 5; }
.gg:has(.gg__hero.is-winner) .gg__hero:not(.is-winner) { scale: 0.85; }
.gg__bow, .gg__rest { position: absolute; inset: 0; transform-origin: 50% 100%; }
.gg__hero img { display: block; width: 100%; height: 100%; object-fit: contain; }
.gg__hero--you { right: 50%; margin-right: 6cqw; animation: gg-walk 700ms var(--ease-out) 150ms both; }
.gg__hero--you .gg__bow { animation: gg-bow 900ms ease-in-out 1000ms; }
.gg__hero--you .gg__rest { animation: gg-rest 5s ease-in-out 1.9s infinite; }
.gg__hero--foe { left: 50%; margin-left: 6cqw; --k: -1; animation: gg-walk 700ms var(--ease-out) 230ms both; }
.gg__hero--foe .gg__bow { animation: gg-bow 900ms ease-in-out 1050ms; }
.gg__hero--foe .gg__rest { animation: gg-rest 5s ease-in-out 1.95s infinite; }
.gg__hero--foe img { transform: scaleX(-1); } /* the cut-outs face right: the rival turns to face you */
.gg__star { position: absolute; left: 50%; top: -6%; width: 18%; aspect-ratio: 1; margin-left: -9%; z-index: 1;
  animation: gg-pop 520ms var(--ease-bounce) 1600ms both; }
.gg__star i, .gg__star-glow i { position: absolute; inset: 0; }
.gg__star i { background: url(assets/ui/confetti-star.svg) center / contain no-repeat; animation: gg-crown 1.6s ease-in-out 2.2s infinite; }
.gg__star-glow { left: 50%; bottom: 19cqh; width: 13cqw; aspect-ratio: 1; margin-left: -6.5cqw; z-index: 3; pointer-events: none;
  animation: gg-pop 600ms var(--ease-bounce) 1300ms both; }
.gg__star-glow i { background: url(assets/ui/confetti-star.svg) center / 62% no-repeat, radial-gradient(circle, var(--gold-hi), transparent 68%);
  animation: gg-glow 2.4s ease-in-out 2s infinite; }
.gg__banner { left: 50%; top: 2cqh; z-index: 5; width: min(70cqw, 104cqh); aspect-ratio: 960 / 280; margin-left: max(-35cqw, -52cqh);
  container-type: inline-size; transform-origin: 50% 0; animation: gg-swing 900ms var(--ease-out) 550ms both; }
.gg__ribbon { position: absolute; inset: 0; display: grid; place-items: center; padding-bottom: 1%; transform-origin: 50% 0;
  background: url(assets/ui/banner-goodgame.svg) center / contain no-repeat;
  animation: gg-wobble 3s ease-in-out 2.2s infinite; } /* the swing-in on .gg__banner, the idle sway here (ops #869) */
.gg__banner span { font: var(--fw-display) 10.5cqi / 1 var(--font-display); color: var(--gold); white-space: nowrap;
  -webkit-text-stroke: 1.3cqi var(--ink); paint-order: stroke fill; text-shadow: 0 0.9cqi 0 var(--ink); }
.gg__why {
  left: 50%; bottom: calc(6cqh + var(--btn-h-lg, 72px) + 18px); z-index: 5; margin: 0; translate: -50% 0;
  padding: 8px 22px; border-radius: var(--radius-pill); display: inline-flex; align-items: center; gap: 10px; white-space: nowrap;
  background: var(--hud); color: var(--hud-ink); box-shadow: inset 0 0 0 2px var(--hud-line), 0 0 0 3px var(--edge);
  font: var(--fw-display) var(--fs-lg) / 1.15 var(--font-display); max-width: 86cqw;
  animation: mo-drop 520ms var(--ease-pop) 1700ms both;
}
.gg__why .ui-icon { font-size: 26px; color: var(--spark); }
.gg:has(.gg__why) .gg__hero { --hb: max(19cqh, calc(6cqh + var(--btn-h-lg, 80px) + 64px)); --hh: min(46cqh, 40cqh + 3cqw); }
.gg__btns { left: 0; right: 0; bottom: 5cqh; z-index: 5; display: flex; gap: 3cqw; justify-content: center; }
.gg__btns .ui-btn { min-width: min(30cqw, 340px); animation: gg-up 620ms var(--ease-pop) 1500ms both; }
.gg__btns .ui-btn + .ui-btn { animation-delay: 1600ms; }
.gg__home { --lip-color: var(--edge); background: var(--rival); color: var(--rival-ink);
  box-shadow: inset 0 4px 0 color-mix(in srgb, var(--rival-ink) 28%, transparent), 0 var(--btn-lip, 6px) 0 var(--edge); }
.gg-bit { position: absolute; top: -8cqh; left: var(--x); width: 4.2cqw; aspect-ratio: 1; background: center / contain no-repeat;
  animation: gg-fall var(--t) linear var(--d) infinite both; }
.gg [data-k="fire"] { background-image: url(assets/ui/confetti-fire.svg); }
.gg [data-k="ice"] { background-image: url(assets/ui/confetti-ice.svg); }
.gg [data-k="leaf"] { background-image: url(assets/ui/confetti-leaf.svg); }
.gg [data-k="electric"] { background-image: url(assets/ui/confetti-electric.svg); }
.gg [data-k="water"] { background-image: url(assets/ui/confetti-water.svg); }
.gg [data-k="rock"] { background-image: url(assets/ui/confetti-rock.svg); }
.gg [data-k="star"] { background-image: url(assets/ui/confetti-star.svg); }
.gg [data-k="heart"] { background-image: url(assets/ui/confetti-heart.svg); }
.gg [data-k="streamer"] { background-image: url(assets/ui/confetti-streamer.svg); width: 5.6cqw; }
@keyframes gg-lights { from { opacity: 0.92; } to { opacity: 0; } }
@keyframes gg-walk  { from { opacity: 0; transform: translateX(calc(var(--k) * -40cqw)); } 60% { opacity: 1; }
                      75% { transform: translateX(calc(var(--k) * 1cqw)) translateY(-1.5cqh); } to { opacity: 1; transform: none; } }
@keyframes gg-bow   { 0%, 100% { transform: none; } 35%, 65% { transform: translateY(3.3%) rotate(calc(var(--k) * 16deg)); } } /* % of the hero: no container units in looping keyframes */
@keyframes gg-rest  { 0%, 70%, 100% { transform: none; } 80%, 88% { transform: translateY(2.2%) rotate(calc(var(--k) * 12deg)); } }
@keyframes gg-pop   { from { opacity: 0; transform: scale(0) rotate(-90deg); } to { opacity: 1; transform: none; } }
@keyframes gg-glow  { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.8; transform: scale(1.12); } }
@keyframes gg-swing { 0% { opacity: 0; transform: translateY(-30cqh) rotate(-14deg); } 45% { opacity: 1; transform: translateY(1cqh) rotate(7deg); }
                      70% { transform: rotate(-3deg); } 100% { opacity: 1; transform: none; } }
@keyframes gg-wobble { 0%, 100% { rotate: -1.5deg; } 50% { rotate: 1.5deg; } }
@keyframes gg-crown { 0%, 100% { rotate: -10deg; } 50% { rotate: 10deg; } }
@keyframes gg-up    { from { opacity: 0; transform: translateY(24cqh); } 70% { opacity: 1; transform: translateY(-1.5cqh); } to { opacity: 1; transform: none; } }
@keyframes gg-fall  { from { transform: translate3d(0, 0, 0) rotate(0); } to { transform: translate3d(calc(var(--s) * 8vw), 118vh, 0) rotate(calc(var(--s) * 720deg)); } } /* vw/vh: .banner is the fixed full viewport; container units here re-resolved every frame (ops #869) */

@media (prefers-reduced-motion: reduce) {
  .mo-evolve, .mo-evolve *, .mo-evolve::after, .mo-super *, .se *, .gg, .gg *, .uc.is-legal { animation: none !important; }
  .mo-evolve__from, .mo-evolve__ring, .mo-evolve::after, .mo-spark, .gg__fall, .gg__lights { display: none; }
  .mo-evolve__to { opacity: 1; }
}

/* ---------- Perf: compositor-only glows (ops #869, ops/perf/tablet-60fps.md §1) ----------
   The kit's infinite box-shadow pulses (ui-legal, ui-medal-glow, ui-pulse, ui-chip-pulse) repaint every frame.
   Their static shadow stays; the pulse moves to a layer that holds the peak shadow and animates opacity/transform only.
   .uc clips its children (overflow: hidden), so the card pulse is an inner edge glow over the static legal ring. */
.uc.is-legal, .ui-medal.is-active, .ui-turn--you, .ui-chip.is-pulse { animation: none; }
.uc-pulse { position: absolute; inset: 0; z-index: 5; border-radius: inherit; pointer-events: none; box-shadow: inset 0 0 0.9em 0.25em var(--spark); opacity: 0; animation: perf-glow 1.4s var(--ease-out) infinite; }
.uc:not(.is-legal) > .uc-pulse { display: none; } /* e.g. a zoom clone without the state */
.ui-medal.is-active::after { content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; box-shadow: 0 0 100px 22px var(--m); opacity: 0; animation: perf-glow 1.8s ease-in-out infinite; }
.ui-turn--you, .ui-chip.is-pulse { position: relative; }
.ui-turn--you::after, .ui-chip.is-pulse::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: 0 0 0 5px var(--accent); opacity: 0; animation: perf-ring 1.6s var(--ease-out) infinite; }
.ui-chip.is-pulse::after { box-shadow: 0 0 0 5px var(--gold); }
@keyframes perf-glow { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
@keyframes perf-ring { 0% { opacity: 0.55; transform: scale(1); } 100% { opacity: 0; transform: scale(1.12, 1.45); } }
@media (prefers-reduced-motion: reduce) {
  .uc-pulse, .ui-medal.is-active::after, .ui-turn--you::after, .ui-chip.is-pulse::after { animation: none; }
}

/* ---------- Battle playmats (art-scenes #424/#948; app.js playmatFor picks one per game at random, Silas #1043) ----------
   The painted location replaces the arena's last background layer; the hero side glows and the clash light stay on
   top, and the flat gradient stays underneath while the image loads or if it is missing. */
.ui-arena[data-mat="temple"]      { --mat: url(assets/table/playmat-temple.webp); }
.ui-arena[data-mat="volcano"]     { --mat: url(assets/table/playmat-volcano.webp); }
.ui-arena[data-mat="glacier"]     { --mat: url(assets/table/playmat-glacier.webp); }
.ui-arena[data-mat="grove"]       { --mat: url(assets/table/playmat-grove.webp); }
.ui-arena[data-mat="stormpeak"]   { --mat: url(assets/table/playmat-stormpeak.webp); }
.ui-arena[data-mat="coralreef"]   { --mat: url(assets/table/playmat-coralreef.webp); }
.ui-arena[data-mat="crystalcave"] { --mat: url(assets/table/playmat-crystalcave.webp); }
.ui-arena[data-mat] {
  background:
    radial-gradient(ellipse 48% 70% at 4% 42%, color-mix(in srgb, var(--you) 75%, transparent), transparent 70%),
    radial-gradient(ellipse 48% 70% at 96% 38%, color-mix(in srgb, var(--foe) 62%, transparent), transparent 70%),
    radial-gradient(ellipse 26% 22% at var(--clash) 30%, rgba(255, 255, 255, 0.3), transparent 70%),
    var(--mat, none) center / cover no-repeat,
    linear-gradient(var(--arena-2), var(--arena-3));
}

/* #995 (QA sweep): table cues (cues.js .cue-layer, z-index 55) must never show over Good Game! (.banner, z-index 40).
   syncBanner clears them when the banner appears; this hides any that start later (an online frame, a late event). */
body:has(#banner.banner:not([hidden])) .cue-layer { visibility: hidden; }

/* ---------- a11y (#963 #965 #967 #973) ---------- */
/* the table's polite live region (app.js announce): read aloud, never seen */
.ui-live { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
/* #973: a clear keyboard focus ring on cards (the gold ring used elsewhere), also on a dimmed card (its filter would mute it) */
.uc:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.uc.is-dim:focus-visible { filter: none; }
/* #965: small text on small tablets. Labels to 12px; hand card names never under 10px (the card scales its text from
   its width; 12px names need a 146px card, which the centered hand can't fit at 960x600). Anything smaller (Wilds,
   Boosts, the ruler) is read big with the card zoom: hold, hover or keyboard focus (web/zoom.js). */
.ui-plate__who small { font-size: 12px; }
.ui-hand > .uc .uc-nm { font-size: max(0.82em, 10px); }

/* a11y #961: the viewport allows pinch zoom now (Home, lobby, Settings); the table itself never zooms mid-game.
   touch-action intersects down the tree, so cards/buttons lose pinch while scrolling and card drags keep working. */
#game { touch-action: pan-x pan-y; }

/* ---------- Heroes act (animator A2, audit A2) ----------
   Idle: both medallions breathe, out of step. Blast wind-up + lunge and the flinch are Web Animations
   (web/motion.js createHeroes). All of it uses the separate scale / translate / rotate properties, so it
   composes with the beam's kick (inline transform) and the mirror tilt. Compositor-only. */
/* #1572 msg 1765 (Silas: "why do the icons shift … based on the active player?"): the breathe moves the hero
   picture only, at the same pace on both turns, so the pills and the Super button on the rim never drift against
   the Boost badges. The turn shows by the glow alone. */
.ui-arena .ui-medal { --away: -1; }
.ui-arena .ui-medal--foe { --away: 1; }
.ui-arena .ui-medal > img { animation: hero-breathe 3.4s ease-in-out infinite; }
.ui-arena .ui-medal--foe > img { animation-delay: -1.7s; }
.ui-arena .ui-medal:is(.is-win, .is-lose) > img,
.ui-arena[data-layout="v2"]:is([data-variant="a"], [data-variant="c"]) .ui-medal > img:not([src*="-evolved"]) { animation: none; }
.ui-arena .ui-medal.is-win { animation: hero-win 1100ms var(--ease-pop) both, hero-cheer 1.6s ease-in-out 1100ms infinite; }
.ui-arena .ui-medal.is-lose { animation: hero-lose 900ms var(--ease-out) both; }
@keyframes hero-breathe { 0%, 100% { scale: 1; translate: 0 0; } 50% { scale: 1.022; translate: 0 -0.6%; } }
@keyframes hero-win {
  0% { scale: 1; translate: 0 0; rotate: 0deg; }
  25% { scale: 0.94 1.06; translate: 0 2%; }
  45% { scale: 1.12; translate: 0 -9%; rotate: calc(var(--away) * -4deg); }
  70% { scale: 1.04 0.97; translate: 0 0; rotate: calc(var(--away) * 3deg); }
  100% { scale: 1.08; translate: 0 -2%; rotate: 0deg; }
}
@keyframes hero-cheer { 0%, 100% { scale: 1.08; translate: 0 -2%; } 50% { scale: 1.11; translate: 0 -4.5%; } }
@keyframes hero-lose {
  0% { scale: 1; translate: 0 0; rotate: 0deg; opacity: 1; }
  30% { scale: 1.03; translate: 0 -2%; rotate: calc(var(--away) * 3deg); }
  100% { scale: 0.9; translate: calc(var(--away) * 3%) 6%; rotate: calc(var(--away) * 9deg); opacity: 0.82; }
}
@media (prefers-reduced-motion: reduce) {
  .ui-arena .ui-medal, .ui-arena .ui-medal.is-win, .ui-arena .ui-medal.is-lose { animation: none; }
}

/* ---------- Idle invites (animator A3, audit A3) ----------
   Between actions the table asks for a tap: legal cards hop one after another, the active hero breathes deeper,
   the "Your turn" chip bobs. translate / scale only (compositor; the static legal ring and the opacity glows from
   the perf block above stay as they are). The hop rests most of its cycle, so the table is calm, not busy. */
.ui-hand > .uc.is-legal, .ui-table__cards > .uc.is-legal, .ui-table .ui-card-back.is-legal {
  animation: invite-hop 2.8s var(--ease-out) calc(500ms + var(--i, 0) * 170ms) infinite;
}
.ui-table .ui-card-back.is-legal { --i: 4; }
.ui-hand > .uc.is-dragging, #game.is-card-dragging .uc { animation: none; } /* the card on the finger, and the rest while it moves */
:is(.ui-hand, .ui-table__cards, .rival-hand) > :nth-child(2) { --i: 1; }
:is(.ui-hand, .ui-table__cards, .rival-hand) > :nth-child(3) { --i: 2; }
:is(.ui-hand, .ui-table__cards, .rival-hand) > :nth-child(4) { --i: 3; }
:is(.ui-hand, .ui-table__cards, .rival-hand) > :nth-child(5) { --i: 4; }
:is(.ui-hand, .ui-table__cards, .rival-hand) > :nth-child(6) { --i: 5; }
:is(.ui-hand, .ui-table__cards, .rival-hand) > :nth-child(7) { --i: 6; }
:is(.ui-hand, .ui-table__cards, .rival-hand) > :nth-child(8) { --i: 7; }
@keyframes invite-hop {
  0%, 62%, 100% { translate: 0 0; scale: 1; }
  72% { translate: 0 -6%; scale: 1.035; }
  82% { translate: 0 0.8%; scale: 0.995; }
  90% { translate: 0 -1%; scale: 1.005; }
}
.ui-at-turn .ui-chip.is-pulse { animation: invite-chip 1.6s ease-in-out infinite; }
@keyframes invite-chip { 0%, 100% { scale: 1; } 50% { scale: 1.06; } }
@media (prefers-reduced-motion: reduce) {
  .ui-hand > .uc.is-legal, .ui-table__cards > .uc.is-legal, .ui-table .ui-card-back.is-legal, .ui-arena .ui-medal > img, .ui-at-turn .ui-chip.is-pulse { animation: none; }
}

/* ---------- Rival thinking (animator A5) ----------
   While the rival decides, its hand fidgets card by card and the turn chip's dots bounce. */
.rival-hand.is-thinking > * { animation: think-fidget 1.3s ease-in-out calc(var(--i, 0) * 120ms) infinite; }
@keyframes think-fidget { 0%, 55%, 100% { translate: 0 0; rotate: 0deg; } 25% { translate: 0 -22%; rotate: -6deg; } 40% { translate: 0 4%; rotate: 3deg; } }
.think-dots { display: inline-flex; gap: 3px; margin-left: 6px; align-items: flex-end; height: 0.9em; }
.think-dots i { width: 0.28em; height: 0.28em; border-radius: 50%; background: currentColor; animation: think-dot 1s ease-in-out infinite; }
.think-dots i:nth-child(2) { animation-delay: 150ms; }
.think-dots i:nth-child(3) { animation-delay: 300ms; }
@keyframes think-dot { 0%, 60%, 100% { translate: 0 0; opacity: 0.45; } 30% { translate: 0 -0.35em; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .rival-hand.is-thinking > *, .think-dots i { animation: none; }
}

/* ---------- Push above each hand card (U8 #1526, Silas) ----------
   The pill sits above the card's top edge, so hand cards stop clipping (as the picked card already did for its
   preview); the art keeps its rounded corners. The strongest card's pill is lit gold. */
.ui-hand > .uc { overflow: visible; }
.ui-hand > .uc > .uc-art { border-radius: inherit; }
.uc-top {
  position: absolute; z-index: 7; left: 50%; top: -0.5em; translate: -50% -100%;
  display: inline-flex; align-items: center; gap: 0.12em; height: 2em; padding: 0 0.55em 0 0.4em; white-space: nowrap;
  border-radius: 1em; background: var(--hud); color: var(--hud-ink); box-shadow: 0 0 0 0.12em var(--hud-line);
  font: 700 1em / 1 var(--font-number); pointer-events: none;
}
.uc-top .ui-icon { font-size: 1.05em; }
.uc-top b { font-size: 1.55em; line-height: 1; }
.uc-top.is-best { background: var(--spark); color: var(--ink); box-shadow: 0 0 0 0.14em var(--edge), var(--glow-gold); }
.uc-top.is-idle { opacity: 0.72; }
.uc.is-dim .uc-top { filter: none; }

/* ---------- Rival's last play (U1 #1518, Silas) ----------
   A small card just above the rival's end of the beam, by its medallion, tagged Blast or Boost. When it is the
   Last move it is the Super effective target: a gold strip under it names the elements that beat it. */
.ui-arena .ui-at-foe-hero { position: relative; }
.foe-last {
  position: absolute; right: calc(100% - 6px); bottom: calc(50% + 30px); z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: auto;
}
.foe-last > .uc { --w: clamp(48px, 4.6cqw, 64px); --r: -6deg; box-shadow: 0 0 0 2px var(--edge), var(--card-drop); }
.foe-last__tag {
  position: absolute; z-index: 2; top: -8px; left: -10px; display: grid; place-items: center; width: 24px; height: 24px;
  border-radius: 50%; background: var(--hud); color: var(--hud-ink); box-shadow: 0 0 0 2px var(--hud-line); font-size: 14px;
}
.foe-last__se {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 7px; border-radius: 999px;
  background: var(--spark); color: var(--ink); box-shadow: 0 0 0 2px var(--edge); font-size: 16px; white-space: nowrap;
}
.foe-last__se .beat-mark { color: var(--m, currentColor); }
.foe-last.is-target > .uc { box-shadow: 0 0 0 2px var(--edge), 0 0 0 5px var(--spark), var(--card-drop); }

/* ---------------------------------------------------------------------------
   U7 #1525: ability explainer side panel (web/explain.js). It slides in at the table side away from what it
   explains: hover a card / Boost / hero (mouse), or pick / tap it (touch). Below the picker (30) and moments (50).
   Transform + opacity only. */
.explain {
  position: absolute; z-index: 25; left: 0; top: 0; /* placed by explain.js with translate, beside its anchor */
  width: max-content; min-width: 150px; max-width: clamp(180px, 17vw, 236px);
  padding: 7px 9px 8px; border-radius: 11px;
  background: var(--hud); color: var(--hud-ink);
  box-shadow: inset 0 0 0 2px var(--hud-line), 0 8px 22px rgba(0, 0, 0, 0.45);
  font: var(--fw-body) 13px / 1.25 var(--font-body);
  pointer-events: none; opacity: 0; visibility: hidden; scale: 0.94;
  transition: opacity 0.14s ease-out, scale 0.16s var(--ease-out, ease-out), visibility 0s 0.16s;
}
.explain[data-side="right"] { transform-origin: 0 50%; }
.explain[data-side="left"] { transform-origin: 100% 50%; }
.explain[data-side="below"] { transform-origin: 50% 0; }
.explain[data-side="above"] { transform-origin: 50% 100%; }
.explain.is-open { opacity: 1; visibility: visible; scale: 1; transition-delay: 0s; }
.explain__head { display: flex; gap: 9px; align-items: center; margin-bottom: 7px; }
.explain__art {
  flex: none; width: 46px; aspect-ratio: 1; object-fit: cover; border-radius: 9px;
  background: var(--m, #fff2); box-shadow: inset 0 0 0 2px var(--line), 0 0 0 2px var(--m, transparent);
}
.explain__title { display: grid; gap: 4px; min-width: 0; }
.explain__title b { font: var(--fw-display) 17px / 1.05 var(--font-display); overflow-wrap: anywhere; }
.explain__title small { display: flex; align-items: center; gap: 4px; color: var(--hud-soft); font-weight: 800; font-size: 11px; }
.explain .ui-icon { flex: none; width: 1.25em; height: 1.25em; }
.explain__now {
  display: flex; align-items: center; gap: 6px; margin: 0 0 7px; padding: 5px 8px; border-radius: 8px;
  background: rgba(255, 180, 0, 0.16); box-shadow: inset 0 0 0 2px rgba(255, 180, 0, 0.55);
}
.explain__now > b { font: var(--fw-display) 21px / 1 var(--font-number); color: var(--gold); }
.explain__now > span { display: grid; font-weight: 800; }
.explain__now small { font-weight: 700; font-size: 10.5px; color: var(--hud-soft); }
.explain__sec { padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.explain__sec + .explain__sec { margin-top: 6px; }
.explain__sec h4 {
  display: flex; align-items: center; gap: 6px; margin: 0 0 4px;
  font: 900 10.5px / 1 var(--font-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--hud-soft);
}
.explain__sec.is-super h4 { color: var(--gold); letter-spacing: 0.04em; font-size: 12.5px; text-transform: none; }
.explain__line { display: flex; align-items: flex-start; gap: 6px; margin: 3px 0 0; }
.explain__line > .ui-icon { margin-top: 0.05em; }
.explain__line > .ui-icon + .ui-icon { margin-left: -4px; }
.explain__line > span { display: inline; }
.explain__line > span > .ui-icon { vertical-align: -0.2em; width: 1.1em; height: 1.1em; }
@media (prefers-reduced-motion: reduce) {
  .explain, .explain.is-open { scale: none; transition: opacity 0.12s linear, visibility 0s 0.12s; }
}

/* ---------------------------------------------------------------------------
   U6 #1524: the Boost zone as a pile of cards + summed power chips; a tap fans the faces out (.is-open).
   The pile's cards keep data-uid (A1 flights land on them) and --r (the landing matches the tilt). */
.ui-at-you-boosts.is-stacked, .ui-at-foe-boosts.is-stacked { display: flex; align-items: center; gap: 12px; }
.ui-at-foe-boosts.is-stacked { flex-direction: row-reverse; }
.ui-boosts[data-tap] { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; border-radius: 10px; }
.ui-boosts[data-tap]:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.bsum b { font: 800 15px / 1 var(--font-number); margin-left: 2px; }
.bsum .ui-icon + .ui-icon { margin-left: -2px; }
.is-stacked .boost-chips { flex-wrap: nowrap; max-width: 30cqw; }
/* explainer bits for the Boost zone */
.explain__badge { flex: none; display: grid; place-items: center; width: 46px; aspect-ratio: 1; border-radius: 12px; background: rgba(255, 255, 255, 0.1); box-shadow: inset 0 0 0 2px var(--hud-line); }
.explain__badge .ui-icon { width: 28px; height: 28px; }
.explain__line small { color: var(--hud-soft); font-weight: 800; }
.explain__minis { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.explain__mini { display: grid; justify-items: center; gap: 2px; width: 54px; min-width: 0; }
.explain__mini img { width: 38px; aspect-ratio: 1; border-radius: 50%; object-fit: cover; background: var(--l); box-shadow: 0 0 0 2px var(--line), 0 0 0 4px var(--m); }
.explain__mini small { max-width: 100%; font-size: 10px; font-weight: 800; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------------------
   U4b #1521: the Super Move button on your hero. A rainbow ring turns and pulses round the medallion while the
   Super can be used; the button on the rim opens a one-time confirm sheet. Compositor-only: the ring is a
   conic gradient masked to a band, animated by rotate + opacity + scale. */
.super-ring {
  position: absolute; inset: -30px; border-radius: 50%; pointer-events: none; z-index: -1;
  background: conic-gradient(from 0deg, #ff4d6d, #ffb400, #f7f72a, #3ddc84, #3db9e8, #7a5cff, #ff4dd8, #ff4d6d);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 16px), #000 calc(100% - 13px), #000 calc(100% - 4px), transparent);
          mask: radial-gradient(farthest-side, transparent calc(100% - 16px), #000 calc(100% - 13px), #000 calc(100% - 4px), transparent);
  filter: blur(1px) saturate(1.2);
  animation: super-spin 3.2s linear infinite, super-pulse 1.4s ease-in-out infinite;
}
/* the button: round, gold, a rainbow ring turning round it, where the Evolved badge was (Silas #1575) */
.super-btn {
  position: absolute; z-index: 3; right: -1%; top: -3%; width: 25%; aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; align-content: center; gap: 1px; isolation: isolate;
  font: var(--fw-display) calc(var(--size, 270px) * 0.05) / 1 var(--font-display); color: var(--gold-ink, #3a2400); cursor: pointer;
  background: radial-gradient(circle at 40% 30%, var(--gold-hi, #ffe27a), var(--gold) 60%, var(--gold-lip, #c77d00));
  box-shadow: 0 0 0 3px var(--edge, #2a1e2e), 0 4px 0 #7a4a00, 0 0 22px rgba(255, 180, 0, 0.7);
  animation: super-btn 1.4s ease-in-out infinite; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.super-btn::before {
  content: ""; position: absolute; inset: -11px; z-index: -1; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from 0deg, #ff4d6d, #ffb400, #f7f72a, #3ddc84, #3db9e8, #7a5cff, #ff4dd8, #ff4d6d);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 9px), #000 calc(100% - 7px), #000 calc(100% - 1px), transparent);
          mask: radial-gradient(farthest-side, transparent calc(100% - 9px), #000 calc(100% - 7px), #000 calc(100% - 1px), transparent);
  animation: super-spin 2.4s linear infinite;
}
.super-btn .ui-icon { width: 44%; height: 44%; }
.super-btn:active { scale: 0.94; }
.super-btn:focus-visible { outline: 4px solid var(--focus); outline-offset: 6px; }
/* #1572: one fixed spot each. The Super button keeps the top-right; the freeze badge on your hero takes the
   top-left (the rival's is there already). Not usable yet = dimmed and still, never hidden or moved. */
.ui-medal:not(.ui-medal--foe) .ui-medal__badge { right: auto; left: 2%; }
.super-btn.is-wait { cursor: default; filter: saturate(0.35) brightness(0.8); opacity: 0.75; animation: none; }
.super-btn.is-wait::before { opacity: 0.45; animation: none; }
.super-btn.is-wait:active { scale: 1; }
@keyframes super-btn { 0%, 100% { scale: 1; } 50% { scale: 1.08; } }
@keyframes super-spin { to { rotate: 1turn; } }
@keyframes super-pulse { 0%, 100% { opacity: 0.75; scale: 1; } 50% { opacity: 1; scale: 1.045; } }
/* the one-time confirm */
.super-ask {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(14, 8, 30, 0.62); animation: super-ask-in 0.18s ease-out both;
}
.super-ask__sheet {
  display: flex; align-items: center; gap: 22px; max-width: min(620px, 100%); padding: 22px 26px 22px 22px;
  border-radius: 22px; background: var(--hud); color: var(--hud-ink);
  box-shadow: inset 0 0 0 2px var(--hud-line), 0 0 0 4px var(--m), 0 20px 50px rgba(0, 0, 0, 0.55);
  animation: super-sheet-in 0.26s cubic-bezier(.2, 1.3, .4, 1) both;
}
.super-ask__hero { position: relative; flex: none; width: clamp(110px, 16vw, 160px); aspect-ratio: 1; isolation: isolate; }
.super-ask__hero > img { position: relative; z-index: 1; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--l); box-shadow: 0 0 0 4px var(--edge, #2a1e2e), 0 0 0 9px var(--m); }
.super-ask__hero > .super-ring { inset: -22px; z-index: 0; }
.super-ask__body { display: grid; gap: 6px; min-width: 0; }
.super-ask__body > small { display: flex; align-items: center; gap: 6px; font: 900 12px / 1 var(--font-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.super-ask__body > b { font: var(--fw-display) 30px / 1.05 var(--font-display); }
.super-ask__body .ui-icon { width: 1.25em; height: 1.25em; flex: none; }
.super-ask__once { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; font-weight: 800; font-size: 17px; }
.super-ask__btns { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.super-ask__btns .ui-action--super { --size: 96px; font-size: 17px; }
@keyframes super-ask-in { from { opacity: 0; } }
@keyframes super-sheet-in { from { opacity: 0; scale: 0.86; } }
@media (prefers-reduced-motion: reduce) {
  .super-ring { animation: none; } .super-btn, .super-btn::before { animation: none; }
  .super-ask, .super-ask__sheet { animation-duration: 0.01s; }
}

/* U5b #1523: the frozen turn's Discard button (sits where Blast was): icy, calm, clearly not an attack */
.ui-action--discard {
  background: radial-gradient(circle at 40% 30%, #f2fbff, var(--el-ice-light) 45%, #8fc9e6);
  color: var(--el-ice-ink); box-shadow: 0 0 0 4px var(--edge, #2a1e2e), 0 8px 0 #2d6a8a;
}
.ui-action--discard[disabled] { filter: saturate(0.4); opacity: 0.6; }

/* ---------------------------------------------------------------------------
   U6 Boost badges (#1572 D, approved msg 1817): round power badges, element-coloured, centered under the hero. */
.boost-chips[data-tap] { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; border-radius: 22px; }
/* 48 px touch target (verify-browser 8-touch-targets): the box grows by padding, the badges stay where they were */
.is-stacked .boost-chips[data-tap] { padding: 5px; margin: -5px; min-width: 48px; min-height: 48px; box-sizing: border-box; }
.boost-chips[data-tap]:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.is-stacked .boost-chips { gap: 4px; }
.is-stacked .bsum {
  height: auto; min-height: 0; width: 38px; aspect-ratio: 1; padding: 0; justify-content: center; border-radius: 50%; gap: 0;
  position: relative; background: var(--m, var(--hud)); color: var(--on, var(--hud-ink));
  box-shadow: 0 0 0 2px var(--line), 0 0 0 4px var(--hud-line), 0 3px 6px rgba(0, 0, 0, 0.4);
}
.is-stacked .boost-chips { justify-content: center; } /* #1572 msg 1802: centered under the hero */
.is-stacked .bsum .ui-icon { width: 22px; height: 22px; }
.is-stacked .bsum b {
  position: absolute; right: -6px; bottom: -4px; margin: 0; padding: 1px 4px; border-radius: 8px; font-size: 11px;
  background: var(--hud); color: var(--hud-ink); box-shadow: inset 0 0 0 1.5px var(--hud-line);
}

/* #1538: which elements beat this hero (a Blast of one is super effective on it), always in view on the rim top.
   Quiet HUD pill (the rival's gold SE strip is the loud one); element marks in their own colours. */
.hero-weak {
  position: absolute; z-index: 2; left: 50%; top: 0; translate: -50% -45%;
  display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px 3px 7px; border-radius: 999px;
  background: var(--hud); color: var(--spark); box-shadow: 0 0 0 2px var(--edge, #2a1e2e), inset 0 0 0 2px var(--hud-line);
  font-size: calc(var(--size, 270px) * 0.065); white-space: nowrap; pointer-events: none;
}
.hero-weak .beat-mark { color: var(--m, currentColor); display: inline-flex; }

/* #1568 msg 1735: three lines only. The math leads (big total), then the power and the Boost, one sentence each. */
.explain__math { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font-weight: 800; font-size: 13px; white-space: nowrap; }
.explain__math b { font: var(--fw-display) 20px / 1 var(--font-number); color: var(--gold); vertical-align: -1px; }
.explain__math .ui-icon { width: 1.3em; height: 1.3em; flex: none; }
.explain__line + .explain__line, .explain__math + .explain__line { margin-top: 5px; padding-top: 5px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.explain__line.is-note { color: var(--hud-soft); }
.explain > .explain__line:first-child { margin-top: 0; }
/* D (rim) Boost spaces: one quiet mark per space, filled per Boost card (the 3/4 cap without a number) */

/* #1572 msg 1810 (Silas: "BIGGER art … similar to the last played card … hyper legible"): the shield stands big in
   the battle area on the beam side of the hero (under the rival's last play), its number on its face. Gain, the
   beam striking it and the number dropping are cues.js (shield up / absorb); when it ends it fades out (.is-off). */
.ui-arena .ui-at-you-hero { position: relative; }
.big-shield {
  --sz: clamp(84px, 9.6cqw, 132px);
  position: absolute; z-index: 4; top: calc(50% - var(--sz) * 0.22); width: var(--sz); aspect-ratio: 1;
  display: grid; place-items: center; pointer-events: none;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.55));
}
.ui-at-you-hero .big-shield { left: 100%; translate: -42% 0; }
.ui-at-foe-hero .big-shield { right: 100%; translate: 42% 0; }
.big-shield__art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.big-shield > .ui-icon { position: absolute; inset: 4%; width: 92%; height: 92%; color: #5ed6c6; filter: drop-shadow(0 0 0 #fff) drop-shadow(0 0 6px rgba(94, 214, 198, 0.8)); }
.big-shield__art:not([hidden]) + .ui-icon { display: none; }
.big-shield__n {
  position: relative; top: calc(var(--sz) * -0.035); /* the art's plate: center (0.498, 0.467), 0.383 wide */
  font: 900 calc(var(--sz) * 0.34) / 1 var(--font-number, var(--font-display));
  color: #0f2a3a; text-shadow: 0 0 6px rgba(255, 255, 255, 0.85), 0 1px 0 #fff;
}
.big-shield.is-held ~ .big-shield:not(.is-held), .big-shield:not(.is-held):has(~ .big-shield.is-held:not(.is-leaving)) { opacity: 0; transition: none; }
.big-shield.is-held { z-index: 5; }
.big-shield.is-off { opacity: 0; scale: 0.72; transition: opacity 0.45s ease, scale 0.45s ease-in; }
@media (prefers-reduced-motion: reduce) { .big-shield.is-off { scale: 1; transition: opacity 0.25s linear; } }
