/* === ROOT VARIABLES === */
:root {
    --color-primary: #2C3E7A;
    --color-primary-dark: #1a2545;
    --color-primary-light: #3d5299;
    --color-accent-orange: #FF8C42;
    --color-accent-green: #7FD957;
    --color-danger: #E74C3C;
    --color-text-light: #E8EEF5;
    --color-text-muted: rgba(232, 238, 245, 0.7);
    --gradient-bg: linear-gradient(135deg, #1a2545 0%, #2C3E7A 50%, #3d5299 100%);
    --glass-bg: rgba(44, 62, 122, 0.15);
    --glass-border: rgba(232, 238, 245, 0.2);

    /* Viewport heights for mobile keyboard handling */
    --vh: 1vh;
    --dvh: 1dvh;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gradient-bg);
    height: 100vh;
    overflow: hidden;
    color: var(--color-text-light);
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    position: relative;
}

/* === ANIMATED NEURAL NETWORK BACKGROUND === */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255, 140, 66, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(127, 217, 87, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(232, 238, 245, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: backgroundPulse 15s ease-in-out infinite;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        repeating-radial-gradient(circle at 0% 0%, transparent 0%, transparent 40px, rgba(232, 238, 245, 0.03) 40px, rgba(232, 238, 245, 0.03) 41px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

@keyframes backgroundPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* === HEADER WITH LOGO === */
header {
    height: 10vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    width: 70px;
    height: 70px;
    filter: drop-shadow(0 4px 12px rgba(255, 140, 66, 0.3));
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo-text h1 {
    font-size: 2.2em;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    color: var(--color-text-light);
}

.logo-accent {
    color: var(--color-accent-orange);
}

.logo-text p {
    font-size: 0.75em;
    font-weight: 400;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Room Selection Screen */
#room-selection {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    max-width: 600px;
    margin: 0 auto;
}

#room-selection h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8em;
    font-weight: 600;
}

/* Room Selection Footer */
.room-footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    color: var(--color-text-muted);
    font-size: 0.9em;
}

.footer-tagline {
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--color-text-light);
    opacity: 0.8;
}

.footer-brand {
    margin: 0;
    font-size: 0.85em;
    opacity: 0.6;
    letter-spacing: 0.5px;
}

.section {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid var(--glass-border);
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.hidden {
    display: none !important;
}

.input-group {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: auto auto;
    gap: 12px;
    max-width: 500px;
    width: 100%;
}

.input-group input {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
}

.input-group #join-btn {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

.input-group #create-room-btn {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
}

input {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    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;
    width: 100%;
}

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

button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--color-accent-green);
    color: white;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 12px rgba(127, 217, 87, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(127, 217, 87, 0.4);
}

button:active {
    transform: translateY(0);
}

#create-room-btn {
    background: var(--color-accent-orange);
    box-shadow: 0 4px 12px rgba(255, 140, 66, 0.3);
}

#create-room-btn:hover {
    box-shadow: 0 6px 20px rgba(255, 140, 66, 0.4);
}

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

.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(200px, 1fr));
    grid-auto-rows: auto;
    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 var(--color-accent-green);
    box-shadow: 0 0 20px rgba(127, 217, 87, 0.3);
}

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

