:root {
  --bg: #0f0e13;
  --panel: #17161d;
  --raised: #201f28;
  --border: #2b2935;
  --text: #ece9f5;
  --muted: #9893a8;
  --accent: #ff5c8a;
  --accent-ink: #2a0712;
  --gold: #ffb74a;
  --good: #5ad19a;
  --bad: #ff7a6b;
  --radius: 12px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

h1 {
  font-size: 28px;
  margin: 0 0 16px;
}

h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 20px 0 10px;
}

h2:first-child {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
}

.spacer {
  flex: 1;
}

.grow {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ---- controls ---- */

input[type='text'],
input[type='search'],
input:not([type]) {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

input:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--muted);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
  border-color: var(--accent);
}

.btn.ghost {
  background: transparent;
}

.btn.large {
  padding: 13px 22px;
  font-size: 16px;
}

.btn.icon {
  padding: 4px 8px;
  font-size: 13px;
}

.row {
  display: flex;
  gap: 8px;
}

.link {
  color: var(--muted);
  font-size: 13px;
}

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  text-align: left;
}

.notice.error {
  border-color: var(--bad);
  color: var(--text);
}

/* ---- logo ---- */

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo .tld {
  color: var(--accent);
}

.logo.big {
  font-size: 44px;
  gap: 14px;
}

.disc {
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold) 0 14%, var(--panel) 15% 32%, var(--accent) 33% 100%);
}

/* ---- login ---- */

.view.center {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.hero {
  width: min(440px, 100%);
  text-align: center;
  display: grid;
  gap: 18px;
  justify-items: center;
}

.hero form {
  display: grid;
  gap: 12px;
  width: 100%;
}

.tagline {
  font-size: 18px;
  color: var(--muted);
  margin: 0;
}

/* ---- top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.crumb {
  color: var(--border);
}

.volume {
  display: flex;
  align-items: center;
  gap: 6px;
}

.volume input {
  width: 110px;
  accent-color: var(--accent);
}

/* ---- lobby ---- */

.lobby {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 40px 20px;
}

.room-list {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.room-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.room-card:hover {
  border-color: var(--accent);
}

.room-card .name {
  font-weight: 700;
}

.room-card .meta {
  color: var(--muted);
  font-size: 13px;
}

/* ---- room layout ---- */

.room-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  height: calc(100vh - 56px);
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

#panel-chat {
  border-right: 0;
  border-left: 1px solid var(--border);
}

.stage {
  padding: 24px;
  overflow-y: auto;
}

/* ---- now playing ---- */

.now {
  display: flex;
  gap: 22px;
  align-items: center;
}

.art,
.thumb {
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #3a2a4d, #5a2440 60%, #7a3b2a);
  color: rgb(255 255 255 / 0.85);
  font-weight: 800;
}

.art {
  width: 200px;
  height: 200px;
  border-radius: 16px;
  font-size: 64px;
  box-shadow: 0 18px 50px rgb(255 92 138 / 0.18);
}

.art.idle {
  background: var(--raised);
  box-shadow: none;
  color: var(--muted);
}

.thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  font-size: 16px;
}

.art img,
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.now-info {
  flex: 1;
  min-width: 0;
}

.label {
  font-size: 13px;
  color: var(--gold);
  min-height: 1.45em;
}

.title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.artists {
  color: var(--muted);
  font-size: 16px;
}

.progress {
  height: 6px;
  margin-top: 16px;
  border-radius: 3px;
  background: var(--raised);
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.5s linear;
}

.times {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.vote.on {
  border-color: var(--accent);
  background: rgb(255 92 138 / 0.15);
}

.sound {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  min-height: 40px;
}

.sound .bad {
  color: var(--bad);
}

/* ---- decks and listeners ---- */

.decks {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.deck {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px 6px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  min-width: 0;
}

.deck.taken {
  border-style: solid;
  background: var(--panel);
  color: var(--text);
}

.deck.playing {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.deck .who,
.person .who {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--raised);
  color: var(--text);
  font-weight: 700;
}

.avatar.small {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.avatar.empty {
  background: transparent;
  border: 1px dashed var(--border);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.listeners {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.person {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  max-width: 220px;
  font-size: 14px;
}

.person .points {
  color: var(--gold);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---- track lists ---- */

.track-list {
  display: grid;
  align-content: start;
  gap: 4px;
}

#results:not(:empty) {
  margin-top: 8px;
  max-height: 40%;
  overflow-y: auto;
}

.track {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: 8px;
}

.track:hover {
  background: var(--raised);
}

.track.pick {
  cursor: pointer;
}

.track.pick:hover,
.track.pick:focus-visible {
  background: var(--raised);
  outline: 1px solid var(--border);
}

.track.pick.queued {
  cursor: default;
  opacity: 0.55;
}

.track .text {
  flex: 1;
  min-width: 0;
}

.track .name,
.track .by {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track .name {
  font-weight: 600;
  font-size: 14px;
}

.track .by {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 6px;
}

/* ---- chat ---- */

.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
}

.message {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.message .body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.message .from {
  font-weight: 700;
  font-size: 13px;
}

.message.system {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

/* ---- toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(480px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--raised);
  border: 1px solid var(--bad);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.5);
  z-index: 10;
}

.toast.ok {
  border-color: var(--good);
}

/* ---- small screens ---- */

@media (max-width: 980px) {
  .room-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .stage {
    order: -1;
    overflow: visible;
  }

  .panel {
    border: 0;
    border-top: 1px solid var(--border);
    max-height: 70vh;
  }

  #panel-chat {
    border-left: 0;
  }

  .volume input {
    width: 70px;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 8px;
    padding: 0 10px;
  }

  .topbar .crumb,
  #room-count,
  .volume span {
    display: none;
  }

  #room-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .volume input {
    width: 64px;
  }

  .topbar .btn {
    padding: 7px 10px;
  }

  .stage {
    padding: 16px;
  }

  .now {
    flex-direction: column;
    align-items: stretch;
  }

  .art {
    align-self: flex-start;
  }

  .decks {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
