/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000;
    color: #fff;
    overflow-x: hidden;
    height: 100vh;
    width: 100vw;
    /* Mobile viewport fix */
    margin: 0;
    padding: 0;
}

.live-container {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
    overflow-y: auto;
}

/* Header Section */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.streamer-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, #ff6b6b, #ffa500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.streamer-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.streamer-name {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.live-status {
    font-size: 12px;
    color: #ff4757;
    font-weight: 600;
    background: rgba(255, 71, 87, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    width: fit-content;
}

.likes-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 20px;
}

.likes-count i {
    color: #ff4757;
}

/* Video Section */
.video-section {
    position: relative !important;
    height: 35vh;
    min-height: 250px;
    background: #000;
    overflow: visible;
    transition: all 0.3s ease;
}

/* Pseudo Fullscreen Mode */
.video-section.pseudo-fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: #000;
    /* Ensure full screen coverage */
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    transition: all 0.3s ease;
}

.video-wrapper.pseudo-fullscreen {
    width: 100vw;
    height: 100vh;
}

.video-wrapper.landscape-video {
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-wrapper.landscape-video #liveVideo {
    width: 100vh;
    height: 100vw;
    transform: rotate(90deg);
    transform-origin: center center;
}

/* Fullscreen Subtitles - Bilibili Style */
.fullscreen-subtitles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 30;
    display: none;
    overflow: hidden;
}

.video-section.pseudo-fullscreen .fullscreen-subtitles {
    display: block;
}

.subtitle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Adjust subtitle container for landscape video */
.video-wrapper.landscape-video .subtitle-container {
    width: 100vh;
    height: 100vw;
    transform: rotate(90deg);
    transform-origin: center center;
}

.subtitle-item {
    position: absolute;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 14px;
    white-space: nowrap;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: danmakuFloat 8s linear;
    opacity: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100vh);
}

/* Rotate subtitles for landscape video */
.video-wrapper.landscape-video .subtitle-item {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%) rotate(90deg);
    transform-origin: center center;
}

.subtitle-item.show {
    opacity: 1;
}

.subtitle-user {
    font-weight: 600;
    color: #ff6b6b;
    margin-right: 6px;
}

.subtitle-text {
    color: #fff;
}

/* Bilibili style danmaku animation - floating from bottom to top */
@keyframes danmakuFloat {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(100vh);
    }
    2% {
        opacity: 1;
        transform: translateX(-50%) translateY(100vh);
    }
    98% {
        opacity: 1;
        transform: translateX(-50%) translateY(-100vh);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-100vh);
    }
}

/* Rotated danmaku animation for landscape video */
.video-wrapper.landscape-video .subtitle-item {
    animation: danmakuFloatRotated 8s linear;
}

@keyframes danmakuFloatRotated {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(100vh) rotate(90deg);
    }
    2% {
        opacity: 1;
        transform: translateX(-50%) translateY(100vh) rotate(90deg);
    }
    98% {
        opacity: 1;
        transform: translateX(-50%) translateY(-100vh) rotate(90deg);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-100vh) rotate(90deg);
    }
}

/* Normal mode subtitle animations */
@keyframes subtitleSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes subtitleFadeOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}



#liveVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    /* iOS Safari specific styles to prevent fullscreen */
    -webkit-playsinline: true;
    -webkit-presentation-mode: inline;
    -webkit-video-playable-inline: true;
}

/* Play Button Overlay */
.play-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.8) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
    transition: opacity 0.3s ease;
    pointer-events: auto !important;
}

.play-overlay.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    display: none !important;
}

.play-btn {
    width: 80px !important;
    height: 80px !important;
    border-radius: 50% !important;
    background: linear-gradient(45deg, #ff4757, #ff3742) !important;
    border: 3px solid rgba(255, 255, 255, 0.3) !important;
    color: #fff !important;
    font-size: 32px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease;
    margin-bottom: 20px !important;
    box-shadow: 0 4px 20px rgba(255, 71, 87, 0.4) !important;
}

.play-btn:hover {
    background: rgba(255, 71, 87, 1);
    transform: scale(1.1);
}

.play-text {
    color: #fff;
    font-size: 16px;
    text-align: center;
    margin: 0;
    opacity: 0.9;
}

.fullscreen-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
}

