:root { --accent: #44cc66; --accent-dark: #2fa84e; }

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--border);
  transition: opacity 0.12s ease, border-color 0.12s ease;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { cursor: default; opacity: 0.5; }
.btn-spotify,
.btn-play,
.btn-primary { background: var(--accent); color: #04160b; }
.btn-spotify:hover,
.btn-play:hover,
.btn-primary:hover { background: var(--accent-dark); opacity: 1; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  padding: 9px 16px;
  font-size: 14px;
}
.btn-ghost:hover { border-color: var(--border-hover); opacity: 1; }

/* Home -------------------------------------------------------------- */
.home-topbar { margin-bottom: 8px; }
.brand { font-size: 18px; font-weight: 700; }
.home-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user-chip { color: var(--text-muted); font-size: 14px; padding: 0 4px; }
.home-hero { text-align: center; padding: 3vh 10px 20px; }
.home-hero h1 { font-size: 26px; margin: 0 0 6px; }
.subtitle { color: var(--text-muted); max-width: 420px; margin: 0 auto; line-height: 1.5; font-size: 14px; }
.home-tools { display: flex; flex-direction: column; gap: 10px; max-width: 620px; margin: 0 auto 10px; }
.link-form { display: flex; gap: 10px; }
.link-form input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.link-form input:focus { border-color: var(--accent); }
.link-hint { color: var(--text-faint); font-size: 12px; margin-top: 12px; }
.search-status { color: var(--text-muted); font-size: 13px; text-align: left; margin: 16px 0 12px; min-height: 1px; }
#search-results:not(:empty) { margin-bottom: 20px; }
.section { margin-top: 30px; }
.section-head { font-size: 15px; color: var(--text-muted); margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Topbar -------------------------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; }
/* 3-slot variant: equal side columns so the middle title is truly centered */
.topbar-3 { display: grid; grid-template-columns: 1fr auto 1fr; }
.topbar-3 > :first-child { justify-self: start; }
.topbar-3 > :last-child { justify-self: end; }
.mp-title { font-size: 16px; margin: 0; color: var(--text-muted); }
.score-box { display: flex; align-items: center; gap: 16px; font-size: 14px; color: var(--text-muted); }
.score b { color: var(--text); }

/* Playlist grid --------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.grid-featured { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.card {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card:hover { border-color: var(--border-hover); }
.card-img { aspect-ratio: 1; background: var(--border); }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-faint); font-size: 28px; }
.card-body { padding: 10px; }
.card-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { color: var(--text-muted); font-size: 12px; margin-top: 3px; }

/* Loading / error --------------------------------------------------- */
.loading { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error {
  background: rgba(204, 68, 68, 0.12);
  border: 1px solid var(--bad);
  color: #ffb3b3;
  padding: 14px 18px;
  border-radius: var(--radius);
  text-align: center;
  font-size: 14px;
}

/* Game ---------------------------------------------------------------- */
.game { text-align: center; }
.cover-area { display: flex; justify-content: center; margin-bottom: 22px; }
.cover {
  position: relative;
  width: 220px; height: 220px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 2px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-inner { font-size: 64px; color: var(--text-faint); font-weight: 700; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 12px 12px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  text-align: left;
}
.cover-song { font-weight: 700; font-size: 14px; }
.cover-artist { font-size: 12px; color: var(--text-muted); }

/* Timer ----------------------------------------------------------------- */
.timer-wrap { max-width: 340px; margin: 0 auto 18px; }
.timer-track { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.timer-bar { height: 100%; width: 100%; background: var(--accent); transition: width 0.05s linear, background 0.2s ease; }
.timer-bar.low { background: var(--bad); }
.timer-text { color: var(--text-muted); font-size: 12px; margin-top: 8px; font-variant-numeric: tabular-nums; font-weight: 600; }
.timer-text.good { color: var(--good); font-size: 14px; }
.timer-text.bad { color: var(--bad); font-size: 14px; }

.gain {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px; font-weight: 800;
  color: var(--good);
  pointer-events: none;
  animation: gain-float 1s ease forwards;
}
@keyframes gain-float {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.8); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1.1); }
}

.controls { margin-bottom: 20px; }
.hint { color: var(--text-faint); font-size: 12px; margin-top: 10px; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  cursor: pointer;
}
.opt-key {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--border);
  color: var(--text-muted);
  font-size: 12px; font-weight: 700;
}
.opt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opt-name, .opt-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.option:hover:not(:disabled) { border-color: var(--border-hover); }
.option:disabled { cursor: default; }
.opt-name { font-weight: 600; font-size: 14px; }
.opt-artist { font-size: 12px; color: var(--text-muted); }
.option.correct { border-color: var(--good); background: rgba(68, 204, 102, 0.1); }
.option.wrong { border-color: var(--bad); background: rgba(204, 68, 68, 0.1); }
.option.chosen-opt { border-color: var(--accent); }

.hidden-player { position: fixed; bottom: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; z-index: -1; }

/* Result ---------------------------------------------------------------- */
.result-screen { text-align: center; padding: 8vh 20px; }
.result-screen h1 { font-size: 28px; margin-bottom: 8px; }
.final-points { font-size: 36px; font-weight: 800; color: var(--good); margin: 0 0 26px; }
.final-hits { font-size: 15px; font-weight: 600; color: var(--text-muted); margin-left: 12px; }
.final-hits b { color: var(--text); font-weight: 700; }
.result-actions { display: flex; gap: 10px; justify-content: center; }

