/* ==========================================================================
   Zero-Cost P2P Omegle - OS Device Theme Driven (#470470 Deep Purple)
   ========================================================================== */

:root {
  color-scheme: dark light;
  
  --primary-purple: #470470;
  --primary-purple-hover: #5e0593;
  --primary-purple-light: #8b0fa8;
  --primary-glow: rgba(71, 4, 112, 0.45);
  
  --accent-magenta: #d946ef;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Dark Mode Default Values */
  --bg-dark: #0b020d;
  --bg-gradient-1: rgba(71, 4, 112, 0.35);
  --bg-gradient-2: rgba(217, 70, 239, 0.18);
  --bg-card: rgba(26, 3, 30, 0.85);
  --bg-card-hover: rgba(46, 5, 52, 0.9);
  --border-glass: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(217, 70, 239, 0.4);
  
  --text-main: #faf5ff;
  --text-muted: #e9d5ff;
  --text-dim: #a855f7;
  
  --input-bg: rgba(0, 0, 0, 0.45);
  --btn-ctrl-bg: rgba(255, 255, 255, 0.08);
  --shadow-color: rgba(0, 0, 0, 0.7);
  --video-bg: #040105;
  --overlay-bg: rgba(11, 2, 13, 0.92);
}

/* Native Browser / Device Dark Mode Sync */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-dark: #0b020d;
    --bg-gradient-1: rgba(71, 4, 112, 0.35);
    --bg-gradient-2: rgba(217, 70, 239, 0.18);
    --bg-card: rgba(26, 3, 30, 0.85);
    --bg-card-hover: rgba(46, 5, 52, 0.9);
    --border-glass: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(217, 70, 239, 0.4);
    
    --text-main: #faf5ff;
    --text-muted: #e9d5ff;
    --text-dim: #a855f7;
    
    --input-bg: rgba(0, 0, 0, 0.45);
    --btn-ctrl-bg: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.7);
    --video-bg: #040105;
    --overlay-bg: rgba(11, 2, 13, 0.92);
  }
}

/* Native Browser / Device Light Mode Sync */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg-dark: #fcf7ff;
    --bg-gradient-1: rgba(217, 70, 239, 0.12);
    --bg-gradient-2: rgba(71, 4, 112, 0.08);
    --bg-card: rgba(255, 255, 255, 0.92);
    --bg-card-hover: rgba(245, 230, 255, 0.98);
    --border-glass: rgba(71, 4, 112, 0.15);
    --border-highlight: rgba(71, 4, 112, 0.4);
    
    --text-main: #230227;
    --text-muted: #581c87;
    --text-dim: #7e22ce;
    
    --input-bg: rgba(71, 4, 112, 0.06);
    --btn-ctrl-bg: rgba(71, 4, 112, 0.08);
    --shadow-color: rgba(71, 4, 112, 0.15);
    --video-bg: #1a031e;
    --overlay-bg: rgba(252, 247, 255, 0.94);
  }
}

/* Explicit HTML Data Attribute Overrides */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg-dark: #0b020d;
  --bg-gradient-1: rgba(71, 4, 112, 0.35);
  --bg-gradient-2: rgba(217, 70, 239, 0.18);
  --bg-card: rgba(26, 3, 30, 0.85);
  --bg-card-hover: rgba(46, 5, 52, 0.9);
  --border-glass: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(217, 70, 239, 0.4);
  
  --text-main: #faf5ff;
  --text-muted: #e9d5ff;
  --text-dim: #a855f7;
  
  --input-bg: rgba(0, 0, 0, 0.45);
  --btn-ctrl-bg: rgba(255, 255, 255, 0.08);
  --shadow-color: rgba(0, 0, 0, 0.7);
  --video-bg: #040105;
  --overlay-bg: rgba(11, 2, 13, 0.92);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-dark: #fcf7ff;
  --bg-gradient-1: rgba(217, 70, 239, 0.12);
  --bg-gradient-2: rgba(71, 4, 112, 0.08);
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: rgba(245, 230, 255, 0.98);
  --border-glass: rgba(71, 4, 112, 0.15);
  --border-highlight: rgba(71, 4, 112, 0.4);
  
  --text-main: #230227;
  --text-muted: #581c87;
  --text-dim: #7e22ce;
  
  --input-bg: rgba(71, 4, 112, 0.06);
  --btn-ctrl-bg: rgba(71, 4, 112, 0.08);
  --shadow-color: rgba(71, 4, 112, 0.15);
  --video-bg: #1a031e;
  --overlay-bg: rgba(252, 247, 255, 0.94);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  position: fixed;
  touch-action: manipulation;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, var(--bg-gradient-1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, var(--bg-gradient-2) 0px, transparent 50%);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  padding: 16px;
  gap: 16px;
}

