:root {
  --bg: #120d1d;
  --bg2: #1a1329;
  --card: #211833;
  --line: #34284d;
  --text: #f1ecfa;
  --muted: #a598bd;
  --accent: #ff5fa2;
  --accent2: #8b7bff;
  --ok: #3ddc97;
  --mid: #ffc857;
  --bad: #ff6b6b;
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 16px; }
.error { color: var(--bad); font-size: 14px; margin: 8px 0 0; }
.spacer { flex: 1; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 20px; }
.brand b { color: var(--accent); }
.logo { width: 28px; height: 28px; }
.who { font-size: 14px; color: var(--muted); }

.view { max-width: 980px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.narrow { max-width: 420px; width: 100%; margin: 6vh auto 0; }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 700;
  padding: 12px 22px; border-radius: 999px; box-shadow: 0 6px 20px rgba(255, 95, 162, .25);
}
.primary:disabled { opacity: .5; cursor: default; }
.primary.big { font-size: 17px; padding: 14px 28px; }
.ghost { padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line); color: var(--muted); }
.ghost:hover { color: var(--text); border-color: var(--muted); }
.ghost.small { padding: 6px 11px; font-size: 13px; }
.ghost.danger:hover { color: var(--bad); border-color: var(--bad); }
.badge { font-size: 11px; background: var(--accent2); color: #fff; padding: 2px 7px; border-radius: 999px; vertical-align: middle; letter-spacing: 0; }

input, select {
  width: 100%; padding: 11px 13px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.lock { margin: 14px 0 0; }

.tabs { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin: 14px 0; }
.tab { flex: 1; padding: 9px; border-radius: 9px; color: var(--muted); }
.tab.active { background: var(--card); color: var(--text); }

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.join { display: flex; gap: 8px; min-width: 0; }
.join button { flex: none; }
.join input { width: 110px; text-transform: uppercase; letter-spacing: .25em; text-align: center; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--bg2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.leader { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.leader li { display: flex; justify-content: space-between; gap: 8px; }
.rows { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.rows li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg2); border-radius: 10px; font-size: 14px; }
.rows li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.invite-new { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.invite-new code { font-size: 20px; letter-spacing: .12em; background: var(--bg); padding: 8px 12px; border-radius: 10px; color: var(--mid); }
details summary { cursor: pointer; font-weight: 600; }

/* ===== Salon ===== */
.room { max-width: 1100px; }
.room-head { display: flex; align-items: center; gap: 10px; }
.room-code { flex: 1; text-align: center; color: var(--muted); }
.room-code b { color: var(--text); font-size: 22px; letter-spacing: .2em; margin-left: 6px; }
.room-body { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
.stage { min-width: 0; }

.settings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.settings label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.settings .check { display: flex; align-items: center; gap: 8px; grid-column: span 2; }
.settings .check input { width: auto; }
.settings .years { display: flex; gap: 8px; }
.settings .readonly { grid-column: span 2; color: var(--text); line-height: 1.6; }

.podium { margin-bottom: 18px; text-align: center; }
.podium h2 { margin-bottom: 14px; }
.podium-steps { display: flex; justify-content: center; align-items: flex-end; gap: 10px; }
.step { width: 31%; max-width: 140px; display: grid; gap: 6px; }
.step .bar { border-radius: 12px 12px 4px 4px; display: grid; place-items: center; font-size: 26px; font-weight: 800; }
.step.r1 .bar { height: 110px; background: linear-gradient(180deg, #ffd76a, #b8860b); }
.step.r2 .bar { height: 80px; background: linear-gradient(180deg, #d9dde6, #8a93a6); }
.step.r3 .bar { height: 60px; background: linear-gradient(180deg, #e3a06b, #8b5a2b); }
.step .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .pts { font-size: 13px; color: var(--muted); }
.podium-rest { list-style: none; padding: 0; margin: 12px 0 0; font-size: 14px; color: var(--muted); }

.round-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-weight: 700; }
.round-info #round-type { flex: 1; font-weight: 400; }
.timer { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: 12px; }
#timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transform-origin: left; }
#timer-bar.low { background: var(--bad); }

.screen {
  position: relative; aspect-ratio: 16 / 9; width: 100%; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(circle at 30% 20%, #3a2466, #120d1d 70%); border: 1px solid var(--line);
}
.mystery { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 18px; padding: 16px; text-align: center; }
.countdown { font-size: 72px; font-weight: 800; color: var(--accent); }
.eq { display: flex; gap: 6px; align-items: flex-end; height: 70px; }
.eq i { width: 10px; height: 20%; border-radius: 6px; background: linear-gradient(180deg, var(--accent), var(--accent2)); }
.eq.on i { animation: eq 0.9s ease-in-out infinite; }
.eq.on i:nth-child(2) { animation-delay: -.2s; } .eq.on i:nth-child(3) { animation-delay: -.5s; }
.eq.on i:nth-child(4) { animation-delay: -.1s; } .eq.on i:nth-child(5) { animation-delay: -.7s; }
.eq.on i:nth-child(6) { animation-delay: -.3s; } .eq.on i:nth-child(7) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 18%; } 50% { height: 100%; } }
.hints { display: grid; gap: 6px; }
.hint { background: rgba(0, 0, 0, .35); padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.reveal-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.answer {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 12px; align-items: center; padding: 14px;
  background: linear-gradient(0deg, rgba(10, 6, 18, .95), rgba(10, 6, 18, .6) 70%, transparent);
}
.answer img { width: 54px; height: 76px; object-fit: cover; border-radius: 8px; flex: none; }
.answer img[src=""] { display: none; }
.answer-title { font-size: 20px; font-weight: 800; }
.answer-sub, .answer-song { font-size: 13px; color: #d9cff0; }

.guess { display: flex; gap: 8px; margin-top: 14px; }
.guess-wrap { position: relative; flex: 1; min-width: 0; }
.guess input { font-size: 17px; padding: 13px 15px; }
.guess input:disabled { opacity: .55; }
.suggest {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 5; list-style: none; margin: 0; padding: 6px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; max-height: 300px; overflow-y: auto;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .4);
}
.suggest li { padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.suggest li.active, .suggest li:hover { background: var(--card); }
.suggest .alt { display: block; font-size: 12px; color: var(--muted); }
.feedback { min-height: 24px; margin: 10px 2px 0; font-weight: 600; }
.feedback.ok { color: var(--ok); } .feedback.mid { color: var(--mid); } .feedback.bad { color: var(--bad); }
.volume { display: flex; align-items: center; gap: 10px; margin-top: 8px; max-width: 260px; }
.volume input { padding: 0; accent-color: var(--accent); background: none; border: 0; }

.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; background: var(--bg2); border: 1px solid transparent; }
.players li.me { border-color: var(--accent2); }
.players li.exact { background: rgba(61, 220, 151, .14); }
.players li.franchise { background: rgba(255, 200, 87, .14); }
.players li.offline { opacity: .45; }
.players .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .sc { font-weight: 700; font-variant-numeric: tabular-nums; }
.players .gain { font-size: 12px; color: var(--ok); }
.players .kick { color: var(--muted); padding: 0 4px; }
.players .kick:hover { color: var(--bad); }

.unmute {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--mid); color: #1b1300; font-weight: 800; padding: 14px 22px; border-radius: 999px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
.hidden-media { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; left: -10px; top: -10px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; max-width: calc(100% - 32px);
  background: var(--bg2); border: 1px solid var(--line); padding: 11px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}

@media (max-width: 760px) {
  .room-body { grid-template-columns: 1fr; }
  .players-card { order: -1; padding: 12px; }
  .players-card h2 { display: none; }
  .players { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
  .players li { flex: none; padding: 7px 10px; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .view { padding: 12px; gap: 12px; }
  .card { padding: 14px; }
  .settings { grid-template-columns: 1fr; }
  .settings .check, .settings .readonly { grid-column: auto; }
  .hero-actions { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .join input { flex: 1; width: auto; min-width: 0; }
  .countdown { font-size: 56px; }
  .answer-title { font-size: 17px; }
}
