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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 20px;
    color: white;
    flex-shrink: 0;
}

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

#video-title {
    font-size: 1.1em;
    opacity: 0.9;
    padding: 0 10px;
}

.main-content {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 20px;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    flex: 1;
    min-height: 0;
}

.video-section {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.video-container {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

#video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    cursor: pointer;
}

/* Кастомные элементы управления */
.custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 10px 15px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.video-container:hover .custom-controls,
.video-container:focus-within .custom-controls {
    opacity: 1;
}

.controls-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.controls-bottom {
    display: flex;
    flex-direction: column;
}

.progress-container {
    position: relative;
    margin-bottom: 8px;
    height: 20px;
    display: flex;
    align-items: center;
}

.progress-bar {
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    overflow: hidden;
    flex: 1;
}

.progress-fill {
    height: 100%;
    background: #667eea;
    width: 0%;
    transition: width 0.1s;
}

.progress-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    font-size: 14px;
}

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

.big-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
}

.time-display {
    color: white;
    font-size: 0.85em;
    font-family: monospace;
    margin: 0 8px;
    white-space: nowrap;
}

.volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 100px;
}

.volume-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
}

/* Сообщение о синхронизации */
.sync-message {
    background: #4caf50;
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    margin-bottom: 12px;
    opacity: 0;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.sync-message.show {
    opacity: 1;
}

.sync-message i {
    font-size: 0.9em;
}

.user-info {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    font-size: 0.95em;
}

/* Подсказка для iOS */
.ios-fullscreen-hint {
    display: none;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8em;
    text-align: center;
    margin-top: 5px;
    flex-shrink: 0;
}

/* iOS Safari - показываем подсказку */
@supports (-webkit-touch-callout: none) {
    .ios-fullscreen-hint {
        display: block;
    }
}

.chat-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.chat-header {
    background: #667eea;
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1em;
}

.online-count {
    background: rgba(255,255,255,0.2);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    min-height: 0;
}

.chat-message {
    margin-bottom: 12px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-size: 0.95em;
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    align-items: center;
}

.user-name {
    font-weight: bold;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
}

.message-time {
    font-size: 0.75em;
    color: #666;
}

.message-text {
    line-height: 1.4;
    font-size: 0.95em;
}

.chat-input-container {
    display: flex;
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
    flex-shrink: 0;
}

#comment-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    min-width: 0;
}

#comment-input:focus {
    border-color: #667eea;
}

#comment-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

#send-button {
    width: 44px;
    height: 44px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#send-button:hover:not(:disabled) {
    background: #5a6fd8;
}

#send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Модальное окно */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-content h3 {
    margin-bottom: 12px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.3em;
}

.modal-content p {
    margin-bottom: 15px;
    color: #666;
}

#name-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

#name-input:focus {
    border-color: #667eea;
}

.modal-content button {
    padding: 12px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

.modal-content button:hover {
    background: #5a6fd8;
}

/* Полноэкранный режим */
.video-container:fullscreen {
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0;
    padding: 0;
    margin: 0;
}

.video-container:fullscreen #video-player {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
}

.video-container:fullscreen .custom-controls {
    padding: 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
}

/* Адаптивность */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .chat-section {
        height: 350px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .main-content {
        padding: 15px;
        gap: 12px;
    }
    
    .control-buttons {
        gap: 8px;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .big-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
    
    .time-display {
        font-size: 0.8em;
        margin: 0 6px;
    }
    
    .volume-container {
        max-width: 70px;
    }
    
    .chat-header h3 {
        font-size: 1em;
    }
    
    .chat-message {
        padding: 8px;
        font-size: 0.9em;
    }
    
    #send-button {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.6em;
    }
    
    .video-container {
        min-height: 250px;
    }
    
    .control-buttons {
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .time-display {
        order: 3;
        flex: 0 0 100%;
        text-align: center;
        margin-top: 5px;
    }
    
    .volume-container {
        max-width: 60px;
    }
}

/* iOS специфичные стили */
@supports (-webkit-touch-callout: none) {
    .video-container {
        -webkit-overflow-scrolling: touch;
    }
    
    .video-container:fullscreen {
        -webkit-overflow-scrolling: auto;
    }
    
    #video-player {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* Улучшаем доступность на iOS */
    .control-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    #comment-input {
        font-size: 16px; /* Предотвращает зум на iOS */
    }
    
    .ios-fullscreen-hint {
        font-size: 0.75em;
        padding: 6px 10px;
    }
}
