/* ==========================================================================
   ESA ARCADE - Shell, ambient, transitions, welcome, intro, play + HUD.
   Depends on css/tokens.css. Menu screens live in css/menus.css and the
   tournament screens in css/tournament.css.

   GAMEPLAY RULE: body.is-gameplay freezes every decorative animation
   (ambient, dust, bezel bulbs, CRT, mascot). Only the game and its HUD move.
   ========================================================================== */

/* --------------------------------------------------------------------------
   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 clamp(16px, 3vw, 40px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s var(--ease-out), visibility .28s;
}
.screen.has-topbar { padding-top: clamp(64px, 9vh, 78px); padding-bottom: clamp(18px, 3vh, 30px); }
.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; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

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

.amb-pattern {
  position: absolute;
  inset: 0;
  opacity: .05;
  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%, var(--x-000000) 10%, transparent 72%);
          mask-image: radial-gradient(120% 80% at 50% 0%, var(--x-000000) 10%, transparent 72%);
}

/* Retro horizon floor: a gold perspective grid fading into the distance. */
.amb-floor {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: 0;
  height: 46%;
  perspective: 420px;
  perspective-origin: 50% 0%;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, var(--x-000000) 55%);
          mask-image: linear-gradient(180deg, transparent 0%, var(--x-000000) 55%);
}
.amb-grid {
  position: absolute;
  inset: 0 0 -60% 0;
  transform-origin: 50% 0%;
  transform: rotateX(62deg);
  opacity: .16;
  background-image:
    linear-gradient(90deg, var(--x-f3c35a-a90) 1px, transparent 1px),
    linear-gradient(0deg, var(--x-f3c35a-a90) 1px, transparent 1px);
  background-size: 64px 64px;
  animation: gridRoll 6s linear infinite;
  animation-play-state: paused;
}
@keyframes gridRoll {
  from { background-position: 0 0; }
  to   { background-position: 0 64px; }
}
/* The floor only rolls in attract mode. */
body.is-attract .amb-grid { animation-play-state: running; opacity: .22; }

/* 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, var(--x-f3c35a-a9) 42%, var(--x-fff6e4-a5) 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); }
}
body.is-attract .amb-sweep { animation-duration: 9s; }

/* 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, var(--x-f3c35a-a14), 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%, var(--x-01050b-a78) 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); }
}

/* GAMEPLAY: the background goes still and dim so the arena owns attention. */
body.is-gameplay .amb-sweep,
body.is-gameplay .amb-dust,
body.is-gameplay .amb-floor { display: none; }
body.is-gameplay .amb-glow { opacity: .35; transform: none; transition: none; }
body.is-gameplay .amb-pattern { transform: none; transition: none; }

/* --------------------------------------------------------------------------
   Transition: an arcade shutter. Two gold-edged panels slam shut, the
   screen swaps behind them, then they open with a CRT line flick.
   Timings match ESA.Screens.go (310ms close, 380ms open).
   -------------------------------------------------------------------------- */
#veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  overflow: hidden;
}
#veil .shutter {
  position: absolute;
  left: 0;
  right: 0;
  height: 50.5%;
  background:
    repeating-linear-gradient(180deg, var(--x-f3c35a-a5) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, var(--navy-800), var(--navy-900));
  will-change: transform;
}
#veil .shutter.top {
  top: 0;
  transform: translate3d(0, -101%, 0);
  border-bottom: 3px solid var(--gold-400);
  box-shadow: 0 6px 24px var(--x-f3c35a-a25);
}
#veil .shutter.bot {
  bottom: 0;
  transform: translate3d(0, 101%, 0);
  border-top: 3px solid var(--gold-400);
  box-shadow: 0 -6px 24px var(--x-f3c35a-a25);
}
#veil.is-in .shutter { transform: none; transition: transform .29s cubic-bezier(.7, 0, .84, 0); }
/* While the shutters close, taps can't reach the screen being left (no
   second navigation / duplicate action mid-transition). Opening stays
   click-through so the new screen is usable immediately. */
#veil.is-in { pointer-events: auto; }
#veil.is-out .shutter.top { transform: translate3d(0, -101%, 0); transition: transform .36s var(--ease-out) .04s; }
#veil.is-out .shutter.bot { transform: translate3d(0, 101%, 0); transition: transform .36s var(--ease-out) .04s; }

