/* Ultra Beam Blasters — UI kit recipes (Artist-owned).
   Optional drop-in: <link rel="stylesheet" href="assets/ui/kit.css"> after theme.css,
   or copy the recipes into style.css. Uses only theme.css tokens. All classes start with .ui-
   Paths in url() are relative to this file (web/assets/ui/). See art/ui/README.md. */

/* ---------- Icons as CSS masks: colour = currentColor, no inline-SVG id clashes ----------
   Pick the icon with a class from icons.css (ui-i-<game key> or ui-i-ui-<ui icon>).
   Do not set --icon to a relative url() in inline styles or other sheets: browsers disagree on what
   a url() inside a custom property is relative to. */
.ui-icon {
  display: inline-block;
  width: 1em; height: 1em;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
          mask: var(--icon) center / contain no-repeat;
}
/* "Sticker" look for icons on busy or same-hue backgrounds: element colour + ink outline. */
.ui-sticker {
  filter: drop-shadow(1.5px 0 0 var(--ink)) drop-shadow(-1.5px 0 0 var(--ink))
          drop-shadow(0 1.5px 0 var(--ink)) drop-shadow(0 -1.5px 0 var(--ink));
}

/* ---------- Buttons ---------- */
.ui-btn {
  --lip-color: var(--accent-lip);
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: var(--btn-h); min-width: var(--btn-h);
  padding: 0 var(--btn-pad-x);
  margin-bottom: var(--btn-lip);              /* room for the lip so layout never jumps */
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font: var(--fw-display) var(--fs-lg) / 1 var(--font-display);
  letter-spacing: 0.01em;
  box-shadow: var(--hi-inset), var(--lip-accent);
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.ui-btn .ui-icon { font-size: 1.15em; }
.ui-btn:active, .ui-btn.is-pressed {
  transform: translateY(calc(var(--btn-lip) - 2px));
  box-shadow: var(--hi-inset), var(--lip-pressed);
}
.ui-btn:focus-visible { outline: 4px solid var(--focus); outline-offset: 4px; }

.ui-btn--lg { min-height: var(--btn-h-lg); font-size: var(--fs-xl); padding: 0 48px; }
.ui-btn--sm { min-height: var(--btn-h-sm); font-size: var(--fs-md); padding: 0 22px; }

.ui-btn--secondary {
  --lip-color: var(--secondary-lip);
  background: var(--surface); color: var(--ink);
  box-shadow: inset 0 4px 0 #fff, var(--lip-secondary);
}
.ui-btn--secondary:active, .ui-btn--secondary.is-pressed { box-shadow: inset 0 4px 0 #fff, var(--lip-pressed); }

.ui-btn--gold {
  --lip-color: var(--gold-lip);
  background: var(--gold); color: var(--gold-ink);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45), var(--lip-gold);
}
.ui-btn--gold:active, .ui-btn--gold.is-pressed { box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45), var(--lip-pressed); }

/* Round icon button */
.ui-btn--icon {
  width: var(--btn-icon); height: var(--btn-icon); min-height: 0; padding: 0;
  border-radius: 50%;
  font-size: 30px;
}
.ui-btn--icon.ui-btn--sm { width: var(--btn-icon-sm); height: var(--btn-icon-sm); font-size: 24px; }

/* Disabled: flat, no lip, sits where the pressed button would (no layout jump) */
.ui-btn:disabled, .ui-btn.is-disabled {
  background: var(--disabled-fill); color: var(--disabled-ink);
  border-color: var(--disabled-line);
  box-shadow: none;
  transform: translateY(calc(var(--btn-lip) - 2px));
  cursor: default; pointer-events: none;
}

/* ---------- Panels ---------- */
/* Cream panel (dialogs content, hero info) */
.ui-panel {
  background: var(--surface); color: var(--ink);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 4px 0 #fff, var(--shadow-md);
  padding: 16px 20px;
}
/* Plum panel that sits on the table (Wilds + discard area, track frame) */
.ui-panel--table {
  background: var(--table-2); color: var(--table-ink);
  border: var(--stroke) solid var(--table-line);
  box-shadow: inset 0 3px 0 var(--table-hi), var(--shadow-sm);
}
/* Player panel: cream capsule with an avatar circle that overhangs on the left */
.ui-player {
  display: flex; align-items: center; gap: 14px;
  min-height: calc(var(--avatar) - 8px);
  padding: 6px 18px 6px calc(var(--avatar) + 12px);
  position: relative;
  background: var(--surface); color: var(--ink);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-pill);
  box-shadow: inset 0 3px 0 #fff, var(--shadow-md);
  font: var(--fw-display) var(--fs-md) / 1.1 var(--font-display);
}
.ui-player__avatar {
  position: absolute; left: -6px; top: 50%; transform: translateY(-50%);
  width: var(--avatar); height: var(--avatar);
  border-radius: 50%;
  border: var(--stroke-bold) solid var(--ink);
  background: var(--el, var(--gold)) center / cover no-repeat;
  box-shadow: 0 0 0 3px var(--surface), var(--shadow-sm);
}
.ui-player--rival { --ring: var(--rival); }
.ui-player.is-active .ui-player__avatar { box-shadow: 0 0 0 3px var(--surface), var(--glow-gold); }

/* Card tray: the trough your hand sits in */
.ui-tray {
  background: var(--table-3);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--tray-inset);
  padding: 14px 18px 0;
}

