:root {
  --bg: #0e0f13;
  --panel: #171920;
  --panel-2: #1f222b;
  --border: #2a2e3a;
  --text: #e8eaf0;
  --muted: #8b90a0;
  --accent: #7c5cff;
  --accent-2: #9b83ff;
  --live: #ff4d5e;
  --ok: #3ecf8e;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

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

a { color: var(--accent-2); }

button, input {
  font: inherit;
  color: inherit;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--live); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.muted { color: var(--muted); }
.error { color: var(--live); min-height: 1.5em; margin: 8px 0 0; }

/* ---------- centered card pages (login, admin, join) ---------- */

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

.card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.card.wide { max-width: 640px; }
.card h1 { margin: 0 0 4px; font-size: 22px; }
.card p { margin: 0 0 20px; }
.card form { display: grid; gap: 12px; }

.logo { font-weight: 700; letter-spacing: .3px; }
.logo span { color: var(--accent-2); }

.room-list { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 8px; }
.room-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.room-list li .grow { flex: 1; min-width: 0; }

/* ---------- party layout (host + viewer) ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}
.topbar .grow { flex: 1; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.live { color: #fff; background: var(--live); border-color: var(--live); }
.badge.live::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%; background: #fff;
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 50% { opacity: .3; } }

.party {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: calc(100% - 57px);
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.video-wrap {
  position: relative;
  flex: 1;
  min-height: 240px;
  background: #000;
  display: grid;
  place-items: center;
}
/* Pinned to the box so the box sets the size, not the video. Otherwise a tall picture
   (portrait video, narrow shared window) grows past the screen and gets cut off. */
.video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  background: #000;
}
.overlay[hidden] { display: none; }

.controls .site-url { width: 240px; padding: 8px 10px; }

.steps { margin: 12px 0 0; padding-left: 20px; text-align: left; }
.steps li { margin: 4px 0; }
.overlay .big { font-size: 18px; color: var(--text); margin-bottom: 6px; }

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}
.controls .grow { flex: 1; }
.controls input[type="range"] { width: 110px; accent-color: var(--accent); }

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--panel);
}
.side h3 {
  margin: 0;
  padding: 12px 16px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.share {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 8px;
}
.share .row { display: flex; gap: 8px; }
.share input { font-size: 13px; }

.viewers {
  list-style: none;
  margin: 0;
  padding: 8px 16px;
  max-height: 140px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.viewers li { padding: 2px 0; }
.viewers li::before { content: "● "; color: var(--ok); font-size: 10px; vertical-align: middle; }
.viewers .empty::before { content: ""; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
}
.chat-log .msg { word-wrap: break-word; }
.chat-log .msg b { color: var(--accent-2); }
.chat-log .msg.host b { color: var(--live); }
.chat-log .sys { color: var(--muted); font-size: 13px; font-style: italic; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 24px);
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}

.stage:fullscreen { width: 100vw; height: 100vh; background: #000; }
.stage:fullscreen .video-wrap { flex: 1; min-height: 0; aspect-ratio: auto; }

@media (max-width: 820px) {
  .party { grid-template-columns: 1fr; height: auto; }
  .video-wrap { aspect-ratio: 16 / 9; flex: none; }
  .side { border-left: 0; border-top: 1px solid var(--border); height: 60vh; }
}