/* Emblem seal on the seam while closed. */
#veil .veil-seal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 66px;
  height: 66px;
  margin: -33px 0 0 -33px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--navy-600), var(--navy-900));
  border: 2px solid var(--gold-400);
  box-shadow: 0 0 26px var(--x-f3c35a-a45);
  opacity: 0;
  transform: scale(.4);
}
#veil .veil-seal img { width: 72%; height: 72%; margin: 14%; object-fit: contain; }
#veil.is-in .veil-seal { opacity: 1; transform: scale(1); transition: opacity .15s linear .16s, transform .2s var(--ease-back) .14s; }
#veil.is-out .veil-seal { opacity: 0; transform: scale(1.3); transition: opacity .14s linear, transform .16s linear; }

/* CRT line flick as the shutters part. */
#veil .veil-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--x-fff8e6);
  box-shadow: 0 0 18px 4px var(--x-ffeebe-a70);
  opacity: 0;
  transform: scaleX(0);
}
#veil.is-out .veil-line { animation: crtLine .34s ease-out; }
@keyframes crtLine {
  0%   { opacity: 1; transform: scaleX(1); }
  60%  { opacity: .7; transform: scaleX(.6) scaleY(1.6); }
  100% { opacity: 0; transform: scaleX(0); }
}

/* --------------------------------------------------------------------------
   WELCOME / BOOT
   -------------------------------------------------------------------------- */
#welcomeScreen { flex-direction: column; }
.welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.8vh, 18px);
  text-align: center;
}

.welcome-emblem {
  position: relative;
  width: clamp(124px, 20vh, 210px);
  aspect-ratio: 1;
  flex: none;
  margin-bottom: clamp(6px, 1.4vh, 14px);
  transform: translate3d(calc(var(--px, 0) * -16px), calc(var(--py, 0) * -12px), 0);
  transition: transform .5s var(--ease-out);
}
.welcome-emblem img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 26px var(--x-000000-a55));
  animation: emblemFloat 6.5s ease-in-out infinite;
}
.welcome-emblem .emblem-glow {
  position: absolute;
  inset: -28%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--x-f3c35a-a32), 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); }
}
body.is-attract .welcome-emblem img { animation-duration: 3.6s; }

/* --- The emblem's secret legs (attract mode skit). Separate elements:
       the emblem artwork itself is never touched. ------------------------ */
.emblem-legs {
  position: absolute;
  left: 50%;
  bottom: 3%;
  z-index: 1;
  width: 40%;
  height: 26%;
  margin-left: -20%;
  pointer-events: none;
}
.emblem-legs .leg {
  position: absolute;
  top: 0;
  width: 15%;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-500) 50%, var(--x-a87518));
  transform-origin: 50% 0;
  transform: scaleY(0);
  transition: transform .28s var(--ease-back);
}
.emblem-legs .leg::after {
  content: "";
  position: absolute;
  bottom: -6px;
  width: 260%;
  height: 12px;
  border-radius: 10px 12px 6px 6px;
  background: var(--x-3a2a10);
  box-shadow: inset 0 2px 0 var(--x-ffffff-a18);
}
.emblem-legs .leg.l { left: 24%; }
.emblem-legs .leg.l::after { right: -20%; }
.emblem-legs .leg.r { right: 24%; }
.emblem-legs .leg.r::after { left: -20%; }

.welcome-emblem.is-walking { animation: emblemWaddle 4.6s var(--ease-in-out); }
.welcome-emblem.is-walking .leg { transform: scaleY(1) translateY(70%); }
.welcome-emblem.is-walking .leg.l { animation: stepL .3s ease-in-out .3s 11 alternate; }
.welcome-emblem.is-walking .leg.r { animation: stepR .3s ease-in-out .3s 11 alternate; }
.welcome-emblem.is-walking img { animation: emblemBob .3s ease-in-out .3s 12 alternate; }
@keyframes stepL { from { transform: scaleY(1) translateY(70%) rotate(18deg); } to { transform: scaleY(1) translateY(70%) rotate(-14deg); } }
@keyframes stepR { from { transform: scaleY(1) translateY(70%) rotate(-14deg); } to { transform: scaleY(1) translateY(70%) rotate(18deg); } }
@keyframes emblemBob { from { transform: translateY(-14px) rotate(-3deg); } to { transform: translateY(-20px) rotate(3deg); } }
@keyframes emblemWaddle {
  0%   { translate: 0 0; }
  22%  { translate: -70px 0; }
  30%  { translate: -70px -8px; }
  52%  { translate: 60px 0; }
  60%  { translate: 60px -8px; }
  82%  { translate: 0 0; }
  100% { translate: 0 0; }
}