.remote-video {
    border: 3px solid var(--color-accent-orange);
    box-shadow: 0 0 15px rgba(255, 140, 66, 0.2);
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remote-video-container {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16/9;
    width: 100%;
}

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

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Уникальные стили для кнопки аудио */
.control-btn.audio {
    border-color: rgba(127, 217, 87, 0.3);
}

.control-btn.audio:hover {
    border-color: var(--color-accent-green);
    box-shadow: 0 6px 16px rgba(127, 217, 87, 0.4);
}

.control-btn.audio.active {
    background: var(--color-accent-green);
    border-color: var(--color-accent-green);
    box-shadow: 0 4px 16px rgba(127, 217, 87, 0.5);
}

/* Уникальные стили для кнопки видео */
.control-btn.video {
    border-color: rgba(255, 140, 66, 0.3);
}

.control-btn.video:hover {
    border-color: var(--color-accent-orange);
    box-shadow: 0 6px 16px rgba(255, 140, 66, 0.4);
}

.control-btn.video.active {
    background: var(--color-accent-orange);
    border-color: var(--color-accent-orange);
    box-shadow: 0 4px 16px rgba(255, 140, 66, 0.5);
}

/* Уникальные стили для кнопки демонстрации экрана */
.control-btn.screen {
    border-color: rgba(44, 62, 122, 0.5);
}

.control-btn.screen:hover {
    border-color: var(--color-primary-light);
    box-shadow: 0 6px 16px rgba(61, 82, 153, 0.4);
}

.control-btn.screen.active {
    background: var(--color-primary-light);
    border-color: var(--color-primary-light);
    box-shadow: 0 4px 16px rgba(61, 82, 153, 0.5);
}

/* Уникальные стили для кнопки завершения */
.control-btn.leave {
    background: rgba(231, 76, 60, 0.2);
    border-color: rgba(231, 76, 60, 0.5);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.control-btn.leave:hover {
    background: var(--color-danger);
    border-color: var(--color-danger);
    box-shadow: 0 6px 16px rgba(231, 76, 60, 0.5);
    transform: translateY(-2px) scale(1.05);
}

/* Legacy active state */
.control-btn.active {
    box-shadow: 0 4px 16px rgba(127, 217, 87, 0.5);
}

.bottom-panel {
    height: auto;
    min-height: 60px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    padding: 10px 20px;
    flex-shrink: 0;
    background: rgba(26, 37, 69, 0.7);
    backdrop-filter: blur(15px);
    border-top: 1px solid var(--glass-border);
}

.bottom-panel .controls {
    justify-self: center;
}

/* Compact room info - минималистичный стиль */
.room-info-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    opacity: 0.9;
    justify-self: start;
}

.info-item {
    cursor: help;
    transition: opacity 0.2s;
}

.info-item:hover {
    opacity: 1;
}

.room-id-hover {
    position: relative;
    cursor: pointer;
}

.room-id-full:empty + .room-id-placeholder {
    display: inline;
}

.room-id-full:not(:empty) {
    display: none;
}

.room-id-full:not(:empty) + .room-id-placeholder {
    display: inline;
}

.room-id-hover:hover .room-id-full:not(:empty) {
    display: inline;
}

.room-id-hover:hover .room-id-full:not(:empty) + .room-id-placeholder {
    display: none;
}

.info-divider {
    opacity: 0.4;
    user-select: none;
}

.user-name-compact {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.edit-name-btn-compact {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    padding: 0;
    opacity: 0.6;
    transition: all 0.2s;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    min-width: 24px;
    max-width: 24px;
    min-height: 24px;
    max-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.edit-name-btn-compact:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Copy room link button */
.copy-room-link-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    max-width: 40px;
    min-height: 40px;
    max-height: 40px;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.3s ease;
    justify-self: end;
    flex-shrink: 0;
    padding: 0;
}

.copy-room-link-btn:hover {
    background: rgba(127, 217, 87, 0.2);
    border-color: var(--color-accent-green);
    box-shadow: 0 4px 12px rgba(127, 217, 87, 0.3);
    transform: scale(1.1);
}

.copy-room-link-btn:active {
    transform: scale(0.95);
}

/* Global footer at bottom of page */
.global-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.75em;
    opacity: 0.5;
    padding: 8px;
    background: rgba(26, 37, 69, 0.5);
    backdrop-filter: blur(10px);
    z-index: 100;
    transition: opacity 0.3s;
}

.global-footer:hover {
    opacity: 0.8;
}

.global-footer p {
    margin: 0;
}

/* Legacy support */
.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(127, 217, 87, 0.2);
    border: 1px solid var(--color-accent-green);
    box-shadow: 0 4px 12px rgba(127, 217, 87, 0.3);
}

.status.error {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid var(--color-danger);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.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;
    }

    .logo-icon {
        width: 40px;
        height: 40px;
    }

    .logo-text h1 {
        font-size: 1.8em;
    }

    .logo-text p {
        font-size: 0.65em;
    }

    .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;
    }

    /* Compact info for mobile */
    .room-info-compact {
        font-size: 0.75em;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .bottom-panel {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 8px;
        padding: 8px 10px;
    }

    .room-info-compact,
    .controls,
    .copy-room-link-btn {
        justify-self: center;
        text-align: center;
    }

    .copy-room-link-btn {
        grid-row: 3;
    }

    .global-footer {
        font-size: 0.7em;
        padding: 6px;
    }

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

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

    .logo-icon {
        width: 35px;
        height: 35px;
    }

    .logo-container {
        gap: 10px;
    }

    .logo-text h1 {
        font-size: 1.5em;
    }

    .logo-text p {
        font-size: 0.6em;
    }

    .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: var(--color-accent-orange); }