/* Dialog / modal */
.ui-scrim {
  position: fixed; inset: 0;
  background: var(--scrim);
  display: grid; place-items: center;
}
.ui-dialog {
  position: relative;
  min-width: min(560px, 92vw);
  background: var(--surface); color: var(--ink);
  border: var(--stroke-bold) solid var(--ink);
  border-radius: 28px;
  box-shadow: inset 0 6px 0 #fff, var(--shadow-lg);
  padding: 56px 32px 28px;
  text-align: center;
  font: var(--fw-body) var(--fs-md) / 1.4 var(--font-body);
}
.ui-dialog__title {             /* ribbon header that overhangs the top edge */
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -55%);
  min-width: 70%;
}
.ui-dialog__close { position: absolute; right: -18px; top: -18px; }

/* ---------- Turn prompt pill ---------- */
.ui-turn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 26px 0 14px;
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-pill);
  font: var(--fw-display) var(--fs-lg) / 1 var(--font-display);
  box-shadow: var(--hi-inset), 0 4px 0 var(--ink);
}
.ui-turn .ui-icon { font-size: 30px; }
.ui-turn--you { background: var(--accent); color: var(--accent-ink); animation: ui-pulse 1.6s var(--ease-out) infinite; }
.ui-turn--rival { background: var(--rival); color: var(--rival-ink); }
@keyframes ui-pulse {
  0%, 100% { box-shadow: var(--hi-inset), 0 4px 0 var(--ink), 0 0 0 0 rgba(214, 47, 120, 0.55); }
  50% { box-shadow: var(--hi-inset), 0 4px 0 var(--ink), 0 0 0 12px rgba(214, 47, 120, 0); }
}

