/* ==========================================================================
   ESA ARCADE - Screens, HUD, transitions and motion.
   Depends on css/tokens.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
#app {
  position: fixed;
  inset: 0;
  z-index: 2;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s var(--ease-out), visibility .28s;
}
.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Children of an activating screen drift up into place. */
.screen.is-active .stagger > * {
  animation: riseIn .5s var(--ease-out) backwards;
}
.screen.is-active .stagger > *:nth-child(1) { animation-delay: .04s; }
.screen.is-active .stagger > *:nth-child(2) { animation-delay: .10s; }
.screen.is-active .stagger > *:nth-child(3) { animation-delay: .16s; }
.screen.is-active .stagger > *:nth-child(4) { animation-delay: .22s; }
.screen.is-active .stagger > *:nth-child(5) { animation-delay: .28s; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Ambient background - navy field, Egyptian chevrons, light sweep, dust.
   Parallax offsets come from --px / --py, set in main.js.
   -------------------------------------------------------------------------- */
#ambient {
  position: fixed;
  inset: -60px;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(130% 95% at 50% -18%, #1a4a7c 0%, #0b2340 38%, #050f1d 72%, #020810 100%);
}

.amb-pattern {
  position: absolute;
  inset: 0;
  opacity: .055;
  transform: translate3d(calc(var(--px, 0) * 10px), calc(var(--py, 0) * 10px), 0);
  transition: transform .5s var(--ease-out);
  background-image:
    repeating-linear-gradient(135deg,
      transparent 0 18px, var(--gold-400) 18px 20px, transparent 20px 38px),
    repeating-linear-gradient(45deg,
      transparent 0 18px, var(--gold-400) 18px 20px, transparent 20px 38px);
  background-size: 54px 54px;
  -webkit-mask-image: radial-gradient(120% 80% at 50% 0%, #000 10%, transparent 72%);
          mask-image: radial-gradient(120% 80% at 50% 0%, #000 10%, transparent 72%);
}

/* A slow band of warm light drifting across the field. */
.amb-sweep {
  position: absolute;
  top: -30%;
  left: -40%;
  width: 55%;
  height: 170%;
  background: linear-gradient(100deg,
    transparent, rgba(243, 195, 90, .085) 42%, rgba(255, 246, 228, .05) 54%, transparent);
  filter: blur(26px);
  animation: sweep 17s linear infinite;
  pointer-events: none;
}
@keyframes sweep {
  from { transform: translateX(0) rotate(8deg); }
  to   { transform: translateX(300%) rotate(8deg); }
}

/* Soft gold pool behind the centre of the composition. */
.amb-glow {
  position: absolute;
  left: 50%;
  top: 34%;
  width: 760px;
  height: 760px;
  margin: -380px 0 0 -380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(243, 195, 90, .14), transparent 62%);
  transform: translate3d(calc(var(--px, 0) * 24px), calc(var(--py, 0) * 18px), 0);
  transition: transform .6s var(--ease-out);
  pointer-events: none;
}

.amb-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(118% 88% at 50% 44%, transparent 52%, rgba(1, 5, 11, .78) 100%);
  pointer-events: none;
}

.amb-dust { position: absolute; inset: 0; pointer-events: none; }
.dust {
  position: absolute;
  bottom: -14px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gold-300);
  opacity: 0;
  animation: driftUp linear infinite;
  will-change: transform, opacity;
}
@keyframes driftUp {
  0%   { opacity: 0; transform: translate3d(0, 0, 0) scale(.6); }
  12%  { opacity: .55; }
  75%  { opacity: .4; }
  100% { opacity: 0; transform: translate3d(var(--drift, 30px), -104vh, 0) scale(1.1); }
}

/* Ambient dims while a match is on so gameplay owns the attention. */
#ambient.is-dim .amb-sweep,
#ambient.is-dim .amb-glow { opacity: .35; }
#ambient.is-dim .amb-dust { opacity: .3; }
#ambient .amb-sweep,
#ambient .amb-glow,
#ambient .amb-dust { transition: opacity .5s var(--ease-out); }

/* --------------------------------------------------------------------------
   Transition veil - the wipe used between every screen change.
   -------------------------------------------------------------------------- */
#veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(105deg, var(--navy-900) 0%, var(--navy-700) 48%, var(--navy-900) 100%);
  clip-path: inset(0 100% 0 0);
}
#veil.is-in {
  opacity: 1;
  clip-path: inset(0 0 0 0);
  transition: clip-path .3s var(--ease-in-out), opacity .05s linear;
}
#veil.is-out {
  opacity: 1;
  clip-path: inset(0 0 0 100%);
  transition: clip-path .36s var(--ease-in-out);
}
/* Gold leading edge on the wipe. */
#veil::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 0 94%, var(--gold-400) 97%, transparent 100%);
  opacity: .9;
}

/* --------------------------------------------------------------------------
   TITLE SCREEN
   -------------------------------------------------------------------------- */
#titleScreen .title-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.2vh, 22px);
  text-align: center;
}

.title-emblem {
  position: relative;
  width: clamp(130px, 19vh, 205px);
  aspect-ratio: 1;
  flex: none;
  transform: translate3d(calc(var(--px, 0) * -16px), calc(var(--py, 0) * -12px), 0);
  transition: transform .5s var(--ease-out);
}
.title-emblem img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, .55));
  animation: emblemFloat 6.5s ease-in-out infinite;
}
.title-emblem::before {
  content: "";
  position: absolute;
  inset: -26%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(243, 195, 90, .3), transparent 64%);
  animation: emblemHalo 6.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes emblemFloat {
  0%, 100% { transform: translateY(0) rotate(-.6deg); }
  50%      { transform: translateY(-13px) rotate(.6deg); }
}
@keyframes emblemHalo {
  0%, 100% { opacity: .62; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.07); }
}

.title-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  line-height: .88;
  font-size: clamp(54px, 10.5vw, 136px);
  letter-spacing: .1em;
  margin-right: -.1em;                   /* compensate trailing letter-space */
  background: linear-gradient(180deg, #fffaf0 6%, var(--gold-300) 46%, var(--gold-600) 99%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 0 rgba(3, 11, 22, .55)) drop-shadow(0 16px 30px rgba(0, 0, 0, .5));
}

.title-sub {
  font-family: var(--font-display);
  font-size: clamp(11px, 1.5vw, 14px);
  letter-spacing: .5em;
  margin-right: -.5em;
  text-transform: uppercase;
  color: var(--muted);
}

.title-rule { width: min(460px, 70vw); }

.title-prompt {
  margin-top: clamp(4px, 1.6vh, 16px);
  padding: 14px 34px;
  border-radius: 999px;
  border: 1px solid rgba(243, 195, 90, .32);
  background: rgba(7, 23, 40, .5);
  font-family: var(--font-display);
  font-size: clamp(14px, 1.8vw, 19px);
  letter-spacing: .3em;
  margin-right: -.3em;
  text-transform: uppercase;
  color: var(--gold-100);
  animation: breathe 2.8s var(--ease-in-out) infinite;
  transition: background .18s var(--ease-out), border-color .18s var(--ease-out),
              transform .18s var(--ease-out);
}
.title-prompt:hover {
  background: rgba(20, 58, 99, .72);
  border-color: var(--gold-400);
  transform: scale(1.03);
}
@keyframes breathe {
  0%, 100% { opacity: .62; box-shadow: 0 0 0 rgba(243, 195, 90, 0); }
  50%      { opacity: 1;   box-shadow: 0 0 30px rgba(243, 195, 90, .16); }
}

.title-foot {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

/* The emblem flies toward the menu header as the title screen leaves. */
#titleScreen.is-launching .title-emblem { animation: emblemLaunch .55s var(--ease-in-out) forwards; }
#titleScreen.is-launching .title-wordmark,
#titleScreen.is-launching .title-sub,
#titleScreen.is-launching .title-rule,
#titleScreen.is-launching .title-prompt { animation: dropAway .4s var(--ease-out) forwards; }
@keyframes emblemLaunch {
  to { transform: translateY(-16vh) scale(.42); opacity: 0; }
}
@keyframes dropAway {
  to { opacity: 0; transform: translateY(16px); }
}

/* --------------------------------------------------------------------------
   Shared screen header (menu + intro + play)
   -------------------------------------------------------------------------- */
.arc-header {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}
.arc-mark {
  width: 46px;
  height: 46px;
  flex: none;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5));
}
.arc-title {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: .22em;
  margin-right: -.22em;
  text-transform: uppercase;
  color: var(--cream);
  line-height: 1;
}
.arc-tag {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--muted-dim);
  margin-top: 4px;
}
.arc-header .spacer { flex: 1; }