.welcome-kicker {
  font-family: var(--font-display);
  font-size: clamp(10px, 1.3vw, 13px);
  letter-spacing: .42em;
  margin-right: -.42em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Chrome-gold wordmark with a stacked retro extrusion. */
.welcome-wordmark {
  position: relative;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  line-height: .9;
  font-size: clamp(54px, 10.5vw, 140px);
  letter-spacing: .1em;
  margin-right: -.1em;
  background: linear-gradient(180deg, var(--x-fffaf0) 4%, var(--gold-300) 40%, var(--gold-500) 62%, var(--gold-700) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 0 var(--gold-700)) drop-shadow(0 3px 0 var(--x-5c400c)) drop-shadow(0 6px 0 var(--navy-800))
          drop-shadow(0 18px 30px var(--x-000000-a55));
}
/* Scanline glint across the wordmark. */
.welcome-wordmark::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 40%, var(--x-ffffff-a85) 50%, transparent 60%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: glint 6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes glint {
  0%, 62%  { background-position: 120% 0; }
  100%     { background-position: -40% 0; }
}

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

.press-start {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-top: clamp(6px, 2vh, 22px);
  padding: 14px 30px;
  border-radius: 12px;
  border: 2px solid var(--x-f3c35a-a50);
  background: var(--x-071728-a62);
  box-shadow: 0 5px 0 var(--x-030b16-a90), 0 0 0 4px var(--x-f3c35a-a7);
  font-family: var(--font-display);
  font-size: clamp(16px, 2vw, 22px);
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--gold-100);
  transition: transform .15s var(--ease-out), border-color .15s, background .15s;
}
.press-start:hover { transform: translateY(-2px); border-color: var(--gold-400); background: var(--x-143a63-a78); }
.press-start .ps-blink { animation: arcadeBlink 1.05s steps(1) infinite; }
.press-start .keycap { font-size: 12px; letter-spacing: .12em; height: 30px; }
@keyframes arcadeBlink {
  0%, 62%  { opacity: 1; }
  63%, 100% { opacity: .18; }
}

.welcome-foot {
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--muted-dim);
}
.welcome-foot .wf-credit { color: var(--gold-500); flex: none; }
.welcome-foot .wf-events { color: var(--gold-500); flex: none; padding: 12px 0; margin: -12px 0; }
.welcome-foot .wf-events:hover { color: var(--gold-300); }
.welcome-foot .wf-ticker { flex: 1; text-align: center; }
.welcome-foot .wf-ticker.is-in { animation: tickerIn .5s var(--ease-out); }
.welcome-foot .wf-ver {
  flex: none;
  padding: 3px 8px;
  border: 1px solid var(--x-f3c35a-a35);
  border-radius: 5px;
  color: var(--gold-400);
}
@keyframes tickerIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Launch: the emblem leaps, everything else drops away. */
#welcomeScreen.is-launching .welcome-emblem img { animation: emblemLaunch .5s var(--ease-in-out) forwards; }
#welcomeScreen.is-launching .welcome-wordmark,
#welcomeScreen.is-launching .welcome-kicker,
#welcomeScreen.is-launching .welcome-rule,
#welcomeScreen.is-launching .press-start { animation: dropAway .36s var(--ease-out) forwards; }
@keyframes emblemLaunch {
  30%  { transform: translateY(8px) scale(1.06, .9); }
  100% { transform: translateY(-18vh) scale(.5); opacity: 0; }
}
@keyframes dropAway {
  to { opacity: 0; transform: translateY(16px); }
}

/* --------------------------------------------------------------------------
   INTRO SCREEN (game briefing)
   -------------------------------------------------------------------------- */
