:root {
  --bg: #06060a;
  --bg-panel: #11111c;
  --bg-panel-2: #161624;
  --border-color: #242438;
  --neon-cyan: #05e8ff;
  --neon-pink: #ff2ec4;
  --neon-violet: #8b5cf6;
  --text-primary: #eef0fb;
  --text-secondary: #8e8ea8;
  --danger: #ff4d6d;
  --success: #2ecc71;
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Hind Siliguri', 'Segoe UI', sans-serif;
}

@property --angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before, body::after {
  content: '';
  position: fixed;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  filter: blur(130px);
  opacity: 0.18;
  z-index: -1;
  pointer-events: none;
  animation: float 20s ease-in-out infinite;
}
body::before { background: var(--neon-violet); top: -220px; left: -160px; }
body::after { background: var(--neon-cyan); bottom: -220px; right: -160px; animation-delay: -10s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(50px, -40px); }
}
@keyframes hue-shift {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(30deg); }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(139,92,246,0.35); }
  50% { box-shadow: 0 0 32px rgba(139,92,246,0.6), 0 0 14px rgba(5,232,255,0.45); }
}
@keyframes rotate-border { to { --angle: 360deg; } }
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes presence-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes float-up {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  15% { opacity: 1; transform: translateY(-20px) scale(1.25); }
  100% { transform: translateY(-230px) scale(1); opacity: 0; }
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Glowing animated border (signature panel treatment) ---------- */
.glow-border { position: relative; z-index: 0; }
.glow-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from var(--angle, 0deg), var(--neon-cyan), var(--neon-violet), var(--neon-pink), var(--neon-cyan));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: -1;
  animation: rotate-border 7s linear infinite;
  opacity: 0.7;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border-color);
  background: rgba(12,12,21,0.6);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10; gap: 12px; flex-wrap: wrap;
}
.brand-link { text-decoration: none; }
.brand {
  font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: 1px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink), var(--neon-violet), var(--neon-cyan));
  background-size: 300% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: hue-shift 6s ease-in-out infinite;
}
.brand-dot { color: var(--neon-pink); margin-left: 2px; }

.nav-tabs { display: flex; gap: 6px; }
.nav-tab { text-decoration: none; color: var(--text-secondary); font-size: 13.5px; padding: 7px 14px; border-radius: 999px; border: 1px solid transparent; }
.nav-tab.active { color: var(--neon-cyan); border-color: var(--neon-cyan); box-shadow: 0 0 12px rgba(5,232,255,0.25); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--neon-cyan); object-fit: cover; background: var(--bg-panel); }
.user-name { font-size: 13.5px; color: var(--text-secondary); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.room-code-badge {
  font-family: 'Courier New', monospace; font-weight: 700; letter-spacing: 3px;
  background: var(--bg-panel); border: 1px solid var(--neon-cyan); color: var(--neon-cyan);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; box-shadow: 0 0 14px rgba(5,232,255,0.25); font-size: 13px;
}
.btn-leave, .btn-signout {
  background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-family: var(--font-body);
}
.btn-leave:hover, .btn-signout:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Shared inputs / buttons ---------- */
.input {
  width: 100%; background: var(--bg-panel); border: 1px solid var(--border-color); color: var(--text-primary);
  padding: 12px 14px; border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 15px;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--text-secondary); }
.input:focus { border-color: var(--neon-cyan); box-shadow: 0 0 0 3px rgba(5,232,255,0.12); }
.input-small { width: 100px; flex: none; text-align: center; }

.btn {
  font-family: var(--font-body); font-weight: 600; font-size: 15px; padding: 12px 18px;
  border-radius: var(--radius-sm); border: none; cursor: pointer; transition: transform .15s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(90deg, var(--neon-cyan), var(--neon-violet)); color: #04040a; animation: pulse-glow 3.5s ease-in-out infinite; }
.btn-primary:hover { box-shadow: 0 0 34px rgba(139,92,246,0.65); }
.btn-secondary { background: var(--bg-panel); border: 1px solid var(--neon-pink); color: var(--neon-pink); }
.btn-secondary:hover { box-shadow: 0 0 18px rgba(255,46,196,0.3); }
.btn-icon {
  background: var(--bg-panel); border: 1px solid var(--border-color); color: var(--text-primary);
  padding: 10px 14px; border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font-body); font-size: 14px; white-space: nowrap;
}
.btn-icon:hover { border-color: var(--neon-cyan); color: var(--neon-cyan); }
.btn-icon.active { border-color: var(--neon-cyan); color: var(--neon-cyan); background: rgba(5,232,255,0.08); }

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  background: #ffffff; color: #1f1f1f; font-weight: 600; padding: 12px 18px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-size: 15px; box-shadow: 0 0 20px rgba(5,232,255,0.15);
}
.btn-google img { width: 18px; height: 18px; }
.btn-google:hover { box-shadow: 0 0 28px rgba(5,232,255,0.3); }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-secondary); margin: 10px 0; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--neon-cyan); }