.connection-indicator.connected { color: var(--color-accent-green); }
.connection-indicator.failed { color: var(--color-danger); }

/* === 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;
    max-height: 100%;
}

.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;
    height: 250px;
    overflow-x: hidden;
    width: 100%;
}

.chat-message {
    margin-bottom: 8px;
    padding: 6px 8px;
    background: var(--glass-bg);
    border-radius: 6px;
    border-left: 2px solid var(--color-accent-green);
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.chat-message.own {
    background: rgba(127, 217, 87, 0.15);
    border-left-color: var(--color-accent-green);
    margin-left: 15px;
}

.chat-message.system {
    background: rgba(255, 140, 66, 0.15);
    border-left-color: var(--color-accent-orange);
    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: var(--color-accent-green);
    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: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(127, 217, 87, 0.3);
}

.chat-send:hover {
    background: #6ec945;
    box-shadow: 0 4px 12px rgba(127, 217, 87, 0.5);
    transform: scale(1.05);
}

.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: 20px;
    width: 100%;
    max-width: 500px;
}

.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: var(--color-accent-green);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(127, 217, 87, 0.3);
}

.room-link-copy-btn:hover {
    background: #6ec945;
    box-shadow: 0 4px 12px rgba(127, 217, 87, 0.5);
    transform: translateY(-2px);
}

.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: var(--color-accent-green);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(127, 217, 87, 0.3);
}

.room-link-display-btn:hover {
    background: #6ec945;
    box-shadow: 0 3px 10px rgba(127, 217, 87, 0.5);
}

/* === 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 MINIMALIST INTERFACE === */

/* Mobile Video Modal (Fullscreen Active Speaker) */
.mobile-video-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-modal-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-speaker-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 14px;
    z-index: 10001;
}

.speaker-icon {
    font-size: 16px;
    animation: pulse 2s infinite;
}

.speaker-name {
    font-weight: 600;
}

.mobile-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: all 0.3s ease;
    padding: 0;
}

.mobile-modal-close:hover {
    background: rgba(0, 0, 0, 0.95);
    transform: scale(1.1);
}

/* Notification state for new messages */
.mobile-modal-close.has-notification {
    background: var(--color-accent-orange);
    animation: pulseNotification 2s infinite;
    box-shadow: 0 0 20px rgba(255, 140, 66, 0.8);
}

.mobile-modal-close.has-notification:hover {
    background: #ff9d5c;
    transform: scale(1.15);
}

@keyframes pulseNotification {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 140, 66, 0.8);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 140, 66, 1);
    }
}

/* Thumbnails Strip (horizontal scrolling participant previews) */
.thumbnails-strip {
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    height: 70px;
    display: flex;
    gap: 10px;
    padding: 0 15px;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 10001;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.thumbnails-strip::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

.thumbnail-item {
    position: relative;
    width: 80px;
    height: 60px;
    min-width: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    background: rgba(0, 0, 0, 0.5);
}

.thumbnail-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-item.active {
    border-color: var(--color-accent-green);
    box-shadow: 0 0 12px rgba(127, 217, 87, 0.8);
}

.thumbnail-item.self {
    border-color: var(--color-accent-orange);
}

.thumbnail-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    color: white;
    font-size: 9px;
    padding: 3px 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile Chat Background Layer */
.mobile-chat-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Dynamic viewport height - учитывает виртуальную клавиатуру */
    background: var(--gradient-bg);
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: pan-y;
    will-change: height;
}

.mobile-chat-header {
    padding: 15px 20px;
    background: rgba(26, 37, 69, 0.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.mobile-chat-header h3 {
    color: white;
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
}

/* Compact Participants Card (shown in chat mode) */
.compact-participants-card {
    margin: 15px 20px;
    padding: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.compact-participants-card:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--color-accent-green);
    box-shadow: 0 4px 12px rgba(127, 217, 87, 0.3);
    transform: translateY(-2px);
}

.compact-card-previews {
    display: flex;
    gap: 6px;
}

.compact-preview {
    width: 50px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.5);
}

.compact-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.compact-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.compact-card-count {
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.compact-card-hint {
    color: var(--color-text-muted);
    font-size: 11px;
}

.mobile-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 20px 180px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    width: 100%;
}