#introScreen .intro-inner {
  width: min(760px, 100%);
  max-height: 100%;
  padding: clamp(18px, 3.4vh, 36px) clamp(18px, 3vw, 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(7px, 1.4vh, 14px);
  text-align: center;
  border-color: color-mix(in srgb, var(--accent, var(--gold-400)) 50%, transparent);
  animation: riseIn .45s var(--ease-out);
}
.intro-kicker {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: .34em;
  margin-right: -.34em;
  text-transform: uppercase;
  color: var(--gold-400);
}
.intro-art { width: clamp(56px, 10vh, 88px); height: clamp(56px, 10vh, 88px); }
.intro-art svg, .intro-art img { width: 100%; height: 100%; overflow: visible; object-fit: contain; }
.intro-inner h2 {
  font-family: var(--font-display);
  font-size: clamp(32px, 5.2vw, 56px);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cream);
  line-height: .95;
}
.intro-mode {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--accent, var(--gold-300));
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent, var(--gold-400)) 55%, transparent);
}
.intro-rule { width: min(360px, 76%); }
.intro-rules {
  max-width: 520px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--x-b4c7da);
}
.intro-rules b { color: var(--gold-300); font-weight: 700; }

/* Two equal columns that are allowed to SHRINK (minmax(0, 1fr)): a plain
   1fr track never goes below its content, so five key caps + a long name
   (EVIL SHAZA, a Guest) pushed the right panel out of the card. */
.intro-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  min-width: 0;
  margin: 2px 0 4px;
}
.ctrl {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 12px);
  min-width: 0;
  padding: 12px clamp(10px, 1.2vw, 14px);
  border-radius: var(--radius-md);
  background: var(--x-05101f-a66);
  border: 1px solid var(--x-ffffff-a8);
  border-top: 3px solid var(--pc, var(--gold-500));
  text-align: left;
}
.ctrl-face {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: var(--x-e9ddc6);
  border: 2px solid var(--pc);
}
.ctrl-face img { width: 100%; height: 100%; object-fit: cover; }
.ctrl-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ctrl-slot {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--muted);
}
.ctrl-name {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Key caps keep their size while there is room, then shrink, then wrap -
   always inside their own panel. */
.ctrl-keys { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; align-items: center; flex: 0 1 auto; min-width: 0; }
.ctrl-keys .keycap { min-width: clamp(22px, 2.3vw, 30px); height: clamp(24px, 2.6vw, 30px); font-size: clamp(11px, 1.1vw, 13px); padding: 0 clamp(3px, .5vw, 6px); }
.ctrl-keys .so-cpu-chip { white-space: normal; text-align: 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((100dvh - 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 var(--x-ffffff-a12);
}
.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, var(--x-0e2c4d-a92), var(--x-05101f-a95));
  border: 1px solid var(--x-ffffff-a7);
  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: var(--x-e9ddc6);
  border: 2px solid var(--pc);
  box-shadow: 0 3px 9px var(--x-000000-a45);
}
.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: var(--x-fffdf4); text-shadow: 0 0 22px var(--x-f3c35a-a90); }
  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: var(--x-ffffff-a11);
  border: 1px solid var(--x-ffffff-a16);
  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 var(--x-f3c35a-a75);
}
.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, var(--x-0e2c4d-a92), var(--x-05101f-a95));
  border: 1px solid var(--x-ffffff-a7);
  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 var(--x-e8584f-a80); }
  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 var(--x-f3c35a-a38);
  box-shadow: 0 22px 52px var(--x-000000-a55), inset 0 0 0 1px var(--x-000000-a50);
  background: var(--x-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 var(--x-050e1a-a50);
  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%,
    var(--x-030b16-a62) 0%, var(--x-030b16-a34) 38%, var(--x-030b16-a0) 68%);
}
.countdown-num {
  font-family: var(--font-display);
  font-size: 19vmin;
  line-height: 1;
  letter-spacing: .04em;
  color: var(--cream);
  -webkit-text-stroke: 4px var(--x-040c17-a92);
  paint-order: stroke fill;
  text-shadow: 0 10px 0 var(--x-030b16-a50), 0 0 70px var(--x-f3c35a-a60);
  animation: countPop .85s var(--ease-out) forwards;
}
.countdown-num.is-go {
  font-size: 23vmin;
  color: var(--gold-300);
  text-shadow: 0 10px 0 var(--x-030b16-a55), 0 0 90px var(--x-f3c35a-a95);
  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, var(--x-0e2c4d-a96), var(--x-040d19-a97));
  border: 1px solid var(--x-f3c35a-a45);
  box-shadow: 0 20px 48px var(--x-000000-a60);
  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: var(--x-020912-a62);
  -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, var(--x-143a63-a97), var(--x-040d19-a98));
  border: 1px solid var(--x-f3c35a-a50);
  box-shadow: 0 30px 70px var(--x-000000-a65), 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 .rp-crop {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 50%;
  background: var(--x-e9ddc6);
  border: 3px solid var(--gold-400);
  box-shadow: 0 10px 26px var(--x-000000-a55);
  animation: portraitIn .6s var(--ease-back) .08s backwards;
}
.result-portrait::before {
  content: "";
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--x-f3c35a-a40), 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 .rp-crop {
  background: transparent;
  border-color: var(--x-f3c35a-a40);
}

