:root {
  --bg: #0a0a0a;
  --card: rgba(15, 15, 20, 0.6);
  --line: rgba(255, 255, 255, 0.1);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.5);
  --accent: #ff0050;
  --accent2: #00f0ff;
  --gold: #ffd700;
  --success: #22c55e;
  --danger: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  backdrop-filter: blur(10px);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}
.logo {
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.5px;
}
.logo-reels { color: var(--accent); }
.me-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
  padding: 4px 10px;
}
.me-chip img { width: 24px; height: 24px; border-radius: 50%; }

.container {
  max-width: 440px;
  margin: 0 auto;
  padding: 0 12px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen { flex: 1; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.center-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.big-emoji { font-size: 4rem; margin-bottom: 16px; }
h2 { margin-bottom: 12px; font-weight: 600; }
.muted { color: var(--muted); font-size: 0.9rem; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 12px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: scale(0.95); }
.btn.small { font-size: 0.85rem; padding: 4px 10px; }

/* Reels feed */
.reels-container {
  flex: 1;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  border-radius: 16px;
  margin-top: 12px;
  -webkit-overflow-scrolling: touch;
}
.reels-container::-webkit-scrollbar { width: 0; }
.reel-slot {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  margin: 0 auto 10px;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  scroll-snap-align: start;
}
.reel-slot video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}
.reel-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.1) 55%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px 16px 18px;
  gap: 6px;
  pointer-events: none;
}
.reel-title { font-weight: 700; font-size: 1.05rem; line-height: 1.3; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }
.reel-meta { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.reel-uploader { font-weight: 600; color: var(--accent2); }
.reel-id { font-family: monospace; opacity: 0.6; font-size: 0.75rem; }
.reel-badge {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(0,0,0,0.5);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--gold);
}
.reel-buffering {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  font-size: 0.9rem;
  color: var(--muted);
  pointer-events: none;
}
.reel-buffering.hidden { display: none; }

/* Controls */
.controls {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 18px;
  margin: 12px auto 0;
  max-width: 100%;
}
.vol-row { display: flex; align-items: center; gap: 14px; }
.vol-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  width: 44px; height: 44px;
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.vol-btn:hover { filter: brightness(1.3); }
.vol-btn:active { transform: scale(0.95); }
input[type="range"] {
  flex: 1;
  height: 32px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2) var(--fill, 70%), rgba(255,255,255,0.12) var(--fill, 70%));
}
input[type="range"]::-moz-range-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.12); }
input[type="range"]::-moz-range-progress { height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text);
  margin-top: -5px;
}
.vol-pct { min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.controls-hint { margin-top: 8px; font-size: 0.82rem; text-align: center; color: var(--muted); }

/* Listener bar + leaderboard */
.listeners-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 14px;
  margin: 12px auto 0;
  max-width: 100%;
  font-size: 13px;
  flex-wrap: wrap;
}
.lb-icon { font-size: 15px; }
.lb-count { font-weight: 700; color: var(--gold); white-space: nowrap; }
.lb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: 999px;
  padding: 3px 10px 3px 3px;
  font-size: 12px;
  cursor: pointer;
  transition: filter 0.15s;
}
.chip:hover { filter: brightness(1.25); }
.chip img { width: 20px; height: 20px; border-radius: 50%; }
.chip-dot { width: 20px; height: 20px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); }

