/* АПОЖ: party night look, sized for a TV across the room. */

:root {
  --bg: #170a36;
  --bg2: #2a0f5c;
  --ink: #fff7fb;
  --muted: rgba(255, 247, 251, .62);
  --pink: #ff4f9a;
  --yellow: #ffd23f;
  --cyan: #3de0ff;
  --lime: #8cff6b;
  --violet: #b388ff;
  --orange: #ff8a3d;
  --card: rgba(255, 255, 255, .075);
  --card-border: rgba(255, 255, 255, .14);
  --radius: 1.6rem;
  --display: 'Unbounded', 'Rubik', system-ui, sans-serif;
  --body: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

/* Everything is sized in rem; the root scales with the viewport so a TV and a laptop look alike. */
html { font-size: clamp(13px, min(1.05vw, 1.9vh), 34px); }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg2), var(--bg) 70%);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.15rem;
  line-height: 1.4;
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }

h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: .02em; }
h3 { font-size: 1.15rem; font-weight: 700; }

.muted { color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.error { color: #ff8fa3; font-weight: 500; min-height: 1.4em; }
.error:empty { min-height: 0; }

/* ---------- Animated background ---------- */

.bg { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.blob {
  position: absolute; width: 48vmax; height: 48vmax; border-radius: 50%;
  filter: blur(9vmax); opacity: .42; mix-blend-mode: screen;
  animation: drift 28s ease-in-out infinite alternate;
}
.b1 { background: var(--pink); top: -18vmax; left: -12vmax; }
.b2 { background: var(--cyan); bottom: -22vmax; right: -14vmax; animation-delay: -7s; opacity: .3; }
.b3 { background: var(--violet); top: 30%; left: 40%; animation-delay: -14s; opacity: .3; }
.b4 { background: var(--yellow); bottom: -26vmax; left: -10vmax; animation-delay: -21s; opacity: .16; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8vmax, 6vmax) scale(1.15); }
  100% { transform: translate(-6vmax, 10vmax) scale(.95); }
}
body::after {
  /* faint stage-light dots */
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1.4px);
  background-size: 2.2rem 2.2rem;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 80%);
}

/* ---------- Layout ---------- */

#app { min-height: 100vh; }
.screen {
  min-height: 100vh; display: flex; flex-direction: column;
  padding: 1.4rem 2.4rem 1.6rem;
  animation: screen-in .45s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes screen-in { from { opacity: 0; transform: translateY(1.2rem) scale(.985); } }

.stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.6rem; padding: 1rem 0; width: 100%; max-width: 92rem; margin: 0 auto;
}

.card {
  background: var(--card); border: 2px solid var(--card-border); border-radius: var(--radius);
  padding: 1.5rem; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 1.2rem 3rem rgba(10, 0, 30, .35);
}

.title { font-size: 2.6rem; font-weight: 900; text-align: center; display: flex; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap; }
.title-xl { font-size: 3.6rem; }
.subtitle { font-size: 1.4rem; color: var(--muted); margin: -.6rem 0 0; text-align: center; }

/* ---------- Logo ---------- */

.logo { display: inline-flex; font-family: var(--display); font-weight: 900; line-height: 1; user-select: none; }
.logo-letter {
  display: inline-block; width: 1em; text-align: center;
  transition: transform 1.2s cubic-bezier(.5, -0.4, .3, 1.4);
}
.logo-letter:nth-child(1) { color: var(--pink); }
.logo-letter:nth-child(2) { color: var(--yellow); }
.logo-letter:nth-child(3) { color: var(--cyan); }
.logo-letter:nth-child(4) { color: var(--lime); }
.logo-lg { font-size: 7.4rem; filter: drop-shadow(0 .5rem 0 rgba(0,0,0,.35)); }
.logo-lg .logo-letter { animation: bob 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * -.35s); }
.logo-lg .logo-letter:nth-child(odd) { rotate: -6deg; }
.logo-lg .logo-letter:nth-child(even) { rotate: 5deg; }
.logo-lg.flip .logo-letter { transform: translateX(calc((3 - 2 * var(--i)) * 1em)); }
.logo-sm { font-size: 1.7rem; }
@keyframes bob { 50% { translate: 0 -.08em; } }

/* ---------- Buttons ---------- */

.btn {
  --b: rgba(255, 255, 255, .12);
  --b-edge: rgba(0, 0, 0, .35);
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  border: 0; border-radius: 999px; cursor: pointer;
  padding: .85rem 1.6rem; font-family: var(--display); font-weight: 700; font-size: 1.1rem;
  background: var(--b); box-shadow: 0 .3rem 0 var(--b-edge);
  transition: transform .12s, box-shadow .12s, filter .2s, background .2s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-2px); box-shadow: 0 .45rem 0 var(--b-edge); }
