/* ============================================================
   stage.css — 16:9 projector battlefront for Genre Tug-of-War
   ============================================================ */
:root {
  --cyan: #00E5FF;
  --magenta: #FF1A8C;
  --disp: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #000; overflow: hidden; font-family: var(--disp); color: #fff; -webkit-font-smoothing: antialiased; }

#viewport { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#stageRoot {
  position: relative; width: 1920px; height: 1080px; flex: none;
  transform-origin: center center; background: #050507; overflow: hidden;
}
#bf { position: absolute; inset: 0; width: 1920px; height: 1080px; }

.overlay { position: absolute; inset: 0; pointer-events: none; }

/* header */
.st-head {
  position: absolute; top: 40px; left: 48px; right: 48px;
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); letter-spacing: 0.22em; text-transform: uppercase;
}
.st-live { display: inline-flex; align-items: center; gap: 14px; font-size: 22px; font-weight: 700; white-space: nowrap; }
.st-dot { width: 16px; height: 16px; border-radius: 50%; background: #FF2D2D; box-shadow: 0 0 18px #FF2D2D; animation: blink 1.2s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.st-mode { font-size: 22px; font-weight: 700; color: rgba(255,255,255,0.7); white-space: nowrap; }

/* center readout */
.readout {
  position: absolute; top: 130px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 60px;
}
.ro-side { display: flex; align-items: baseline; gap: 34px; }
.ro-side.techno { color: var(--cyan); }
.ro-side.disco { color: var(--magenta); }
.ro-name { font-family: var(--disp); font-weight: 700; font-size: 76px; letter-spacing: -0.01em; text-transform: uppercase; white-space: nowrap; }
.ro-pct { font-family: var(--disp); font-weight: 700; font-size: 124px; line-height: 0.85; letter-spacing: -0.03em; }
.ro-pct::after { content: '%'; font-size: 46px; opacity: 0.6; }
.ro-dash { font-size: 90px; font-weight: 700; color: rgba(255,255,255,0.35); }
.techno .ro-name, .techno .ro-pct { text-shadow: 0 0 50px color-mix(in srgb, var(--cyan) 70%, transparent); }
.disco .ro-name, .disco .ro-pct { text-shadow: 0 0 50px color-mix(in srgb, var(--magenta) 70%, transparent); }

/* round + score */
.round {
  position: absolute; top: 360px; left: 0; right: 0; text-align: center;
  font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: 0.24em;
  color: rgba(255,255,255,0.75); text-transform: uppercase;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
#roundTxt { white-space: nowrap; }
.round-sub { font-family: var(--mono); font-size: 38px; font-weight: 700; letter-spacing: 0.16em; color: rgba(255,255,255,0.82); white-space: nowrap; text-shadow: 0 0 24px rgba(0,0,0,0.6); }
.score { display: inline-flex; gap: 12px; }
.score i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); display: block; }
.score i.a { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 16px var(--cyan); }
.score i.b { background: var(--magenta); border-color: var(--magenta); box-shadow: 0 0 16px var(--magenta); }

/* hype meter */
.hype {
  position: absolute; bottom: 56px; left: 50%; transform: translateX(-50%); width: 640px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.hype-lbl { font-family: var(--mono); font-size: 20px; font-weight: 700; letter-spacing: 0.3em; color: rgba(255,255,255,0.6); }
.hype-bar { width: 100%; height: 18px; border-radius: 999px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); overflow: hidden; }
.hype-bar i { display: block; height: 100%; width: 10%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), #fff, var(--magenta)); box-shadow: 0 0 22px rgba(255,255,255,0.6); transition: width .12s linear; }

/* sudden death indicator */
.sudden-stage {
  position: absolute; top: 470px; left: 50%; transform: translateX(-50%);
  font-family: var(--disp); font-weight: 700; font-size: 56px; letter-spacing: 0.04em;
  text-transform: uppercase; text-align: center; opacity: 0; transition: opacity .2s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.sudden-stage[data-on="1"] { opacity: 1; animation: sdpulse .5s ease-in-out infinite; }
.sudden-stage .sd-count { font-size: 120px; line-height: 0.9; }
@keyframes sdpulse { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.06); } }

/* win flash */
.win-flash {
  position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px; opacity: 0; pointer-events: none;
}
.win-flash[data-on="1"] { animation: wflash 2.9s ease-out forwards; }
/* The "next song is for…" reveal card already shows the winning genre, and it
   fires at the same moment — so suppress the win-flash while the reveal is up,
   otherwise the bright flash bleeds through the reveal's dark backdrop. */