/* Header Component */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px 0 var(--shadow-color);
  transition: var(--transition);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-magenta));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 15px var(--primary-glow);
}


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

.theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--btn-ctrl-bg);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  background: var(--bg-card-hover);
  transform: scale(1.08);
  border-color: var(--border-highlight);
  color: var(--accent-magenta);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--btn-ctrl-bg);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.online-users-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fbbf24;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.online-users-badge.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.online-fire-icon {
  color: #f59e0b;
  animation: firePulse 1.5s infinite ease-in-out;
}

@keyframes firePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.8; }
}

.online-label {
  font-size: 0.725rem;
  font-weight: 500;
  color: rgba(251, 191, 36, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-dot.idle { background: var(--text-dim); }
.status-dot.searching { background: var(--accent-amber); box-shadow: 0 0 10px var(--accent-amber); animation: pulse 1.5s infinite; }
.status-dot.connected { background: var(--accent-emerald); box-shadow: 0 0 10px var(--accent-emerald); }
.status-dot.error { background: var(--accent-rose); box-shadow: 0 0 10px var(--accent-rose); }

/* Full-Screen App Container */
.app-container {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Main Stage Workspace */
.main-stage {
  flex: 1;
  display: flex;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Video Viewport (100vh Immersive Stage) */
.video-viewport {
  flex: 1;
  position: relative;
  background: #050508;
  border-radius: 0;
  border: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Top Viewport Actions Overlay (Status Badge & Theme Toggle) */
.viewport-top-bar {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

/* TV Channel / Watermark Logo Overlay & Online Badge Stack (Top-Left Video Container) */
.brand-watermark-container {
  position: absolute;
  top: 20px;
  left: 24px;
  z-index: 25;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.brand-watermark {
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(15, 15, 15, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 5px 12px;
  border-radius: 20px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.brand-watermark i {
  color: var(--accent-magenta);
}

#brand-title-text {
  transition: opacity 0.2s ease-in-out;
}

/* Media Permission Overlay on Local PIP */
.media-perm-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 20, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  gap: 8px;
  color: var(--accent-rose);
  font-size: 0.75rem;
  z-index: 10;
}

.media-perm-overlay i {
  font-size: 1.5rem;
}

.remote-video-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

video#remote {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Self Local PIP Video */
.local-pip-container {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 220px;
  height: 145px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border-highlight);
  box-shadow: 0 12px 30px var(--shadow-color);
  background: var(--bg-card);
  transition: var(--transition);
  z-index: 10;
}

.local-pip-container:hover {
  transform: scale(1.04);
  border-color: var(--accent-magenta);
  box-shadow: 0 0 25px var(--primary-glow);
}

.local-pip-container.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none !important;
  transform: scale(0.9);
}

video#local {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.pip-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border-radius: 4px;
  font-size: 0.7rem;
  color: #ffffff;
}

/* Radar Searching Screen Overlay */
.searching-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 5;
  transition: var(--transition);
}

.searching-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.radar-spinner {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radar-circle {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--primary-purple);
  opacity: 0;
  animation: radarPulse 2s cubic-bezier(0.1, 0.8, 0.3, 1) infinite;
}

.radar-circle:nth-child(2) { animation-delay: 0.6s; }
.radar-circle:nth-child(3) { animation-delay: 1.2s; }

.radar-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-magenta));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  z-index: 2;
  box-shadow: 0 0 25px var(--primary-glow);
}