/* ---------- Big moments ---------- */
.ui-moment {
  position: relative;
  container-type: inline-size;
  display: grid; place-items: center;
  width: min(720px, 86vw); aspect-ratio: 800 / 496;
  background: url('banner-burst.svg') center / contain no-repeat;
}
.ui-moment--se    { background-image: url('banner-burst-fire.svg'); }
.ui-moment--rally { background-image: url('banner-burst-accent.svg'); }
.ui-moment--knock { background-image: url('banner-burst-water.svg'); }
.ui-moment--lose  { background-image: url('banner-burst-soft.svg'); }
.ui-moment.is-in  { animation: ui-moment-in var(--dur-slow) var(--ease-bounce) both; }
@keyframes ui-moment-in {
  from { transform: scale(0.3) rotate(-8deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
/* Display text: cream fill, thick ink outline, ink lip. */
.ui-shout {
  font: 700 clamp(40px, 7vw, 76px) / 0.95 var(--font-display);
  color: var(--surface);
  -webkit-text-stroke: var(--text-stroke) var(--ink);
  paint-order: stroke fill;
  text-shadow: var(--text-lip);
  text-align: center;
  letter-spacing: 0.01em;
}
.ui-moment .ui-shout { max-width: 62%; font-size: 9cqw; color: var(--ink); -webkit-text-stroke: 0; text-shadow: 0 3px 0 rgba(42, 30, 46, 0.18); }
.ui-moment > .ui-icon { font-size: 30cqw; color: var(--ink); }

/* Ribbon title (9-slice: tails fixed, middle stretches) */
.ui-ribbon {
  display: inline-grid; place-items: center;
  min-width: 360px; height: 120px;
  padding: 0 24px 22px;
  white-space: nowrap;
  border-style: solid; border-width: 0 102px; border-color: transparent;
  border-image: url('banner-ribbon.svg') 0 170 fill / 0 102px / 0 stretch;
  box-sizing: border-box;
}
.ui-ribbon .ui-shout { font-size: 52px; padding: 0; }
.ui-ribbon--accent { border-image-source: url('banner-ribbon-accent.svg'); }
.ui-ribbon--soft   { border-image-source: url('banner-ribbon-soft.svg'); }

/* ---------- End screens + pass-the-tablet cover ---------- */
.ui-end { position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 24px;
  background: var(--table) center / cover no-repeat; }
.ui-end--win  { background-image: url('win-bg.webp'); }
.ui-end--lose { background-image: url('lose-bg.webp'); }
.ui-cover { position: fixed; inset: 0; display: grid; place-items: end center; padding-bottom: 6vh;
  background: var(--table) url('cover.webp') center 30% / cover no-repeat; }

/* ---------- Room code ---------- */
.ui-code { display: inline-flex; gap: 16px; padding: 18px; background: var(--surface);
  border: var(--stroke) solid var(--ink); border-radius: 28px; box-shadow: inset 0 4px 0 #fff, var(--shadow-md); }
.ui-code-tile, .ui-key {
  --c: var(--surface-2); --c-lip: var(--secondary-lip); --c-ink: var(--ink);
  display: grid; place-items: center;
  width: var(--code-tile); height: var(--code-tile);
  margin-bottom: var(--btn-lip);
  background: var(--c); color: var(--c-ink);
  border: var(--stroke) solid var(--ink);
  border-radius: 24px;
  box-shadow: inset 0 5px 0 rgba(255, 255, 255, 0.4), 0 var(--btn-lip) 0 var(--c-lip);
  font: 700 64px / 1 var(--font-display);       /* letter codes */
}
.ui-code-tile .ui-icon, .ui-key .ui-icon { width: 62%; height: 62%; }
.ui-code-tile.is-empty { background: var(--surface-3); box-shadow: inset 0 6px 0 rgba(42, 30, 46, 0.15); margin-bottom: 0; transform: translateY(var(--btn-lip)); }
.ui-key { width: var(--key-tile); height: var(--key-tile); border-radius: 20px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: transform var(--dur-fast) var(--ease-out); }
.ui-key:active { transform: translateY(calc(var(--btn-lip) - 2px)); box-shadow: inset 0 5px 0 rgba(255,255,255,.4), 0 2px 0 var(--c-lip); }
/* Element colouring for tiles and keys: main fill, ink icon, ink lip */
.ui-el--fire     { --c: var(--el-fire);     --c-lip: var(--el-fire-ink);     --c-ink: var(--el-fire-light); }
.ui-el--ice      { --c: var(--el-ice);      --c-lip: var(--el-ice-ink);      --c-ink: var(--el-ice-ink); }
.ui-el--leaf     { --c: var(--el-leaf);     --c-lip: var(--el-leaf-ink);     --c-ink: var(--el-leaf-light); }
.ui-el--electric { --c: var(--el-electric); --c-lip: var(--el-electric-ink); --c-ink: var(--el-electric-ink); }
.ui-el--water    { --c: var(--el-water);    --c-lip: var(--el-water-ink);    --c-ink: #FFFFFF; }
.ui-el--rock     { --c: var(--el-rock);     --c-lip: var(--el-rock-ink);     --c-ink: var(--el-rock-light); }

@media (prefers-reduced-motion: reduce) {
  .ui-turn--you, .ui-moment.is-in { animation: none; }
}

/* =====================================================================
   FACE-OFF (direction B, approved 2026-11-21) — the game table.
   Dark arena lit by both heroes' colors, hero medallions facing off,
   a beam track between them, arched-window cards with a color foot.
   Full guide and markup: art/ui/README.md ("Face-Off table").
   Reference build: art/ui/faceoff.html -> art/lookdev/faceoff-review.png
   ===================================================================== */

/* ---------- Element scope ----------
   data-el="<element>" on any Face-Off part sets:
   --m main, --k ink, --l light, --on text on main, --pat motif (mask image). */
[data-el="fire"]     { --m: var(--el-fire);     --k: var(--el-fire-ink);     --l: var(--el-fire-light);     --on: var(--el-fire-on);     --pat: url('../icons/el-fire.svg'); }
[data-el="ice"]      { --m: var(--el-ice);      --k: var(--el-ice-ink);      --l: var(--el-ice-light);      --on: var(--el-ice-on);      --pat: url('../icons/el-ice.svg'); }
[data-el="leaf"]     { --m: var(--el-leaf);     --k: var(--el-leaf-ink);     --l: var(--el-leaf-light);     --on: var(--el-leaf-on);     --pat: url('../icons/el-leaf.svg'); }
[data-el="electric"] { --m: var(--el-electric); --k: var(--el-electric-ink); --l: var(--el-electric-light); --on: var(--el-electric-on); --pat: url('../icons/el-electric.svg'); }
[data-el="water"]    { --m: var(--el-water);    --k: var(--el-water-ink);    --l: var(--el-water-light);    --on: var(--el-water-on);    --pat: url('../icons/el-water.svg'); }
[data-el="rock"]     { --m: var(--el-rock);     --k: var(--el-rock-ink);     --l: var(--el-rock-light);     --on: var(--el-rock-on);     --pat: url('../icons/el-rock.svg'); }

/* Token position on the track, -7 (your wall) .. +7 (rival wall). Registered so it animates. */
@property --pos { syntax: '<number>'; inherits: true; initial-value: 0; }

/* ---------- Card ----------
   <div class="ui-card" data-el="electric" style="--w:180px">
     <div class="ui-card__art"><img src="assets/creatures/elec_staticcat.webp" alt=""></div>
     <span class="ui-card__el"><span class="ui-icon ui-i-el-electric"></span></span>
     <span class="ui-card__push">2</span>
     <span class="ui-card__fx"><span class="ui-icon ui-i-chain"></span></span>      (only if the Blast has an effect)
     <b class="ui-card__name">Fuzzbolt</b>
     <div class="ui-card__row">
       <span class="ui-card__beats"><span class="ui-icon ui-i-push"></span>
         <span data-el="water"><span class="ui-icon ui-i-el-water"></span></span>
         <span data-el="rock"><span class="ui-icon ui-i-el-rock"></span></span></span>
       <span class="ui-card__chip"><span class="ui-icon ui-i-boost"></span><span class="ui-icon ui-i-super-effective"></span>+1</span>
     </div>
   </div>
   Everything scales with --w (font-size = --w / 10). */
.ui-card {
  --w: 180px;
  position: relative; flex: none;
  width: var(--w); height: calc(var(--w) * 1.4);
  font-size: calc(var(--w) / 10);
  border-radius: 0.8em;
  background: var(--m, var(--rival));
  color: var(--on, var(--ink));
  box-shadow: 0 0 0 3px var(--edge), var(--card-drop);
  overflow: hidden;
  isolation: isolate;
  transform: translateY(var(--lift, 0)) rotate(var(--r, 0deg)) scale(var(--zoom, 1));
  transition: transform var(--dur-med) var(--ease-pop), box-shadow var(--dur-med) var(--ease-out), filter var(--dur-med) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.ui-card::before {                   /* element motif on the foot: the card reads with no color */
  content: ""; position: absolute; inset: -20%; z-index: -1;
  background: var(--k); opacity: 0.22;
  -webkit-mask: var(--pat) 0 0 / 1.25em 1.25em repeat;
          mask: var(--pat) 0 0 / 1.25em 1.25em repeat;
  transform: rotate(-12deg);
}
.ui-card__art {
  position: absolute; left: 0; right: 0; top: 0; height: 72%;
  overflow: hidden;
  border-radius: 0 0 50% 50% / 0 0 1.3em 1.3em;
  background: var(--l);
  box-shadow: 0 0.14em 0 var(--edge);
}
.ui-card__art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; }
.ui-card__el {
  position: absolute; left: 0.4em; top: 0.4em;
  width: 1.8em; height: 1.8em; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--l); color: var(--k);
  border: 0.12em solid var(--edge);
}
.ui-card__el .ui-icon { font-size: 1.05em; }
.ui-card__push {                     /* push number (creature) or element / Super Move icon (hero) */
  position: absolute; left: 0.38em; top: calc(72% - 1.25em);
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink);
  border: 0.14em solid var(--edge); box-shadow: 0 0.14em 0 var(--edge);
  font: 700 1.55em / 1 var(--font-number);
}
.ui-card__push { width: calc(2.5em / 1.55); height: calc(2.5em / 1.55); } /* 2.5 card-em, after the font change */
.ui-card__push .ui-icon { font-size: 0.85em; color: var(--k); }
.ui-card__fx {
  position: absolute; left: 2.55em; top: calc(72% - 0.1em);
  width: 1.5em; height: 1.5em; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--k);
  border: 0.11em solid var(--edge);
}
.ui-card__fx .ui-icon { font-size: 0.95em; }
.ui-card__name {
  position: absolute; left: 3em; right: 0.3em; top: calc(72% + 0.32em);
  font: 700 1em / 1.1 var(--font-display);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ui-card:has(.ui-card__fx) .ui-card__name { left: 4.25em; }
.ui-card__row {
  position: absolute; left: 0.42em; right: 0.42em; bottom: 0.42em;
  display: flex; justify-content: space-between; align-items: center; gap: 0.2em;
}
.ui-card__chip {
  display: inline-flex; align-items: center; gap: 0.16em;
  height: 1.4em; padding: 0 0.42em; border-radius: 0.7em;
  background: var(--surface); color: var(--ink);
  border: 0.09em solid var(--edge);
  font: 700 0.76em / 1 var(--font-display);
  white-space: nowrap;
}
.ui-card__chip .ui-icon { font-size: 1.05em; }
.ui-card__beats { display: inline-flex; align-items: center; gap: 0.1em; font-size: 0.78em; }
.ui-card__beats > [data-el] {
  width: 1.3em; height: 1.3em; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--l); color: var(--k);
  border: 0.08em solid var(--edge);
}
.ui-card__beats > [data-el] .ui-icon { font-size: 0.85em; }

/* Hero cards: put an el-<element> icon in __push; evolved: super-move icon, gold body. */
.ui-card.ui-card--evolved { --m: var(--gold); --on: var(--ink); }
/* Small cards (Wilds, deck, Last move; under ~150 px): keep badge, number, effect. */
.ui-card--sm .ui-card__name, .ui-card--sm .ui-card__row { display: none; }

/* States */
.ui-card.is-selected {
  --lift: -0.9em; --zoom: 1.05; --r: 0deg; z-index: 3;
  box-shadow: 0 0 0 3px var(--edge), 0 0 0 0.38em #fff, 0 0 2.4em 0.7em var(--m), var(--card-drop);
}
.ui-card.is-legal { box-shadow: 0 0 0 3px var(--edge), 0 0 0 0.3em var(--spark), var(--card-drop); animation: ui-legal 1.4s var(--ease-out) infinite; }
.ui-card.is-dim { filter: saturate(0.35) brightness(0.7); }
@keyframes ui-legal {
  0%, 100% { box-shadow: 0 0 0 3px var(--edge), 0 0 0 0.3em var(--spark), var(--card-drop); }
  50%      { box-shadow: 0 0 0 3px var(--edge), 0 0 0 0.3em var(--spark), 0 0 1.6em 0.4em rgba(255, 226, 122, 0.7), var(--card-drop); }
}

/* Card back (deck, rival hand, blind pick): the approved back J "Title Crest" (board #606).
   Files + contract: web/assets/frames/card-back.webp (2x up to 240 px) and card-back-sm.webp (under 70 px: add .is-sm);
   art/frames/README.md "Card back". The child icon (if any) is hidden: the art is the back. */
.ui-card-back {
  --w: 96px;
  position: relative; flex: none;
  display: grid; place-items: center;
  width: var(--w); height: calc(var(--w) * 1.4);
  font-size: calc(var(--w) / 10);
  border-radius: calc(var(--w) * 0.075);
  background: var(--arena-2) url("../frames/card-back.webp") center / 100% 100% no-repeat;
  box-shadow: 0 0 0 3px var(--edge), 0 0.6em 1.2em rgba(0, 0, 0, 0.5);
  transform: rotate(var(--r, 0deg));
}
.ui-card-back.is-sm { background-image: url("../frames/card-back-sm.webp"); }
.ui-card-back > .ui-icon { display: none; }

/* ---------- Arena (the whole game screen) ----------
   <main class="ui-arena" data-you="fire" data-foe="electric" style="--pos:2"> ... </main>
   Grid areas: you-plate turn foe-plate / you-hero beam foe-hero / you-hero table foe-hero /
               you-boosts table foe-boosts / tools hand actions.
   Put each part in its area with .ui-at-<area>. Sizes follow the arena (container units). */
.ui-arena {
  --you: var(--el-fire); --foe: var(--el-electric); --pos: 0;
  --t: calc((var(--pos) + 7.5) / 15 * 100%);          /* token as % of the beam */
  --clash: calc(28% + (var(--pos) + 7.5) / 15 * 44%); /* token as % of the arena */
  --medal: clamp(160px, min(21cqw, 33cqh), 270px);
  --hand-w: clamp(132px, 17cqw, 236px);
  --small-w: clamp(72px, 8.2cqw, 112px);
  position: relative; overflow: hidden;
  box-sizing: border-box;
  container-type: size;
  width: 100%; height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 27%) minmax(0, 1fr) minmax(0, 27%);
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  grid-template-areas:
    "you-plate turn  foe-plate"
    "you-hero  beam  foe-hero"
    "you-hero  table foe-hero"
    "you-boosts table foe-boosts"
    "tools     hand  actions";
  gap: 10px 16px; padding: 16px 20px;
  color: var(--hud-ink);
  font: var(--fw-body) var(--fs-md) / 1.2 var(--font-body);
  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%),
    linear-gradient(var(--arena-2), var(--arena-3));
  transition: --pos var(--dur-slow) var(--ease-pop);
}
.ui-arena::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 22px); }
.ui-arena::after  { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 36%; pointer-events: none; background: linear-gradient(to bottom, transparent, rgba(8, 4, 16, 0.75) 45%); }
.ui-arena > * { position: relative; z-index: 1; min-width: 0; }
.ui-arena[data-you="fire"]     { --you: var(--el-fire); }     .ui-arena[data-foe="fire"]     { --foe: var(--el-fire); }
.ui-arena[data-you="ice"]      { --you: var(--el-ice); }      .ui-arena[data-foe="ice"]      { --foe: var(--el-ice); }
.ui-arena[data-you="leaf"]     { --you: var(--el-leaf); }     .ui-arena[data-foe="leaf"]     { --foe: var(--el-leaf); }
.ui-arena[data-you="electric"] { --you: var(--el-electric); } .ui-arena[data-foe="electric"] { --foe: var(--el-electric); }
.ui-arena[data-you="water"]    { --you: var(--el-water); }    .ui-arena[data-foe="water"]    { --foe: var(--el-water); }
.ui-arena[data-you="rock"]     { --you: var(--el-rock); }     .ui-arena[data-foe="rock"]     { --foe: var(--el-rock); }
.ui-at-you-plate { grid-area: you-plate; } .ui-at-turn  { grid-area: turn; }  .ui-at-foe-plate { grid-area: foe-plate; }
.ui-at-you-hero  { grid-area: you-hero; }  .ui-at-beam  { grid-area: beam; }  .ui-at-foe-hero  { grid-area: foe-hero; }
.ui-at-you-boosts { grid-area: you-boosts; } .ui-at-table { grid-area: table; } .ui-at-foe-boosts { grid-area: foe-boosts; }
.ui-at-tools     { grid-area: tools; }     .ui-at-hand  { grid-area: hand; }  .ui-at-actions   { grid-area: actions; }
.ui-at-you-hero, .ui-at-foe-hero { display: grid; place-items: center; padding: 20px 0; }
.ui-at-turn { display: grid; justify-items: center; align-content: start; gap: 6px; }
.ui-at-tools { display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: 8px; }
.ui-at-actions { display: grid; justify-items: end; align-content: end; gap: 14px; }

