* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
    color: white;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    height: 10vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 20px;
    flex-shrink: 0;
}

header h1 {
    font-size: 2em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 0.9em;
    opacity: 0.8;
}

.section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none;
}

.input-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

input {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    flex: 1;
    max-width: 300px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
}

input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #4CAF50;
    color: white;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

#create-room-btn {
    background: #2196F3;
}

.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 2fr 1fr;
    gap: 15px;
    padding: 0 20px;
    min-height: 0;
    height: 70vh;
    overflow: visible;
}

.videos-layout {
    display: contents;
}

.local-video-container {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: visible;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.remote-videos-container {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    grid-auto-rows: minmax(120px, 1fr);
    align-content: start;
    overflow-y: auto;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 10px;
}

video {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background: #000;
    object-fit: cover;
}

#local-video {
    border: 3px solid #4CAF50;
}

/* Стили для удаленных видео перенесены в .remote-videos-container выше */

.remote-video {
    border: 3px solid #2196F3;
    width: 100%;
    height: 100%;
    min-height: 200px;
    object-fit: cover;
}

.remote-video-container {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    min-height: 200px;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 0;
    padding: 10px 0;
}

.control-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.control-btn.active {
    background: #4CAF50;
}

.control-btn.leave {
    background: #f44336;
}

.control-btn.leave:hover {
    background: #d32f2f;
}

.bottom-panel {
    height: 15vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
}

.room-info {
    text-align: left;
    opacity: 0.8;
    font-size: 0.9em;
}

.room-info p {
    margin: 5px 0;
}

.status {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    margin-top: 20px;
    font-weight: bold;
}

.status.success {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid #4CAF50;
}

.status.error {
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid #f44336;
}

.help-content {
    text-align: left;
}

.help-content p {
    margin: 10px 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-content p:last-child {
    border-bottom: none;
}

.help-content code {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 2.2em;
    }

    .videos-layout {
        grid-template-columns: 1fr;
        gap: 15px;
        min-height: 300px;
    }

    .remote-videos-container {
        grid-template-columns: 1fr;
        max-height: 300px;
        overflow-y: auto;
    }

    .input-group {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    input {
        max-width: 100%;
        margin-bottom: 10px;
        padding: 10px 15px;
        font-size: 16px;
    }

    button {
        padding: 10px 20px;
        font-size: 14px;
        min-width: 120px;
    }

    .controls {
        gap: 10px;
        margin: 15px 0;
    }

    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .section {
        padding: 20px 15px;
        margin-bottom: 15px;
    }

    .quality-controls {
        justify-content: center;
        gap: 8px;
        margin-bottom: 10px;
    }

    .quality-btn {
        padding: 6px 12px;
        font-size: 11px;
    }

    .room-info {
        text-align: center;
        font-size: 14px;
    }

    .stats-display {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }

    header h1 {
        font-size: 1.8em;
        margin-bottom: 5px;
    }

    header p {
        font-size: 1em;
    }

    .videos-layout {
        min-height: 250px;
        gap: 10px;
    }

    .remote-videos-container {
        grid-template-columns: 1fr;
        max-height: 200px;
        overflow-y: auto;
    }

    .section {
        padding: 15px 10px;
        margin-bottom: 10px;
        border-radius: 10px;
    }

    .controls {
        gap: 8px;
        margin: 10px 0;
    }

    .control-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .quality-controls {
        gap: 5px;
        margin-bottom: 8px;
    }

    .quality-btn {
        padding: 4px 8px;
        font-size: 10px;
    }

    .room-info {
        font-size: 12px;
    }

    .room-link-info p {
        font-size: 12px !important;
    }

    .room-link-info input {
        font-size: 10px !important;
        padding: 6px 8px !important;
    }

    .room-link-info button {
        font-size: 10px !important;
        padding: 6px 8px !important;
        min-width: auto;
    }

    .fullscreen-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
        bottom: 5px;
        right: 5px;
    }

    .video-overlay {
        bottom: 5px;
        left: 5px;
        right: 5px;
        padding: 8px;
    }

    .stats-display {
        font-size: 9px;
    }
}

/* === ADDITIONAL STYLES MOVED FROM HTML === */

/* === CONNECTION INDICATOR === */
.connection-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    background: rgba(0,0,0,0.7);
    border-radius: 15px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.connection-indicator.connecting { color: #FFC107; }
.connection-indicator.connected { color: #4CAF50; }
.connection-indicator.failed { color: #f44336; }

/* === VIDEO OVERLAY === */
.video-overlay {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.5);
    padding: 10px;
    border-radius: 8px;
}

/* === FULLSCREEN BUTTON === */
.fullscreen-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    border: none;
    color: white;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
}

.fullscreen-btn:hover {
    background: rgba(0,0,0,0.9);
    transform: scale(1.1);
}

/* === FULLSCREEN MODES === */
.local-video-container.fullscreen,
.remote-video-container.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: black !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.local-video-container.fullscreen video,
.remote-video-container.fullscreen video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block !important;
    margin: auto !important;
}

