/* ==========================================================================
   ESA ARCADE - Menu screens and global chrome
   Top bar + BACK, cabinet bezel, CRT overlay, pixel arrows, Mode Select,
   Character Select, VS, Game Library, modals (pause / confirm), mascot.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Global top bar - one consistent BACK control in the same place on
   every non-game screen.
   -------------------------------------------------------------------------- */
#topbar {
  position: fixed;
  top: 18px;
  left: 22px;
  right: 22px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#topbar.is-hidden { display: none; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px 0 14px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold-100);
  background: linear-gradient(180deg, var(--x-143a63-a95), var(--x-071728-a95));
  border: 2px solid var(--gold-500);
  box-shadow: 0 4px 0 var(--x-3a2a08), 0 10px 20px var(--x-000000-a40), inset 0 1px 0 var(--x-ffffff-a12);
  transition: transform .12s var(--ease-out), background .12s, box-shadow .12s;
}
.back-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, var(--x-1d4e80-a98), var(--x-0a2039-a98));
  box-shadow: 0 6px 0 var(--x-3a2a08), 0 14px 24px var(--x-000000-a45), 0 0 18px var(--x-f3c35a-a30);
}
.back-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--x-3a2a08); }
.back-btn .px-arrow { --px: 3px; color: var(--gold-400); }
.back-btn .keycap { height: 24px; min-width: 38px; font-size: 10px; letter-spacing: .14em; box-shadow: 0 2px 0 var(--x-030b16-a90); }

.topbar-crumb {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sound toggle */
.sound-btn {
  margin-left: auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--gold-300);
  background: var(--x-0a2039-a80);
  border: 1px solid var(--x-f3c35a-a30);
  transition: color .15s, border-color .15s, background .15s;
}
/* The way out on a browser too old for the ☰ menu; the bar it sits in is hidden during a match. */
.home-btn {
  margin-left: auto;
  display: grid;
  place-items: center;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--gold-300);
  background: var(--x-0a2039-a80);
  border: 1px solid var(--x-f3c35a-a30);
  font: 700 13px/1 var(--font-display);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
}
.home-btn:hover { color: var(--cream); border-color: var(--gold-400); background: var(--x-143a63-a90); }
.home-btn + .sound-btn { margin-left: 0; }
@supports selector(:popover-open) {
  .home-btn { display: none; }
  .home-btn + .sound-btn { margin-left: auto; }
}
@supports not selector(:popover-open) {
  body > .side-menu { display: none; }
}
.sound-btn:hover { color: var(--cream); border-color: var(--gold-400); background: var(--x-143a63-a90); }
.sound-btn svg { width: 20px; height: 20px; fill: currentColor; }
.sound-btn .icon-off { display: none; }
.sound-btn.is-muted { color: var(--muted-dim); }
.sound-btn.is-muted .icon-on { display: none; }
.sound-btn.is-muted .icon-off { display: block; }

/* --------------------------------------------------------------------------
   Cabinet bezel - a gold frame with marquee bulbs around the viewport.
   -------------------------------------------------------------------------- */
#bezel {
  position: fixed;
  inset: 8px;
  z-index: 1;
  pointer-events: none;
  border: 1px solid var(--x-f3c35a-a22);
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px var(--x-030b16-a60), inset 0 0 60px var(--x-000000-a35);
}
.bz-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 2px solid var(--gold-500);
  opacity: .75;
}
.bz-corner.tl { top: 6px; left: 6px; border-right: 0; border-bottom: 0; border-top-left-radius: 10px; }
.bz-corner.tr { top: 6px; right: 6px; border-left: 0; border-bottom: 0; border-top-right-radius: 10px; }
.bz-corner.bl { bottom: 6px; left: 6px; border-right: 0; border-top: 0; border-bottom-left-radius: 10px; }
.bz-corner.br { bottom: 6px; right: 6px; border-left: 0; border-top: 0; border-bottom-right-radius: 10px; }

.bezel-bulbs {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -4px;
  display: flex;
  justify-content: space-between;
}
.bezel-bulbs i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--x-ffe9a8);
  opacity: .28;
  box-shadow: 0 0 8px var(--x-ffe9a8-a60);
}
/* Chase only in attract mode - menus stay calm while people are using them. */
body.is-attract .bezel-bulbs i {
  animation: bulbChase 1.4s steps(1) infinite;
  animation-delay: calc(var(--i) * -.1s);
}
@keyframes bulbChase {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: .22; }
}
body.is-gameplay #bezel { opacity: .5; }
body.is-gameplay .bezel-bulbs { display: none; }

/* --------------------------------------------------------------------------
   CRT overlay - static scanlines + curvature vignette. Off during play.
   -------------------------------------------------------------------------- */
#crt {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background:
    repeating-linear-gradient(180deg, var(--x-000000-a16) 0 1px, transparent 1px 3px),
    radial-gradient(130% 110% at 50% 50%, transparent 62%, var(--x-000000-a32) 100%);
  opacity: .55;
  mix-blend-mode: multiply;
}
body.is-gameplay #crt { display: none; }

/* --------------------------------------------------------------------------
   Shared menu primitives
   -------------------------------------------------------------------------- */
/* Chunky pixel arrow built from stacked squares. --px = pixel size. */
.px-arrow {
  --px: 4px;
  position: relative;
  display: inline-block;
  width: calc(var(--px) * 4);
  height: calc(var(--px) * 7);
  flex: none;
  color: var(--gold-400);
}
.px-arrow::before {
  content: "";
  position: absolute;
  width: var(--px);
  height: var(--px);
  background: currentColor;
  left: 0;
  top: calc(var(--px) * 3);
  box-shadow:
    var(--px) calc(var(--px) * -1) 0 currentColor, var(--px) 0 0 currentColor, var(--px) var(--px) 0 currentColor,
    calc(var(--px) * 2) calc(var(--px) * -2) 0 currentColor, calc(var(--px) * 2) calc(var(--px) * -1) 0 currentColor,
    calc(var(--px) * 2) 0 0 currentColor, calc(var(--px) * 2) var(--px) 0 currentColor, calc(var(--px) * 2) calc(var(--px) * 2) 0 currentColor,
    calc(var(--px) * 3) calc(var(--px) * -3) 0 currentColor, calc(var(--px) * 3) calc(var(--px) * -2) 0 currentColor,
    calc(var(--px) * 3) calc(var(--px) * -1) 0 currentColor, calc(var(--px) * 3) 0 0 currentColor,
    calc(var(--px) * 3) var(--px) 0 currentColor, calc(var(--px) * 3) calc(var(--px) * 2) 0 currentColor,
    calc(var(--px) * 3) calc(var(--px) * 3) 0 currentColor;
}
.px-arrow.right { transform: scaleX(-1); }