/* Small caps label over a zone ("Wilds", "Your Boosts") */
.ui-label { display: inline-flex; white-space: nowrap; align-items: center; gap: 6px; font: 900 12px / 1 var(--font-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--hud-soft); }
.ui-label .ui-icon { font-size: 16px; }

/* ---------- HUD plate (top corners) ----------
   <div class="ui-plate"><div class="ui-plate__who"><small>You</small><b>Scorchy</b></div> … </div>
   Add .ui-plate--foe to mirror it. */
.ui-plate {
  display: flex; align-items: center; gap: 12px;
  min-height: 66px; padding: 0 16px;
  border-radius: 16px;
  background: var(--hud); color: var(--hud-ink);
  box-shadow: inset 0 0 0 2px var(--hud-line);
}
.ui-plate--foe { flex-direction: row-reverse; text-align: right; }
.ui-plate__who { display: grid; gap: 3px; margin-right: auto; }
.ui-plate--foe .ui-plate__who { margin: 0 0 0 auto; }
.ui-plate__who small { font: 900 11px / 1 var(--font-body); letter-spacing: 0.16em; text-transform: uppercase; color: var(--hud-soft); }
.ui-plate__who b { font: 700 24px / 1 var(--font-display); white-space: nowrap; }

/* Evolve pips: 3 element-shaped pips, lit for each home-element Boost.
   <span class="ui-pips" data-el="fire"><i class="ui-icon ui-i-el-fire is-on"></i>… x3</span> */