.searching-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

.searching-subtext {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 340px;
  text-align: center;
  line-height: 1.5;
}

/* Firewall Notice Banner */
.firewall-banner {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 650px;
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.4);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  z-index: 20;
  box-shadow: 0 10px 30px var(--shadow-color);
  animation: slideDown 0.3s ease-out;
}

.firewall-banner.hidden { display: none; }

.firewall-icon {
  color: var(--accent-rose);
  font-size: 1.4rem;
  margin-top: 2px;
}

.firewall-content h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-rose);
  margin-bottom: 4px;
}

.firewall-content p {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Control Toolbar */
.control-toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: 40px;
  box-shadow: 0 16px 40px var(--shadow-color);
  z-index: 15;
  transition: var(--transition);
}

.control-toolbar.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none !important;
  transform: translateX(-50%) translateY(20px);
}

.btn-ctrl {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--btn-ctrl-bg);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.btn-ctrl:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.btn-ctrl.muted, .btn-ctrl.off {
  background: rgba(244, 63, 94, 0.2);
  border-color: var(--accent-rose);
  color: var(--accent-rose);
}

.btn-action-primary {
  padding: 0 24px;
  height: 48px;
  border-radius: 24px;
  border: none;
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-magenta));
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 0 20px var(--primary-glow);
  transition: var(--transition);
}

.btn-action-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px var(--primary-glow);
  opacity: 0.95;
}

.btn-action-secondary {
  padding: 0 20px;
  height: 48px;
  border-radius: 24px;
  border: 1px solid var(--border-glass);
  background: var(--btn-ctrl-bg);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-action-secondary:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--accent-rose);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-dark);
}

.unread-badge.hidden { display: none; }

/* P2P Text Chat Sidebar Floating Overlay (Viewport Fixed) */
.chat-drawer {
  position: fixed !important;
  top: 70px !important;
  right: 20px !important;
  bottom: 90px !important;
  width: 360px !important;
  max-width: calc(100vw - 32px) !important;
  background: rgba(15, 20, 28, 0.98) !important;
  backdrop-filter: blur(24px) !important;
  -webkit-backdrop-filter: blur(24px) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 16px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  z-index: 999999 !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9) !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.chat-drawer.closed {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.chat-drawer.open,
.chat-drawer:not(.closed) {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.chat-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 14, 20, 0.95);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff !important;
}

.chat-header span {
  color: #ffffff !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header span i {
  color: #10b981 !important;
  font-size: 1.05rem;
}

#btn-close-chat {
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.12) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: #ffffff !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem !important;
  transition: all 0.2s ease !important;
}

#btn-close-chat:hover {
  background: rgba(244, 63, 94, 0.25) !important;
  border-color: #f43f5e !important;
  color: #f43f5e !important;
  transform: scale(1.08) !important;
}

.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-msg.sent {
  align-self: flex-end;
  background: linear-gradient(135deg, #10b981, #059669) !important;
  color: #ffffff !important;
  font-weight: 500;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.chat-msg.received {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.12) !important;
  color: #f8fafc !important;
  border-bottom-left-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.chat-msg.system {
  align-self: center;
  background: rgba(245, 158, 11, 0.15) !important;
  color: #fbbf24 !important;
  border: 1px solid rgba(245, 158, 11, 0.3) !important;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 8px;
  text-align: center;
  max-width: 95%;
  padding: 8px 12px;
}

.chat-input-area {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 14, 20, 0.95);
  display: flex;
  gap: 8px;
}

.chat-input-area input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #ffffff !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  outline: none;
  caret-color: #10b981 !important;
}

.chat-input-area input::placeholder {
  color: rgba(255, 255, 255, 0.45) !important;
}