.screen-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.screen-head .px-arrow { animation: arrowNudge 1.6s var(--ease-in-out) infinite; }
.screen-head .px-arrow.right { animation-name: arrowNudgeR; }
@keyframes arrowNudge { 0%, 100% { translate: 0 0; } 50% { translate: 5px 0; } }
@keyframes arrowNudgeR { 0%, 100% { translate: 0 0; } 50% { translate: -5px 0; } }

.screen-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 3.6vw, 44px);
  font-weight: 700;
  letter-spacing: .14em;
  margin-right: -.14em;
  line-height: 1;
  text-transform: uppercase;
  background: linear-gradient(180deg, var(--x-fffaf0) 10%, var(--gold-300) 55%, var(--gold-600));
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 var(--x-030b16-a80));
}
.screen-sub {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: .04em;
}

.nav-hint {
  text-align: center;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted-dim);
}
.nav-hint b { color: var(--gold-400); font-weight: 700; }

/* --------------------------------------------------------------------------
   MODE SELECT
   -------------------------------------------------------------------------- */
.mode-inner {
  width: min(1060px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(14px, 3vh, 30px);
}
.screen.is-active .mode-inner > * { animation: riseIn .5s var(--ease-out) backwards; }
.screen.is-active .mode-inner > :nth-child(2) { animation-delay: .08s; }
.screen.is-active .mode-inner > :nth-child(3) { animation-delay: .16s; }

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(16px, 3vw, 40px);
}

.mode-card {
  --accent: var(--gold-400);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  min-height: 0;
  border-radius: 20px 20px 14px 14px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--x-102f52), var(--x-06121f) 70%);
  border: 2px solid var(--x-f3c35a-a28);
  box-shadow: 0 10px 0 var(--x-020810), 0 26px 50px var(--x-000000-a50);
  transform: translateY(0) scale(.97);
  opacity: .72;
  transition: transform .26s var(--ease-out), opacity .26s, border-color .26s, box-shadow .26s, filter .26s;
}
.mode-card[data-mode="tournament"] { --accent: var(--x-ffd36b); }
.mode-card.is-focus {
  opacity: 1;
  transform: translateY(-8px) scale(1);
  border-color: var(--gold-400);
  box-shadow: 0 14px 0 var(--x-020810), 0 34px 60px var(--x-000000-a55), 0 0 46px var(--x-f3c35a-a30);
}

.mc-marquee {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2.2vh, 20px) 16px clamp(10px, 1.8vh, 16px);
  background: linear-gradient(180deg, var(--gold-300), var(--gold-600));
  border-bottom: 3px solid var(--x-5c400c);
}
.mc-title {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(28px, 3.8vw, 46px);
  font-weight: 700;
  letter-spacing: .16em;
  margin-right: -.16em;
  text-transform: uppercase;
  color: var(--x-2a1a02);
  text-shadow: 0 2px 0 var(--x-fff6e4-a55);
  line-height: 1;
}
.mc-bulbs {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 5px;
  height: 4px;
  background-image: radial-gradient(circle, var(--cream) 1.6px, transparent 2.2px);
  background-size: 14px 4px;
  opacity: .5;
}
.mode-card.is-focus .mc-bulbs { animation: bulbsMarch .6s steps(2) infinite; opacity: 1; }
@keyframes bulbsMarch { to { background-position: 14px 0; } }

.mc-screen {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(110px, 24vh, 230px);
  margin: clamp(10px, 2vh, 18px) clamp(12px, 2vw, 22px) 0;
  border-radius: 14px;
  background:
    repeating-linear-gradient(180deg, var(--x-ffffff-a3) 0 1px, transparent 1px 3px),
    radial-gradient(80% 90% at 50% 40%, var(--x-f3c35a-a18), transparent 70%),
    var(--navy-900);
  border: 2px solid var(--x-000000-a60);
  box-shadow: inset 0 0 30px var(--x-000000-a80), 0 0 0 1px var(--x-f3c35a-a18);
}
.mc-screen svg { width: 52%; height: 78%; filter: drop-shadow(0 8px 14px var(--x-000000-a60)); }
.mode-card.is-focus .mc-screen svg { animation: artIdle 2.2s var(--ease-in-out) infinite; }
@keyframes artIdle {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-7px) rotate(3deg); }
}

.mc-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: clamp(10px, 2vh, 18px) 18px 4px;
  font-size: clamp(13px, 1.3vw, 15px);
  font-weight: 600;
  color: var(--x-c4d4e5);
}
.mc-lines .mc-count {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--gold-400);
}
.mc-cta {
  margin: clamp(8px, 1.6vh, 14px) auto clamp(12px, 2.2vh, 20px);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--gold-300);
  opacity: 0;
}
.mode-card.is-focus .mc-cta { opacity: 1; animation: arcadeBlink 1.05s steps(1) infinite; }

/* Selection: the chosen cabinet flashes and surges, the other bows out. */
#modeGrid.is-choosing .mode-card:not(.is-chosen) { opacity: 0; transform: translateY(30px) scale(.9); }
.mode-card.is-chosen { animation: chosenSurge .56s var(--ease-out) forwards; }
.mode-card.is-chosen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cream);
  mix-blend-mode: overlay;
  animation: chosenFlash .5s ease-out forwards;
  pointer-events: none;
}
@keyframes chosenSurge {
  0%   { transform: translateY(-8px) scale(1); }
  30%  { transform: translateY(-14px) scale(1.06); }
  100% { transform: translateY(-10px) scale(1.04); }
}
@keyframes chosenFlash {
  0%, 30% { opacity: .9; }
  15%, 45% { opacity: .1; }
  100% { opacity: 0; }
}

/* --------------------------------------------------------------------------
   CHARACTER SELECT - fighter-game layout that scales from 2 to 24+.
   -------------------------------------------------------------------------- */
.cs-inner {
  width: min(1280px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 20px);
}
.cs-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(200px, 22vw, 300px) 1fr clamp(200px, 22vw, 300px);
  gap: clamp(12px, 2vw, 28px);
}

/* --- Player side panels ------------------------------------------------- */
.cs-side {
  --slot: var(--p1);
  --cc: var(--gold-400);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 0;
  padding: 12px 12px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--slot) 16%, var(--navy-800)), var(--x-050f1d) 75%);
  border: 2px solid color-mix(in srgb, var(--slot) 55%, transparent);
  box-shadow: 0 8px 0 var(--x-020810), 0 20px 40px var(--x-000000-a45);
  transition: border-color .2s, box-shadow .2s;
}
.cs-side.is-locked {
  border-color: var(--gold-400);
  box-shadow: 0 8px 0 var(--x-020810), 0 20px 40px var(--x-000000-a45), 0 0 34px var(--x-f3c35a-a35);
}
.cs-side.just-locked { animation: lockPunch .45s var(--ease-back); }
@keyframes lockPunch {
  0% { transform: scale(1); }
  35% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.cs-side-head {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.slot-tag {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--x-ffffff);
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--slot);
  box-shadow: 0 3px 0 var(--x-000000-a45);
}
.cs-state {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--muted);
  animation: arcadeBlink 1.2s steps(1) infinite;
}
.cs-side.is-locked .cs-state { color: var(--gold-300); animation: none; }