.ui-pips { display: inline-flex; gap: 4px; align-items: center; }
.ui-pips .ui-icon { font-size: 24px; color: rgba(255, 255, 255, 0.25); }
.ui-pips .ui-icon.is-on { color: var(--m); filter: drop-shadow(0 0 6px var(--m)); }

/* Chips: status, "Your turn", Super Move ready, Last move counters */
.ui-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.1); color: var(--hud-ink);
  font: 700 15px / 1 var(--font-display); white-space: nowrap;
}
.ui-chip .ui-icon { font-size: 18px; }
.ui-chip--gold { background: var(--gold); color: var(--gold-ink); }
.ui-chip--hud  { background: var(--hud); box-shadow: inset 0 0 0 2px var(--hud-line); }
.ui-chip--lg   { height: 38px; padding: 0 16px; font-size: 18px; border-radius: 19px; }
.ui-chip.is-pulse { animation: ui-chip-pulse 1.6s var(--ease-out) infinite; }
@keyframes ui-chip-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 180, 0, 0.6); } 50% { box-shadow: 0 0 0 10px rgba(255, 180, 0, 0); } }

/* ---------- Hero medallion ----------
   <div class="ui-medal" data-el="fire"><img src="assets/heroes/fire-normal.webp" alt=""></div>
   .ui-medal--foe mirrors the art so the heroes face each other.
   .is-active = it is this player's turn. Evolved: add <span class="ui-medal__badge"><i class="ui-icon ui-i-evolve"></i></span>.
   .is-frozen = cannot Blast next play. .is-shielded = shield is up. */
