:root {
  --bg-0: #000000;
  --bg-1: #0a0008;
  --bg-2: #14001f;
  --bg-3: #2a0420;
  --accent: #e50914;
  --accent-2: #ff4d8d;
  --accent-soft: #ff9ec0;
  --rose: #c2185b;
  --burgundy: #5c0a2a;
  --gold: #f0c97a;
  --text: #f6e6ee;
  --text-dim: #9a8090;
  --glass: rgba(20, 0, 16, 0.65);
  --glass-border: rgba(255, 158, 192, 0.14);
  --ok: #5bd99a;
  --danger: #ff5a7a;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --netflix-red: #e50914;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(229, 9, 20, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 100%, rgba(92, 10, 42, 0.45), transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 50%, var(--bg-0) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.bg-hearts {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 77, 141, 0.06) 0, transparent 2px),
    radial-gradient(circle at 78% 32%, rgba(255, 158, 192, 0.05) 0, transparent 2px),
    radial-gradient(circle at 45% 70%, rgba(240, 201, 122, 0.04) 0, transparent 2px),
    radial-gradient(circle at 88% 85%, rgba(229, 9, 20, 0.05) 0, transparent 2px);
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  background: rgba(0, 0, 0, 0.72);
  border-bottom: 1px solid var(--glass-border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { color: var(--netflix-red); font-size: 22px; filter: drop-shadow(0 0 10px rgba(229, 9, 20, 0.6)); animation: heartbeat 2.4s ease-in-out infinite; }
.brand-text { font-family: 'Bebas Neue', sans-serif; font-size: 26px; letter-spacing: 3px; color: var(--netflix-red); text-shadow: 0 0 16px rgba(229, 9, 20, 0.35); }

@keyframes heartbeat { 0%,100%{transform:scale(1);} 10%,30%{transform:scale(1.18);} 20%{transform:scale(0.95);} }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.name-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
}
.name-chip:hover { background: rgba(229, 9, 20, 0.15); border-color: rgba(229, 9, 20, 0.4); }
.name-icon { font-size: 14px; }

.status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); padding: 6px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.04); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 8px currentColor; transition: background 0.3s; }
.dot.ok { background: var(--ok); color: var(--ok); }

.layout {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  padding: 18px;
  max-width: 1500px;
  margin: 0 auto;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
}

.player-wrap { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.url-bar {
  display: flex; gap: 8px;
  padding: 7px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.url-bar input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 14px;
  padding: 9px 12px; font-family: inherit;
}
.url-bar input::placeholder { color: var(--text-dim); }

.btn-primary {
  border: none; cursor: pointer;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: inherit; font-weight: 600; font-size: 13px;
  color: white;
  background: linear-gradient(135deg, var(--netflix-red), #b00710);
  box-shadow: 0 4px 16px rgba(229, 9, 20, 0.35);
  transition: transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.4px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(229, 9, 20, 0.5); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 9px 18px; border-radius: 8px;
  cursor: pointer; font-family: inherit; font-weight: 500; font-size: 13px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); }

/* Player frame */
.player-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: var(--shadow), 0 20px 60px rgba(0, 0, 0, 0.6);
  isolation: isolate;
}

.player-frame:fullscreen { border-radius: 0; border: none; }
.player-frame.is-fullscreen { border-radius: 0; }

.yt-host, .yt-host iframe {
  width: 100%; height: 100%; border: 0; display: block;
  position: absolute; inset: 0;
}

/* Shield blocks pointer events on YT iframe so our overlay controls win */
.yt-shield {
  position: absolute; inset: 0; z-index: 2;
  background: transparent;
  cursor: pointer;
}

.empty-state {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px;
  background: radial-gradient(ellipse at center, rgba(40, 8, 32, 0.95), rgba(0, 0, 0, 0.98));
}
.empty-state.hidden { display: none; }
.empty-heart { font-size: 64px; color: var(--netflix-red); margin-bottom: 16px; filter: drop-shadow(0 0 22px rgba(229, 9, 20, 0.55)); animation: heartbeat 2s ease-in-out infinite; }
.empty-state h2 { font-family: 'Cormorant Garamond', serif; font-size: 34px; font-weight: 600; margin-bottom: 8px; background: linear-gradient(120deg, var(--accent-soft), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.empty-state p { color: var(--text-dim); font-size: 14px; max-width: 320px; }

.tap-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.78); backdrop-filter: blur(6px);
  cursor: pointer;
}
.tap-overlay.show { display: flex; }
.tap-inner { text-align: center; }
.tap-heart { font-size: 64px; color: var(--netflix-red); margin-bottom: 12px; }
.tap-overlay p { font-family: 'Cormorant Garamond', serif; font-size: 22px; color: var(--accent-soft); }