/* Sound toggle */
.sound-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--gold-300);
  background: rgba(10, 32, 57, .7);
  border: 1px solid rgba(243, 195, 90, .26);
  transition: color .15s, border-color .15s, background .15s;
}
.sound-btn:hover { color: var(--cream); border-color: var(--gold-400); background: rgba(20, 58, 99, .85); }
.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; }

/* --------------------------------------------------------------------------
   MENU SCREEN
   -------------------------------------------------------------------------- */
#menuScreen .menu-inner {
  width: min(1120px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2.2vh, 22px);
}

/* Roster strip */
.roster {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: rgba(5, 16, 31, .62);
  border: 1px solid rgba(243, 195, 90, .18);
}
.roster-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--gold-400);
  flex: none;
}
.roster-person { display: flex; align-items: center; gap: 11px; }
.roster-person img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 18%;
  background: #e9ddc6;
  border: 2px solid var(--pc, var(--gold-500));
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
}
.roster-person b {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.roster-person span { font-size: 11px; font-weight: 600; color: var(--muted-dim); letter-spacing: .06em; }
.roster-vs {
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  letter-spacing: .1em;
  color: var(--gold-400);
}
.roster-note {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted-dim);
  text-align: right;
  flex: none;
}

/* Game cards */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(12px, 1.4vw, 20px);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: clamp(226px, 36vh, 320px);
  padding: 22px;
  text-align: left;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, .09);
  background: linear-gradient(168deg, rgba(23, 66, 109, .9), rgba(5, 15, 29, .96));
  box-shadow: var(--shadow-card);
  transition: transform .22s var(--ease-out), border-color .22s var(--ease-out),
              box-shadow .22s var(--ease-out);
}

/* Accent wash keyed to each game. */
.card::before {
  content: "";
  position: absolute;
  inset: auto -30% -58% -10%;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 68%);
  opacity: .22;
  transition: opacity .22s var(--ease-out), transform .3s var(--ease-out);
  pointer-events: none;
}
/* Animated gold border that draws in on hover. */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid var(--gold-400);
  opacity: 0;
  transform: scale(1.012);
  transition: opacity .22s var(--ease-out), transform .22s var(--ease-out);
  pointer-events: none;
}

.card:hover,
.card.is-focus {
  transform: translateY(-6px);
  border-color: rgba(243, 195, 90, .5);
  box-shadow: 0 26px 48px rgba(0, 0, 0, .5), var(--glow-gold);
}
.card:hover::before,
.card.is-focus::before { opacity: .4; transform: translateY(-8px); }
.card:hover::after,
.card.is-focus::after { opacity: .85; transform: scale(1); }
.card:active { transform: translateY(-1px) scale(.988); }

.card-no {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .3em;
  color: var(--gold-500);
  opacity: .8;
}

.card-art {
  position: relative;
  width: 82px;
  height: 82px;
  flex: none;
  display: grid;
  place-items: center;
  margin: 2px 0 2px;
}
.card-art svg { width: 100%; height: 100%; overflow: visible; }
/* Idle motion inside the card art, lifted on hover. */
.card-art .art-move, .intro-art .art-move {
  transform-origin: 50% 50%;
  animation: artIdle 3.6s var(--ease-in-out) infinite;
}
.card:hover .card-art .art-move,
.card.is-focus .card-art .art-move { animation-duration: 1.5s; }
@keyframes artIdle {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-7px) rotate(3deg); }
}

.card .card-title {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.1vw, 29px);
  line-height: 1;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--cream);
  position: relative;
  z-index: 1;
}
.card .card-desc {
  display: block;
  position: relative;
  z-index: 1;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  color: #a9bdd2;
  min-height: 39px;
}