.ui-medal {
  --size: var(--medal, 270px);
  position: relative; flex: none;
  width: var(--size); height: var(--size); border-radius: 50%;
  background: var(--l);
  box-shadow: 0 0 0 5px var(--edge), 0 0 0 13px var(--m), 0 0 0 17px var(--edge), 0 0 70px 10px var(--m);
}
.ui-medal > img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.ui-medal--foe > img { transform: scaleX(-1); }
.ui-medal.is-active { animation: ui-medal-glow 1.8s ease-in-out infinite; }
@keyframes ui-medal-glow {
  0%, 100% { box-shadow: 0 0 0 5px var(--edge), 0 0 0 13px var(--m), 0 0 0 17px var(--edge), 0 0 60px 6px var(--m); }
  50%      { box-shadow: 0 0 0 5px var(--edge), 0 0 0 13px var(--m), 0 0 0 17px var(--edge), 0 0 100px 22px var(--m); }
}
.ui-medal__badge {                   /* put an icon in it: evolve (crown), freeze, shield */
  position: absolute; right: 2%; top: 0; width: 21%; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; font-size: calc(var(--size) * 0.12);
  background: var(--gold); color: var(--gold-ink);
  box-shadow: 0 0 0 4px var(--edge), 0 0 20px rgba(255, 180, 0, 0.8);
}
.ui-medal--foe .ui-medal__badge { right: auto; left: 2%; }
.ui-medal.is-frozen::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: 1;
  background: linear-gradient(160deg, rgba(221, 244, 255, 0.75), rgba(61, 185, 232, 0.35) 60%, rgba(221, 244, 255, 0.6));
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.85);
}
.ui-medal.is-shielded { box-shadow: 0 0 0 5px var(--edge), 0 0 0 13px var(--m), 0 0 0 17px var(--edge), 0 0 0 24px rgba(255, 248, 236, 0.16), 0 0 0 27px rgba(255, 248, 236, 0.75), 0 0 70px 10px var(--m); }

/* ---------- Boosts (under each medallion, max 4) ----------
   <div class="ui-boosts"><span class="ui-boost" data-el="fire"><img …></span> … <span class="ui-boost is-empty"></span></div> */
.ui-boosts { display: flex; gap: 8px; }
.ui-boost {
  --size: clamp(44px, 4.8cqw, 60px);
  width: var(--size); height: var(--size); flex: none; border-radius: 50%;
  overflow: hidden; background: var(--l);
  box-shadow: 0 0 0 3px var(--edge), 0 0 0 6px var(--m);
}
.ui-boost img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ui-boost.is-empty { background: transparent; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.28); outline: 2px dashed rgba(255, 255, 255, 0.28); outline-offset: 3px; }
.ui-at-foe-boosts .ui-boosts, .ui-boosts--foe { justify-content: flex-end; }

/* ---------- Beam track ----------
   <div class="ui-beam"><div class="ui-beam__rail"></div><div class="ui-beam__cells"></div><div class="ui-beam__token"></div></div>
   Reads --pos (-7..+7), --you and --foe from the arena. Change --pos and the beam animates.
   Cells, Rally zones (2 cells at each end) and both rays are drawn by CSS. */