/* Volume ----------------------------------------------------------------- */
.volume-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 260px;
  margin: 14px auto 0;
}
.vol-label { font-size: 12px; color: var(--text-muted); flex: 0 0 auto; user-select: none; }
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
.volume-slider::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
.volume-slider::-moz-range-progress { background: var(--accent); height: 5px; border-radius: 999px; }

/* Multiplayer ------------------------------------------------------------ */
.mode-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 620px;
  margin: 4vh auto 0;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 20px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease;
}
.mode-card:hover { border-color: var(--accent); }
.mode-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--border);
  color: var(--accent);
  font-size: 22px; font-weight: 700;
  margin-bottom: 4px;
}
.mode-name { font-size: 16px; font-weight: 700; }
.mode-desc { font-size: 13px; color: var(--text-muted); }

.rounds-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.rounds-input { width: 76px; margin-bottom: 0; text-align: center; }
.lobby-rounds-row { max-width: 240px; margin: 0 auto 10px; }

.mp-single { max-width: 440px; margin: 0 auto; position: relative; }
.mode-back { margin-bottom: 14px; padding: 6px 12px; font-size: 12px; }

.mp-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mp-panel { background: var(--panel); border: 2px solid var(--border); border-radius: var(--radius); padding: 18px; text-align: left; }
.mp-panel h2 { font-size: 15px; margin: 0 0 14px; color: var(--text-muted); font-weight: 600; }
.mp-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
}
.mp-input:focus { border-color: var(--accent); }
.mp-code-input { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }
.mp-full { width: 100%; }
.chosen {
  background: rgba(68, 204, 102, 0.1);
  border: 1px solid var(--good);
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.mp-quick-head { color: var(--text-faint); font-size: 12px; margin: 6px 0 8px; }
.mp-picklist { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
.pick {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}
.pick:hover { border-color: var(--border-hover); }
.pick img { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; flex: 0 0 auto; }
.pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.invite-banner {
  background: rgba(68, 204, 102, 0.1);
  border: 1px solid var(--good);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  text-align: center;
  font-size: 14px;
}
.chooser { margin-bottom: 10px; }
.chooser-search { margin-bottom: 8px; }

/* Lobby */
.lobby-code { text-align: center; margin: 18px 0 18px; }
.share-row { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.share-row .btn { font-size: 12px; padding: 8px 14px; }
.lobby-host-tools { max-width: 440px; margin: 0 auto 18px; text-align: center; }
.lobby-host-tools .chooser { margin-top: 10px; text-align: left; }
.over-host-tools { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.over-host-tools .chooser { width: 100%; text-align: left; margin-top: 4px; }
.lobby-code-label { color: var(--text-faint); font-size: 13px; }
.lobby-code-value { font-size: 52px; font-weight: 800; letter-spacing: 8px; color: var(--accent); }
.lobby-playlist { text-align: center; color: var(--text-muted); margin-bottom: 18px; font-size: 14px; }
.mp-wait { text-align: center; color: var(--text-muted); margin-top: 16px; font-size: 13px; }

/* Player list */
.player-list { display: flex; flex-direction: column; gap: 8px; max-width: 400px; margin: 0 auto; }
.player-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; }
.player-row.offline { opacity: 0.4; }
.p-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: 0 0 auto; }
.p-dot.done { background: var(--good); }
.p-dot.miss { background: var(--bad); }
.p-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.p-score { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.p-gain { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.p-gain.good { color: var(--good); }

/* Game grid: equal 1fr side columns keep the game itself dead-center,
   with the player list off to the right. */
.app:has(#mp-game:not(.hidden)) { max-width: 1100px; }
.mp-game-grid { display: grid; grid-template-columns: 1fr minmax(0, 560px) 1fr; gap: 20px; align-items: start; }
.mp-main { text-align: center; grid-column: 2; }
.mp-side { grid-column: 3; grid-row: 1; justify-self: end; width: 100%; max-width: 240px; }
.mp-round-label { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }
.mp-side { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.mp-side-head { font-weight: 700; margin-bottom: 10px; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.mp-side .player-list { max-width: none; }
.mp-sound { margin-top: 14px; font-size: 12px; }

/* Leaderboard */
.leaderboard { max-width: 400px; margin: 20px auto 26px; display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; font-size: 15px; }
.lb-winner { border-color: var(--good); background: rgba(68, 204, 102, 0.08); }
.lb-rank { font-size: 14px; width: 24px; color: var(--text-muted); font-weight: 700; }
.lb-name { flex: 1; text-align: left; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-hits { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }

@media (max-width: 960px) {
  .mp-game-grid { grid-template-columns: 1fr; }
  .mp-main { grid-column: 1; }
  .mp-side { grid-column: 1; grid-row: auto; justify-self: center; max-width: 400px; }
}
@media (max-width: 720px) {
  .mp-cards { grid-template-columns: 1fr; }
  .mode-select { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .options { grid-template-columns: 1fr; }
  .cover { width: 180px; height: 180px; }
  .lobby-code-value { font-size: 40px; letter-spacing: 5px; }
}