.card-keys {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  width: 100%;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.card-keys .who {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .14em;
  color: var(--muted-dim);
  min-width: 42px;
}
.card-keys .keycap { min-width: 25px; height: 25px; font-size: 11px; padding: 0 6px; }
.card-keys .keycap.wide { min-width: 62px; font-size: 9.5px; }
.card-keys .row { display: flex; align-items: center; gap: 5px; }
.card-keys .divider { width: 1px; height: 22px; background: rgba(255, 255, 255, .1); margin: 0 3px; }

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

/* --------------------------------------------------------------------------
   INTRO SCREEN
   -------------------------------------------------------------------------- */
#introScreen .intro-inner {
  width: min(720px, 100%);
  padding: clamp(22px, 4vh, 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.8vh, 18px);
  text-align: center;
}
.intro-art { width: clamp(64px, 11vh, 92px); height: clamp(64px, 11vh, 92px); }
.intro-art svg { width: 100%; height: 100%; overflow: visible; }
.intro-inner h2 {
  font-family: var(--font-display);
  font-size: clamp(34px, 5.4vw, 56px);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cream);
  line-height: .95;
}
.intro-rule { width: min(360px, 76%); }
.intro-rules {
  max-width: 480px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
  color: #b4c7da;
}
.intro-rules b { color: var(--gold-300); font-weight: 700; }

.intro-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin: 2px 0 4px;
}
.ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 14px 12px;
  border-radius: var(--radius-md);
  background: rgba(5, 16, 31, .66);
  border: 1px solid rgba(255, 255, 255, .08);
  border-top: 2px solid var(--pc, var(--gold-500));
}
.ctrl-name {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--pc, var(--cream));
}
.ctrl-keys { display: flex; gap: 6px; align-items: center; }

.intro-actions { display: flex; gap: 12px; align-items: center; margin-top: 4px; }

/* --------------------------------------------------------------------------
   PLAY SCREEN
   -------------------------------------------------------------------------- */
#playScreen { padding: 14px 20px; align-items: center; }

.stage {
  /* One width drives the HUD and the arena so they read as one object.
     --stage-chrome reserves room for the top bar, HUD and padding. */
  --stage-chrome: 214px;
  width: min(1120px, 100%, calc((100vh - var(--stage-chrome)) * 16 / 9));
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.play-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.play-bar .game-name {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold-300);
}
.play-bar .game-mode {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted-dim);
  padding-left: 12px;
  margin-left: 2px;
  border-left: 1px solid rgba(255, 255, 255, .12);
}
.play-bar .spacer { flex: 1; }

/* --- HUD ---------------------------------------------------------------- */
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: stretch;
}

.hud-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  border-radius: var(--radius-md) var(--radius-md) 4px 4px;
  background: linear-gradient(180deg, rgba(14, 44, 77, .92), rgba(5, 16, 31, .95));
  border: 1px solid rgba(255, 255, 255, .07);
  border-bottom: 2px solid var(--pc);
  min-width: 0;
}
.hud-player.is-right { flex-direction: row-reverse; text-align: right; }

.hud-face {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 18%;
  background: #e9ddc6;
  border: 2px solid var(--pc);
  box-shadow: 0 3px 9px rgba(0, 0, 0, .45);
}
.hud-meta { min-width: 0; }
.hud-name {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--cream);
  line-height: 1.1;
}
.hud-keys {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--muted-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-tail { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.hud-player.is-right .hud-tail { margin-left: 0; margin-right: auto; flex-direction: row-reverse; }

.hud-score {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--gold-300);
  font-variant-numeric: tabular-nums;
  min-width: 42px;
  text-align: center;
}
.hud-score.bump { animation: scoreBump .42s var(--ease-back); }
@keyframes scoreBump {
  0%   { transform: scale(1);    color: var(--gold-300); text-shadow: none; }
  32%  { transform: scale(1.42); color: #fffdf4; text-shadow: 0 0 22px rgba(243, 195, 90, .9); }
  100% { transform: scale(1);    color: var(--gold-300); text-shadow: none; }
}
.hud-score.bump-down { animation: scoreDown .42s var(--ease-out); }
@keyframes scoreDown {
  0%   { transform: scale(1); color: var(--gold-300); }
  32%  { transform: scale(.78); color: var(--danger); }
  100% { transform: scale(1); color: var(--gold-300); }
}

/* Round pips (Bomb Pass) */
.hud-pips { display: flex; gap: 5px; }
.hud-player.is-right .hud-pips { flex-direction: row-reverse; }
.pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .11);
  border: 1px solid rgba(255, 255, 255, .16);
  transition: background .3s var(--ease-out), box-shadow .3s var(--ease-out);
}
.pip.on {
  background: var(--gold-400);
  border-color: var(--gold-300);
  box-shadow: 0 0 12px rgba(243, 195, 90, .75);
}
.pip.just-on { animation: pipPop .5s var(--ease-back); }
@keyframes pipPop {
  0%   { transform: scale(.4); }
  55%  { transform: scale(1.6); }
  100% { transform: scale(1); }
}