.lb-card {
  background: linear-gradient(135deg, rgba(255,193,7,0.10), rgba(99,102,241,0.08));
  border: 1px solid rgba(255,193,7,0.28);
  border-radius: 18px;
  padding: 12px 14px;
  margin: 12px auto 0;
  max-width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.lb-title { font-size: 14px; color: var(--gold); letter-spacing: 0.3px; white-space: nowrap; }
.lb-sub { font-size: 11px; color: var(--muted); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-show {
  background: rgba(255,193,7,0.15);
  border: 1px solid rgba(255,193,7,0.4);
  color: var(--gold);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.lb-show:hover { filter: brightness(1.25); }
.lb-rows { display: flex; flex-direction: column; gap: 4px; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}
.lb-row.me { background: linear-gradient(135deg, rgba(99,102,241,0.3), rgba(139,92,246,0.22)); border-color: rgba(99,102,241,0.5); }
.lb-row.muted-row { background: transparent; border: none; color: var(--muted); }
.lb-medal { width: 24px; text-align: center; font-size: 15px; flex-shrink: 0; }
.lb-rank { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,0.1); font-size: 12px; font-weight: 800; color: var(--muted); }
.lb-av { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.2); flex-shrink: 0; object-fit: cover; }
.lb-initial { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 800; }
.lb-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.lb-you-tag { font-size: 10px; font-weight: 800; color: #0b1020; background: var(--gold); border-radius: 6px; padding: 1px 6px; margin-left: 6px; text-transform: uppercase; }
.lb-hours { font-weight: 800; color: var(--gold); font-size: 13px; white-space: nowrap; }
.lb-you { margin-top: 6px; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; gap: 5px; }
.lb-you.hidden { display: none; }

/* Chat */
.chat-card {
  background: linear-gradient(180deg, rgba(99,102,241,0.07), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
  border-radius: 18px;
  margin: 12px auto 0;
  max-width: 100%;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; cursor: pointer; font-weight: 800; font-size: 14px; user-select: none; }
.chat-head:hover { background: rgba(255,255,255,0.04); }
.chat-title { display: flex; align-items: center; gap: 8px; }
.chat-ico { font-size: 15px; }
.chat-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.8); display: inline-block; }
.chat-right { display: flex; align-items: center; gap: 8px; }
.chat-badge { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-radius: 999px; font-size: 11px; padding: 2px 8px; font-weight: 800; animation: pop 0.25s ease; }
.chat-chev { color: var(--muted); font-size: 12px; transition: transform 0.2s; }
.chat-body.open .chat-chev { transform: rotate(180deg); }
.chat-body { border-top: 1px solid var(--line); padding: 12px; }
.chat-body.hidden { display: none; }
.chat-msgs { min-height: 80px; max-height: 200px; overflow-y: auto; padding: 4px 0; display: flex; flex-direction: column; gap: 8px; }
.chat-empty { text-align: center; padding: 16px 0; font-style: italic; color: var(--muted); }
.chat-msg { display: flex; gap: 8px; font-size: 13.5px; }
.chat-msg .c-av { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.chat-msg .c-initial { width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }
.chat-msg .c-body { flex: 1; min-width: 0; }
.chat-msg .c-name { font-weight: 700; color: var(--accent2); cursor: pointer; }
.chat-msg .c-name:hover { text-decoration: underline; }
.chat-msg .c-text { word-break: break-word; }
.chat-msg .c-time { color: var(--muted); font-size: 11px; margin-left: 6px; }
.chat-msg .c-reply { background: rgba(255,255,255,0.06); border-left: 2px solid var(--accent); border-radius: 6px; padding: 3px 8px; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.chat-msg .c-mention { color: var(--accent); font-weight: 700; }
.chat-reply-chip { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.04); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; }
#chat-reply-text { flex: 1; color: var(--muted); }
.chip-x { background: transparent; border: none; color: var(--muted); font-size: 14px; cursor: pointer; }
.chip-x:hover { color: var(--text); }
.chat-compose { display: flex; gap: 8px; }
#chat-input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); font-size: 14px; }
#chat-input:focus { outline: none; border-color: var(--accent); }
#chat-send { flex-shrink: 0; background: var(--accent); color: #000; border: none; border-radius: 12px; padding: 8px 16px; font-weight: 600; cursor: pointer; }
#chat-send:hover { filter: brightness(1.2); }

/* Countdown */
.countdown { position: fixed; inset: 0; z-index: 200; background: rgba(5,8,18,0.82); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; }
.countdown.hidden { display: none; }
.cd-inner { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px 32px; }
.cd-num { font-size: 4rem; font-weight: 800; letter-spacing: -2px; margin-bottom: 12px; color: var(--accent); }
.cd-label { color: var(--muted); font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(5,8,18,0.82); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-box { width: 100%; max-width: 440px; max-height: 82vh; background: var(--card); border: 1px solid var(--line); border-radius: 22px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-title { font-weight: 800; font-size: 14px; }
.modal-close { background: rgba(255,255,255,0.08); border: none; color: var(--muted); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 14px; }
.modal-close:hover { color: #fff; background: rgba(255,255,255,0.18); }
.modal-body { padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.modal-body .lb-row { padding: 8px 10px; }

.footer { text-align: center; padding: 16px; font-size: 0.82rem; }
.footer a { color: var(--muted); text-decoration: none; margin: 0 8px; }
.footer a:hover { text-decoration: underline; }
.support-link { color: var(--gold); font-weight: 600; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { 0% { transform: scale(0.6); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .spinner { animation: none; }
}
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
