html { overflow-x: hidden; overflow-y: auto; }
body { font-family: Arial, sans-serif; margin: 0; padding: 10px; background: #f0f0f0; overflow-x: hidden; overflow-y: auto; }
.container { max-width: 100%; margin: 0 auto; overflow: hidden; }
.content-wrapper { display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.video-section { flex: 1; min-width: 0; overflow: hidden; }
.video-grid { display: flex; flex-direction: row; gap: 5px; margin-bottom: 0; flex-wrap: wrap; 
    overflow: hidden; width: 100%; height: calc(100vh - 100px); align-content: flex-start;
}
.video-box { background: transparent; padding: 0; border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-height: 100%; overflow: hidden;
    flex: 1; position: relative; box-sizing: border-box;
    display: flex; flex-direction: column;
}
.video-box h3 { margin: 0; color: white; position: absolute; top: 10px; left: 10px; z-index: 10;
    background: rgba(0, 0, 0, 0.5); padding: 7px 11px; border-radius: 4px;
    font-size: 14px; text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
canvas { border-radius: 8px; display: block; object-fit: cover; width: 100%; flex: 1; min-height: 0; margin: 0; box-sizing: border-box; }
.controls { background: white; padding: 4px 10px 4px; border-radius: 8px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.1); margin-bottom: 10px; 
}
.controls-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.input-group { display: flex; align-items: center; gap: 5px; margin: 0 5px 0 0; }
.input-group label { display: inline-block; width: auto; font-weight: bold; white-space: nowrap; }
button { padding: 10px 15px; margin: 0; font-size: 14px; cursor: pointer; background: #5d81cf;
    color: white; border: none; border-radius: 4px; transition: background 0.3s;
}
button:hover { background: #4a53a7; }
button:disabled { background: #cccccc; cursor: not-allowed; }
#connectionBtn { background: #4CAF50; }
#connectionBtn:hover { background: #45a049; }
#connectionBtn:disabled { background: #cccccc; cursor: not-allowed; }
#connectionBtn.disconnect { background: #f44336; }
#connectionBtn.disconnect:hover { background: #da190b; }
#shareBtn.sharing { background: #f44336; }
#shareBtn.sharing:hover { background: #da190b; }
input[type="text"] { padding: 8px; margin: 0; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }
.chat-container { background: white; padding: 10px 20px 20px; border-radius: 8px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.1); margin-top: 0; margin-bottom: 0; position: relative; 
    width: 100%; box-sizing: border-box; 
}
.chat-container h2 { margin-top: 5px; margin-bottom: 10px; }
.resize-handle { position: absolute; left: 0; top: 0; bottom: 0; width: 40px; cursor: ew-resize; z-index: 100; background: transparent; }
.resize-handle::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: transparent; }
.resize-handle:hover::before { background: rgba(66, 133, 244, 0.3); }
.resize-handle.resizing::before { background: rgba(66, 133, 244, 0.5); }
.chat-messages { height: 300px; overflow-y: auto; background: #f9f9f9; padding: 15px; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 15px; }
.chat-message { margin-bottom: 10px; padding: 8px 12px; border-radius: 4px; }
.chat-message.own { background: #e3f2fd; text-align: right; }
.chat-message.remote { background: #f5f5f5; text-align: left; }
.chat-message .sender { font-weight: bold; font-size: 12px; color: #666; margin-bottom: 3px; }
.chat-message .text { font-size: 14px; color: #333; }
.chat-message .timestamp { font-size: 11px; color: #999; margin-top: 3px; }
.chat-input-group { display: flex; gap: 10px; }
.chat-input-group input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }
.chat-input-group button { padding: 10px 20px; min-width: 80px; }

/* Local video overlay styles */
.local-video-overlay {
    position: absolute !important;
    bottom: 20px !important;
    left: 20px !important;
    width: 20% !important;
    height: 20% !important;
    min-width: 200px !important;
    max-width: 20% !important;
    max-height: 20% !important;
    z-index: 1000 !important;
    border: 2px solid #5d81cf !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
    flex: none !important;
}

.local-video-overlay canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Overlay styles */
.overlay { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4); }
.overlay.active { display: block; }
.overlay-content { background-color: #fefefe; margin: 10% auto; padding: 20px; border: 1px solid #888; 
    border-radius: 8px; width: 80%; max-width: 600px; position: relative; box-shadow: 0 4px 16px rgba(0,0,0,0.2); 
}
.overlay-close { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; line-height: 20px; }
.overlay-close:hover, .overlay-close:focus { color: #000; text-decoration: none; }
.overlay-row { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.overlay-row label { min-width: 120px; font-weight: bold; }
.overlay-row select { flex: 1; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }

/* Wide screen layout - chat on the right */
@media (min-aspect-ratio: 1/1) {
    html { overflow: hidden; height: 100%; }
    body { overflow: hidden; height: 100%; box-sizing: border-box; }
    .container { height: 100%; display: flex; flex-direction: column; }
    .content-wrapper { flex-direction: row; flex: 1; min-height: 0; }
    .video-section { flex: 1; height: 100%; min-height: 0; }
    .chat-container { flex: 0 0 350px; margin-bottom: 0; height: 100%; display: flex; flex-direction: column; }
    .chat-messages { flex: 1; height: auto; }
    .video-grid { margin-bottom: 0; height: 100%; align-content: stretch; }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    body { background: #1a1a1a; color: #e0e0e0; }
    
    .controls { background: #2d2d2d; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
    .chat-container { background: #2d2d2d; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
    .chat-container h2 { color: #e0e0e0; }
    
    .chat-messages { background: #1f1f1f; border-color: #444; }
    .chat-message.own { background: #1a3a52; }
    .chat-message.remote { background: #2a2a2a; }
    .chat-message .sender { color: #aaa; }
    .chat-message .text { color: #e0e0e0; }
    .chat-message .timestamp { color: #888; }
    
    input[type="text"], .chat-input-group input, .overlay-row select { background: #1f1f1f; border-color: #444; color: #e0e0e0; }
    input[type="text"]:disabled { background: #2a2a2a; color: #666; }
    button:disabled, #connectionBtn:disabled { background: #3a3a3a; color: #666; }
    
    .overlay { background-color: rgba(0,0,0,0.7); }
    .overlay-content { background-color: #2d2d2d; border-color: #444; color: #e0e0e0; }
    .overlay-close { color: #aaa; }
    .overlay-close:hover, .overlay-close:focus { color: #fff; }
    
    .video-box { box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
}