body.revealing .win-flash { opacity: 0 !important; animation: none !important; }
.wf-name { font-family: var(--disp); font-weight: 700; font-size: 200px; line-height: 0.85; color: #050507; text-transform: uppercase; letter-spacing: -0.03em; white-space: nowrap; }
.wf-sub { font-family: var(--mono); font-size: 40px; font-weight: 700; letter-spacing: 0.3em; color: #050507; }
@keyframes wflash { 0% { opacity: 0; } 8% { opacity: 1; } 86% { opacity: 1; } 100% { opacity: 0; } }

.hint {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; color: rgba(255,255,255,0.4);
  text-align: center; padding: 0 16px;
}
.hint b { color: rgba(255,255,255,0.7); }

@media (prefers-reduced-motion: reduce) {
  .st-dot, .sudden-stage, .win-flash { animation: none !important; }
  .win-flash[data-on="1"] { opacity: 0.92; }
}

/* ============================================================
   MERGED FROM design-handoff — PARTY-ENDED finale (cross-fades
   over the battlefront when the DJ ends the show).
   NOTE: the handoff's INTRO/lobby rules are intentionally omitted
   here — this app already has its own scan-to-join lobby, and the
   handoff's bare `.lobby { display:flex … }` would collide with
   the live `<body class="lobby">`. Only the `.ended` finale +
   credits + QR styles are merged.
   ============================================================ */
.screen-state {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none; transition: opacity .6s ease;
}
#ended { z-index: 30; }
.overlay, #bf { transition: opacity .6s ease; }

/* When the finale fades in, restore interactivity — .screen-state defaults to
   pointer-events:none, so without this the "START A NEW SHOW" button is visible
   but every click passes through it to the battle layers behind. */
body.ended #ended { opacity: 1; pointer-events: auto; }
body.ended .overlay, body.ended #bf { opacity: 0; }
body.ended .hint { display: none; }

/* calm bloom backdrop for the finale */
.screen-state::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 55% at 22% 24%, rgba(0,229,255,0.18), transparent 60%),
    radial-gradient(58% 52% at 80% 30%, rgba(255,26,140,0.16), transparent 60%),
    radial-gradient(80% 60% at 50% 116%, rgba(0,229,255,0.12), transparent 62%);
  filter: blur(8px);
}

/* steady (non-blinking) green dot variant */
.st-live.done .st-dot { background: #2DD36F; box-shadow: 0 0 18px #2DD36F; animation: none; }

.state-hint {
  position: absolute; bottom: 44px; left: 0; right: 0; text-align: center;
  font-family: var(--mono); font-size: 22px; letter-spacing: 0.16em;
  color: rgba(255,255,255,0.55); text-transform: uppercase;
}

@keyframes lobbypan { from { background-position: 0% 0; } to { background-position: 100% 0; } }

/* QR (reuses the lobby QR box from stage-live.html; `.small` sizes the finale) */
.lobby-qr.small { width: 300px; height: 300px; padding: 20px; box-sizing: border-box; }
.qr-kicker { font-family: var(--disp); font-weight: 700; font-size: 32px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cyan); text-shadow: 0 0 30px rgba(0,229,255,0.6); white-space: nowrap; }
.qr-kicker.save { font-size: 28px; }
.qr-url { font-family: var(--mono); font-size: 22px; font-weight: 700; letter-spacing: 0.18em; color: rgba(255,255,255,0.75); white-space: nowrap; }

/* ---- PARTY-ENDED ---- */
.ended-main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 40px 80px 124px; text-align: center;
}
.ended-title {
  display: block; width: 100%; max-width: 1500px;
  font-family: var(--disp); font-weight: 700; font-size: 124px; line-height: 0.9;
  letter-spacing: -0.03em; text-transform: uppercase; margin: 0;
  background: linear-gradient(100deg, var(--cyan) 12%, #fff 50%, var(--magenta) 88%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  animation: lobbypan 9s ease-in-out infinite alternate;
}
.ended-stats {
  display: block; white-space: nowrap;
  font-family: var(--mono); font-size: 42px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: rgba(255,255,255,0.7);
}
.ended-stats .es b { font-family: var(--disp); font-size: 50px; }
.ended-stats .es.a b { color: var(--cyan); text-shadow: 0 0 40px rgba(0,229,255,0.6); }
.ended-stats .es.b b { color: var(--magenta); text-shadow: 0 0 40px rgba(255,26,140,0.6); }
.ended-stats .es-dash { color: rgba(255,255,255,0.35); margin: 0 18px; }

.ended-save { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 4px; }
.save-note { font-family: var(--mono); font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255,255,255,0.45); }

/* slow auto-scrolling credits ticker */
.credits {
  position: absolute; bottom: 96px; left: 0; right: 0; overflow: hidden;
  -webkit-mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
          mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.credits-track {
  display: inline-flex; gap: 56px; white-space: nowrap; padding-left: 100%;
  font-family: var(--mono); font-size: 20px; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  animation: creditscroll 38s linear infinite;
}
.credits-track .cr b { color: rgba(255,255,255,0.85); font-weight: 700; }
.credits-track .cr i { font-style: normal; }
@keyframes creditscroll { to { transform: translateX(-50%); } }

/* entrance pop on the finale */
body.ended #ended .ended-main { animation: stateRise .7s cubic-bezier(.2,.8,.2,1) both; }
@keyframes stateRise { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