.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, var(--x-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-text {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--x-a9bdd2);
  line-height: 1.5;
  max-width: 360px;
}
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

.result-actions .btn.is-default { box-shadow: 0 5px 0 var(--gold-700), 0 0 0 3px var(--x-f3c35a-a30), 0 12px 22px var(--x-000000-a40); }

/* Result protection (js/arena.js initResultGuard): a thin gold line that
   drains over 5 s while stray taps / Esc can't dismiss the card. */
.result-guard {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 9px;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--x-f3c35a-a14);
  opacity: 0;
  transition: opacity .45s var(--ease-out);
  pointer-events: none;
}
.result-guard span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-400));
  transform-origin: left center;
  transform: scaleX(0);
}
.result-card.is-guarded .result-guard { opacity: .9; }
.result-card.is-guarded .result-guard span { animation: resultGuard 5s linear forwards; }
@keyframes resultGuard { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* --- Play bar extras ----------------------------------------------------- */
.pause-btn { gap: 8px; }
.play-tag {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold-300);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--x-f3c35a-a40);
  background: var(--x-071728-a70);
  white-space: nowrap;
}

/* Paused: freeze in-arena DOM animations (countdown, banner, HUD pulses). */
#playScreen.is-paused .countdown-layer *,
#playScreen.is-paused .banner-layer *,
#playScreen.is-paused .hud * { animation-play-state: paused !important; }
#playScreen.is-paused .canvas-frame { filter: saturate(.55) brightness(.7); transition: filter .2s; }

/* --------------------------------------------------------------------------
   Responsive - the arcade targets laptops and desktops.
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .intro-controls { grid-template-columns: 1fr; }
  .stage { --stage-chrome: 190px; }
  .welcome-foot .wf-ticker { display: none; }
}

@media (max-height: 820px) {
  .intro-rules { font-size: 14px; line-height: 1.5; }
}

@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; }
  .intro-art { display: none; }
}

/* --------------------------------------------------------------------------
   Character crops. Faces and tiles are square overflow:hidden boxes; the
   <img> inside is positioned from the registry trim data (ESA.headStyle).
   -------------------------------------------------------------------------- */
.hud-face { position: relative; display: block; overflow: hidden; }
.hud-face img, .rp-crop img { display: block; }

/* --------------------------------------------------------------------------
   V4 AMBIENCE (menus only; js/attract.js drives the attract-mode moments)
   Always: a faint ESA emblem breathing far behind everything and a few
   slow star twinkles. Attract mode (idle): slightly richer, plus ONE rare
   moment at a time - body.amb-m-glint / amb-m-pulse / amb-m-scan.
   Compositor-friendly only: transform + opacity, no filters animated.
   -------------------------------------------------------------------------- */
.amb-emblem {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(62vmin, 560px);
  height: min(62vmin, 560px);
  margin: calc(min(62vmin, 560px) / -2) 0 0 calc(min(62vmin, 560px) / -2);
  opacity: .035;
  pointer-events: none;
  animation: embBreathe 14s ease-in-out infinite;
  will-change: transform, opacity;
}
.amb-emblem img { width: 100%; height: 100%; object-fit: contain; }
@keyframes embBreathe {
  0%, 100% { transform: scale(1); opacity: .03; }
  50%      { transform: scale(1.035); opacity: .05; }
}
body.is-attract .amb-emblem { animation-duration: 9s; }

.amb-stars { position: absolute; inset: 0; pointer-events: none; }
.amb-stars i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 0 6px var(--x-f3c35a-a90);
  opacity: 0;
  animation: starTwinkle 7s ease-in-out var(--d) infinite;
}
@keyframes starTwinkle {
  0%, 70%, 100% { opacity: 0; transform: scale(.6); }
  82%           { opacity: .55; transform: scale(1); }
}
body.is-attract .amb-stars i { animation-duration: 4.5s; }