/* HUD centre module - timer / round counter */
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 132px;
  padding: 6px 20px;
  border-radius: var(--radius-md) var(--radius-md) 4px 4px;
  background: linear-gradient(180deg, rgba(14, 44, 77, .92), rgba(5, 16, 31, .95));
  border: 1px solid rgba(255, 255, 255, .07);
  border-bottom: 2px solid var(--gold-500);
}
.hud-label {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .26em;
  margin-right: -.26em;
  text-transform: uppercase;
  color: var(--muted);
}
.hud-value {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.05;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  transition: color .3s var(--ease-out);
}
/* Final stretch emphasis */
.hud-center.is-urgent { border-bottom-color: var(--danger); }
.hud-center.is-urgent .hud-value { color: var(--danger); animation: urgentTick 1s var(--ease-out) infinite; }
.hud-center.is-urgent .hud-label { color: var(--danger); }
@keyframes urgentTick {
  0%   { transform: scale(1.14); text-shadow: 0 0 20px rgba(232, 88, 79, .8); }
  40%  { transform: scale(1);    text-shadow: none; }
  100% { transform: scale(1);    text-shadow: none; }
}

/* --- Arena frame -------------------------------------------------------- */
.canvas-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(243, 195, 90, .38);
  box-shadow: 0 22px 52px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .5);
  background: #10182a;
}
#gameCanvas { display: block; width: 100%; height: 100%; }

/* Soft inner vignette so the arena sits inside the frame. */
.canvas-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 70px rgba(5, 14, 26, .5);
  border-radius: inherit;
}

/* --- Countdown ---------------------------------------------------------- */
.countdown-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 4;
}
/* Darkened pool behind the numerals so they stay legible on pale sandstone. */
.countdown-layer:not(:empty) {
  background: radial-gradient(circle at 50% 50%,
    rgba(3, 11, 22, .62) 0%, rgba(3, 11, 22, .34) 38%, rgba(3, 11, 22, 0) 68%);
}
.countdown-num {
  font-family: var(--font-display);
  font-size: 19vmin;
  line-height: 1;
  letter-spacing: .04em;
  color: var(--cream);
  -webkit-text-stroke: 4px rgba(4, 12, 23, .92);
  paint-order: stroke fill;
  text-shadow: 0 10px 0 rgba(3, 11, 22, .5), 0 0 70px rgba(243, 195, 90, .6);
  animation: countPop .85s var(--ease-out) forwards;
}
.countdown-num.is-go {
  font-size: 23vmin;
  color: var(--gold-300);
  text-shadow: 0 10px 0 rgba(3, 11, 22, .55), 0 0 90px rgba(243, 195, 90, .95);
  animation: goPop .72s var(--ease-out) forwards;
}
@keyframes countPop {
  0%   { opacity: 0; transform: scale(2.1); }
  26%  { opacity: 1; transform: scale(1); }
  70%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.74); }
}
@keyframes goPop {
  0%   { opacity: 0; transform: scale(.4); }
  22%  { opacity: 1; transform: scale(1.22); }
  40%  { transform: scale(1); }
  72%  { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0; transform: scale(1.5); }
}
/* Expanding gold ring behind each beat. */
.countdown-ring {
  position: absolute;
  width: 16vmin;
  height: 16vmin;
  border-radius: 50%;
  border: 3px solid var(--gold-400);
  animation: ringOut .85s var(--ease-out) forwards;
}
@keyframes ringOut {
  0%   { opacity: .75; transform: scale(.4); }
  100% { opacity: 0;   transform: scale(2.6); }
}