.mobile-chat-input-container {
    display: flex;
    padding: 15px 20px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    gap: 10px;
    background: rgba(26, 37, 69, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10001;
    transform: translateZ(0); /* Аппаратное ускорение для плавности */
}

.mobile-chat-input {
    flex: 1;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 12px 16px;
    color: white;
    font-size: 14px;
    outline: none;
}

.mobile-chat-input::placeholder {
    color: var(--color-text-muted);
}

.mobile-chat-send {
    background: var(--color-accent-green);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(127, 217, 87, 0.4);
    padding: 0;
}

.mobile-chat-send:hover {
    background: #6ec945;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(127, 217, 87, 0.6);
}

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

@media (max-width: 768px) {
    /* Keep body normal - only fix when in chat with keyboard */
    body {
        background: var(--gradient-bg);
    }

    /* Fix body only when in call (chat is open) */
    body.in-call {
        position: fixed;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        overflow: hidden;
    }

    /* Container should not hide background */
    .container {
        background: transparent;
        min-height: 100vh;
    }

    /* Room selection mobile styles */
    #room-selection {
        padding: 30px 15px;
        max-width: 90%;
        margin: 20px auto;
        background: var(--glass-bg);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border: 1px solid var(--glass-border);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        border-radius: 20px;
    }

    /* Switch to vertical layout on mobile */
    .input-group {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 10px;
    }

    .input-group input {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
    }

    .input-group #join-btn {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
    }

    .input-group #create-room-btn {
        grid-column: 1 / 2;
        grid-row: 3 / 4;
    }

    #room-selection h2 {
        font-size: 1.5em;
        margin-bottom: 25px;
    }

    /* Footer mobile styles */
    .room-footer {
        padding: 15px;
        margin-top: 15px;
        font-size: 0.85em;
    }

    .footer-tagline {
        font-size: 0.9em;
    }

    .footer-brand {
        font-size: 0.8em;
    }

    /* Hide desktop-only elements on mobile */
    .desktop-only {
        display: none !important;
    }

    /* Section styling for mobile */
    .section {
        background: var(--glass-bg);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
    }

    /* Hide header during call */
    #call-interface:not(.hidden) ~ header,
    body:has(#call-interface:not(.hidden)) header {
        display: none !important;
    }

    /* Hide desktop sections on mobile */
    .main-content .section {
        display: none !important;
    }

    /* Hide main-content grid on mobile */
    .main-content {
        display: none !important;
    }

    /* Hide desktop video containers and chat on mobile */
    #local-video-container,
    #remote-videos,
    #chat-container,
    .local-video-container,
    .remote-videos-container,
    .chat-container {
        display: none !important;
    }

    /* Hide room selection and footer when in call */
    #call-interface:not(.hidden) ~ #room-selection,
    #call-interface:not(.hidden) ~ .room-footer {
        display: none !important;
    }

    /* Show mobile chat layer and video modal */
    .mobile-chat-layer:not(.hidden),
    .mobile-video-modal:not(.hidden) {
        display: flex !important;
    }

    /* Bottom Panel: Floating controls over video */
    .bottom-panel {
        position: fixed;
        bottom: calc(80px + env(safe-area-inset-bottom));
        left: 50%;
        transform: translateX(-50%) translateZ(0);
        width: auto;
        height: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px 20px;
        background: transparent;
        backdrop-filter: none;
        border-radius: 30px;
        border: none;
        box-shadow: none;
        z-index: 10003;
        transition: bottom 0.3s ease;
    }

    /* Hide room info on mobile */
    .room-info,
    .room-link-info {
        display: none !important;
    }

    /* Controls: centered, compact */
    .controls {
        display: flex;
        gap: 15px;
        justify-content: center;
        align-items: center;
        margin: 0;
        padding: 0;
    }

    /* Control buttons: 50px size, floating style */
    .control-btn {
        width: 50px;
        height: 50px;
        min-width: 50px;
        min-height: 50px;
        font-size: 20px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
    }

    .control-btn:active {
        transform: scale(0.9);
    }

    header h1 {
        font-size: 1.5em;
    }

    header p {
        font-size: 0.8em;
    }

    .section {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    /* Room selection ultra mobile */
    #room-selection {
        padding: 20px 10px;
    }

    #room-selection h2 {
        font-size: 1.3em;
        margin-bottom: 20px;
    }

    /* Footer ultra mobile styles */
    .room-footer {
        padding: 12px;
        margin-top: 12px;
        font-size: 0.75em;
    }

    .footer-tagline {
        font-size: 0.85em;
        margin-bottom: 6px;
    }

    .footer-brand {
        font-size: 0.75em;
    }

    /* Ultra mobile adjustments */
    .mobile-menu-btn {
        top: 15px !important;
        right: 15px !important;
        width: 45px !important;
        height: 45px !important;
    }

    .mobile-slide-panel {
        width: 95% !important;
    }

    .slide-panel-header {
        padding: 15px !important;
    }

    .slide-panel-header h3 {
        font-size: 1.1em !important;
    }

    .mobile-participants-section,
    .mobile-chat-section h4 {
        padding: 15px !important;
    }

    .mobile-chat-messages {
        padding: 0 15px !important;
        min-height: 150px !important;
    }

    .mobile-chat-input-container {
        padding: 12px 15px 15px 15px !important;
    }

    .mobile-chat-input {
        padding: 10px 14px !important;
        font-size: 13px !important;
    }

    .mobile-chat-send {
        width: 40px !important;
        height: 40px !important;
        font-size: 14px !important;
    }

    .mobile-remote-videos {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)) !important;
        gap: 8px !important;
    }

    /* Full screen video on ultra mobile */
    .main-content {
        height: calc(100vh - 8vh - 12vh) !important;
    }

    .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 stays floating on ultra mobile */
    .bottom-panel {
        padding: 10px 15px;
        bottom: 95px;
    }

    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    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;
    }
}