.cs-portrait {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.cs-portrait-glow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 4%;
  height: 70%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--cc) 55%, transparent), transparent 68%);
  opacity: .7;
}
.cs-art {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px var(--x-000000-a55));
  animation: idleBob 3.2s ease-in-out infinite;
}
.cs-portrait.is-swap .cs-art { animation: portraitSwap .28s var(--ease-out), idleBob 3.2s ease-in-out .28s infinite; }
.cs-side[data-slot="p2"] .cs-art { transform: scaleX(-1); }
@keyframes idleBob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}
@keyframes portraitSwap {
  from { opacity: 0; translate: 0 14px; filter: brightness(2.2) drop-shadow(0 12px 18px var(--x-000000-a55)); }
  to { opacity: 1; translate: 0 0; }
}
.cs-side.is-locked .cs-art { animation: none; filter: drop-shadow(0 0 16px var(--x-f3c35a-a55)) drop-shadow(0 12px 18px var(--x-000000-a55)); }

.cs-stamp {
  position: absolute;
  left: 50%;
  bottom: 18%;
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 700;
  letter-spacing: .14em;
  white-space: nowrap;
  text-transform: uppercase;
  color: var(--x-2a1a02);
  background: linear-gradient(180deg, var(--x-fde7ae), var(--gold-500));
  border: 2px solid var(--x-5c400c);
  border-radius: 8px;
  box-shadow: 0 4px 0 var(--x-5c400c), 0 10px 20px var(--x-000000-a50);
  transform: translateX(-50%) rotate(-8deg) scale(0);
  opacity: 0;
}
.cs-side.is-locked .cs-stamp { animation: stampIn .34s var(--ease-back) forwards; }
@keyframes stampIn {
  0% { opacity: 0; transform: translateX(-50%) rotate(-8deg) scale(2.2); }
  100% { opacity: 1; transform: translateX(-50%) rotate(-8deg) scale(1); }
}

.cs-name {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.6vw, 32px);
  font-weight: 700;
  letter-spacing: .14em;
  margin-right: -.14em;
  text-transform: uppercase;
  color: var(--cream);
  line-height: 1;
}
.cs-side.is-locked .cs-name { color: var(--gold-300); }
.cs-tagline { font-size: 12px; color: var(--muted); text-align: center; min-height: 1.3em; }
.cs-keys {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.cs-keys .keycap { height: 24px; font-size: 10px; min-width: 0; padding: 0 7px; }
.cs-change { visibility: hidden; min-height: 30px; }
.cs-side.is-locked .cs-change { visibility: visible; }

/* --- Selected, waiting for Confirm ------------------------------------- */
.cs-side.is-pending {
  border-color: var(--gold-300);
  animation: pendingGlow 1.1s ease-in-out infinite;
}
@keyframes pendingGlow {
  0%, 100% { box-shadow: 0 8px 0 var(--x-020810), 0 20px 40px var(--x-000000-a45), 0 0 10px var(--x-f3c35a-a25); }
  50% { box-shadow: 0 8px 0 var(--x-020810), 0 20px 40px var(--x-000000-a45), 0 0 28px var(--x-f3c35a-a60); }
}
.cs-side.is-pending .cs-state { color: var(--gold-300); }
.cs-side.is-pending .cs-art { scale: 1.07; transform-origin: 50% 100%; }
.cs-confirm {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 10px;
  z-index: 3;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 9px 8px 8px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--x-0c243e-a96), var(--x-040e1a-a97));
  border: 2px solid var(--gold-400);
  box-shadow: 0 6px 0 var(--x-020810), 0 14px 26px var(--x-000000-a55);
}
.cs-side.is-pending .cs-confirm { display: flex; }
/* The ask line names the fighter, so the panel's own text steps aside. */
.cs-side.is-pending .cs-name,
.cs-side.is-pending .cs-tagline,
.cs-side.is-pending .cs-keys { visibility: hidden; }
.cs-confirm.is-in { animation: confirmIn .22s var(--ease-back); }
.cs-confirm.is-nudge { animation: confirmNudge .32s ease-out; }
@keyframes confirmIn { from { opacity: 0; transform: translateY(10px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes confirmNudge { 0%, 100% { transform: none; } 30% { transform: scale(1.05); } 60% { transform: scale(.98); } }
.cs-ask {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  line-height: 1.15;
}
.cs-ask b { color: var(--gold-300); font-size: 16px; }
.cs-confirm-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: 100%; }
.cs-confirm-row .btn { flex: 1 1 auto; min-width: 0; padding: 0 10px; }
.cs-confirm-keys { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cs-confirm-keys .keycap { height: 18px; font-size: 9px; min-width: 0; padding: 0 5px; }

/* Roster tile that is selected but not yet confirmed. */
.cs-tile.pending-p1 .cs-tile-img, .cs-tile.pending-p2 .cs-tile-img {
  border-color: var(--gold-300);
  animation: tilePending 1s ease-in-out infinite;
}
@keyframes tilePending {
  0%, 100% { box-shadow: 0 5px 0 var(--x-020810), 0 0 8px var(--x-f3c35a-a30); }
  50% { box-shadow: 0 5px 0 var(--x-020810), 0 0 22px var(--x-f3c35a-a75); }
}
.cs-tile.pending-p1 .cs-tile-img::after, .cs-tile.pending-p2 .cs-tile-img::after {
  content: "Selected";
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--x-2a1a02);
  background: linear-gradient(180deg, var(--x-fde7ae), var(--gold-500));
  box-shadow: 0 3px 0 var(--x-000000-a50);
  pointer-events: none;
}

/* Short "LOCKED IN" flash after Confirm. */
.cs-lockflash {
  position: absolute;
  left: -6px;
  right: -6px;
  top: 38%;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, transparent, var(--x-040e1a-a92) 18%, var(--x-040e1a-a92) 82%, transparent);
  border-top: 2px solid var(--gold-400);
  border-bottom: 2px solid var(--gold-400);
}
.cs-lf-who { font-family: var(--font-display); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--cream); }
.cs-lf-word {
  font-family: var(--font-display);
  font-size: clamp(18px, 2.2vw, 26px);
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold-300);
  text-shadow: 0 0 14px var(--x-f3c35a-a70);
}
.cs-lockflash.is-on { animation: lockFlash .95s ease-out forwards; }
@keyframes lockFlash {
  0% { opacity: 0; transform: scaleX(.3); filter: brightness(2.4); }
  18% { opacity: 1; transform: scaleX(1.04); filter: brightness(1.6); }
  30% { transform: none; filter: none; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-side.is-pending, .cs-tile.pending-p1 .cs-tile-img, .cs-tile.pending-p2 .cs-tile-img { animation: none; }
}

/* --- Roster grid -------------------------------------------------------- */
.cs-roster-wrap {
  min-height: 0;
  min-width: 0;
  display: grid;
  place-items: center;
  /* V4.1: the roster grows in ROWS. Never a horizontal scrollbar: the
     stable gutter means a vertical scrollbar can no longer steal width
     from tiles that were sized before it appeared. */
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.cs-roster, .ps-roster {
  --tile: 140px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), var(--tile));
  gap: 12px;
  justify-content: center;
  align-content: center;
}