.local-video-container.fullscreen .video-overlay,
.local-video-container.fullscreen .connection-indicator,
.remote-video-container.fullscreen .connection-indicator {
    display: none !important;
}

.local-video-container.fullscreen .fullscreen-btn,
.remote-video-container.fullscreen .fullscreen-btn {
    display: block !important;
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 10000 !important;
}

/* === CHAT STYLES === */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-header {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.1);
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}

.chat-title {
    color: white;
    font-size: 13px;
    font-weight: bold;
    margin: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    color: white;
    font-size: 11px;
}

.chat-message {
    margin-bottom: 8px;
    padding: 6px 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    border-left: 2px solid #4CAF50;
}

.chat-message.own {
    background: rgba(76, 175, 80, 0.2);
    border-left-color: #4CAF50;
    margin-left: 15px;
}

.chat-message.system {
    background: rgba(255, 193, 7, 0.2);
    border-left-color: #FFC107;
    font-style: italic;
}

.message-sender {
    font-weight: bold;
    font-size: 11px;
    opacity: 0.8;
    margin-bottom: 3px;
}

.message-time {
    font-size: 10px;
    opacity: 0.6;
    float: right;
}

.chat-input-container {
    display: flex;
    padding: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
    gap: 8px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 15px;
    padding: 6px 12px;
    color: white;
    font-size: 11px;
    outline: none;
}

.chat-input::placeholder {
    color: rgba(255,255,255,0.6);
}

.chat-send {
    background: #4CAF50;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.chat-send:hover {
    background: #45a049;
}

.chat-send:disabled {
    background: rgba(255,255,255,0.2);
    cursor: not-allowed;
}

/* === UTILITY CLASSES === */
.video-container-flex {
    flex: 1;
    position: relative;
}

.participants-title {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    text-align: center;
}

.room-link-container {
    display: none;
    margin-top: 15px;
}

.room-link-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.room-link-input {
    flex: 1;
    padding: 10px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: white;
}

.room-link-copy-btn {
    padding: 10px 15px;
    background: #4CAF50;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
}

.room-link-description {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 5px;
}

.room-link-info {
    display: none;
}

.room-link-display {
    flex: 1;
    padding: 6px 10px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: white;
    font-size: 11px;
}

.room-link-display-btn {
    padding: 6px 10px;
    background: #4CAF50;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 11px;
}

/* === ANIMATIONS === */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* === STATUS STYLES === */
.status.positioned {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}


/* === MOBILE RESPONSIVE MEDIA QUERIES === */

/* Mobile adaptation for new layout */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 200px 160px;
        gap: 8px;
        padding: 0 10px;
        height: calc(100vh - 20vh);
        margin-bottom: 8px;
    }

    .bottom-panel {
        flex-direction: column;
        gap: 8px;
        height: auto;
        min-height: 18vh;
        padding: 8px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.9);
        backdrop-filter: blur(10px);
        z-index: 1000;
    }

    .controls {
        order: 1;
    }

    .room-info {
        order: 2;
        text-align: center;
        font-size: 0.8em;
    }

    .room-link-info {
        order: 3;
    }

    header h1 {
        font-size: 1.5em;
    }

    header p {
        font-size: 0.8em;
    }

    .section {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .main-content {
        grid-template-rows: 1fr 180px 140px;
        gap: 6px;
        padding: 0 8px;
        height: calc(100vh - 22vh);
        margin-bottom: 6px;
    }

    .section {
        padding: 8px;
    }

    .chat-messages {
        font-size: 11px;
        padding: 6px;
        max-height: 100px;
        overflow-y: auto;
    }

    .chat-message {
        padding: 3px 5px;
        margin-bottom: 4px;
        font-size: 10px;
    }

    .chat-input {
        font-size: 11px;
        padding: 6px 8px;
        height: 32px;
    }

    .chat-send {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .bottom-panel {
        padding: 6px;
        min-height: 20vh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(15px);
    }

    .control-btn {
        width: 42px;
        height: 42px;
        font-size: 16px;
        padding: 8px;
    }

    header h1 {
        font-size: 1.3em;
    }

    header p {
        font-size: 0.7em;
    }

    /* Ensure controls are visible above everything else */
    .controls {
        z-index: 1001;
        display: flex;
        justify-content: center;
        gap: 15px;
        margin-bottom: 8px;
    }

    /* Prevent container overflow */
    .container {
        overflow-y: auto;
        max-height: 100vh;
    }

    /* Improve video container sizing */
    .local-video-container video,
    .remote-videos-container video {
        max-height: 160px;
        object-fit: cover;
    }

    /* Chat container improvements */
    .chat-container {
        height: 130px;
        overflow: hidden;
    }
}