/* --- In-arena banner ---------------------------------------------------- */
.banner-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 5;
}
.banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 46px;
  border-radius: var(--radius-md);
  background: linear-gradient(170deg, rgba(14, 44, 77, .96), rgba(4, 13, 25, .97));
  border: 1px solid rgba(243, 195, 90, .45);
  box-shadow: 0 20px 48px rgba(0, 0, 0, .6);
  animation: bannerIn .42s var(--ease-back);
}
.banner.is-out { animation: bannerOut .3s var(--ease-out) forwards; }
.banner .b-kicker {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .32em;
  margin-right: -.32em;
  text-transform: uppercase;
  color: var(--gold-400);
}
.banner .b-main {
  font-family: var(--font-display);
  font-size: clamp(24px, 4.2vw, 40px);
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--cream);
  line-height: 1;
}
@keyframes bannerIn {
  0%   { opacity: 0; transform: translateY(22px) scale(.9); }
  100% { opacity: 1; transform: none; }
}
@keyframes bannerOut {
  to { opacity: 0; transform: translateY(-14px) scale(.96); }
}

/* --- Result overlay ----------------------------------------------------- */
.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 9, 18, .62);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  animation: fadeIn .3s var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.result-card {
  position: relative;
  width: min(480px, 94%);
  padding: 26px 30px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  border-radius: var(--radius-lg);
  background: linear-gradient(170deg, rgba(20, 58, 99, .97), rgba(4, 13, 25, .98));
  border: 1px solid rgba(243, 195, 90, .5);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .65), var(--glow-gold);
  animation: resultIn .5s var(--ease-back);
}
@keyframes resultIn {
  0%   { opacity: 0; transform: translateY(26px) scale(.92); }
  100% { opacity: 1; transform: none; }
}

.result-portrait {
  position: relative;
  width: 104px;
  height: 104px;
  flex: none;
  margin-top: -2px;
}
.result-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 16%;
  border-radius: 50%;
  background: #e9ddc6;
  border: 3px solid var(--gold-400);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .55);
  animation: portraitIn .6s var(--ease-back) .08s backwards;
}
.result-portrait::before {
  content: "";
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(243, 195, 90, .4), transparent 66%);
  animation: emblemHalo 3s ease-in-out infinite;
  pointer-events: none;
}
@keyframes portraitIn {
  0%   { opacity: 0; transform: scale(.4) rotate(-12deg); }
  100% { opacity: 1; transform: none; }
}
/* Draw state shows the emblem instead of a winner portrait. */
.result-portrait.is-draw img {
  object-fit: contain;
  object-position: center;
  background: transparent;
  border-color: rgba(243, 195, 90, .4);
}

.result-kicker {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .34em;
  margin-right: -.34em;
  text-transform: uppercase;
  color: var(--gold-400);
}
.result-card h2 {
  font-family: var(--font-display);
  font-size: clamp(32px, 6vw, 50px);
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: .96;
  background: linear-gradient(180deg, #fffaf0, var(--gold-400));
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.result-score {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-display);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  color: var(--cream);
}
.result-score i { font-style: normal; color: var(--gold-600); font-size: 22px; }
.result-score .sc { min-width: 46px; }
.result-score .sc.zima { color: #7fb7f0; }
.result-score .sc.shaza { color: #c79ad8; }
.result-text {
  font-size: 13.5px;
  font-weight: 500;
  color: #a9bdd2;
  line-height: 1.5;
  max-width: 360px;
}
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

/* --------------------------------------------------------------------------
   Responsive - the arcade targets laptops and desktops.
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card { min-height: 0; flex-direction: row; align-items: center; gap: 16px; flex-wrap: wrap; }
  .card-art { width: 56px; height: 56px; }
  .card-keys { width: 100%; }
  .roster-note { display: none; }
  .intro-controls { grid-template-columns: 1fr; }
  .stage { --stage-chrome: 190px; }
}

@media (max-height: 700px) {
  .stage { --stage-chrome: 186px; }
  .hud-score { font-size: 26px; }
  .hud-face { width: 36px; height: 36px; }
  .hud-center { min-width: 112px; }
  .hud-value { font-size: 23px; }
}