.chat-input-area input:focus {
  border-color: #10b981 !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25) !important;
  background: rgba(255, 255, 255, 0.12) !important;
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: #10b981 !important;
  color: #ffffff !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-send:hover {
  background: #059669 !important;
}

.btn-send:hover { background: var(--primary-purple-hover); }

/* Keyframe Animations */
@keyframes radarPulse {
  0% { transform: scale(0.3); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

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

@keyframes slideDown {
  from { transform: translate(-50%, -20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .app-container { padding: 12px; gap: 12px; }
  .chat-drawer { width: 300px; }
  .local-pip-container { width: 180px; height: 120px; bottom: 20px; right: 20px; }
}

@media (max-width: 768px) {
  .main-stage { flex-direction: column; }
  
  .chat-drawer {
    width: 100%;
    height: 280px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -10px 30px var(--shadow-color);
  }
  
  .local-pip-container {
    width: 130px;
    height: 90px;
    bottom: 90px;
    right: 16px;
  }
  
  .control-toolbar {
    bottom: 16px;
    padding: 8px 14px;
    gap: 8px;
    width: 92%;
    justify-content: center;
  }

  .btn-ctrl { width: 42px; height: 42px; font-size: 1rem; }
  .btn-action-primary, .btn-action-secondary { height: 42px; padding: 0 16px; font-size: 0.85rem; }
  .brand-logo { font-size: 1.05rem; }
  .brand-icon { width: 32px; height: 32px; font-size: 0.9rem; }
}

@media (max-width: 480px) {
  .app-header { padding: 10px 14px; }
  .status-text { display: none; }
  .status-badge { padding: 6px 10px; }
  
  .control-toolbar {
    padding: 6px 10px;
    gap: 6px;
    border-radius: 30px;
  }

  .btn-action-primary span, .btn-action-secondary span { display: none; }
  .btn-action-primary, .btn-action-secondary { padding: 0 16px; width: 42px; justify-content: center; border-radius: 50%; }
}

/* Terms of Service Consent Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 1;
  visibility: visible;
  transition: var(--transition);
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 50px var(--shadow-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  background: var(--btn-ctrl-bg);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  gap: 16px;
}

.modal-icon {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-magenta));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.35rem;
  box-shadow: 0 0 15px var(--primary-glow);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-notice {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--input-bg);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.modal-rules li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.45;
}

.rule-icon {
  color: var(--accent-magenta);
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.consent-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.checkbox-container {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  width: 20px;
  height: 20px;
  background: var(--input-bg);
  border: 1.5px solid var(--border-highlight);
  border-radius: 6px;
  flex-shrink: 0;
  position: relative;
  transition: var(--transition);
}

.checkbox-container:hover input ~ .checkmark {
  border-color: var(--accent-magenta);
}

.checkbox-container input:checked ~ .checkmark {
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-magenta));
  border-color: transparent;
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-glass);
  background: var(--btn-ctrl-bg);
  display: flex;
  justify-content: flex-end;
}

.btn-modal-agree {
  width: 100%;
  height: 46px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-magenta));
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 0 20px var(--primary-glow);
  transition: var(--transition);
}

.btn-modal-agree:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.5);
}

.btn-modal-agree:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px var(--primary-glow);
}

.btn-ctrl-warning:hover {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.modal-legal-contact {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.legal-email {
  color: var(--accent-magenta);
  font-weight: 600;
  text-decoration: none;
}

.legal-email:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Monetization Native Sponsored Video Ads Styling
   ========================================================================== */

/* ==========================================================================
   Authentic YouTube-Style Video Ad Experience
   ========================================================================== */

.yt-ad-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  pointer-events: none;
}

.yt-ad-overlay.hidden {
  display: none;
}

/* YouTube Bottom-Right Skip Button */
.yt-skip-btn {
  position: absolute;
  bottom: 14px;
  right: 0;
  z-index: 30;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-right: none;
  border-radius: 4px 0 0 4px;
  padding: 10px 16px;
  color: #fff;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: not-allowed;
  transition: all 0.2s ease-in-out;
  box-shadow: -4px 4px 15px rgba(0, 0, 0, 0.6);
}

.yt-skip-btn:not(:disabled) {
  background: rgba(15, 15, 15, 0.95);
  border-color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
}

.yt-skip-btn:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.95);
  color: #0f0f0f;
  transform: translateX(-4px);
}

.yt-skip-icon {
  font-size: 0.85rem;
}

/* Live In-Call Adsterra 4-Second Ultra-Fast Sponsored Banner Overlay (Bottom-Left) */
.incall-adsterra-banner-box {
  position: absolute;
  bottom: 84px;
  left: 16px;
  z-index: 18;
  min-width: 300px;
  min-height: 50px;
  max-width: calc(100vw - 32px);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 15, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  padding: 4px;
  opacity: 1;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.incall-adsterra-banner-box.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none !important;
}

.incall-adsterra-banner-box.fading-out {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none !important;
}

/* YouTube Bottom-Left Sponsor Info Card (Right above yellow progress line) */
.yt-sponsor-card {
  position: absolute;
  bottom: 14px;
  left: 16px;
  z-index: 25;
  pointer-events: auto;
  max-width: 360px;
  background: rgba(15, 15, 15, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.yt-sponsor-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.yt-ad-tag {
  background: #ffcc00;
  color: #000;
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}

.yt-ad-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.yt-ad-timer {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  font-family: monospace;
  margin-left: auto;
}

.yt-sponsor-details h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.yt-sponsor-details p {
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.3;
  margin-top: 2px;
}

.yt-sponsor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.yt-cta-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  background: #3ea6ff;
  color: #0f0f0f;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 18px;
  transition: all 0.2s ease;
}

.yt-cta-btn:hover {
  background: #65b8ff;
  transform: translateY(-1px);
}

.yt-ctrl-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 18px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.yt-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}

/* YouTube Iconic Yellow Video Progress Bar (Bottom Video Edge) */
.yt-ad-progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  z-index: 20;
}

