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

html {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    overflow-x: hidden;
    background: #000;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Force all content to respect viewport bounds */
body > * {
    max-width: 100vw;
}

.reels-container {
    width: 100%;
    max-width: 100vw;
    height: calc(100vh - 50px);
    height: calc(100dvh - 50px);
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.reels-container::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.reels-container {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.reel {
    width: 100%;
    max-width: 100%;
    height: 100%;
    scroll-snap-align: start;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

.reel-content {
    width: 100%;
    max-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* HTML Reel */
.reel-html {
    width: 100%;
    max-width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.reel-html iframe {
    width: 100%;
    max-width: 100%;
    height: 100%;
    border: none;
    display: block;
    overflow: hidden;
}

/* Image Reel */
.reel-image {
    width: 100%;
    max-width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.reel-image img {
    width: 100%;
    max-width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Video Reel */
.reel-video {
    width: 100%;
    max-width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.video-script-container {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

.video-script-container iframe {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border: none;
    pointer-events: none;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

/* Stream Reel (Cloudflare Stream) */
.reel-stream {
    width: 100%;
    max-width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #000;
}

.stream-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.stream-mute-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Sound overlay (tap to enable sound) */
.sound-overlay {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 15px;
    cursor: pointer;
    z-index: 10;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(10px);
    white-space: nowrap;
    animation: soundOverlayIn 0.3s ease;
}

@keyframes soundOverlayIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* VAST Ad */
.vast-ad-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 5;
    display: none;
    background: #000;
}

.vast-countdown {
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 14px;
    border-radius: 15px;
    font-size: 13px;
    z-index: 6;
    display: none;
    backdrop-filter: blur(10px);
}

.vast-skip-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 16px;
    border-radius: 15px;
    font-size: 13px;
    cursor: pointer;
    z-index: 6;
    display: none;
    backdrop-filter: blur(10px);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Video controls */
.video-controls {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1100;
    display: none;
    gap: 10px;
}

.reel.active .video-controls {
    display: flex;
}

.video-control-btn {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    font-size: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-control-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

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

/* Progress indicator */
.progress-indicator {
    position: fixed;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.3s;
    cursor: pointer;
}

.progress-dot.active {
    background: white;
    height: 20px;
    border-radius: 4px;
}

/* Ad Reel */
.reel-ad .reel-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Close button */
.close-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 22px;
    line-height: 36px;
    text-align: center;
    text-decoration: none;
    z-index: 1100;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

/* Info overlay */
.info-overlay {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    backdrop-filter: blur(10px);
    color: white;
}

/* Loading indicator */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    color: white;
}

.loading-indicator.visible {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Controls */
.controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 1000;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Responsive */
@media (max-width: 768px) {
    .progress-indicator {
        right: 5px;
        gap: 6px;
    }

    .progress-dot {
        width: 6px;
        height: 6px;
    }

    .progress-dot.active {
        height: 16px;
    }

    .controls {
        bottom: 20px;
    }

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

    .video-controls {
        top: 50%;
    }

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

/* Previous page trigger reel */
.reel-prev-page {
    height: 120px !important;
    min-height: 120px;
    max-height: 120px;
    margin-bottom: 0 !important;
    background: #000;
    cursor: pointer;
}

.prev-page-trigger {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    animation: prevPagePulse 2s ease-in-out infinite;
}

.prev-page-arrow {
    font-size: 32px;
    margin-bottom: 4px;
}

.prev-page-text {
    font-size: 14px;
}

@keyframes prevPagePulse {
    0%, 100% { opacity: 0.5; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-5px); }
}

.reel-next-page {
    background: #000;
    cursor: pointer;
}

.next-page-trigger {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    animation: nextPagePulse 2s ease-in-out infinite;
}

.next-page-arrow {
    font-size: 32px;
    margin-bottom: 4px;
}

.next-page-text {
    font-size: 14px;
}

@keyframes nextPagePulse {
    0%, 100% { opacity: 0.5; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(5px); }
}

/* Touch gestures */
@media (hover: none) {
    .control-btn:active {
        transform: scale(0.95);
    }
}
