:root {
  --blue: #1f5fff;
  --blue-deep: #0a2a8a;
  --yellow: #ffd400;
  --yellow-deep: #a67c00;
  --ink: #0b0b12;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: #fff; overflow: hidden; font-family: Inter, system-ui, sans-serif; cursor: default; }

/* 16:9 frame fitted to the viewport; everything inside scales with cqw. */
#frame {
  position: absolute; inset: 0; margin: auto;
  width: min(100vw, 177.78vh); height: min(100vh, 56.25vw);
  container-type: size; overflow: hidden; background: #000;
}
#stage, #fx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fx { pointer-events: none; z-index: 50; }

/* ---------- score bar ---------- */
#scorebar {
  position: absolute; z-index: 20; top: 1.2cqw; left: 1.4cqw; right: 1.4cqw;
  display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none;
  transition: opacity .4s, transform .4s;
}
body[data-phase="LOBBY"] #scorebar { opacity: 0; transform: translateY(-3cqw); }
.team {
  display: flex; align-items: center; gap: 1cqw; padding: .5cqw 1.1cqw; border-radius: 99cqw;
  font-family: Bungee, Inter, sans-serif; font-size: 2.3cqw; line-height: 1;
  box-shadow: 0 .3cqw 1.2cqw rgba(0,0,0,.45), inset 0 -.25cqw 0 rgba(0,0,0,.2);
  position: relative; transition: filter .3s, opacity .3s;
}
.team.blue { background: linear-gradient(180deg, #4b82ff, var(--blue)); color: #fff; }
.team.yellow { background: linear-gradient(180deg, #ffe45c, var(--yellow)); color: #221a00; }
.team .name { font-size: .7em; opacity: .9; letter-spacing: .05em; }
.team .score { min-width: 2.2ch; text-align: center; display: inline-block; }
.team .score.bump { animation: bump .6s cubic-bezier(.2,2,.4,1); }
.team .lock { display: none; position: absolute; bottom: -1.6cqw; left: 50%; transform: translateX(-50%); font: 800 .9cqw Inter; background: #000a; color: #fff; padding: .15cqw .6cqw; border-radius: 1cqw; text-transform: uppercase; letter-spacing: .1em; }
.team.locked { filter: grayscale(.8) brightness(.6); }
.team.locked .lock { display: block; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.6); } 100% { transform: scale(1); } }

#center { text-align: center; font-family: Bungee, sans-serif; text-shadow: 0 .2cqw .6cqw #000c; }
#round { font-size: 1.1cqw; letter-spacing: .15em; opacity: .85; }
#value { font-size: 3.2cqw; line-height: 1; margin-top: .3cqw; opacity: 0; transition: opacity .3s; }
#value-label { font-size: .35em; margin-left: .4em; opacity: .8; }
/* The clip itself plays clean: no score bar while it runs. */
body[data-phase="PLAYING"] #scorebar { opacity: 0; transform: translateY(-3cqw); }
body[data-phase="BUZZED"] #value { opacity: 1; }

#badge {
  position: absolute; z-index: 20; top: 1.2cqw; right: 1.4cqw; padding: .4cqw 1cqw; border-radius: 99cqw;
  font: 400 1.1cqw Bungee, sans-serif; letter-spacing: .08em; background: #000a; color: var(--yellow);
  border: .15cqw solid var(--yellow); opacity: 0; transition: opacity .3s;
}
body[data-stage="2"][data-phase="PLAYING"] #badge, body[data-stage="3"][data-phase="PLAYING"] #badge { opacity: 1; }

#replay { background: radial-gradient(circle, #2a1a33, #000 70%); }

#joinpanel { z-index: 40; background: #0b0b12f0; gap: 1.6cqw; }
#joinpanel .joins { gap: 6cqw; }
#joinpanel .join { width: 18cqw; }
.team .off { display: none; position: absolute; top: -1.3cqw; left: 50%; transform: translateX(-50%); white-space: nowrap; font: 800 .8cqw Inter; background: #c00; color: #fff; padding: .1cqw .6cqw; border-radius: 1cqw; }
.team.offline .off { display: block; }
#replay .big { margin: 1.2cqw 0; color: var(--yellow); animation: pulse 1.6s ease-in-out infinite; }

#progress { position: absolute; z-index: 20; left: 0; right: 0; bottom: 0; height: .5cqw; background: #0006; opacity: 0; transition: opacity .3s; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), #fff, var(--yellow)); }
body[data-phase="PLAYING"] #progress, body[data-phase="BUZZED"] #progress { opacity: 1; }

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; opacity: 0; pointer-events: none; transition: opacity .35s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.big { font-family: Bungee, sans-serif; font-size: 6cqw; line-height: 1; }
.kicker { font-family: Bungee, sans-serif; font-size: 1.8cqw; letter-spacing: .2em; color: var(--yellow); }
.hint { font-size: 1.4cqw; opacity: .7; margin-top: 1.5cqw; }

#lobby { background: #12062b; justify-content: flex-start; padding-top: 3.2cqw; }
#lobby > *:not(canvas) { position: relative; z-index: 1; }
#intro-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }

/* Miami Vice title: wide teal caps, hot-pink neon script, chrome year. */
#lobby .title { margin: 0; display: grid; justify-items: center; line-height: 1; transform: skewX(-8deg); }
#lobby .rungsted {
  font: 400 7.4cqw Michroma, Bungee, sans-serif; letter-spacing: .12em; padding-left: .12em;
  background: linear-gradient(180deg, #e9fffd 0%, #7ff8ef 45%, #19c8c0 55%, #b8fff9 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 .35cqw #41f5e5) drop-shadow(0 .45cqw 0 #1c0a33);
}
#lobby .quiz {
  font: 400 11cqw 'Mr Dafoe', cursive; color: #ffe3f6; margin-top: -4.6cqw; margin-left: 22cqw;
  transform: rotate(-7deg);
  text-shadow: 0 0 .3cqw #fff, 0 0 1cqw #ff5fc8, 0 0 2.2cqw #ff5fc8, 0 0 4.5cqw #ff2fa8;
  animation: neon-on 2.4s steps(1) 1 both, neon-hum 3.2s ease-in-out 2.4s infinite;
}
#lobby .year {
  font: 400 2.4cqw Michroma, sans-serif; letter-spacing: .6em; padding-left: .6em; margin-top: -2cqw;
  background: linear-gradient(180deg, #fff 0%, #c9c2ff 48%, #6a5acd 52%, #fff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: flex; align-items: center; gap: 1.2cqw;
}
#lobby .year::before, #lobby .year::after { content: ''; width: 9cqw; height: .25cqw; background: linear-gradient(90deg, transparent, #ff5fc8, #41f5e5); }
#lobby .year::after { transform: scaleX(-1); }
@keyframes neon-on {
  0%, 12%, 22%, 30% { opacity: .15; }
  8%, 18%, 26%, 40%, 100% { opacity: 1; }
}
@keyframes neon-hum { 50% { opacity: .88; text-shadow: 0 0 .3cqw #fff, 0 0 .8cqw #ff5fc8, 0 0 1.8cqw #ff5fc8, 0 0 3.6cqw #ff2fa8; } }
#lobby .sub { font: 600 1.35cqw Inter, sans-serif; letter-spacing: .06em; color: #ffe6f7; text-shadow: 0 .15cqw .6cqw #000c; margin: 1cqw 0 1.4cqw; }
#lobby .rules { font-size: 1.1cqw; max-width: 72cqw; margin-top: 1.1cqw; line-height: 1.4; color: #fff; background: #1c0a33b3; padding: .6cqw 1.2cqw; border-radius: .8cqw; }
.joins { display: flex; gap: 30cqw; }
.join {
  all: unset; cursor: pointer; width: 13.5cqw; padding: .9cqw; border-radius: 1.4cqw; text-align: center;
  box-shadow: 0 1cqw 3cqw #0009, 0 0 0 .2cqw #ffffff55; transition: transform .2s;
}
.join:hover { transform: scale(1.02); }
.join.blue { background: linear-gradient(160deg, #4b82ff, var(--blue-deep)); }
.join.yellow { background: linear-gradient(160deg, #ffe45c, var(--yellow-deep)); color: #221a00; }
.join .qr { background: #fff; border-radius: 1cqw; padding: .6cqw; aspect-ratio: 1; }
.join .qr svg { width: 100%; height: 100%; display: block; }
.join .label { font-family: Bungee, sans-serif; font-size: 1.8cqw; margin-top: .7cqw; }
.join .status { font-size: .95cqw; font-weight: 600; margin-top: .2cqw; opacity: .9; }
.join.connected .qr { opacity: .15; }
.join.connected .status::before { content: '✔ '; }

#intro { background: radial-gradient(circle, #1a1a33, #000 70%); }
#intro .big { margin: 1.2cqw 0; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }

#buzzed { background: #0008; }
#buzzed .who, #buzzed .big { font-family: Bungee, sans-serif; }
#buzzed .who { font-size: 4cqw; }
#buzzed .big { font-size: 11cqw; }
#buzzed .pts { font-size: 2.2cqw; font-weight: 800; margin-top: 1cqw; }
#buzzed.blue .who, #buzzed.blue .big { color: #fff; text-shadow: 0 0 2cqw var(--blue), 0 .5cqw 0 var(--blue-deep); }
#buzzed.yellow .who, #buzzed.yellow .big { color: var(--yellow); text-shadow: 0 0 2cqw var(--yellow), 0 .5cqw 0 var(--yellow-deep); }
#buzzed.show .big { animation: slam .5s cubic-bezier(.2,1.6,.4,1); }
#buzzed.blue { box-shadow: inset 0 0 0 1.2cqw var(--blue); }
#buzzed.yellow { box-shadow: inset 0 0 0 1.2cqw var(--yellow); }
@keyframes slam { from { transform: scale(3) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }

#verdict { pointer-events: none !important; }
#verdict-text { font-family: Bungee, sans-serif; font-size: 12cqw; color: #ff3344; text-shadow: 0 .6cqw 0 #700, 0 0 3cqw #f008; transform: rotate(-6deg); }
#verdict.show #verdict-text { animation: slam .45s cubic-bezier(.2,1.6,.4,1); }

#reveal { background: radial-gradient(circle, #0000 30%, #000c 100%); }
#reveal .card {
  background: #0b0b12e6; border-radius: 2cqw; padding: 2.4cqw 4cqw; min-width: 50cqw; box-shadow: 0 1cqw 4cqw #000c;
  border: .3cqw solid #fff2; backdrop-filter: blur(.4cqw);
}
#reveal.show .card { animation: rise .6s cubic-bezier(.2,1.3,.4,1); }
@keyframes rise { from { transform: translateY(8cqw) scale(.9); opacity: 0; } }
#reveal .result { font-family: Bungee, sans-serif; font-size: 1.7cqw; margin-bottom: 1.2cqw; }
#reveal .result.blue { color: #7ea6ff; } #reveal .result.yellow { color: var(--yellow); } #reveal .result.none { color: #aaa; }
#reveal .title { font-family: Bungee, sans-serif; font-size: 4.6cqw; line-height: 1.05; }
#reveal .artist { font-size: 2.4cqw; font-weight: 800; margin-top: .6cqw; opacity: .9; }
#reveal .style { font-size: 1.4cqw; margin-top: 1.2cqw; opacity: .6; font-style: italic; }

#final { background: radial-gradient(circle, #1a1a33, #000 75%); }
#final .big { font-size: 7cqw; margin: 1.5cqw 0 3cqw; }
.finalscores { display: flex; gap: 6cqw; font-family: Bungee, sans-serif; }
.finalscores div { padding: 1.5cqw 3cqw; border-radius: 1.5cqw; display: flex; flex-direction: column; align-items: center; }
.finalscores span { font-size: 2cqw; }
.finalscores b { font-size: 7cqw; font-weight: 400; }
.finalscores .blue { background: var(--blue); }
.finalscores .yellow { background: var(--yellow); color: #221a00; }

#unlock { position: fixed; z-index: 100; background: #000d; cursor: pointer; }

#help {
  position: fixed; z-index: 90; left: 50%; bottom: .6vh; transform: translateX(-50%); font-size: 12px; color: #fff9;
  background: #000a; padding: 4px 12px; border-radius: 8px; white-space: nowrap;
}
#help.hidden { display: none; }
#conn { position: fixed; z-index: 95; top: 8px; left: 50%; transform: translateX(-50%); background: #c00; color: #fff; padding: 4px 12px; border-radius: 8px; font-size: 14px; display: none; }
#conn.show { display: block; }
