:root {
  --bg: #0b0d12;
  --panel: #14171f;
  --panel-2: #1c2029;
  --border: #2a2f3a;
  --text: #e8ebf0;
  --muted: #8b93a5;
  --accent: #7c5cff;
  --accent-2: #4cc9f0;
  --danger: #f85149;
  --ok: #3fb950;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: radial-gradient(1200px 600px at 20% -10%, #1a1f2e 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 23, 31, 0.6);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(124, 92, 255, 0.6));
}

.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.pill {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.pill-idle { color: var(--muted); background: var(--panel); }
.pill-idle::before { background: var(--muted); }

.pill-live {
  color: var(--ok);
  background: rgba(63, 185, 80, 0.12);
  border-color: rgba(63, 185, 80, 0.4);
}
.pill-live::before {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 1.6s infinite;
}

.pill-paused {
  color: #ffc93c;
  background: rgba(255, 201, 60, 0.12);
  border-color: rgba(255, 201, 60, 0.4);
}
.pill-paused::before { background: #ffc93c; }

.pill-buffering {
  color: var(--accent-2);
  background: rgba(76, 201, 240, 0.1);
  border-color: rgba(76, 201, 240, 0.35);
}
.pill-buffering::before { background: var(--accent-2); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  .pill-live::before { animation: none; }
  .buffer-progress span {
    animation: none;
    transform: translateX(106%);
    opacity: 0.72;
  }
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.empty {
  text-align: center;
  color: var(--muted);
  max-width: 420px;
}

.empty-icon {
  font-size: 64px;
  color: var(--panel-2);
  margin-bottom: 16px;
}

.empty h2 {
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty p {
  font-size: 15px;
  line-height: 1.5;
}

.player-wrap {
  position: relative;
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.player-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(0, 0, 0, 0.78);
}

.buffer-progress {
  width: min(360px, 80%);
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}

.buffer-progress span {
  display: block;
  width: 32%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
  animation: buffer-scan 1.1s cubic-bezier(0.76, 0, 0.24, 1) infinite alternate;
}

@keyframes buffer-scan {
  from { transform: translateX(-100%); }
  to { transform: translateX(312%); }
}

.play-overlay button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.play-overlay button:hover { background: #6d4df0; }
.play-overlay button:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 3px;
}
.play-overlay button:active { transform: translateY(1px); }
.play-overlay p {
  max-width: 52ch;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.ended-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  backdrop-filter: blur(4px);
}

.ended-card {
  color: var(--text);
}

.ended-icon {
  font-size: 56px;
  color: var(--danger);
  margin-bottom: 16px;
}

.ended-card h3 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
}

.ended-card p {
  color: var(--muted);
  font-size: 14px;
}

.hidden { display: none !important; }

.poll-card {
  max-width: 560px;
  margin: 24px auto 0;
  padding: 24px 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: poll-fade-in 0.4s ease;
}

.poll-question {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 18px;
  color: var(--text);
}

.poll-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
}

.vote-btn {
  flex: 1;
  max-width: 160px;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
}

.vote-btn:hover { filter: brightness(1.12); }
.vote-btn:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 3px;
}
.vote-btn:active { transform: translateY(1px); }

.vote-yes {
  background: var(--accent);
}
.vote-yes:hover { background: #6d4df0; }

.vote-no {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.vote-no:hover { background: #252a35; color: var(--text); }

.poll-done {
  max-width: 420px;
  margin: 24px auto 0;
  padding: 20px 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  animation: poll-fade-in 0.4s ease;
}

.poll-done-icon {
  font-size: 24px;
  color: var(--ok);
}

.poll-done p {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

@keyframes poll-fade-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .poll-card, .poll-done { animation: none; }
}

@media (max-width: 640px) {
  .poll-card { margin: 16px 12px 0; padding: 20px 18px; }
  .poll-question { font-size: 15px; }
  .poll-actions { gap: 10px; }
}

.meta {
  display: flex;
  justify-content: space-between;
  padding: 12px 28px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

#stats {
  color: var(--accent-2);
}

@media (max-width: 640px) {
  .topbar { padding: 14px 16px; }
  .brand h1 { font-size: 17px; }
  .meta { padding: 10px 16px; flex-direction: column; gap: 4px; }
  .empty-icon { font-size: 48px; }
}