/* Moment: a glint travels round the top-right corner. */
.amb-glint {
  position: absolute;
  right: 9%;
  top: 11%;
  width: 120px;
  height: 120px;
  opacity: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 47%, var(--x-fff6e4-a90) 50%, transparent 53%),
    linear-gradient(0deg, transparent 47%, var(--x-fff6e4-a90) 50%, transparent 53%),
    radial-gradient(circle, var(--x-f3c35a-a55), transparent 40%);
}
body.amb-m-glint .amb-glint { animation: ambGlint 2.4s ease-out; }
@keyframes ambGlint {
  0%   { opacity: 0; transform: scale(.3) rotate(0deg); }
  25%  { opacity: .9; transform: scale(1) rotate(45deg); }
  100% { opacity: 0; transform: scale(.5) rotate(90deg); }
}

/* Moment: a soft CRT scanline pass down the field. */
.amb-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 90px;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, var(--x-f3c35a-a7) 45%, var(--x-fff6e4-a12) 50%, var(--x-f3c35a-a7) 55%, transparent);
}
body.amb-m-scan .amb-scan { animation: ambScan 2.5s linear; }
@keyframes ambScan {
  0%   { opacity: 0; transform: translateY(-100px); }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(110vh); }
}

/* Moment: the background emblem gives one slow gold pulse. */
body.amb-m-pulse .amb-emblem { animation: embPulse 2.5s ease-in-out; }
@keyframes embPulse {
  0%, 100% { transform: scale(1); opacity: .04; }
  45%      { transform: scale(1.06); opacity: .12; }
}

/* Gameplay: the ambience is gone (nothing animates behind a match). */
body.is-gameplay .amb-emblem,
body.is-gameplay .amb-stars,
body.is-gameplay .amb-glint,
body.is-gameplay .amb-scan { display: none; }

@media (prefers-reduced-motion: reduce) {
  .amb-emblem, .amb-stars i, .amb-glint, .amb-scan { animation: none !important; }
  .amb-stars i { opacity: .25; }
}

/* ==========================================================================
   V4.1 PERFORMANCE
   1. Inactive screens are only visibility:hidden (they must keep their
      layout for measuring), so their infinite decorative animations
      (arrow nudges, idle bobs, bulbs, breathing faces) used to keep
      ticking behind whatever was on screen - including behind gameplay.
      They now pause while their screen is not the active one.
   2. Adaptive quality (js/quality.js): body.q-medium / body.q-low trim
      DECORATION only - never anything a game reads.
   ========================================================================== */
.screen:not(.is-active) *,
.screen:not(.is-active) *::before,
.screen:not(.is-active) *::after { animation-play-state: paused !important; }

/* Medium: the blurred light sweep and the dust field go. */
body.q-medium .amb-sweep, body.q-low .amb-sweep,
body.q-medium .amb-dust, body.q-low .amb-dust { display: none; }
/* Low: the menu ambience goes still and big drop-shadows are dropped. */
body.q-low .amb-stars i, body.q-low .amb-emblem, body.q-low .amb-grid,
body.q-low .bezel-bulbs i { animation: none !important; }
body.q-low .vs-art, body.q-low .cs-art, body.q-low .fn-art, body.q-low .ch-art,
body.q-low .welcome-emblem img, body.q-low .cab-art svg, body.q-low .cab-art img { filter: none !important; }
body.q-low .art-frame.is-evil > .art-img {
  filter: var(--evil-tone, brightness(.8)) drop-shadow(0 0 2px var(--evil-rim-color, var(--x-e21a3e-a85))) !important;
}
body.q-low .result-overlay { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--x-020912-a80); }