.cs-tile {
  --cc: var(--gold-400);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
}
.cs-tile-img {
  position: relative;
  display: block;
  width: var(--tile);
  height: var(--tile);
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--cc) 45%, var(--navy-600)), var(--navy-800) 75%);
  border: 3px solid var(--x-ffffff-a10);
  box-shadow: 0 5px 0 var(--x-020810);
  transition: transform .14s var(--ease-out), border-color .14s, box-shadow .14s;
}
.cs-tile-name {
  font-family: var(--font-display);
  font-size: clamp(11px, calc(var(--tile) * .11), 16px);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
@media (hover: hover) {
  .cs-tile:hover .cs-tile-img { transform: translateY(-3px); border-color: var(--x-f3c35a-a50); }
}

.cs-cursor {
  position: absolute;
  top: -9px;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--x-ffffff);
  box-shadow: 0 3px 0 var(--x-000000-a50);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .12s, transform .12s var(--ease-back);
}
.cs-cursor.p1 { left: -6px; background: var(--p1); }
.cs-cursor.p2 { right: -6px; background: var(--p2); }
.cs-tile.has-p1 .cs-cursor.p1, .cs-tile.has-p2 .cs-cursor.p2 { opacity: 1; transform: none; }
/* Selection states only recolour / glow - they never resize or move a card. */
.cs-tile.has-p1 .cs-tile-img { border-color: var(--p1); }
.cs-tile.has-p2 .cs-tile-img { border-color: var(--p2); }
.cs-tile.has-p1.has-p2 .cs-tile-img {
  border-color: transparent;
  background-clip: padding-box;
  box-shadow: 0 5px 0 var(--x-020810), 0 0 0 3px var(--p1), 6px 0 0 0 var(--p2);
}
.cs-tile.has-p1 .cs-tile-name, .cs-tile.has-p2 .cs-tile-name { color: var(--cream); }
.cs-tile.locked-p1 .cs-tile-img, .cs-tile.locked-p2 .cs-tile-img {
  border-color: var(--gold-400);
  box-shadow: 0 5px 0 var(--x-020810), 0 0 22px var(--x-f3c35a-a55);
}
.cs-tile.locked-p1 .cs-cursor.p1::after, .cs-tile.locked-p2 .cs-cursor.p2::after { content: " ✓"; }

#charSelectScreen.is-ready .cs-stage { animation: readyPulse .7s ease-out; }
@keyframes readyPulse {
  0% { filter: brightness(1); }
  25% { filter: brightness(1.5); }
  100% { filter: brightness(1); }
}

/* --------------------------------------------------------------------------
   VS PRESENTATION
   -------------------------------------------------------------------------- */
.vs-screen { padding: 0; overflow: hidden; }
.vs-half {
  --cc: var(--gold-400);
  position: absolute;
  top: 0;
  bottom: 0;
  width: 56%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 7vh;
  overflow: hidden;
}
.vs-half.p1 {
  left: 0;
  clip-path: polygon(0 0, 100% 0, 82% 100%, 0 100%);
  background:
    repeating-linear-gradient(115deg, var(--x-ffffff-a4) 0 2px, transparent 2px 14px),
    linear-gradient(110deg, color-mix(in srgb, var(--cc) 70%, var(--navy-900)), var(--navy-900) 85%);
}
.vs-half.p2 {
  right: 0;
  clip-path: polygon(18% 0, 100% 0, 100% 100%, 0 100%);
  background:
    repeating-linear-gradient(65deg, var(--x-ffffff-a4) 0 2px, transparent 2px 14px),
    linear-gradient(250deg, color-mix(in srgb, var(--cc) 70%, var(--navy-900)), var(--navy-900) 85%);
}
.vs-art-wrap { flex: 1; min-height: 0; display: flex; align-items: flex-end; justify-content: center; width: 100%; }
.vs-art { max-height: 74vh; max-width: 80%; object-fit: contain; filter: drop-shadow(0 16px 22px var(--x-000000-a55)); }
.vs-half.p2 .vs-art { transform: scaleX(-1); }
.vs-plate { display: flex; align-items: baseline; gap: 12px; margin-top: 8px; }
.vs-slot {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--x-ffffff);
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--p1);
}
.vs-half.p2 .vs-slot { background: var(--p2); }
.vs-name {
  font-family: var(--font-display);
  font-size: clamp(36px, 6vw, 76px);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: 0 5px 0 var(--x-030b16-a80);
}
.vs-center {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  z-index: 2;
}
/* WHITE-SQUARE FIX (V4.1): the emblem and the VS word no longer carry CSS
   filters while they scale / rotate in. A filtered layer being composited
   mid-animation (drop-shadow on the 1254px emblem; drop-shadow over
   background-clip:text on the VS word) could briefly paint its bounding
   box as a pale square. The glow is now a plain radial-gradient disc
   behind the emblem, and the VS word's hard shadow + glow is a separate
   solid-colour copy underneath it. Same look, genuine transparency. */