.btn:active:not(:disabled) { transform: translateY(.25rem); box-shadow: 0 .05rem 0 var(--b-edge); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { --b: linear-gradient(135deg, var(--pink), var(--orange)); --b-edge: #9c1f57; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.btn-secondary { --b: rgba(255, 255, 255, .14); }
.btn-ghost { --b: transparent; box-shadow: inset 0 0 0 2px rgba(255,255,255,.22); }
.btn-ghost:hover:not(:disabled) { box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); transform: none; }
.btn-ghost:active:not(:disabled) { box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); }
.btn-danger { --b: rgba(255, 79, 120, .2); box-shadow: inset 0 0 0 2px rgba(255, 79, 120, .6); }
.btn-xl { font-size: 1.6rem; padding: 1.15rem 2.4rem; }
.btn-icon { display: inline-flex; font-size: 1.15em; line-height: 1; }
.btn-play .btn-icon { width: 1em; justify-content: center; }
.btn-play.playing { --b: var(--yellow); color: #2a0f5c; --b-edge: #a07c00; }
.btn-play.playing .btn-icon { animation: pulse .8s ease-in-out infinite; }

kbd {
  font-family: var(--body); font-weight: 700; font-size: .72em; line-height: 1;
  padding: .3em .55em; border-radius: .45em; letter-spacing: .02em;
  background: rgba(0, 0, 0, .28); border: 1px solid rgba(255, 255, 255, .25); color: rgba(255,255,255,.9);
}
.btn-play.playing kbd { background: rgba(42, 15, 92, .15); border-color: rgba(42, 15, 92, .3); color: #2a0f5c; }

.icon-btn {
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  width: 2.4rem; height: 2.4rem; border-radius: 50%; font-size: 1rem;
}
.icon-btn:hover { background: rgba(255,255,255,.1); color: var(--ink); }

/* ---------- Avatars and tags ---------- */

.avatar {
  --c: var(--pink);
  display: inline-grid; place-items: center; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
  box-shadow: 0 .25rem 0 color-mix(in srgb, var(--c) 55%, #000), inset 0 -.2rem .4rem rgba(0,0,0,.15);
  line-height: 1;
}
.avatar-sm { width: 1.9rem; height: 1.9rem; font-size: 1.15rem; box-shadow: 0 .12rem 0 color-mix(in srgb, var(--c) 55%, #000); }
.avatar-md { width: 3rem; height: 3rem; font-size: 1.7rem; }
.avatar-lg { width: 4.6rem; height: 4.6rem; font-size: 2.7rem; }
.avatar-xl { width: 8rem; height: 8rem; font-size: 4.8rem; box-shadow: 0 .45rem 0 color-mix(in srgb, var(--c) 55%, #000); }
.avatar-btn { border: 0; cursor: pointer; transition: transform .2s; }
.avatar-btn:hover { transform: rotate(-12deg) scale(1.08); }

.player-tag {
  display: inline-flex; align-items: center; gap: .45rem; padding: .25rem .9rem .25rem .3rem;
  border-radius: 999px; background: color-mix(in srgb, var(--c) 22%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent);
  font-weight: 700; white-space: nowrap;
}

/* ---------- Top bar and bottom ---------- */

.topbar { display: flex; align-items: center; gap: 1.6rem; min-height: 3.4rem; }
.topbar .btn { padding: .55rem 1.1rem; font-size: .95rem; }
.topbar-round { font-family: var(--display); font-size: 1.2rem; color: var(--muted); white-space: nowrap; }
.topbar-round b { color: var(--ink); font-size: 1.35em; }

.steps { flex: 1; display: flex; justify-content: center; gap: .5rem; list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  counter-increment: step; padding: .45rem 1.1rem; border-radius: 999px; font-weight: 700; font-size: 1rem;
  color: var(--muted); background: rgba(255,255,255,.05); white-space: nowrap;
}
.steps li::before { content: counter(step) '. '; opacity: .7; }
.steps li.done { color: var(--lime); }
.steps li.done::before { content: '✓ '; opacity: 1; }
.steps li.active { color: #2a0f5c; background: var(--yellow); box-shadow: 0 0 1.4rem rgba(255, 210, 63, .45); }

.bottom { display: flex; justify-content: center; padding-top: .6rem; }
.hint-bottom { color: var(--muted); font-size: 1.15rem; text-align: center; }
.hint-bottom .player-tag { margin: 0 .3rem; vertical-align: middle; }

.scoreboard { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: center; }
.score-item {
  position: relative; display: flex; align-items: center; gap: .55rem;
  padding: .35rem 1rem .35rem .35rem; border-radius: 999px;
  background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 2px rgba(255,255,255,.08);
}
.score-name { font-weight: 500; }
.score-points { font-family: var(--display); font-size: 1.2rem; color: var(--yellow); min-width: 1.2rem; text-align: right; }
.score-item.bump { box-shadow: inset 0 0 0 2px var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); animation: bump .6s 1.1s both; }
.score-delta {
  position: absolute; top: -1.1rem; right: -.3rem; font-family: var(--display); font-weight: 900;
  color: var(--lime); font-size: 1.1rem; animation: float-up 1.8s 1.1s both;
}
@keyframes bump { 40% { transform: scale(1.18); } }
@keyframes float-up { 0% { opacity: 0; transform: translateY(.8rem); } 30% { opacity: 1; transform: none; } 100% { opacity: 1; } }

/* ---------- Home ---------- */

.home { flex: 1; display: grid; grid-template-columns: 1fr 1.05fr; gap: 3rem; align-items: center; max-width: 100rem; margin: 0 auto; width: 100%; }
.home-hero { display: flex; flex-direction: column; align-items: flex-start; gap: 1.4rem; }
.tagline { font-family: var(--display); font-weight: 700; font-size: 2rem; margin-top: -1rem; }
.mirror { display: inline-block; transform: scaleX(-1); color: var(--yellow); }
.rules { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .8rem; font-size: 1.3rem; }
.rules li { display: flex; gap: 1rem; align-items: center; }
.rule-icon {
  flex: none; width: 3rem; height: 3rem; display: grid; place-items: center; font-size: 1.6rem;
  border-radius: 1rem; background: rgba(255,255,255,.08);
}
.rules b { color: var(--yellow); }
.scoring { font-size: 1.15rem; color: var(--muted); padding: .9rem 1.2rem; border-radius: 1rem; background: rgba(255,255,255,.05); }
.scoring b { color: var(--lime); }

.setup { display: flex; flex-direction: column; gap: 1rem; padding: 2rem; }
.setup h2 { display: flex; align-items: center; gap: .6rem; margin-top: .3rem; }
.setup h2 .count {
  font-size: .85rem; background: var(--pink); color: #fff; border-radius: 999px; padding: .15rem .6rem;
}
.setup h2 .count:empty { display: none; }

.players-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.player-row {
  display: flex; align-items: center; gap: .6rem; padding: .35rem .4rem .35rem .4rem;
  border-radius: 999px; background: rgba(0,0,0,.18);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 35%, transparent);
}
.player-row:focus-within { box-shadow: inset 0 0 0 2px var(--c); }
.player-input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font-size: 1.25rem; font-weight: 500; padding: .3rem .2rem;
}
.player-input::placeholder { color: rgba(255,255,255,.3); }
.add-player {
  border: 2px dashed rgba(255,255,255,.25); background: transparent; border-radius: 999px; cursor: pointer;
  color: var(--muted); font-weight: 700; font-size: 1.05rem; min-height: 3.8rem;
}
.add-player:hover { border-color: var(--yellow); color: var(--yellow); }

.chips { display: flex; flex-wrap: wrap; gap: .6rem; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
  padding: .55rem .95rem; border-radius: 999px; border: 0; font-weight: 500; font-size: 1.05rem;
  background: rgba(255,255,255,.06); color: var(--muted); box-shadow: inset 0 0 0 2px rgba(255,255,255,.12);
  transition: all .15s;
}
.chip:hover { color: var(--ink); }
.chip.on { background: rgba(140, 255, 107, .14); color: var(--ink); box-shadow: inset 0 0 0 2px var(--lime); }
.chip-emoji { font-size: 1.15em; }
.chip-count { font-size: .8em; opacity: .65; }
.chip-count:empty { display: none; }

.custom-songs summary { cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 1rem; color: var(--muted); padding: .2rem 0; }
.custom-songs summary:hover { color: var(--ink); }
.custom-songs textarea {
  width: 100%; margin-top: .6rem; border-radius: 1rem; border: 2px solid rgba(255,255,255,.15);
  background: rgba(0,0,0,.2); padding: .8rem 1rem; resize: vertical; font-size: 1rem; outline: none;
}
.custom-songs textarea:focus { border-color: var(--cyan); }

.circles-row { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: .3rem; border-radius: 999px; background: rgba(0,0,0,.25); }
.segmented button {
  border: 0; background: transparent; cursor: pointer; padding: .55rem 1.2rem; border-radius: 999px;
  font-weight: 700; color: var(--muted);
}
.segmented button.on { background: var(--cyan); color: #10223a; }
.rounds-info { color: var(--muted); }
.btn-start { margin-top: .6rem; align-self: stretch; }

/* ---------- Recorder ---------- */

.recorder { display: flex; flex-direction: column; gap: .6rem; width: 100%; }
.rec-main { display: flex; align-items: center; gap: 1.6rem; }
.rec-ring { position: relative; width: 9.5rem; height: 9.5rem; flex: none; }
.rec-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.rec-ring circle { fill: none; stroke-width: 6; }
.rec-ring .track { stroke: rgba(255,255,255,.12); }
.rec-ring .progress { stroke: var(--yellow); stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.rec-btn {
  position: absolute; inset: .9rem; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #ff7fb5, #f0115f);
  box-shadow: 0 .45rem 0 #8c0a3a, 0 0 0 0 rgba(255, 79, 154, .6);
  display: grid; place-items: center; font-size: 3rem; color: #fff;
  transition: transform .12s, box-shadow .12s;
}
.rec-btn:hover { transform: translateY(-2px) scale(1.03); }
.rec-btn:active { transform: translateY(.3rem); box-shadow: 0 .1rem 0 #8c0a3a; }
.recorder.recording .rec-btn { animation: rec-pulse 1.2s ease-out infinite; font-size: 2.4rem; }
.recorder.starting .rec-btn { opacity: .6; }
@keyframes rec-pulse {
  0% { box-shadow: 0 .45rem 0 #8c0a3a, 0 0 0 0 rgba(255, 79, 154, .7); }
  100% { box-shadow: 0 .45rem 0 #8c0a3a, 0 0 0 2.2rem rgba(255, 79, 154, 0); }
}
.rec-side { flex: 1; display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.rec-caption { font-family: var(--display); font-weight: 700; font-size: 1.4rem; display: flex; align-items: center; gap: .6rem; }
.recorder.recording .rec-caption { color: #ff7fb5; }
.rec-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 1.05rem; }
.rec-levels { width: 100%; height: 3.6rem; }
.rec-hint { color: var(--muted); font-size: 1.05rem; }

/* ---------- Waveforms ---------- */

.wave { display: block; width: 100%; --wave-on: var(--yellow); --wave-off: rgba(255,255,255,.35); }
.wave-alt { --wave-on: var(--cyan); --wave-off: rgba(61, 224, 255, .35); }

/* ---------- Intro ---------- */

.round-big {
  font-family: var(--display); font-weight: 900; font-size: 2rem; color: var(--yellow);
  text-transform: uppercase; letter-spacing: .12em;
}
.duo { display: flex; align-items: center; gap: 3rem; }
.duo-arrow { font-size: 3.4rem; animation: spin 4s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
.role-card {
  display: flex; flex-direction: column; align-items: center; gap: 1rem; min-width: 19rem;
  padding: 1.6rem 2.4rem 2rem; border-radius: 2rem;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 26%, transparent), rgba(255,255,255,.04));
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--c) 60%, transparent), 0 1.4rem 3rem rgba(0,0,0,.3);
  animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) both;
}
.role-card:last-child { animation-delay: .12s; }
.role-label { font-family: var(--display); font-weight: 700; font-size: 1.3rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.role-name { font-family: var(--display); font-weight: 900; font-size: 2.6rem; }
.guessers { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: center; font-size: 1.2rem; }
.banner {
  display: flex; align-items: center; gap: 1.2rem; padding: 1.1rem 2rem; border-radius: 1.4rem;
  background: rgba(255, 210, 63, .12); box-shadow: inset 0 0 0 2px rgba(255, 210, 63, .5);
  font-size: 1.5rem; max-width: 60rem;
}
.banner-icon { font-size: 2.6rem; animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 25% { rotate: -10deg; } 75% { rotate: 10deg; } }
@keyframes pop { from { opacity: 0; transform: scale(.6) translateY(2rem); } }

/* ---------- Singer ---------- */

.secret-label {
  display: inline-flex; align-items: center; gap: .5rem; padding: .5rem 1.3rem; border-radius: 999px;
  font-family: var(--display); font-weight: 700; font-size: 1.3rem;
  background: color-mix(in srgb, var(--c) 20%, transparent); box-shadow: inset 0 0 0 2px var(--c);
}
.singer-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 2.4rem; width: 100%; align-items: center; }
.singer-song { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.singer-rec { display: flex; flex-direction: column; gap: 1.4rem; }
.recorded { display: flex; flex-direction: column; gap: 1rem; }

.song-card {
  position: relative; width: 100%; padding: 2.4rem 2rem; border-radius: 2rem; text-align: center;
  background: linear-gradient(135deg, #ff4f9a 0%, #b04fff 55%, #4f6bff 100%);
  box-shadow: 0 .7rem 0 #4a1d8f, 0 1.8rem 4rem rgba(80, 20, 160, .55);
  overflow: hidden;
}
.song-card::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,.07) 0 1.2rem, transparent 1.2rem 2.4rem);
}
.song-note { position: relative; font-size: 2.6rem; }
.song-title { position: relative; font-family: var(--display); font-weight: 900; font-size: 3rem; line-height: 1.12; margin: .4rem 0; text-wrap: balance; }
.song-lyric { position: relative; font-size: 1.5rem; font-style: italic; font-weight: 500; margin: -.1rem 0 .6rem; text-wrap: balance; }
.song-artist { position: relative; font-size: 1.6rem; font-weight: 500; opacity: .9; }

.pop-in { animation: pop .55s cubic-bezier(.2, 1.6, .4, 1) both; }

/* ---------- Mimic ---------- */

.mimic-layout { display: grid; grid-template-columns: 1fr 1.25fr; gap: 1.6rem; width: 100%; align-items: stretch; }
.step-card { position: relative; display: flex; flex-direction: column; gap: 1.1rem; padding-top: 2rem; }
.step-num {
  position: absolute; top: -1.3rem; left: 1.4rem; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--display); font-weight: 900;
  background: var(--yellow); color: #2a0f5c; box-shadow: 0 .25rem 0 #a07c00;
}
.step-card h3 { font-size: 1.5rem; }
.listens { color: var(--muted); }

/* ---------- Guess ---------- */

.wobble { animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 25% { rotate: -2deg; } 75% { rotate: 2deg; } }
.result-card { width: 100%; max-width: 70rem; display: flex; flex-direction: column; gap: 1.2rem; }
.guess-who { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.guess-who h3 { font-size: 1.5rem; }
.guess-buttons { display: flex; flex-wrap: wrap; gap: .9rem; justify-content: center; }
.btn-player { font-size: 1.35rem; padding: .7rem 1.4rem .7rem .7rem; }
.btn-player .avatar-sm { width: 2.4rem; height: 2.4rem; font-size: 1.5rem; }

.countdown {
  position: fixed; inset: 0; z-index: 35; display: grid; place-items: center;
  background: rgba(23, 10, 54, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.countdown-num {
  font-family: var(--display); font-weight: 900; font-size: 18rem; color: var(--yellow);
  text-shadow: 0 .6rem 0 #a0164f, 0 0 4rem rgba(255, 210, 63, .5);
  animation: count-pop .8s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes count-pop { from { transform: scale(2.2); opacity: 0; } 60% { opacity: 1; } to { transform: scale(.9); } }

/* ---------- Reveal ---------- */

.reveal { gap: 1.4rem; }
.reveal-top { display: grid; grid-template-columns: 1.15fr 1fr; gap: 2.4rem; width: 100%; align-items: center; }
.flip { perspective: 1600px; }
.flip-inner { display: grid; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.3, 1.3, .4, 1); }
.flip.animate .flip-inner { animation: flip-in 1.1s .25s cubic-bezier(.3, 1.3, .4, 1) both; }
.flip.shown .flip-inner { transform: rotateY(180deg); }
@keyframes flip-in { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }
.flip-front, .flip-back { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; }
.flip-front {
  border-radius: 2rem; display: grid; place-items: center; font-family: var(--display); font-weight: 900; font-size: 9rem;
  background: repeating-linear-gradient(45deg, #3a1a7a 0 1.4rem, #2f1466 1.4rem 2.8rem); color: var(--yellow);
  box-shadow: 0 .7rem 0 #1d0a45;
}
.flip-back { transform: rotateY(180deg); }
.flip-back .song-card { display: flex; flex-direction: column; justify-content: center; }

.outcome { display: flex; flex-direction: column; gap: 1rem; animation: pop .6s 1.1s cubic-bezier(.2, 1.6, .4, 1) both; }
.outcome-big { font-family: var(--display); font-weight: 900; font-size: 2.6rem; line-height: 1.15; }
.outcome-small { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: 1.3rem; color: var(--muted); }

.compare { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 1rem; width: 100%; }
.compare-item { display: flex; flex-direction: column; gap: .7rem; padding: 1.1rem 1.2rem; }
.compare-item .btn { align-self: flex-start; }
.compare-main { background: rgba(255, 210, 63, .08); border-color: rgba(255, 210, 63, .35); }
.compare-head { display: flex; flex-direction: column; gap: .1rem; }
.compare-head b { font-family: var(--display); font-size: 1.15rem; }
.compare-head .muted { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reveal-actions { display: flex; gap: 1rem; align-items: center; justify-content: center; }

/* sandbox reuses .compare with two columns */
.sandbox .compare { grid-template-columns: 1fr 1fr; max-width: 70rem; }
.sandbox .recorder { max-width: 50rem; }

/* ---------- Final ---------- */

.final { justify-content: flex-start; gap: 2rem; padding-top: 1.5rem; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 1.6rem; }
.podium-slot { display: flex; flex-direction: column; align-items: center; gap: .55rem; width: 15rem; animation: pop .7s cubic-bezier(.2, 1.6, .4, 1) both; }
.podium-slot.place-1 { animation-delay: .5s; }
.podium-slot.place-2 { animation-delay: .25s; }
.podium-slot.empty { visibility: hidden; }
.podium-medal { font-size: 3rem; }
.podium-name { font-family: var(--display); font-weight: 900; font-size: 1.6rem; text-align: center; }
.podium-points { color: var(--yellow); font-weight: 700; font-size: 1.2rem; }
.podium-block {
  width: 100%; display: grid; place-items: center; border-radius: 1.2rem 1.2rem .4rem .4rem;
  font-family: var(--display); font-weight: 900; font-size: 3rem; color: rgba(255,255,255,.85);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 75%, #fff 0%), color-mix(in srgb, var(--c) 40%, #2a0f5c));
  box-shadow: inset 0 .3rem 0 rgba(255,255,255,.3);
}
.place-1 .podium-block { height: 11rem; }
.place-2 .podium-block { height: 7.5rem; }
.place-3 .podium-block { height: 5rem; }
.rest { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.rest-item { display: flex; align-items: center; gap: .6rem; font-size: 1.2rem; }
.rest-item b { color: var(--yellow); font-family: var(--display); }

.awards { display: flex; gap: 1.2rem; justify-content: center; flex-wrap: wrap; }
.award { display: flex; flex-direction: column; align-items: center; gap: .5rem; min-width: 16rem; text-align: center; padding: 1.2rem 1.6rem; }
.award-icon { font-size: 2.6rem; }
.award-title { font-family: var(--display); font-weight: 900; font-size: 1.3rem; color: var(--yellow); }
.award-who { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }

.highlights { width: 100%; display: flex; flex-direction: column; gap: 1rem; }
.highlights h2 { font-size: 1.6rem; text-align: center; }
.highlight-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); gap: 1rem; }
.highlight { display: flex; flex-direction: column; gap: .4rem; padding: 1.2rem; }
.highlight.missed { opacity: .8; }
.highlight-title { font-family: var(--display); font-weight: 700; font-size: 1.25rem; }
.highlight-who { font-size: 1rem; margin-bottom: .4rem; }
.highlight .btn { font-size: .95rem; padding: .6rem 1.1rem; }

/* ---------- Modal ---------- */

#overlay { display: none; }
#overlay.open { display: block; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: rgba(10, 4, 30, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade .2s;
}
.modal {
  background: #2a1460; border-radius: 2rem; padding: 2.2rem 2.6rem; min-width: 30rem;
  box-shadow: 0 2rem 5rem rgba(0,0,0,.5), inset 0 0 0 2px rgba(255,255,255,.1);
  display: flex; flex-direction: column; gap: 1.2rem; animation: pop .4s cubic-bezier(.2, 1.5, .4, 1);
}
.modal h2 { font-size: 2rem; }
.modal-actions { display: flex; flex-direction: column; gap: .8rem; }
.modal-actions .btn { justify-content: space-between; }
.modal p { margin: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.25); } }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ---------- Narrow screens (laptop window, phone) ---------- */

@media (max-aspect-ratio: 4/3), (max-width: 900px) {
  html { font-size: clamp(12px, 1.9vw, 22px); }
  .home, .singer-layout, .mimic-layout, .reveal-top { grid-template-columns: 1fr; }
  .compare { grid-template-columns: 1fr 1fr; }
  .steps { display: none; }
  .logo-lg { font-size: 6rem; }
  .duo { gap: 1rem; }
  .role-card { min-width: 0; padding: 1.2rem 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Phones: TV side ---------- */

.phone-panel {
  display: flex; align-items: center; gap: 1.2rem; padding: 1rem 1.2rem; border-radius: 1.4rem;
  background: rgba(61, 224, 255, .08); box-shadow: inset 0 0 0 2px rgba(61, 224, 255, .35);
}
.qr { flex: none; width: 8.5rem; height: 8.5rem; border-radius: .9rem; overflow: hidden; background: #fff; }
.qr svg { display: block; width: 100%; height: 100%; }
.phone-text { display: flex; flex-direction: column; gap: .35rem; font-size: 1.05rem; }
.phone-text > b { font-family: var(--display); font-size: 1.2rem; }
.phone-code { color: var(--muted); }
.phone-code b { color: var(--cyan); font-family: var(--display); letter-spacing: .15em; }
.phone-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.phone-chip { padding: .15rem .7rem; border-radius: 999px; background: rgba(61, 224, 255, .15); font-weight: 500; font-size: .95rem; }
.phone-badge { font-size: 1.2rem; padding-right: .3rem; }
.phone-badge[hidden] { display: none; }

.intro-local { display: flex; align-items: center; gap: 1.4rem; }
.intro-qr {
  display: flex; align-items: center; gap: 1rem; padding: .8rem 1.2rem .8rem .8rem; border-radius: 1.4rem;
  background: rgba(61, 224, 255, .08); box-shadow: inset 0 0 0 2px rgba(61, 224, 255, .35); max-width: 22rem;
}
.intro-qr .qr { width: 6.5rem; height: 6.5rem; }
.banner-phone { background: rgba(61, 224, 255, .1); box-shadow: inset 0 0 0 2px rgba(61, 224, 255, .5); }
.remote-status {
  display: flex; align-items: center; gap: .9rem; font-family: var(--display); font-weight: 700; font-size: 2rem;
  padding: .9rem 2rem; border-radius: 999px; background: rgba(255,255,255,.07);
}
.remote-icon { font-size: 2.4rem; }
.remote-status.state-recording { color: #ff7fb5; background: rgba(255, 79, 154, .12); }
.remote-status.state-recording .remote-icon,
.remote-status.state-sending .remote-icon { animation: pulse .9s ease-in-out infinite; }
.remote-status.state-sent .remote-icon,
.remote-status.state-seen .remote-icon { animation: wiggle 1.6s ease-in-out infinite; }

/* ---------- Phones: phone side ---------- */

html.phone { font-size: 16px; }
html.phone body { font-size: 1rem; }
.phone .screen { padding: 0; }
.phone-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.phone-top {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .8rem 1rem; padding-top: max(.8rem, env(safe-area-inset-top));
}
.phone-top .logo-sm { font-size: 1.4rem; }
.phone-status { font-size: .8rem; padding: .3rem .7rem; border-radius: 999px; text-align: right; }
.phone-status.ok { color: var(--lime); background: rgba(140, 255, 107, .1); }
.phone-status.bad { color: #ff8fa3; background: rgba(255, 79, 120, .12); }
.phone-body {
  flex: 1; display: flex; flex-direction: column; gap: 1rem; padding: .5rem 1.1rem 1.6rem;
  padding-bottom: max(1.6rem, env(safe-area-inset-bottom));
}
.phone-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; text-align: center; }
.center { text-align: center; }
.phone-title { font-size: 1.8rem; font-weight: 900; text-align: center; }
.phone h2 { font-size: 1.3rem; }
.big-emoji { font-size: 4rem; line-height: 1; }
.warn { color: var(--yellow); }
.mic-ok { color: var(--lime); font-weight: 700; }
.spinner {
  width: 3.4rem; height: 3.4rem; border-radius: 50%;
  border: .35rem solid rgba(255,255,255,.15); border-top-color: var(--pink);
  animation: spin 0.9s linear infinite;
}
.pick-list { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.pick-btn {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem .5rem .5rem; border: 0; cursor: pointer;
  border-radius: 999px; font-weight: 700; font-size: 1.1rem; text-align: left;
  background: color-mix(in srgb, var(--c) 18%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent);
}
.pick-btn:active { transform: scale(.97); }
.pick-btn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-me { display: flex; flex-direction: column; gap: .7rem; padding: 1rem; }
.add-me .row { flex-wrap: nowrap; }
.phone-name-input, .code-input {
  flex: 1; min-width: 0; border-radius: 999px; padding: .7rem 1rem; outline: none;
  background: rgba(0,0,0,.25); border: 2px solid rgba(255,255,255,.15); font-size: 1.1rem;
}
.phone-name-input:focus, .code-input:focus { border-color: var(--cyan); }
.code-input { flex: none; width: 9rem; text-align: center; font-family: var(--display); font-size: 1.8rem; letter-spacing: .2em; text-transform: uppercase; }
.sent-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .4rem; background: rgba(140, 255, 107, .1); border-color: rgba(140, 255, 107, .45); }
.sent-card p { margin: 0; }
.phone .secret-label { align-self: center; font-size: 1rem; background: rgba(255, 79, 154, .15); box-shadow: inset 0 0 0 2px var(--pink); }
.phone .song-card { padding: 1.4rem 1rem; border-radius: 1.4rem; }
.phone .song-title { font-size: 1.9rem; }
.phone .song-lyric { font-size: 1.05rem; }
.phone .song-artist { font-size: 1.1rem; }
.phone .song-note { font-size: 1.8rem; }
.phone .btn { font-size: 1rem; }
.phone .btn-ghost { align-self: center; }
.phone .recorder { align-items: center; }
.phone .rec-main { flex-direction: column; gap: .8rem; width: 100%; }
.phone .rec-ring { width: 8.5rem; height: 8.5rem; }
.phone .rec-side { align-items: center; width: 100%; }
.phone .rec-caption { font-size: 1.2rem; }
.phone .rec-caption kbd { display: none; }
.phone .rec-levels { height: 3rem; }
.phone .recorded { display: flex; flex-direction: column; gap: .8rem; padding: 1rem; }
.phone-actions { display: flex; gap: .6rem; }
.phone-actions .btn { flex: 1; padding: .85rem .8rem; }
.phone .btn kbd { display: none; }
/* Canvases size themselves from their box; never let them push the layout wider. */
.wave, .rec-levels { max-width: 100%; min-width: 0; }
.phone .rec-side { align-items: stretch; text-align: center; }
.phone .rec-caption { justify-content: center; }
.phone .btn { white-space: normal; }
.phone-body > *, .phone .recorded { min-width: 0; max-width: 100%; }
/* Home hero gets a phone panel too; keep it within one TV screen. */
.home-hero { gap: 1rem; }
.home-hero .logo-lg { font-size: 6.4rem; }
.home-hero .tagline { font-size: 1.7rem; margin-top: -.6rem; }
.home-hero .rules { font-size: 1.15rem; gap: .55rem; }
.home-hero .rule-icon { width: 2.5rem; height: 2.5rem; font-size: 1.3rem; border-radius: .8rem; }
.home-hero .scoring { font-size: 1rem; padding: .6rem 1rem; }

/* ---------- Phone-sized screens (the whole game played on one phone) ---------- */

@media (max-width: 640px) {
  html { font-size: 15px; }
  body { font-size: 1rem; }
  .screen { padding: .8rem .9rem 1.2rem; }
  .stage { gap: 1.1rem; padding: .6rem 0; justify-content: flex-start; }
  .card { padding: 1.1rem; border-radius: 1.2rem; }
  .btn { white-space: normal; padding: .75rem 1.2rem; font-size: 1rem; }
  .btn-xl { font-size: 1.2rem; padding: .95rem 1.4rem; width: 100%; }
  .title { font-size: 1.7rem; }
  .title-xl { font-size: 2.1rem; }
  .subtitle { font-size: 1.05rem; margin: -.4rem 0 0; }

  .topbar { gap: .7rem; min-height: 2.6rem; }
  .topbar .logo-sm { font-size: 1.3rem; }
  .topbar-round { font-size: 1rem; flex: 1; }
  .topbar .btn { padding: .45rem .9rem; font-size: .85rem; }

  .home { gap: 1.2rem; align-items: start; }
  .home-hero { align-items: center; text-align: center; }
  .home-hero .logo-lg { font-size: 4.6rem; }
  .home-hero .tagline { font-size: 1.3rem; }
  .home-hero .rules { font-size: 1rem; text-align: left; }
  .home-hero .scoring { font-size: .92rem; text-align: left; }
  .phone-panel { display: none; }
  .setup { padding: 1.2rem; }
  .players-grid { grid-template-columns: 1fr; }
  .add-player { min-height: 3.2rem; }
  .chip { font-size: .95rem; padding: .5rem .8rem; }
  .circles-row { flex-direction: column; align-items: stretch; gap: .6rem; }
  .segmented { display: flex; }
  .segmented button { flex: 1; padding: .55rem .4rem; }

  .round-big { font-size: 1.4rem; }
  .duo { gap: .6rem; width: 100%; }
  .duo-arrow { font-size: 1.8rem; }
  .role-card { flex: 1; min-width: 0; padding: 1rem .6rem 1.2rem; gap: .6rem; border-radius: 1.4rem; }
  .role-label { font-size: .85rem; }
  .role-card .avatar-xl { width: 4.6rem; height: 4.6rem; font-size: 2.8rem; }
  .role-name { font-size: 1.5rem; overflow-wrap: anywhere; text-align: center; }
  .guessers { font-size: 1rem; }
  .banner { font-size: 1.05rem; padding: .9rem 1rem; gap: .8rem; }
  .banner-icon { font-size: 1.8rem; }
  .intro-local { flex-direction: column; }
  .intro-qr { display: none; }
  .remote-status { font-size: 1.15rem; padding: .7rem 1.2rem; }

  .secret-label { font-size: 1rem; }
  .singer-layout, .mimic-layout { gap: 1.2rem; }
  .song-card { padding: 1.4rem 1rem; border-radius: 1.4rem; }
  .song-title { font-size: 1.9rem; }
  .song-lyric { font-size: 1.05rem; }
  .song-artist { font-size: 1.1rem; }
  .song-note { font-size: 1.8rem; }

  .rec-main { gap: 1rem; }
  .rec-ring { width: 6.5rem; height: 6.5rem; }
  .rec-btn { inset: .6rem; font-size: 2rem; }
  .recorder.recording .rec-btn { font-size: 1.6rem; }
  .rec-caption { font-size: 1.1rem; flex-wrap: wrap; }
  .rec-hint, .rec-time { font-size: .9rem; }
  .rec-levels { height: 2.6rem; }

  .title .avatar-lg { width: 2.6rem; height: 2.6rem; font-size: 1.5rem; }
  .step-card { padding-top: 1.6rem; }
  .step-card h3 { font-size: 1.15rem; }

  .guess-who h3 { font-size: 1.15rem; text-align: center; }
  .btn-player { font-size: 1.1rem; }
  .countdown-num { font-size: 9rem; }

  .reveal-top { gap: 1rem; }
  .flip-front { font-size: 5rem; border-radius: 1.4rem; }
  .outcome { text-align: center; align-items: center; }
  .outcome-big { font-size: 1.6rem; }
  .outcome-small { font-size: 1rem; justify-content: center; }
  .compare { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .compare-item { padding: .8rem; gap: .5rem; }
  .compare-head b { font-size: .95rem; }
  .compare-head .muted { font-size: .8rem; }
  .compare-item .btn { align-self: stretch; padding: .6rem .7rem; font-size: .9rem; }
  .reveal-actions { flex-direction: column-reverse; width: 100%; gap: .6rem; }
  .reveal-actions .btn { width: 100%; }
  .scoreboard { gap: .4rem; }
  .score-item { padding: .25rem .7rem .25rem .25rem; font-size: .9rem; }

  .podium { gap: .5rem; width: 100%; }
  .podium-slot { width: auto; flex: 1; min-width: 0; }
  .podium-medal { font-size: 2rem; }
  .podium-name { font-size: 1.1rem; overflow-wrap: anywhere; }
  .podium-points { font-size: .95rem; }
  .podium-block { font-size: 2rem; }
  .place-1 .podium-block { height: 7rem; }
  .place-2 .podium-block { height: 5rem; }
  .place-3 .podium-block { height: 3.4rem; }
  .podium .avatar-xl { width: 5rem; height: 5rem; font-size: 3rem; }
  .podium .avatar-lg { width: 3.6rem; height: 3.6rem; font-size: 2.1rem; }
  .award { min-width: 0; width: 100%; }
  .highlight-grid { grid-template-columns: 1fr; }
  .modal { min-width: 0; width: calc(100vw - 2rem); padding: 1.6rem 1.3rem; }
  .sandbox .compare { grid-template-columns: 1fr; }
}

/* Touch screens have no keyboard: hide shortcut hints. */
@media (hover: none) and (pointer: coarse) {
  kbd { display: none; }
}
@media (max-aspect-ratio: 4/3), (max-width: 900px) {
  .home, .singer-layout, .mimic-layout, .reveal-top { grid-template-columns: minmax(0, 1fr); }
  .home > *, .singer-layout > *, .mimic-layout > *, .reveal-top > * { min-width: 0; }
}
.player-input { width: 0; }
@media (max-width: 640px) {
  .players-grid { grid-template-columns: minmax(0, 1fr); }
  .setup { min-width: 0; }
}

/* ---------- Mimic: piece by piece ---------- */

.mode-switch { margin-top: -.4rem; }
.mode-switch button { font-size: 1rem; }
.pieces { display: flex; flex-wrap: wrap; gap: .5rem; }
.piece {
  min-width: 2.8rem; height: 2.8rem; padding: 0 .7rem; border-radius: 999px; border: 0; cursor: pointer;
  font-family: var(--display); font-weight: 700; font-size: 1.05rem;
  background: rgba(255,255,255,.08); color: var(--muted); box-shadow: inset 0 0 0 2px rgba(255,255,255,.15);
}
.piece.done { color: var(--lime); box-shadow: inset 0 0 0 2px rgba(140, 255, 107, .55); }
.piece.current { background: var(--cyan); color: #10223a; box-shadow: 0 0 1rem rgba(61, 224, 255, .5); }
.mode-switch button { white-space: nowrap; }