/* Back to Library (js/game-page.js): in the top bar beside the sound toggle, and over the pause screen or a live online match. */
#topbar .lib-btn { display: grid; margin-left: auto; }
#topbar .lib-btn + .sound-btn { margin-left: 0; }
@supports not selector(:popover-open) { #topbar .home-btn + .lib-btn { margin-left: 0; } }
.lib-float {
  position: fixed; top: max(18px, env(safe-area-inset-top)); left: max(22px, env(safe-area-inset-left)); z-index: 81;
  height: 44px; padding: 0 16px; border-radius: 10px; color: var(--gold-100); background: linear-gradient(180deg, var(--x-143a63-a95), var(--x-071728-a95)); border: 2px solid var(--gold-500);
  font: 700 13px/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase;
}
.lib-float:hover { color: var(--cream); border-color: var(--gold-400); }
.lib-float[hidden] { display: none; }
/* A phone held upright plays sideways (body.vland): turned with the game, on the free middle of the left edge. */
body.vland .lib-float { top: 50%; left: 44px; transform: translate(-50%, -50%) rotate(90deg); }
/* Its question (ESA.Modal.confirm) keeps 44 px buttons on a phone mid-match too, where touch.css makes menu buttons 40 px. */
#modalLayer .modal-confirm .modal-btn { min-height: 44px; }

/* Loading overlay (js/boot.js, written into each game page by the build): above everything until body.is-booted, then fades. */
#boot {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-content: center; justify-items: center; gap: var(--space-4);
  padding: max(var(--space-5), env(safe-area-inset-top)) var(--space-5); text-align: center; color: var(--cream); background: var(--navy-900);
  transition: opacity var(--dur-slow) var(--ease-out), visibility 0s var(--dur-slow);
}
#boot.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-name { font: 700 clamp(28px, 7vw, 56px)/1.05 var(--font-display); letter-spacing: .08em; text-transform: uppercase; color: var(--gold-400); }
#bootBar { -webkit-appearance: none; appearance: none; width: min(320px, 72vw); height: 14px; border: 2px solid var(--gold-600); border-radius: 999px; background: var(--navy-700); overflow: hidden; }
#bootBar::-webkit-progress-bar { background: var(--navy-700); }
#bootBar::-webkit-progress-value { background: var(--gold-400); transition: width var(--dur-fast) linear; }
#bootBar::-moz-progress-bar { background: var(--gold-400); }
.boot-status { font: 600 15px/1.3 var(--font-ui); color: var(--muted); }
#bootBar[hidden], .boot-status[hidden], .boot-fail[hidden] { display: none; }
.boot-fail { display: grid; justify-items: center; gap: var(--space-4); font: 600 18px/1.3 var(--font-ui); color: var(--cream); }
.boot-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); }
.boot-btn {
  display: inline-grid; place-items: center; min-width: 120px; min-height: 48px; padding: 0 var(--space-5); border-radius: 10px;
  border: 2px solid var(--gold-500); color: var(--gold-100); background: var(--navy-600); text-decoration: none;
  font: 700 14px/1 var(--font-display); letter-spacing: .14em; text-transform: uppercase;
}
#bootRetry { color: var(--ink); background: var(--gold-400); }
.boot-btn:hover { border-color: var(--gold-300); }
@media (prefers-reduced-motion: reduce) { #boot, #bootBar::-webkit-progress-value { transition: none; } }

/* Fake fullscreen (iPhone Safari has no requestFullscreen; js/touch.js asks for the real one where it exists): the shell fills the dynamic viewport and the page never rubber-bands. */
html, body { overscroll-behavior: none; }
#app { height: 100dvh; }

/* Rotate your phone: a touch phone held upright. Every game page but the tournament's, whose setup screens work upright and whose matches do not. */
.rotate-prompt { display: none; }
@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  body:not([data-game="tournament"]) .rotate-prompt,
  body[data-game="tournament"][data-state="play"] .rotate-prompt,
  body[data-game="tournament"][data-state="hsPlay"] .rotate-prompt {
    position: fixed; inset: 0; z-index: 999; display: grid; place-content: center; justify-items: center; gap: var(--space-3);
    padding: max(var(--space-5), env(safe-area-inset-top)) var(--space-5) max(var(--space-5), env(safe-area-inset-bottom)); text-align: center;
    color: var(--cream); background: var(--navy-900); touch-action: none;
  }
}
.rp-phone { width: 44px; height: 76px; border: 3px solid var(--gold-400); border-radius: 10px; animation: rpTurn 2.4s var(--ease-out) infinite; }
.rp-head { margin: var(--space-3) 0 0; font: 700 clamp(24px, 7vw, 34px)/1.1 var(--font-display); letter-spacing: .08em; text-transform: uppercase; color: var(--gold-400); }
.rp-sub { margin: 0; font: 600 16px/1.35 var(--font-ui); color: var(--muted); }
@keyframes rpTurn { 0%, 30% { transform: none; } 60%, 100% { transform: rotate(90deg); } }
@media (prefers-reduced-motion: reduce) { .rp-phone { animation: none; transform: rotate(90deg); } }

