:root {
  color-scheme: dark;
  --bg: #080812;
  --panel: #141421;
  --panel-soft: #1d1d2d;
  --line: #2d2d42;
  --text: #f6f6fb;
  --muted: #aaa9c0;
  --accent: #9146ff;
  --accent-strong: #b995ff;
}

* {
  box-sizing: border-box;
}

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

.topbar,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.disclaimer {
  color: var(--accent-strong);
  font-weight: 700;
}

.disclaimer a {
  color: var(--text);
}

.status,
.controls label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#randomStatus {
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.controls {
  justify-content: flex-start;
  flex-wrap: wrap;
}

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

.manual-toggle {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  cursor: pointer;
}

.manual-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.manual-controls {
  display: contents;
}

.manual-controls[hidden] {
  display: none !important;
}

select,
button {
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font: inherit;
}

select {
  min-width: 220px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-soft);
}

button {
  padding: 0 14px;
  color: white;
  background: var(--accent);
  cursor: pointer;
}

button:hover {
  background: #7d32f0;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  height: calc(100vh - 126px);
  min-height: 560px;
  padding: 10px;
}

.player {
  grid-column: span 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050509;
}

.slot-wide {
  grid-column: span 3;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  background: var(--panel);
}

.slot-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.channel-link {
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-link:hover {
  color: var(--accent-strong);
}

.player-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.player.has-chat .player-body {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 32%);
}

iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: black;
}

.chat-frame {
  display: none;
  border-left: 1px solid var(--line);
}

.player.has-chat .chat-frame {
  display: block;
}

.player-meta {
  min-height: 30px;
  margin: 0;
  padding: 7px 10px;
  overflow: hidden;
  color: var(--muted);
  background: var(--panel);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-slot {
  display: grid;
  place-content: center;
  gap: 8px;
  height: 100%;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-slot strong {
  color: var(--text);
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .player.has-chat .player-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 280px;
  }

  .player,
  .slot-wide {
    grid-column: span 1;
    height: 360px;
  }
}

@media (max-width: 560px) {
  select {
    min-width: 0;
    width: 100%;
  }

  .controls label,
  .controls button {
    width: 100%;
  }
}