.vs-emblem { width: clamp(150px, 24vh, 240px); opacity: .35; }
.vs-glow {
  position: absolute;
  width: clamp(230px, 36vh, 360px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--x-f3c35a-a30), var(--x-f3c35a-a8) 45%, transparent 68%);
  pointer-events: none;
}
.vs-word-sh {
  position: absolute;
  font-family: var(--font-display);
  font-size: clamp(90px, 15vw, 190px);
  font-weight: 700;
  font-style: italic;
  letter-spacing: .02em;
  color: var(--x-3a2a08);
  translate: 0 6px;
  text-shadow: 0 0 40px var(--x-f3c35a-a60);
  pointer-events: none;
}
.vs-word {
  position: absolute;
  font-family: var(--font-display);
  font-size: clamp(90px, 15vw, 190px);
  font-weight: 700;
  font-style: italic;
  letter-spacing: .02em;
  background: linear-gradient(180deg, var(--x-fffaf0) 10%, var(--gold-300) 50%, var(--gold-600));
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.vs-flash {
  position: absolute;
  inset: 0;
  background: var(--cream);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.vs-screen.is-playing .vs-half.p1 { animation: vsInLeft .5s var(--ease-out) backwards; }
.vs-screen.is-playing .vs-half.p2 { animation: vsInRight .5s var(--ease-out) backwards; }
.vs-screen.is-playing .vs-art { animation: vsArt .7s var(--ease-out) .12s backwards; }
.vs-screen.is-playing .vs-half.p2 .vs-art { animation-name: vsArtR; }
.vs-screen.is-playing .vs-word, .vs-screen.is-playing .vs-word-sh { animation: vsSlam .42s var(--ease-back) .38s backwards; }
.vs-screen.is-playing .vs-glow { animation: vsEmblem 1s ease-out .38s backwards; }
.vs-screen.is-playing .vs-emblem { animation: vsEmblem 1s ease-out .38s backwards; }
.vs-screen.is-playing .vs-flash { animation: vsFlash .5s ease-out .4s; }
@keyframes vsInLeft { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes vsInRight { from { transform: translateX(100%); } to { transform: none; } }
@keyframes vsArt { from { opacity: 0; translate: -60px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes vsArtR { from { opacity: 0; translate: 60px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes vsSlam { from { opacity: 0; transform: scale(3) rotate(-8deg); } to { opacity: 1; transform: none; } }
@keyframes vsEmblem { from { opacity: 0; transform: scale(.4) rotate(-30deg); } to { opacity: .35; transform: none; } }
@keyframes vsFlash { 0% { opacity: .75; } 100% { opacity: 0; } }

/* --------------------------------------------------------------------------
   GAME LIBRARY - an arcade floor of cabinets you walk past.
   -------------------------------------------------------------------------- */
.lib-inner {
  width: min(1240px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.4vh, 14px);
}
.lib-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.matchup {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--x-05101f-a75);
  border: 1px solid var(--x-f3c35a-a30);
}
.mu-side { display: flex; align-items: center; gap: 10px; }
.mu-face {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--x-e9ddc6);
  border: 2px solid var(--cc);
  flex: none;
}
.mu-face img { width: 100%; height: 100%; object-fit: cover; }
.mu-name {
  display: flex;
  flex-direction: column;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--cream);
  line-height: 1.05;
}
.mu-side.p2 .mu-name { text-align: right; }
.mu-name small { font-size: 9px; letter-spacing: .24em; color: var(--muted); }
.mu-vs { font-family: var(--font-display); font-style: italic; font-size: 15px; color: var(--gold-400); }

.lib-head { gap: 16px; }
.lib-count {
  font-family: var(--font-digits);
  font-size: 14px;
  letter-spacing: .14em;
  color: var(--gold-300);
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--x-020810);
  border: 1px solid var(--x-f3c35a-a30);
  box-shadow: inset 0 0 8px var(--x-f3c35a-a18);
}

.lib-floor {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
}
.lib-carousel {
  --card-w: clamp(250px, min(26vw, 44vh), 340px);
  --spread: calc(var(--card-w) * .92);
  position: relative;
  flex: 1;
  height: 100%;
  perspective: 1200px;
}

.cabinet {
  --accent: var(--gold-400);
  --off: 0;
  --abs: 0;
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--card-w);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  text-align: center;
  border-radius: 18px 18px 12px 12px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--x-0f2c4c), var(--x-050f1d) 72%);
  border: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: 0 8px 0 var(--x-020810), 0 22px 44px var(--x-000000-a50);
  transform:
    translate(-50%, -50%)
    translateX(calc(var(--off) * var(--spread)))
    rotateY(calc(var(--off) * -24deg))
    scale(calc(1 - var(--abs) * .17));
  z-index: calc(10 - var(--abs));
  filter: brightness(calc(1 - var(--abs) * .3)) saturate(calc(1 - var(--abs) * .25));
  transition: transform .42s var(--ease-out), filter .42s var(--ease-out), opacity .3s, box-shadow .3s, border-color .3s;
}
.cabinet.is-hidden { opacity: 0; pointer-events: none; }
.cabinet.is-center {
  border-color: var(--accent);
  box-shadow: 0 10px 0 var(--x-020810), 0 30px 60px var(--x-000000-a60),
              0 0 50px color-mix(in srgb, var(--accent) 45%, transparent);
}
.cabinet:not(.is-center):hover { filter: brightness(calc(1.1 - var(--abs) * .25)); }

.cab-marquee {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 16px 12px 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 85%, var(--cream)), color-mix(in srgb, var(--accent) 70%, var(--x-1a0f00)));
  border-bottom: 3px solid var(--x-000000-a45);
}
.cab-bulbs {
  position: absolute;
  top: 5px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
}
.cab-bulbs i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cream);
  opacity: .4;
}
.cabinet.is-center .cab-bulbs i { animation: bulbChase .9s steps(1) infinite; }
.cabinet.is-center .cab-bulbs i:nth-child(odd) { animation-delay: -.45s; }
.cab-no {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .3em;
  color: var(--x-1a0f00-a70);
}
.cab-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--x-1a0f00);
  text-shadow: 0 1px 0 var(--x-fff6e4-a60);
  line-height: 1;
}

.cab-screen {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(96px, 20vh, 170px);
  margin: 12px 14px 0;
  border-radius: 12px;
  background:
    repeating-linear-gradient(180deg, var(--x-ffffff-a4b) 0 1px, transparent 1px 3px),
    radial-gradient(70% 80% at 50% 45%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 72%),
    var(--x-020810);
  border: 2px solid var(--x-000000-a70);
  box-shadow: inset 0 0 28px var(--x-000000-a90);
}
.cab-art { width: 58%; height: 72%; display: grid; place-items: center; }
.cab-art svg, .cab-art img { width: 100%; height: 100%; object-fit: contain; overflow: visible; filter: drop-shadow(0 8px 12px var(--x-000000-a60)); }
.cabinet.is-center .cab-art .art-move { animation: artIdle 1.8s var(--ease-in-out) infinite; }
.cab-mode {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--x-020810-a85);
}

.cab-desc {
  padding: 10px 16px 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--x-a9bdd2);
  min-height: 3.2em;
}
.cab-panel {
  display: flex;
  flex-wrap: wrap;            /* 5-key schemes (Air Hockey) drop to two rows */
  justify-content: center;
  gap: 6px 12px;
  margin: 10px 12px 0;
  padding: 9px 8px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--x-0b2240), var(--x-061529));
  border: 1px solid var(--x-ffffff-a6);
}
.cab-ctrl { display: flex; align-items: center; gap: 4px; }
.cab-ctrl .who {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--x-ffffff);
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--p1);
  margin-right: 2px;
}
.cab-ctrl + .cab-ctrl .who { background: var(--p2); }
.cab-ctrl .keycap { min-width: 22px; height: 22px; font-size: 10px; padding: 0 4px; }