/* --------------------------------------------------------------------------
   The lounge (arcade/references): its backdrop behind every menu, gold rules
   either side of a screen's title, the ESA ARCADE mark in the top bar.
   Colours from css/tokens.css's --lounge-* set, which swaps for light mode.
   -------------------------------------------------------------------------- */
#ambient { background: var(--x-020810) url("/art/arcade/esa-arcade__lounge__desktop__dark.2x.4614c8ed7858a407.webp") 50% 50% / cover no-repeat; }
.amb-pattern, .amb-floor { display: none; }
:root[data-mode=light] #ambient { background-image: url("/art/arcade/esa-arcade__lounge__desktop__light.2x.e16b125d37232319.webp"); }
@media (prefers-color-scheme: light) { :root:not([data-mode]) #ambient { background-image: url("/art/arcade/esa-arcade__lounge__desktop__light.2x.e16b125d37232319.webp"); } }
@media (max-aspect-ratio: 3/4) {
  #ambient { background-image: url("/art/arcade/esa-arcade__lounge__phone__dark.phone.a555a0fea1eefdd3.webp"); }
  :root[data-mode=light] #ambient { background-image: url("/art/arcade/esa-arcade__lounge__phone__light.phone.dbc0942870a823e7.webp"); }
}
@media (max-aspect-ratio: 3/4) and (prefers-color-scheme: light) { :root:not([data-mode]) #ambient { background-image: url("/art/arcade/esa-arcade__lounge__phone__light.phone.dbc0942870a823e7.webp"); } }

.screen-head .px-arrow { width: clamp(32px, 9vw, 120px); height: 2px; animation: none; color: var(--lounge-gold); background: linear-gradient(90deg, transparent, currentColor); }
.screen-head .px-arrow::before { left: auto; right: -4px; top: -4px; width: 10px; height: 10px; box-shadow: none; transform: rotate(45deg); }
/* #app: this sheet loads before css/menus.css, whose rules these follow. */
#app .screen-title { background-image: linear-gradient(180deg, var(--lounge-title-hi) 10%, var(--lounge-title-lo)); filter: drop-shadow(0 3px 6px var(--lounge-shade)); }
/* The light lounge: words that sit straight on the backdrop turn navy (panels stay navy, as in the references). */
:root[data-mode=light] #app :is(.hub-title, .screen-sub, .nav-hint, .touch-hint, .hub-phase, .welcome-kicker, .welcome-foot, .cs-tile-name, .ps-tile-name, .hp-step:not(.is-now), .nav-hint b, .touch-hint b),
:root[data-mode=light] #topbar .topbar-crumb { color: var(--lounge-ink); text-shadow: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-mode]) #app :is(.hub-title, .screen-sub, .nav-hint, .touch-hint, .hub-phase, .welcome-kicker, .welcome-foot, .cs-tile-name, .ps-tile-name, .hp-step:not(.is-now), .nav-hint b, .touch-hint b),
  :root:not([data-mode]) #topbar .topbar-crumb { color: var(--lounge-ink); text-shadow: none; }
}

.topbar-mark {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 10px; pointer-events: none;
  font: 800 24px/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; white-space: nowrap;
  color: var(--lounge-title-lo); background-image: linear-gradient(180deg, var(--lounge-title-hi), var(--lounge-title-lo));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.topbar-mark img { width: 36px; height: auto; filter: drop-shadow(0 0 10px var(--x-f3c35a-a45)); }
/* Only where the bar has room between Back and the buttons on the right. */
@media (max-width: 1099px) { .topbar-mark { display: none; } }

/* Panels framed in the lounge's gold line. */
.hub-panel, .st-table-wrap, .br-wrap, #introScreen .intro-inner, .ps-bar { border: 2px solid var(--lounge-line); box-shadow: 0 8px 0 var(--x-020810), 0 22px 44px var(--x-000000-a45), inset 0 0 24px var(--x-f3c35a-a8); }
/* A game's own page offers two modes (js/game-page.js hides the tournament's card): two columns, centred. */
@media (min-width: 861px) {
  body[data-game]:not([data-game="tournament"]):not(.is-touch) .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(820px, 100%); margin-inline: auto; }
}