details.room-options { margin: 14px 0; }
details.room-options summary { cursor: pointer; font-size: 13.5px; color: var(--neon-cyan); padding: 6px 0; }
details.room-options .input { margin-top: 8px; margin-bottom: 8px; }

/* ---------- Landing ---------- */
.landing { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.landing-card {
  width: 100%; max-width: 460px; background: rgba(17,17,28,0.7); border: 1px solid var(--border-color);
  border-radius: 20px; padding: 32px 26px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.hero-title { font-size: 26px; line-height: 1.35; margin-bottom: 10px; font-weight: 700; }
.hero-sub { color: var(--text-secondary); font-size: 14.5px; margin-bottom: 22px; line-height: 1.6; }
.landing-card .input { margin-bottom: 14px; }
.landing-card .btn-primary { width: 100%; }
.divider { display: flex; align-items: center; text-align: center; color: var(--text-secondary); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-color); }
.divider span { padding: 0 12px; }
.join-row { display: flex; gap: 10px; }
.join-row .input { flex: 1; }
.join-row .btn { flex: none; }
.error-text { color: var(--danger); font-size: 13.5px; margin-top: 10px; min-height: 18px; }
.demo-note { margin-top: 20px; font-size: 12.5px; color: var(--text-secondary); border-top: 1px solid var(--border-color); padding-top: 14px; line-height: 1.6; }
.post-auth { display: none; }
.post-auth.visible { display: block; }
.pre-auth.hidden { display: none; }

/* ---------- Room layout ---------- */
.room-layout { flex: 1; display: flex; gap: 16px; padding: 16px; max-width: 1450px; width: 100%; margin: 0 auto; }
.video-panel { flex: 2; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.source-tabs { display: flex; gap: 6px; }
.source-tab { background: var(--bg-panel); border: 1px solid var(--border-color); color: var(--text-secondary); padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 13.5px; font-family: var(--font-body); }
.source-tab.active { color: var(--neon-cyan); border-color: var(--neon-cyan); }
.source-panel { display: none; flex-direction: column; gap: 10px; }
.source-panel.active { display: flex; }

.video-url-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.video-url-bar .input { flex: 1; min-width: 160px; }

.search-results { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.search-result-item, .queue-item {
  display: flex; align-items: center; gap: 10px; background: var(--bg-panel); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 8px; animation: fade-in-up .3s ease both;
}
.search-result-item img, .queue-item img { width: 64px; height: 40px; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
.search-result-info, .queue-item-info { flex: 1; min-width: 0; }
.search-result-title, .queue-item-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-result-channel, .queue-item-added { font-size: 11.5px; color: var(--text-secondary); }
.search-result-actions { display: flex; gap: 4px; flex: none; }
.search-result-actions .btn-icon, .queue-item .btn-icon { padding: 6px 10px; font-size: 13px; }

.video-meta { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.video-meta img { width: 56px; height: 34px; object-fit: cover; border-radius: 6px; }
.video-meta-title { font-size: 13px; font-weight: 600; }
.video-meta-channel { font-size: 11.5px; color: var(--text-secondary); }

.player-wrap {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border-color); box-shadow: 0 0 40px rgba(5,232,255,0.08);
}
.player-wrap iframe, .player-wrap > div { width: 100%; height: 100%; border: 0; display: block; }
.player-placeholder { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); font-size: 14px; text-align: center; padding: 20px; }

.reaction-float { position: absolute; bottom: 50px; font-size: 30px; animation: float-up 2.6s ease-out forwards; pointer-events: none; z-index: 5; }

.controls-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.reactions-bar { display: flex; gap: 8px; }
.reaction-btn { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 999px; font-size: 18px; padding: 6px 12px; cursor: pointer; }
.reaction-btn:hover { border-color: var(--neon-pink); transform: scale(1.1); }
.hint-text { color: var(--text-secondary); font-size: 12.5px; }

/* ---------- Tabbed side panel (chat / queue / members) ---------- */
.side-panel {
  flex: 1; min-width: 300px; max-width: 380px; background: rgba(17,17,28,0.6); border: 1px solid var(--border-color);
  border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
}
.side-tabs { display: flex; border-bottom: 1px solid var(--border-color); }
.side-tab { flex: 1; background: none; border: none; color: var(--text-secondary); padding: 12px 8px; font-size: 13px; cursor: pointer; font-family: var(--font-body); border-bottom: 2px solid transparent; }
.side-tab.active { color: var(--neon-cyan); border-bottom-color: var(--neon-cyan); }
.tab-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; min-height: 0; }
.tab-panel.active { display: flex; }

.chat-messages, .queue-list, .dm-list, .member-list { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-messages::-webkit-scrollbar, .dm-list::-webkit-scrollbar, .queue-list::-webkit-scrollbar, .member-list::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb, .dm-list::-webkit-scrollbar-thumb, .queue-list::-webkit-scrollbar-thumb, .member-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.msg { max-width: 82%; display:flex; gap:8px; align-items:flex-end; animation: fade-in-up .25s ease both; }
.msg-avatar { width: 24px; height: 24px; border-radius: 50%; flex: none; background: var(--bg-panel); }
.msg-user { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 3px; }
.msg-text { padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; word-break: break-word; }
.msg-other { align-self: flex-start; }
.msg-other .msg-text { background: var(--bg-panel); border: 1px solid var(--border-color); border-left: 2px solid var(--neon-cyan); }
.msg-mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-mine .msg-user { text-align: right; }
.msg-mine .msg-text { background: linear-gradient(135deg, rgba(139,92,246,0.35), rgba(255,46,196,0.25)); border: 1px solid var(--neon-violet); }
.msg-system { align-self: center; color: var(--text-secondary); font-size: 12px; font-style: italic; text-align: center; }

.chat-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border-color); }
.chat-input-row .input { flex: 1; }
.btn-send { flex: none; width: 44px; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; }

.member-item { display: flex; align-items: center; gap: 10px; animation: fade-in-up .25s ease both; }
.member-item img { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-panel); }
.presence-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 6px var(--success); margin-right: 2px; animation: presence-pulse 2s ease-in-out infinite; }