.cab-play {
  margin: 10px auto 14px;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--gold-300);
  opacity: 0;
}
.cabinet.is-center .cab-play { opacity: 1; animation: arcadeBlink 1.05s steps(1) infinite; }

.px-nav {
  position: relative;
  z-index: 20;
  width: 52px;
  height: 64px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--x-071728-a85);
  border: 2px solid var(--x-f3c35a-a45);
  box-shadow: 0 5px 0 var(--x-020810);
  transition: transform .12s, border-color .12s, background .12s;
}
.px-nav:hover { border-color: var(--gold-400); background: var(--x-143a63-a95); transform: translateY(-2px); }
.px-nav:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--x-020810); }
.px-nav .px-arrow { --px: 4px; }

.lib-dots { display: flex; justify-content: center; gap: 8px; min-height: 10px; }
.lib-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  transform: rotate(45deg);
  background: var(--x-ffffff-a14);
  border: 1px solid var(--x-f3c35a-a30);
  transition: background .2s, box-shadow .2s;
}
.lib-dot.is-on { background: var(--gold-400); box-shadow: 0 0 10px var(--x-f3c35a-a70); }

/* --------------------------------------------------------------------------
   MODALS - pause menu, confirmations, standings peek.
   -------------------------------------------------------------------------- */
#modalLayer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--x-020810-a72);
  animation: fadeIn .18s ease-out;
}
#modalLayer.hidden { display: none !important; }

.modal-card {
  width: min(440px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 24px 26px 18px;
  border-radius: 18px;
  text-align: center;
  background:
    repeating-linear-gradient(180deg, var(--x-ffffff-a2) 0 1px, transparent 1px 3px),
    linear-gradient(170deg, var(--navy-500), var(--x-040d19) 80%);
  border: 2px solid var(--gold-500);
  box-shadow: 0 10px 0 var(--x-020810), 0 30px 70px var(--x-000000-a70), 0 0 40px var(--x-f3c35a-a20);
  animation: modalIn .26s var(--ease-back);
}
.modal-card.modal-confirm { border-color: var(--danger); box-shadow: 0 10px 0 var(--x-020810), 0 30px 70px var(--x-000000-a70), 0 0 40px var(--x-e8584f-a25); }
.modal-card:has(.modal-html) { width: min(620px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.94); } to { opacity: 1; transform: none; } }

.modal-kicker {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--gold-400);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 34px;
  letter-spacing: .14em;
  margin-right: -.14em;
  text-transform: uppercase;
  color: var(--cream);
  line-height: 1;
}
.modal-confirm .modal-title { color: var(--x-ffd0cb); }
.modal-body { font-size: 15px; color: var(--x-b9cadd); line-height: 1.5; }

.modal-menu { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }

.modal-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--x-b9cadd);
  background: var(--x-05101f-a70);
  border: 2px solid var(--x-ffffff-a8);
  transition: background .1s, border-color .1s, color .1s, transform .1s;
}
.modal-btn .mb-cursor {
  position: absolute;
  left: 14px;
  width: 0;
  height: 0;
  border-left: 9px solid var(--gold-400);
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  opacity: 0;
}
.modal-btn.is-focus {
  color: var(--x-1a0f00);
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500));
  border-color: var(--x-fff1c8);
  box-shadow: 0 4px 0 var(--gold-700);
  transform: translateY(-1px);
}
.modal-btn.is-focus .mb-cursor { opacity: 1; border-left-color: var(--x-1a0f00); animation: cursorNudge .6s ease-in-out infinite alternate; }
@keyframes cursorNudge { to { translate: 4px 0; } }
.modal-btn.is-danger:not(.is-focus) { color: var(--x-ff9f97); }
.modal-btn.is-danger.is-focus {
  color: var(--x-ffffff);
  background: linear-gradient(180deg, var(--x-f07a72), var(--x-c2382f));
  border-color: var(--x-ffd0cb);
  box-shadow: 0 4px 0 var(--x-6e1c16);
}
.modal-btn.is-danger.is-focus .mb-cursor { border-left-color: var(--x-ffffff); }

.modal-hint {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted-dim);
}
.modal-hint b { color: var(--gold-400); }
.modal-html { text-align: left; }

/* --------------------------------------------------------------------------
   THE MASCOT - the official emblem plus separate legs/arms. Attract only.
   -------------------------------------------------------------------------- */
#mascot {
  position: fixed;
  left: 0;
  bottom: 26px;
  z-index: 35;
  width: 78px;
  height: 96px;
  pointer-events: none;
  display: none;
  will-change: transform;
}
#mascot.is-on { display: block; }
#mascot.is-leaving { opacity: 0; transition: opacity .24s linear !important; }
body.is-gameplay #mascot { display: none !important; }

.m-body {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 78px;
  transform-origin: 50% 100%;
}
#mascot.face-left .m-body { transform: scaleX(-1); }
.m-body img {
  position: relative;
  z-index: 2;
  width: 78px;
  height: 78px;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px var(--x-000000-a50));
}
.m-leg {
  position: absolute;
  z-index: 1;
  top: 64px;
  width: 9px;
  height: 22px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-500) 50%, var(--x-a87518));
  transform-origin: 50% 0;
}
.m-leg::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: -2px;
  width: 17px;
  height: 8px;
  border-radius: 8px 9px 4px 4px;
  background: var(--x-3a2a10);
}
.m-leg.l { left: 27px; }
.m-leg.r { left: 42px; }
.m-arm {
  position: absolute;
  z-index: 3;
  top: 42px;
  width: 20px;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--gold-500), var(--x-a87518));
  opacity: 0;
  transform-origin: 0 50%;
}
.m-arm::after {
  content: "";
  position: absolute;
  right: -4px;
  top: -2px;
  width: 9px;
  height: 11px;
  border-radius: 50%;
  background: var(--gold-400);
  border: 1px solid var(--gold-700);
}
.m-arm.l { left: 62px; transform: rotate(-10deg); }
.m-arm.r { left: 60px; top: 50px; transform: rotate(8deg); }
.m-shadow {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -4px;
  height: 8px;
  border-radius: 50%;
  background: var(--x-000000-a35);
}