/* Netflix-style overlay UI */
.player-ui {
  position: absolute; inset: 0; z-index: 3;
  pointer-events: none;
  display: flex; flex-direction: column;
  opacity: 0;
  transition: opacity 0.25s ease;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.55) 0%, transparent 18%, transparent 65%, rgba(0,0,0,0.85) 100%);
}
.player-ui.visible { opacity: 1; }
.player-ui.visible > * { pointer-events: auto; }
.player-ui.locked-hidden { opacity: 0 !important; }

.ui-top {
  padding: 18px 22px;
  display: flex; justify-content: space-between; align-items: center;
}
.ui-title {
  color: white;
  font-weight: 600;
  font-size: 18px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
  max-width: 80%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ui-center {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 38px;
  pointer-events: none;
}
.player-ui.visible .ui-center { pointer-events: auto; }

.big-play, .big-skip {
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  cursor: pointer;
  color: white;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
  backdrop-filter: blur(6px);
}
.big-play { width: 88px; height: 88px; }
.big-skip { width: 64px; height: 64px; }
.big-play:hover, .big-skip:hover { background: rgba(229, 9, 20, 0.6); border-color: rgba(255,255,255,0.4); transform: scale(1.08); }
.big-play:active, .big-skip:active { transform: scale(0.96); }
.big-skip svg text { pointer-events: none; }

.ui-bottom {
  padding: 4px 20px 16px;
  display: flex; flex-direction: column; gap: 10px;
}

.progress-row { width: 100%; }
.progress-wrap { position: relative; padding: 14px 0; cursor: pointer; }
.progress-track {
  position: relative;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  transition: height 0.15s;
}
.progress-wrap:hover .progress-track { height: 8px; }
.progress-buffer {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: rgba(255,255,255,0.35);
  border-radius: 2px;
  width: 0%;
}
.progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--netflix-red);
  border-radius: 2px;
  width: 0%;
  box-shadow: 0 0 8px rgba(229, 9, 20, 0.6);
}
.progress-thumb {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--netflix-red);
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s;
  box-shadow: 0 0 12px rgba(229, 9, 20, 0.7);
}
.progress-wrap:hover .progress-thumb,
.progress-wrap.dragging .progress-thumb { transform: translate(-50%, -50%) scale(1); }
.progress-tooltip {
  position: absolute; bottom: 30px;
  background: rgba(0,0,0,0.92);
  color: white; font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
.progress-wrap.show-tooltip .progress-tooltip { opacity: 1; }

.controls-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.ctl-left, .ctl-right { display: flex; align-items: center; gap: 6px; }

.ctl-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  width: 38px; height: 38px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s;
}
.ctl-btn:hover { background: rgba(255,255,255,0.12); }
.ctl-btn:active { transform: scale(0.92); }

.volume-wrap {
  display: flex; align-items: center;
  overflow: hidden;
}
.volume-bar {
  width: 0;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  margin-left: 0;
  position: relative;
  cursor: pointer;
  transition: width 0.2s ease, margin-left 0.2s ease;
}
.volume-wrap:hover .volume-bar,
.volume-wrap.active .volume-bar { width: 80px; margin-left: 6px; }
.volume-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: white;
  border-radius: 2px;
  width: 100%;
}

.time-text {
  margin-left: 10px;
  color: white;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px;
}
.time-sep { opacity: 0.5; }

/* Quality menu */
.quality-wrap { position: relative; display: flex; align-items: center; }
.quality-btn {
  width: auto !important;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  letter-spacing: 0.5px;
}
.quality-btn::after {
  content: 'HD';
  position: absolute;
  top: 2px; right: 2px;
  font-size: 8px;
  background: var(--netflix-red);
  color: white;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.quality-btn.is-hd::after { opacity: 1; }

.quality-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  background: rgba(10, 0, 14, 0.96);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  display: none;
  z-index: 10;
}
.quality-menu.open { display: block; }
.quality-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.quality-menu-item:hover { background: rgba(229, 9, 20, 0.2); }
.quality-menu-item.active { background: rgba(229, 9, 20, 0.3); color: white; }
.quality-menu-item .check {
  color: var(--netflix-red); font-weight: 700; opacity: 0;
}
.quality-menu-item.active .check { opacity: 1; }
.quality-menu-empty {
  padding: 10px 12px; font-size: 12px; color: var(--text-dim); text-align: center;
}


/* Under-player row */
.under-player {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.reactions { display: flex; gap: 6px; flex-wrap: wrap; }
.react-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.2s;
}
.react-btn:hover { transform: scale(1.15); background: rgba(229, 9, 20, 0.25); }
.react-btn:active { transform: scale(0.95); }

.voice-bar {
  display: flex; align-items: center; gap: 8px;
}