.side-panel-header { padding: 10px 16px; border-bottom: 1px solid var(--border-color); font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; justify-content: space-between; }
.dm-empty, .empty-state { color: var(--text-secondary); font-size: 13.5px; text-align: center; padding: 20px; }

/* ---------- Theater mode ---------- */
.room-layout.theater-mode .side-panel { display: none; }
.room-layout.theater-mode .video-panel { flex: 1; }
.room-layout.theater-mode .player-wrap { max-width: 1100px; margin: 0 auto; width: 100%; }

/* ---------- Password gate modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,4,8,0.75); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-card { width: 100%; max-width: 380px; background: var(--bg-panel-2); border: 1px solid var(--border-color); border-radius: 18px; padding: 26px 22px; }
.modal-card h2 { font-size: 19px; margin-bottom: 8px; }
.modal-card p { color: var(--text-secondary); font-size: 13.5px; margin-bottom: 16px; }
.modal-card .input { margin-bottom: 10px; }

/* ---------- Public rooms ---------- */
.public-rooms-layout { flex: 1; max-width: 1100px; width: 100%; margin: 0 auto; padding: 20px 16px; }
.public-rooms-header { margin-bottom: 18px; }
.public-rooms-header h1 { font-size: 22px; margin-bottom: 6px; }
.public-rooms-header p { color: var(--text-secondary); font-size: 13.5px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.room-card {
  position: relative; background: rgba(17,17,28,0.7); border: 1px solid var(--border-color); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 8px; animation: fade-in-up .3s ease both;
}
.room-card-thumb { width: 100%; aspect-ratio: 16/9; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg-panel); }
.room-card-title { font-weight: 700; font-size: 15px; }
.room-card-meta { color: var(--text-secondary); font-size: 12.5px; }
.room-card .btn { width: 100%; margin-top: 6px; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center; padding: 18px 16px; font-size: 12.5px; color: var(--text-secondary);
  border-top: 1px solid var(--border-color); margin-top: auto;
}
.site-footer strong {
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .room-layout { flex-direction: column; padding: 12px; }
  .side-panel { min-width: 0; max-width: none; height: 400px; }
  .room-layout.theater-mode .side-panel { display: none; }
}
@media (max-width: 480px) {
  .hero-title { font-size: 22px; }
  .landing-card { padding: 24px 18px; }
  .nav-tab { padding: 6px 10px; font-size: 12.5px; }
  .user-name { display: none; }
  .room-grid { grid-template-columns: 1fr 1fr; }
}