#mascot.is-walking .m-leg.l { animation: mLegA .26s ease-in-out infinite alternate; }
#mascot.is-walking .m-leg.r { animation: mLegB .26s ease-in-out infinite alternate; }
#mascot.is-walking .m-body img { animation: mBob .26s ease-in-out infinite alternate; }
#mascot.is-dash .m-leg.l, #mascot.is-dash .m-leg.r { animation-duration: .1s !important; }
#mascot.is-dash .m-body { transform: scaleX(-1) rotate(-8deg); }
@keyframes mLegA { from { transform: rotate(26deg); } to { transform: rotate(-22deg); } }
@keyframes mLegB { from { transform: rotate(-22deg); } to { transform: rotate(26deg); } }
@keyframes mBob { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-5px) rotate(3deg); } }

#mascot.is-hop .m-body { animation: mHop .45s ease-out 2; }
@keyframes mHop {
  0%, 100% { translate: 0 0; }
  45% { translate: 0 -26px; }
}
#mascot.is-look .m-body img { animation: mLook 1.2s ease-in-out; }
@keyframes mLook {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-12deg); }
  70% { transform: rotate(12deg); }
}
#mascot.is-push .m-body { transform: rotate(-14deg); }
#mascot.face-left.is-push .m-body { transform: scaleX(-1) rotate(-14deg); }
#mascot.is-push .m-arm { opacity: 1; animation: mPush .25s ease-in-out infinite alternate; }
#mascot.is-push .m-leg.l { transform: rotate(30deg); }
#mascot.is-push .m-leg.r { transform: rotate(16deg); }
@keyframes mPush { to { translate: 4px 0; } }

/* Peek: rise from behind the bottom edge of the cabinet. */
#mascot.is-peek { transition: bottom .55s var(--ease-back) !important; }
#mascot.is-peek .m-leg, #mascot.is-peek .m-shadow { display: none; }
#mascot.is-peek.peek-up { bottom: -22px !important; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .cs-stage { grid-template-columns: clamp(170px, 24vw, 240px) 1fr clamp(170px, 24vw, 240px); }
  .cs-tagline { display: none; }
}
@media (max-width: 860px) {
  .mode-grid { grid-template-columns: 1fr; }
  .mc-screen { height: 90px; }
  .cs-stage { grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr; }
  .cs-roster-wrap { grid-column: 1 / -1; grid-row: 2; }
  .cs-side { grid-row: 1; height: 240px; }
  .topbar-crumb { display: none; }
}
@media (max-height: 760px) {
  .back-btn { height: 38px; font-size: 13px; }
  .cs-keys .keycap { height: 22px; }
  .mc-lines { font-size: 13px; gap: 2px; }
  .cab-desc { font-size: 12px; min-height: 0; }
  .cab-panel { margin-top: 8px; padding: 7px 6px; }
  .nav-hint { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  #mascot, .emblem-legs { display: none !important; }
}

/* --- QA polish ----------------------------------------------------------- */
.modal-card.modal-confirm { width: min(520px, 100%); }
.cabinet {
  transform:
    translate(-50%, -50%)
    translateX(calc(var(--k, 0) * var(--spread)))
    rotateY(calc(var(--off) * -24deg))
    scale(calc(1 - var(--abs) * .17));
}
.cabinet.is-far { opacity: .55; }

/* --------------------------------------------------------------------------
   Character art crops + lightweight roster animation (menus only).
   -------------------------------------------------------------------------- */
.cs-tile-img, .ps-tile-img, .mu-face, .ctrl-face, .t-face { position: relative; overflow: hidden; }
.cs-tile-img img, .ps-tile-img img { display: block; }

/* Tiles deal in one after another when a select screen opens. */
.screen.is-active .cs-tile, .screen.is-active .ps-tile {
  animation: tileDeal .42s var(--ease-back) backwards;
  animation-delay: calc(.06s + var(--i, 0) * .035s);
}
@keyframes tileDeal {
  from { opacity: 0; transform: translateY(18px) scale(.86); }
  to   { opacity: 1; transform: none; }
}

/* Smooth hover / focus scale-up. */
.cs-tile-img, .ps-tile-img { transition: transform .18s var(--ease-out), border-color .14s, box-shadow .14s, filter .18s; }
@media (hover: hover) {
  .cs-tile:hover .cs-tile-img { transform: translateY(-4px) scale(1.05); }
}
.cs-tile:focus-visible .cs-tile-img { box-shadow: 0 5px 0 var(--x-020810), 0 0 0 3px var(--x-f3c35a-a60); }

/* Quick pop when a fighter is locked in. */
.cs-tile.locked-p1 .cs-tile-img, .cs-tile.locked-p2 .cs-tile-img { animation: tileLock .36s var(--ease-back); }
@keyframes tileLock {
  0%   { filter: brightness(1); }
  40%  { filter: brightness(1.6); }
  100% { filter: brightness(1); }
}

/* Locked faces breathe gently instead of sitting still. */
.cs-tile.locked-p1 .cs-tile-img img, .cs-tile.locked-p2 .cs-tile-img img,
.ps-tile.is-on .ps-tile-img img { animation: faceBob 2.8s ease-in-out infinite; }
@keyframes faceBob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }

/* --------------------------------------------------------------------------
   Full-body presentation art (P1/P2 panels, VS, Final, Champion).
   PRESENTATION ONLY - gameplay sprites/colliders never read any of this.

   .art-box    the slot the character stands in (a size container).
   .art-frame  a box with the aspect ratio of the character's VISIBLE art
               (--ar, from the trim data), feet on the floor, centred. Its
               height fits the slot: min(--cap-h, --cap-w / max(--ar, --ar-ref)).
               --ar-ref is a shared reference width, so a slim fighter and a
               broad one get the SAME height when width is the limit -
               fighters never look giant next to tiny.
   .art-img    the untouched PNG, positioned so its transparent padding
               falls outside the frame (no CSS crop needed - works in
               every browser).
   Optional per-character ui { scale, offsetX, offsetY } feed --ui-s/x/y.
   -------------------------------------------------------------------------- */
.art-box { container-type: size; }
.art-frame.art-frame {
  --ar: .7;
  --ar-ref: .8;
  --cap-h: 100cqh;
  --cap-w: 100cqw;
  --fh: calc(min(var(--cap-h), var(--cap-w) / max(var(--ar), var(--ar-ref))) * var(--ui-s, 1));
  position: relative;
  display: block;
  flex: none;
  width: auto;
  height: var(--fh);
  aspect-ratio: var(--ar);
  max-width: none;
  max-height: none;
  left: calc(var(--ui-x, 0) * var(--fh));
  top: calc(var(--ui-y, 0) * var(--fh));
}
.art-frame > .art-img {
  position: absolute;
  display: block;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: 50% 100%;
  pointer-events: none;
  user-select: none;
}
.cs-art.art-frame { --cap-h: 100cqh; --cap-w: 100cqw; }
/* V4.1: a bounded presentation box, slightly smaller than before (was
   74vh x 80cqw), and a wider shared reference ratio so slim and broad
   fighters (Normal, Evil, Guest) stand at the SAME height. UI only. */