.ui-beam {
  --t: calc((var(--pos) + 7.5) / 15 * 100%);
  position: relative; height: 64px; align-self: center;
  isolation: isolate;
  margin: 0 4px;
}
.ui-beam::before, .ui-beam::after { content: ""; position: absolute; z-index: 1; top: 18px; height: 28px; border-radius: 14px; }
.ui-beam::before { left: 0; width: var(--t); background: linear-gradient(90deg, var(--you), color-mix(in srgb, var(--you) 45%, #fff)); box-shadow: 0 0 24px var(--you); }
.ui-beam::after  { right: 0; left: var(--t); background: linear-gradient(90deg, color-mix(in srgb, var(--foe) 35%, #fff), var(--foe)); box-shadow: 0 0 24px var(--foe); }
.ui-beam__rail { position: absolute; z-index: 0; left: 0; right: 0; top: 14px; height: 36px; border-radius: 18px; background: var(--hud); box-shadow: inset 0 0 0 2px var(--hud-line); }
.ui-beam__cells {
  position: absolute; left: 0; right: 0; top: 22px; height: 20px; z-index: 2;
  background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 30 - 12px), rgba(255, 255, 255, 0.22) calc(100% / 30 - 12px) calc(100% / 30 + 12px), transparent calc(100% / 30 + 12px) calc(100% / 15));
  border-radius: 6px;
}
.ui-beam__cells::before, .ui-beam__cells::after {   /* Rally zones */
  content: ""; position: absolute; top: -6px; bottom: -6px; width: calc(200% / 15 - 6px);
  border-radius: 10px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}
.ui-beam__cells::before { left: 3px; }
.ui-beam__cells::after  { right: 3px; }
.ui-beam__token {
  position: absolute; z-index: 3; left: var(--t); top: -6px;
  width: 76px; height: 76px; margin-left: -38px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 30%, #FFF4C2 45%, rgba(255, 220, 120, 0) 72%);
}
.ui-beam__token::before {
  content: ""; position: absolute; inset: -26px; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.75) 0 4deg, transparent 4deg 22deg);
  -webkit-mask: radial-gradient(circle, transparent 30%, #000 32%, transparent 70%);
          mask: radial-gradient(circle, transparent 30%, #000 32%, transparent 70%);
  animation: ui-spin 9s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }
.ui-beam__labels { display: flex; justify-content: space-between; margin-top: 2px; }

/* ---------- Table center: Deck · Wilds · Last move ---------- */
.ui-table { display: flex; align-items: flex-start; justify-content: center; gap: 14px; }
.ui-table__zone { display: grid; gap: 8px; justify-items: start; }
.ui-table__cards { display: flex; gap: 10px; }
.ui-table .ui-card, .ui-table .ui-card-back { --w: var(--small-w, 96px); }
.ui-table__last .ui-card { --r: 7deg; }

/* ---------- Hand ---------- */
.ui-hand { display: flex; justify-content: center; align-items: flex-end; padding-bottom: 8px; }
.ui-hand > .ui-card { --w: var(--hand-w, 180px); margin: 0 calc(var(--hand-w, 180px) * -0.025); }
.ui-hand > .ui-card:first-child:not(:last-child) { --r: -6deg; --lift: 0.6em; }
.ui-hand > .ui-card:last-child:not(:first-child)  { --r: 6deg;  --lift: 0.6em; }
/* :nth-child(n) lifts this above the first/last fan rules, so a selected end card still straightens and lifts. */
.ui-hand > .ui-card.is-selected:nth-child(n) { --r: 0deg; --lift: -0.9em; }
.ui-hand-wrap { position: relative; display: grid; justify-items: center; align-content: end; }
.ui-hand-wrap > .ui-math { margin-bottom: calc(var(--hand-w, 180px) * 0.16); z-index: 4; }

/* Push preview over the selected card: <span class="ui-math">2 + <i class="ui-icon ui-i-super-effective"></i> 1 = <b>3</b></span> */
.ui-math {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 6px 0 16px; border-radius: 19px;
  background: var(--hud); color: var(--hud-ink);
  box-shadow: 0 0 0 2px rgba(255, 226, 122, 0.55);
  font: 700 20px / 1 var(--font-display); white-space: nowrap;
}
.ui-math .ui-icon { color: var(--spark); font-size: 20px; }
.ui-math b { display: inline-grid; place-items: center; min-width: 32px; height: 28px; padding: 0 8px; border-radius: 12px; background: var(--spark); color: var(--ink); font-size: 22px; }

/* ---------- Arcade action buttons (bottom right) ----------
   <button class="ui-action ui-action--blast"><i class="ui-icon ui-i-blast"></i><span>Blast 3</span></button> */
.ui-action {
  --size: 146px;
  -webkit-appearance: none; appearance: none; border: 0;
  width: var(--size); height: var(--size); border-radius: 50%;
  display: grid; place-items: center; align-content: center; gap: 4px;
  font: 700 22px / 1 var(--font-display); text-align: center;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.ui-action .ui-icon { font-size: calc(var(--size) * 0.3); }
.ui-action--blast { background: radial-gradient(circle at 40% 30%, #FF7A9E, var(--accent) 60%, #9E1352); color: #fff; box-shadow: 0 0 0 4px var(--edge), 0 9px 0 #6E0B37, 0 0 40px rgba(214, 47, 120, 0.6); }
.ui-action--boost  { --size: 104px; font-size: 19px; background: radial-gradient(circle at 40% 30%, #fff, var(--surface-2)); color: var(--ink); box-shadow: 0 0 0 4px var(--edge), 0 7px 0 #A8916C; }
.ui-action--super { --size: 120px; font-size: 19px; background: radial-gradient(circle at 40% 30%, var(--gold-hi), var(--gold) 60%, var(--gold-lip)); color: var(--gold-ink); box-shadow: 0 0 0 4px var(--edge), 0 8px 0 #7A4A00, 0 0 40px rgba(255, 180, 0, 0.6); }
.ui-action:active { transform: translateY(6px); box-shadow: 0 0 0 4px var(--edge), 0 2px 0 var(--edge); }
.ui-action:focus-visible { outline: 4px solid var(--focus); outline-offset: 6px; }
.ui-action:disabled { background: #3A3150; color: rgba(255, 255, 255, 0.4); box-shadow: 0 0 0 4px var(--edge); transform: translateY(6px); cursor: default; }

/* Round dark icon button for the arena corners (menu, log, sound) */
.ui-btn--hud { width: 52px; height: 52px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 50%;
  background: var(--hud); color: var(--hud-ink); box-shadow: inset 0 0 0 2px var(--hud-line); font-size: 24px; }
.ui-btn--hud:active { transform: scale(0.94); box-shadow: inset 0 0 0 2px var(--hud-line); }

/* ---------- Versus moment: super effective (full screen, --dur-moment) ----------
   <div class="ui-versus is-in" data-a="electric" data-d="water">
     <div class="ui-versus__a"><img src="assets/creatures/elec_staticcat.webp" alt=""></div>
     <div class="ui-versus__d"><img src="assets/creatures/water_splashfrog.webp" alt=""></div>
     <div class="ui-versus__title">Super effective!</div>
     <div class="ui-versus__foot"> plate · ui-math ui-math--lg · plate </div>
   </div>
   Attacker (a) is lit on the left; defender (d) is dimmed on the right. Add .ui-versus--flip when the rival attacks. */
.ui-versus {
  --a: var(--el-fire); --d: var(--el-water);
  --cut-top: 60%; --cut-bot: 44%;
  position: fixed; inset: 0; overflow: hidden; z-index: 50;
  container-type: size;
  background: var(--arena-3);
}
.ui-versus[data-a="fire"] { --a: var(--el-fire); }   .ui-versus[data-d="fire"] { --d: var(--el-fire); }
.ui-versus[data-a="ice"] { --a: var(--el-ice); }     .ui-versus[data-d="ice"] { --d: var(--el-ice); }
.ui-versus[data-a="leaf"] { --a: var(--el-leaf); }   .ui-versus[data-d="leaf"] { --d: var(--el-leaf); }
.ui-versus[data-a="electric"] { --a: var(--el-electric); } .ui-versus[data-d="electric"] { --d: var(--el-electric); }
.ui-versus[data-a="water"] { --a: var(--el-water); } .ui-versus[data-d="water"] { --d: var(--el-water); }
.ui-versus[data-a="rock"] { --a: var(--el-rock); }   .ui-versus[data-d="rock"] { --d: var(--el-rock); }
.ui-versus::before {                 /* attacker half: color, rays */
  content: ""; position: absolute; inset: 0;
  clip-path: polygon(0 0, var(--cut-top) 0, var(--cut-bot) 100%, 0 100%);
  background:
    repeating-conic-gradient(from 0deg at 28% 50%, rgba(255, 255, 255, 0.22) 0 3deg, transparent 3deg 12deg),
    radial-gradient(circle at 28% 50%, color-mix(in srgb, var(--a) 25%, #fff), var(--a) 45%, color-mix(in srgb, var(--a) 70%, #000));
}
.ui-versus::after {                  /* defender half: dimmed */
  content: ""; position: absolute; inset: 0;
  clip-path: polygon(var(--cut-top) 0, 100% 0, 100% 100%, var(--cut-bot) 100%);
  background: radial-gradient(circle at 76% 55%, color-mix(in srgb, var(--d) 55%, #fff), var(--d) 50%, color-mix(in srgb, var(--d) 55%, #000));
  filter: saturate(0.7) brightness(0.8);
}
.ui-versus > * { position: absolute; z-index: 1; }
.ui-versus__a { left: -1cqw; top: 13cqh; width: 54cqw; aspect-ratio: 1; z-index: 2;
  -webkit-mask: radial-gradient(circle, #000 58%, transparent 71%); mask: radial-gradient(circle, #000 58%, transparent 71%); }
.ui-versus__d { right: 1cqw; top: 26cqh; width: 41cqw; aspect-ratio: 1; transform: rotate(10deg);
  filter: saturate(0.6) brightness(0.8);
  -webkit-mask: radial-gradient(circle, #000 56%, transparent 70%); mask: radial-gradient(circle, #000 56%, transparent 70%); }
.ui-versus__a img, .ui-versus__d img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ui-versus__d img { transform: scaleX(-1); }
.ui-versus__seam { inset: 0; z-index: 3; pointer-events: none; background: url('versus-seam.svg') center / 100% 100% no-repeat; }
.ui-versus__title {
  left: 50%; top: 5cqh; z-index: 4; transform: translateX(-50%) rotate(-5deg);
  padding: 10px 36px 16px; border-radius: 16px;
  background: var(--accent); color: #fff;
  box-shadow: 0 0 0 6px var(--edge), 0 12px 0 var(--edge);
  font: 700 clamp(48px, 7.2cqw, 96px) / 1 var(--font-display); white-space: nowrap;
  -webkit-text-stroke: 8px var(--edge); paint-order: stroke fill;
}
.ui-versus__foot { left: 3cqw; right: 3cqw; bottom: 4cqh; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ui-math--lg { height: 96px; padding: 0 12px 0 28px; border-radius: 24px; gap: 14px; font-size: 40px; box-shadow: 0 0 0 3px var(--edge), inset 0 0 0 2px var(--hud-line); background: rgba(14, 8, 28, 0.9); }
.ui-math--lg .ui-icon { font-size: 38px; }
.ui-math--lg b { min-width: 64px; height: 64px; font-size: 44px; border-radius: 16px; }
/* Rival attacks: attacker on the right */
.ui-versus--flip { --cut-top: 40%; --cut-bot: 56%; }
.ui-versus--flip::before { clip-path: polygon(var(--cut-top) 0, 100% 0, 100% 100%, var(--cut-bot) 100%);
  background:
    repeating-conic-gradient(from 0deg at 72% 50%, rgba(255, 255, 255, 0.22) 0 3deg, transparent 3deg 12deg),
    radial-gradient(circle at 72% 50%, color-mix(in srgb, var(--a) 25%, #fff), var(--a) 45%, color-mix(in srgb, var(--a) 70%, #000)); }
.ui-versus--flip::after { clip-path: polygon(0 0, var(--cut-top) 0, var(--cut-bot) 100%, 0 100%);
  background: radial-gradient(circle at 24% 55%, color-mix(in srgb, var(--d) 55%, #fff), var(--d) 50%, color-mix(in srgb, var(--d) 55%, #000)); }
.ui-versus--flip .ui-versus__a { left: auto; right: -1cqw; }
.ui-versus--flip .ui-versus__a img { transform: scaleX(-1); }
.ui-versus--flip .ui-versus__d { right: auto; left: 1cqw; transform: rotate(-10deg); }
.ui-versus--flip .ui-versus__d img { transform: none; }
.ui-versus--flip .ui-versus__seam { transform: scaleX(-1); }
/* Entrance */
.ui-versus.is-in::before { animation: ui-vs-l var(--dur-slow) var(--ease-out) both; }
.ui-versus.is-in::after  { animation: ui-vs-r var(--dur-slow) var(--ease-out) both; }
.ui-versus.is-in .ui-versus__a { animation: ui-vs-l var(--dur-slow) var(--ease-pop) both; }
.ui-versus.is-in .ui-versus__d { animation: ui-vs-r var(--dur-slow) var(--ease-pop) both; }
.ui-versus.is-in .ui-versus__title { animation: ui-vs-title var(--dur-slow) var(--ease-bounce) 160ms both; }
@keyframes ui-vs-l { from { translate: -60% 0; } to { translate: 0 0; } }
@keyframes ui-vs-r { from { translate: 60% 0; } to { translate: 0 0; } }
@keyframes ui-vs-title { from { scale: 0.2; opacity: 0; } to { scale: 1; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .ui-arena { transition: none; }
  .ui-card, .ui-card.is-legal, .ui-medal.is-active, .ui-chip.is-pulse, .ui-beam__token::before { animation: none; transition: none; }
  .ui-versus.is-in::before, .ui-versus.is-in::after, .ui-versus.is-in > * { animation: none; }
}
