:root {
    --primary: #2563eb;
    --danger: #ef4444;
    --dark-bg: #000000;
    --glass: rgba(20, 20, 20, 0.85);
    --text: #ffffff;
    --off-state: #ef4444; 
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--dark-bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    user-select: none; 
    -webkit-tap-highlight-color: transparent;
}

.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.video-stage {
    flex: 1;
    position: relative;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: contain; 
}

.local-video-wrapper {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 110px;
    height: 150px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.3);
    background: #1a1a1a;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 50;
    cursor: grab;
    touch-action: none; 
}
.local-video-wrapper:active { cursor: grabbing; border-color: var(--primary); }

#localVideo { width: 100%; height: 100%; object-fit: cover; }

.drag-handle {
    position: absolute; top: 5px; left: 5px; opacity: 0.7; pointer-events: none;
}

.status-text {
    position: absolute; z-index: 0; color: #888; text-align: center; font-size: 14px;
}

.controls-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    display: flex;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 1;
    transform: translateY(0);
}

.controls-bar.fade-out {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none; 
}

.control-group {
    background: var(--glass);
    padding: 10px;
    border-radius: 24px;
    display: flex;
    gap: 12px;
    backdrop-filter: blur(8px);
    align-items: center;
}

.control-group.hidden { display: none; }

.control-group input {
    background: transparent; border: none; color: white;
    padding: 10px; width: 90px; text-align: center; outline: none; font-size: 16px;
}

button {
    border: none; border-radius: 12px;
    padding: 10px 20px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
button:active { transform: scale(0.95); }

.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; padding: 10px 15px; }

.btn-icon { 
    background: rgba(255,255,255,0.1); 
    color: white; 
    padding: 12px; 
    border-radius: 50%; 
    width: 48px; height: 48px;
}

.btn-off {
    background: var(--off-state) !important;
    position: relative;
}

.btn-off::after {
    content: '';
    position: absolute;
    width: 70%; height: 2px;
    background: white;
    top: 50%; left: 15%;
    transform: rotate(-45deg);
}

.chat-overlay {
    position: absolute;
    bottom: 90px; left: 20px;
    width: 300px; height: 40%; max-height: 400px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    display: flex; flex-direction: column;
    z-index: 90; backdrop-filter: blur(10px);
}
.chat-overlay.hidden { display: none; }

.chat-header {
    padding: 12px 15px; border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: space-between; background: rgba(255,255,255,0.05);
}
.btn-close { background: none; color: #aaa; padding: 0; font-size: 20px; width: auto; height: auto;}

.chat-messages { flex: 1; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.message { padding: 8px 12px; border-radius: 8px; font-size: 14px; max-width: 80%; word-wrap: break-word; }
.message.local { background: var(--primary); align-self: flex-end; }
.message.remote { background: #333; align-self: flex-start; color: #ddd; }

.chat-input-area { padding: 10px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; gap: 8px; }
.chat-input-area input { flex: 1; background: #222; border: 1px solid #444; padding: 8px 12px; border-radius: 20px; color: white; outline: none; }
.btn-send { background: var(--primary); color: white; border-radius: 50%; width: 35px; height: 35px; padding: 0; }

.mobile-only { display: none; }
@media (max-width: 768px) {
    .mobile-only { display: flex; }
    .chat-overlay { width: calc(100% - 40px); bottom: 90px; }
}