.voice-btn {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500;
  transition: all 0.2s;
}
.voice-btn:hover { background: rgba(255,255,255,0.08); }
.voice-btn.on {
  background: linear-gradient(135deg, var(--netflix-red), #b00710);
  color: white;
  border-color: transparent;
  box-shadow: 0 0 14px rgba(229, 9, 20, 0.4);
}
.voice-btn.ptt-down {
  background: linear-gradient(135deg, var(--ok), #3aa872);
  color: white;
  box-shadow: 0 0 14px rgba(91, 217, 154, 0.5);
}

.voice-mode {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit; font-size: 12px;
  transition: background 0.2s;
}
.voice-mode:hover { background: rgba(255,255,255,0.08); color: var(--text); }

.voice-meter {
  flex: 0 0 100px;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ok), var(--gold), var(--netflix-red));
  border-radius: 3px;
  transition: width 0.08s ease-out;
}

/* Side panel */
.side-panel { display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.users-strip {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}
.user-row:hover { background: rgba(255,255,255,0.04); }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--netflix-red), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: white;
  flex-shrink: 0;
  position: relative;
}
.user-avatar.speaking { box-shadow: 0 0 0 3px var(--ok), 0 0 14px var(--ok); }
.user-name { font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name.me { color: var(--accent-soft); font-weight: 600; }
.user-mic {
  font-size: 13px;
  opacity: 0.5;
}
.user-mic.on { opacity: 1; color: var(--ok); }

.chat-wrap {
  display: flex; flex-direction: column;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  overflow: hidden;
  flex: 1;
  min-height: 320px;
}

@media (max-width: 980px) {
  .chat-wrap { min-height: 280px; max-height: 50vh; }
}

.chat-header {
  padding: 12px 16px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  color: var(--accent-soft);
  border-bottom: 1px solid var(--glass-border);
  background: rgba(229, 9, 20, 0.04);
}

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(229, 9, 20, 0.3) transparent;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(229, 9, 20, 0.3); border-radius: 3px; }

.msg {
  padding: 7px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
  word-wrap: break-word;
  animation: msgIn 0.25s ease-out;
  max-width: 92%;
}
.msg .from { font-size: 11px; color: var(--accent-soft); font-weight: 600; margin-bottom: 2px; display: block; }
.msg.mine { background: linear-gradient(135deg, rgba(229, 9, 20, 0.22), rgba(194, 24, 91, 0.18)); border-color: rgba(229, 9, 20, 0.35); align-self: flex-end; }
.msg.system { font-style: italic; color: var(--text-dim); text-align: center; background: transparent; border: none; font-size: 12px; max-width: 100%; align-self: center; }

@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.chat-input {
  display: flex; gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.4);
}
.chat-input input {
  flex: 1; min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 8px;
  outline: none;
  font-family: inherit; font-size: 14px;
}
.chat-input input:focus { border-color: var(--netflix-red); }
.btn-send {
  background: linear-gradient(135deg, var(--netflix-red), #b00710);
  color: white; border: none;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 13px;
}

/* Reactions floating layer */
.reaction-layer { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.floating-emoji {
  position: absolute; font-size: 36px;
  animation: floatUp 2.6s ease-out forwards;
  user-select: none;
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.6) rotate(0deg); opacity: 0; }
  15% { opacity: 1; transform: translateY(-30px) scale(1.2) rotate(-8deg); }
  100% { transform: translateY(-70vh) scale(0.9) rotate(12deg); opacity: 0; }
}

/* Name modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: linear-gradient(180deg, var(--bg-3), var(--bg-1));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 380px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
.modal h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  color: var(--accent-soft);
  margin-bottom: 4px;
}
.modal-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }
.modal input {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 8px;
  outline: none;
  font-family: inherit; font-size: 15px;
  margin-bottom: 16px;
}
.modal input:focus { border-color: var(--netflix-red); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

#remoteAudios { display: none; }

/* Mobile tweaks */
@media (max-width: 600px) {
  .topbar { padding: 8px 12px; }
  .brand-text { font-size: 20px; letter-spacing: 2px; }
  .name-chip { font-size: 12px; padding: 5px 10px; }
  .status { font-size: 11px; padding: 5px 8px; }
  .url-bar input { font-size: 14px; padding: 8px 10px; }
  .btn-primary { padding: 8px 14px; font-size: 13px; }
  .empty-state h2 { font-size: 26px; }
  .empty-heart { font-size: 52px; }
  .big-play { width: 64px; height: 64px; }
  .big-skip { width: 50px; height: 50px; }
  .ui-center { gap: 22px; }
  .big-play svg { width: 44px; height: 44px; }
  .big-skip svg { width: 30px; height: 30px; }
  .ui-bottom { padding: 4px 12px 10px; }
  .ctl-btn { width: 34px; height: 34px; }
  .time-text { font-size: 11px; margin-left: 4px; }
  .react-btn { width: 32px; height: 32px; font-size: 15px; }
  .voice-btn { padding: 6px 10px; font-size: 12px; }
  .voice-meter { flex: 1; max-width: 90px; }
  .volume-wrap .volume-bar { width: 0; }
  .volume-wrap:hover .volume-bar { width: 60px; }
}