.yt-ad-progress-bar {
  height: 100%;
  width: 0%;
  background: #ffcc00;
  box-shadow: 0 0 8px rgba(255, 204, 0, 0.8);
  transition: width 0.15s linear;
}

/* Mobile View Adjustments for Ad Overlay */
@media (max-width: 768px) {
  .yt-sponsor-card {
    bottom: 14px;
    left: 12px;
    max-width: calc(100vw - 165px);
    padding: 8px 10px;
  }

  .yt-sponsor-details h4 {
    font-size: 0.82rem;
  }

  .yt-sponsor-details p {
    font-size: 0.68rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .yt-skip-btn {
    bottom: 14px;
    right: 0;
    z-index: 30;
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  .brand-watermark-container {
    top: 14px;
    left: 14px;
    gap: 5px;
  }

  .brand-watermark {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  .online-users-badge {
    padding: 4px 10px;
    font-size: 0.72rem;
  }

  .viewport-top-bar {
    top: 14px;
    right: 14px;
    gap: 8px;
  }

  .status-badge {
    padding: 4px 10px;
    font-size: 0.72rem;
  }

  .control-toolbar {
    bottom: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    padding: 8px 12px;
    gap: 8px;
    max-width: calc(100vw - 24px);
  }

  .btn-ctrl {
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .local-pip-container {
    bottom: 74px;
    bottom: max(74px, calc(60px + env(safe-area-inset-bottom)));
    right: 14px;
    width: 140px;
    height: 95px;
  }
}

/* Tablet Resolution Adjustments (501px to 900px) */
@media (max-width: 900px) and (min-width: 501px) {
  .chat-drawer {
    position: fixed !important;
    top: 60px !important;
    right: 16px !important;
    bottom: 80px !important;
    width: 320px !important;
    max-width: calc(100vw - 32px) !important;
    z-index: 999999 !important;
    border-radius: 14px !important;
  }
}

/* Mobile Phone Resolution Adjustments (<= 500px) */
@media (max-width: 500px) {
  .chat-drawer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    z-index: 999999 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
}