.vs-art.art-frame { --cap-h: min(100cqh, 60vh); --cap-w: 66cqw; --ar-ref: .86; }
.fn-art.art-frame { --cap-h: min(100cqh, 64vh); --cap-w: 90cqw; }
.ch-art.art-frame { --cap-h: 100cqh; --cap-w: 80cqw; }
.fn-art-wrap { flex: 1; min-height: 0; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
/* Browsers without container units: a fixed, still-consistent height. */
@supports not (height: 1cqh) {
  .art-frame.art-frame { --fh: calc(var(--fallback-h, 34vh) * var(--ui-s, 1)); }
  .vs-art.art-frame { --fallback-h: 46vh; }
  .cs-art.art-frame { --fallback-h: 20vh; }
}

@media (prefers-reduced-motion: reduce) {
  .screen.is-active .cs-tile, .screen.is-active .ps-tile { animation: none; }
}
/* Headroom so the P1 / P2 cursor badges never touch the title. */
.cs-roster { padding-top: 10px; }

/* --------------------------------------------------------------------------
   Mirror safety (presentation only). Side-flipped art (P2 select panel,
   VS P2, the Final's right side) is NOT flipped when the character's art
   carries readable text / numbers / logos - see mirrorSafe in
   js/characters.js. Entrance animations use `translate`, so they still run.
   -------------------------------------------------------------------------- */
.art-frame.no-mirror.no-mirror.no-mirror { transform: none; }   /* outranks every side-flip rule */

/* --------------------------------------------------------------------------
   VS - plate structure (all sizes): [badge row] + name. The badge row is
   the slot tag (P1 / P2 / YOU) or, for a Solo CPU, the "CPU · HARD" chip.
   -------------------------------------------------------------------------- */
.vs-tags { display: inline-flex; align-items: center; gap: 8px; flex: none; }
/* Long names (Evil variants, Guests) step down so they stay inside their half. */
.vs-name.is-long { font-size: clamp(30px, 4.4vw, 60px); }
/* Desktop halves are diagonal: centre each plate in the part you can see. */
.vs-half.p1 .vs-plate { margin-right: 12%; max-width: 84%; }
.vs-half.p2 .vs-plate { margin-left: 12%; max-width: 84%; }
.vs-name.is-xlong { font-size: clamp(26px, 3.9vw, 52px); }

/* --------------------------------------------------------------------------
   VS on phones / narrow portrait: two STRICT, bounded halves. Each half is
   exactly 50% wide and clips its own content; the plate stacks
   (badge -> EVIL badge -> name) and wraps inside its half, so nothing can
   cross into the opponent's side, clip off-screen or meet the BACK /
   volume bar (top padding reserves it, bottom padding the home bar).
   Sprites are capped to their own box: comparable presence, presentation
   only (colliders / hitboxes are untouched).
   -------------------------------------------------------------------------- */
@media (orientation: portrait), (max-width: 760px) {
  .vs-half {
    width: 50%;
    clip-path: none;
    justify-content: center;
    gap: 10px;
    padding: calc(var(--sa-t, 0px) + 76px) 10px calc(var(--sa-b, 0px) + 30px);
  }
  /* The desktop gradients fade to black at the inner edge (hidden there
     by the diagonal overlap); bounded halves fade downward instead. */
  .vs-half.p1 {
    clip-path: none;
    box-shadow: inset -1px 0 0 var(--x-f3c35a-a35);
    background:
      repeating-linear-gradient(115deg, var(--x-ffffff-a4) 0 2px, transparent 2px 14px),
      linear-gradient(180deg, color-mix(in srgb, var(--cc) 55%, var(--navy-900)), var(--navy-900) 92%);
  }
  .vs-half.p2 {
    clip-path: none;
    background:
      repeating-linear-gradient(65deg, var(--x-ffffff-a4) 0 2px, transparent 2px 14px),
      linear-gradient(180deg, color-mix(in srgb, var(--cc) 55%, var(--navy-900)), var(--navy-900) 92%);
  }
  .vs-name.is-long { font-size: clamp(15px, 5vw, 26px); }
  .vs-name.is-xlong { font-size: clamp(14px, 4.3vw, 22px); overflow-wrap: break-word; }
  .vs-art-wrap { flex: none; height: min(44vh, 80vw); width: 100%; }
  .vs-art.art-frame { --cap-h: 92cqh; --cap-w: 84cqw; }
  .vs-art { max-width: 100%; }
  .vs-half.p1 .vs-plate, .vs-half.p2 .vs-plate { margin-left: 0; margin-right: 0; max-width: 100%; }
  .vs-plate {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    margin-top: 4px;
    text-align: center;
  }
  .vs-tags { flex-wrap: wrap; justify-content: center; max-width: 100%; }
  .vs-slot { font-size: 13px; padding: 2px 9px; letter-spacing: .14em; }
  .vs-screen.is-solo .vs-plate .so-cpu-chip { font-size: 11px; letter-spacing: .12em; padding: 3px 8px; }
  .vs-name {
    max-width: 100%;
    font-size: clamp(17px, 6vw, 30px);
    letter-spacing: .06em;
    line-height: 1.05;
    overflow-wrap: break-word;
    text-shadow: 0 3px 0 var(--x-030b16-a80);
  }
  /* EVIL is a compact badge above the name, not a giant word beside it. */
  .vs-name .evil-name { display: flex; flex-direction: column; align-items: center; gap: 5px; }
  .vs-name .evil-word {
    font-size: 10px;
    letter-spacing: .24em;
    line-height: 1.4;
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--x-e21a3e-a22);
    border: 1px solid var(--x-ff5a6e-a60);
  }
  .vs-center { top: calc(var(--sa-t, 0px) + 76px + min(22vh, 40vw)); }
  .vs-word, .vs-word-sh { font-size: clamp(48px, 16vw, 84px); }
  .vs-emblem { width: clamp(84px, 24vw, 130px); }
  .vs-glow { width: clamp(130px, 36vw, 200px); }
}
/* Phones in landscape (short): smaller plate, sprites capped by height. */
@media (max-height: 560px) and (orientation: landscape) {
  .vs-half { padding-bottom: calc(var(--sa-b, 0px) + 18px); }
  .vs-art.art-frame { --cap-h: min(100cqh, 54vh); }
  .vs-plate { flex-wrap: wrap; justify-content: center; gap: 4px 10px; max-width: 80%; }
  .vs-name { font-size: clamp(20px, 4.2vw, 40px); overflow-wrap: anywhere; }
  .vs-name .evil-word { font-size: .5em; letter-spacing: .2em; vertical-align: middle; }
  .vs-word, .vs-word-sh { font-size: clamp(64px, 12vw, 120px); }
}
