:root {
  --bg: #1a1233;
  --card: #2c2155;
  --accent: #9b5cff;
  --accent-light: #d391ff;
  --good: #2fe88f;
  --bad: #ff4f7b;
  --text: #ffffff;
  --muted: #b6a8d9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #4a2f8f, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 640px;
  padding: 24px 18px 60px;
}

h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 18px 0 8px; }
.subtitle { color: var(--muted); margin: 0 0 16px; }

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

.card-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.card {
  flex: 1 1 240px;
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
}

input, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #4a3d7a;
  background: #352a5e;
  color: var(--text);
  font-size: 1rem;
}

button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #ff5fa8);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  transition: filter 0.15s ease, transform 0.1s ease;
}

button:hover { filter: brightness(1.12); }
button:active { transform: scale(0.98); }
button:disabled { background: #5b4f86; filter: none; cursor: default; }

.secondary-btn {
  background: #352a5e;
  border: 1px solid #4a3d7a;
}
.secondary-btn:hover { filter: none; background: #3f3470; }

.leave-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  width: auto;
  margin: 0;
  padding: 8px 14px;
  font-size: 0.85rem;
  background: var(--bad);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.leave-btn:hover { filter: brightness(1.12); background: var(--bad); }

.leave-host-hint {
  position: fixed;
  top: 54px;
  left: 16px;
  z-index: 20;
  max-width: 200px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(26, 18, 51, 0.92);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.3;
}

.error {
  color: var(--bad);
  min-height: 1.2em;
  font-size: 0.85rem;
}

#lobby-code {
  color: var(--accent-light);
  letter-spacing: 4px;
}

.notice {
  background: #3a2f1f;
  border: 1px solid #6b5126;
  color: #f0c987;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.volume-warning {
  background: #4a1f2a;
  border: 1px solid var(--bad);
  color: #ffd6e0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 16px;
}

.player-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.player-list li {
  background: var(--card);
  padding: 10px 14px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
}

.player-list li.offline { opacity: 0.5; }

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.round-name {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
}

.timer-bar {
  height: 8px;
  border-radius: 6px;
  background: #382c63;
  overflow: hidden;
  margin-bottom: 18px;
}

#timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.2s linear;
}

.song-card {
  background: var(--card);
  border-radius: 14px;
  padding: 22px;
  text-align: center;
  margin-bottom: 18px;
}

.song-title { font-size: 1.4rem; font-weight: 700; }
.song-meta { color: var(--muted); margin-top: 4px; }

.spotify-embed-wrap {
  margin-top: 14px;
  border-radius: 10px;
  overflow: hidden;
}

.prompt { text-align: center; font-weight: 600; margin-bottom: 12px; }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-btn {
  background: #352a5e;
  border: 2px solid #4a3d7a;
  border-radius: 12px;
  padding: 16px 10px;
  font-weight: 600;
  width: auto;
  margin: 0;
}

.choice-btn:hover { border-color: var(--accent-light); background: #3f3470; }
.choice-btn.selected { border-color: var(--accent); background: #4b3585; }
.choice-btn:disabled { cursor: default; }

.countdown {
  text-align: center;
  margin: 16px 0;
}

.countdown-label {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.countdown-number {
  color: var(--text);
  font-size: 3rem;
  font-weight: 800;
  margin: 0;
  line-height: 1;
}

.reveal-self {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 16px;
}
.reveal-self.correct { color: var(--good); }
.reveal-self.incorrect { color: var(--bad); }

.reveal-answer-label {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 2px;
}

.reveal-answer {
  text-align: center;
  font-size: 2.1rem;
  margin: 0 0 20px;
}

.leaderboard {
  list-style: none;
  counter-reset: rank;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard li {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.leaderboard li .rank { color: var(--muted); margin-right: 10px; }
.leaderboard li.me { border: 1px solid var(--accent-light); }

.leaderboard li > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.leaderboard li > span:last-child {
  flex: 0 0 auto;
  text-align: right;
}

.leaderboard-guess {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-guess.correct { color: var(--good); }
.leaderboard-guess.incorrect { color: var(--bad); }

@media (max-width: 420px) {
  .choices { grid-template-columns: 1fr; }
}