/* Ensure fullscreen button is visible in fullscreen mode */
.video-section.pseudo-fullscreen .fullscreen-btn {
    z-index: 10000;
    position: fixed;
    bottom: 20px;
    right: 20px;
}

.fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.video-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
}

.game-title {
    font-weight: 600;
    color: #fff;
}

.game-version {
    color: #ccc;
    font-size: 10px;
}

/* Warning Message */
.warning-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(255, 193, 7, 0.1);
    border-left: 4px solid #ffc107;
    font-size: 13px;
    color: #ffc107;
    line-height: 1.4;
}

.warning-message i {
    font-size: 16px;
    flex-shrink: 0;
}

/* Comments Section */
.comments-section {
    background: rgba(0, 0, 0, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex: 1;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.comments-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.comments-count {
    font-size: 12px;
    color: #ccc;
}

.comments-list {
    padding: 0 20px;
}

.comment-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.comment-user {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.comment-text {
    font-size: 14px;
    color: #e0e0e0;
    line-height: 1.4;
}

/* Input Section */
.input-section {
    background: rgba(0, 0, 0, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    padding: 8px 15px;
}

#commentInput {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    outline: none;
    padding: 8px 0;
}

#commentInput::placeholder {
    color: #ccc;
}

.emoji-btn, .send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.emoji-btn:hover, .send-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.send-btn {
    background: #ff4757;
}

.send-btn:hover {
    background: #ff3742;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.like-btn.active {
    background: #ff4757;
    color: #fff;
}

.like-btn.active i {
    animation: heartBeat 0.6s ease;
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Scrollbar Styling */
.comments-section::-webkit-scrollbar {
    width: 4px;
}

.comments-section::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.comments-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.comments-section::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Responsive Design */
@media (max-width: 480px) {
    .header {
        padding: 12px 15px;
    }
    
    .avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .streamer-name {
        font-size: 14px;
    }
    
    .likes-count {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .fullscreen-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        bottom: 15px;
        right: 15px;
    }
    
    .warning-message {
        padding: 10px 15px;
        font-size: 12px;
    }
    
    .comments-header {
        padding: 12px 15px;
    }
    
    .comments-list {
        padding: 0 15px;
    }
    
    .comment-item {
        padding: 10px 0;
    }
    
    .comment-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .comment-user {
        font-size: 12px;
    }
    
    .comment-text {
        font-size: 13px;
    }
    
    .input-section {
        padding: 12px 15px;
    }
    
    .action-buttons {
        gap: 15px;
    }
    
    .action-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Mobile fullscreen fixes */
    .video-section.pseudo-fullscreen {
        width: 100vw;
        height: 100vh;
        position: fixed !important;
        top: 0;
        left: 0;
        margin: 0;
        padding: 0;
    }
    
    .video-section.pseudo-fullscreen .fullscreen-btn {
        position: fixed !important;
        z-index: 10000;
        bottom: 20px;
        right: 20px;
    }
}

/* Video Fullscreen Container */
.video-fullscreen-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.video-fullscreen-container.active {
    display: flex;
}

.video-fullscreen-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#fullscreenVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.exit-fullscreen-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.exit-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Fullscreen Styles */
.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: #000;
}

.fullscreen .video-section {
    height: 100vh;
}

.fullscreen .header,
.fullscreen .warning-message,
.fullscreen .comments-section,
.fullscreen .input-section {
    display: none;
}

/* Loading State */
.loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    z-index: 20;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.loading-text {
    color: #fff;
    font-size: 14px;
    opacity: 0.8;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom Scrollbar for Mobile */
@media (max-width: 768px) {
    .comments-section {
        -webkit-overflow-scrolling: touch;
    }
}
