:root {
  --bg: #12141a;
  --surface: #1b1e27;
  --surface-2: #232734;
  --border: #2e3342;
  --text: #e8eaf0;
  --muted: #9aa1b2;
  --accent: #f5a623;
  --accent-text: #1a1305;
  --discord: #5865f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.inline { display: inline; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  font-size: 1.05rem;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar nav a {
  color: var(--text);
  text-decoration: none;
  opacity: 0.85;
}
.topbar nav a:hover { opacity: 1; text-decoration: underline; }

.user { color: var(--muted); font-size: 0.9rem; }

.linklike {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  padding: 0;
  text-decoration: underline;
}
.linklike:hover { color: var(--text); }

/* ── Cards / hero ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.hero {
  text-align: center;
  max-width: 560px;
  margin: 3rem auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-discord { background: var(--discord); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }

/* ── Vote screen ─────────────────────────────────────────────────────────── */
.vs-heading { text-align: center; }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 680px) {
  .pair { grid-template-columns: 1fr; }
}

.song-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: stretch;
  text-align: center;
}

.song-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.15em;
}

.song-title { font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.song-artist { color: var(--muted); font-size: 0.9rem; }

.song-card audio { width: 100%; }

.vote-btn { margin-top: auto; }

.pair-actions {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.msg { text-align: center; color: var(--accent); min-height: 1.2em; }

/* ── Rankings ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table.rankings {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.rankings th, .rankings td {
  padding: 0.55rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.rankings thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rankings tbody tr:last-child td { border-bottom: none; }
.rankings .num { text-align: right; font-variant-numeric: tabular-nums; }
.rankings .rank { color: var(--muted); }
.rankings tr.top-three .rank { color: var(--accent); font-weight: 700; }
.rankings tr.playing td { background: var(--surface-2); }

.play-cell { width: 2.5rem; }

.play-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}
.play-btn:hover { border-color: var(--accent); color: var(--accent); }
tr.playing .play-btn { border-color: var(--accent); color: var(--accent); }

/* ── Shared bottom player (rankings) ─────────────────────────────────────── */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

.player-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}

.player-bar audio { flex: 1; min-width: 0; max-width: 560px; margin-left: auto; }

body.has-player main { padding-bottom: 4.5rem; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}