/* === ADAPTIVE GRID FOR PARTICIPANTS === */

/* Адаптивная сетка в зависимости от количества участников */
.remote-videos-container.participants-1 {
    grid-template-columns: 1fr;
}

.remote-videos-container.participants-2 {
    grid-template-columns: repeat(2, 1fr);
}

.remote-videos-container.participants-3 {
    grid-template-columns: repeat(2, 1fr);
}

.remote-videos-container.participants-4 {
    grid-template-columns: repeat(2, 1fr);
}

.remote-videos-container.participants-5,
.remote-videos-container.participants-6 {
    grid-template-columns: repeat(3, 1fr);
}

.remote-videos-container.participants-7,
.remote-videos-container.participants-8,
.remote-videos-container.participants-9 {
    grid-template-columns: repeat(3, 1fr);
}

.remote-videos-container.participants-10,
.remote-videos-container.participants-11,
.remote-videos-container.participants-12 {
    grid-template-columns: repeat(4, 1fr);
}

/* Для большого количества участников */
.remote-videos-container.many-participants {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* Особые случаи для 3 участников - лучше выглядит в 2 столбца */
.remote-videos-container.participants-3 .remote-video-container:nth-child(3) {
    grid-column: 1 / -1;
    max-width: 300px;
    margin: 0 auto;
}

/* Мобильные адаптации для адаптивной сетки */
@media (max-width: 768px) {
    .remote-videos-container.participants-2,
    .remote-videos-container.participants-3,
    .remote-videos-container.participants-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .remote-videos-container.participants-5,
    .remote-videos-container.participants-6 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .remote-videos-container.participants-7,
    .remote-videos-container.participants-8,
    .remote-videos-container.participants-9 {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* На мобильных 3 участника лучше в 1 столбец */
    .remote-videos-container.participants-3 .remote-video-container:nth-child(3) {
        grid-column: auto !important;
        max-width: none !important;
    }
}

@media (max-width: 480px) {
    /* На маленьких экранах максимум 2 столбца */
    .remote-videos-container.participants-3,
    .remote-videos-container.participants-4,
    .remote-videos-container.participants-5,
    .remote-videos-container.participants-6,
    .remote-videos-container.participants-7,
    .remote-videos-container.participants-8,
    .remote-videos-container.participants-9 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* === NAME EDITING === */
.user-name-display {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
}

.edit-name-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    padding: 2px 5px;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.1s;
}

.edit-name-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.edit-name-btn:active {
    transform: scale(0.95);
}

/* === MODAL === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 25px;
    min-width: 300px;
    max-width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: var(--color-text-light);
    font-size: 1.2em;
}

.modal-content input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--color-text-light);
    font-size: 1em;
    outline: none;
    transition: border-color 0.2s;
}

.modal-content input:focus {
    border-color: var(--color-accent-orange);
}

.modal-content input::placeholder {
    color: var(--color-text-muted);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-light);
}

.modal-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.modal-btn:active {
    transform: translateY(0);
}

.modal-btn.primary {
    background: var(--color-accent-orange);
    color: white;
}

.modal-btn.primary:hover {
    background: #ff9d5c;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Name label on video */
.video-name-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    color: white;
    z-index: 2;
    pointer-events: none;
}

.local-video-container .video-name-label {
    background: rgba(44, 62, 122, 0.8);
}

