/* Main Stylesheet for 4NICEPORN */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: #000;
    color: #fff;
    line-height: 1.6;
    scroll-behavior: smooth;
    min-height: 100vh; /* Reserve space to prevent layout shift */
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Prevent horizontal scroll causing layout shift */
    position: relative; /* Create stacking context */
}

/* Header Styles */
.header {
    background-color: #000;
    border-bottom: 1px solid #333;
    padding: 0; /* Remove padding to allow banner to fit properly */
    flex-shrink: 0; /* Prevent header from shrinking */
    position: relative;
    contain: layout style;
    /* Allow header to grow to accommodate all children */
    min-height: auto;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* CRITICAL: Fixed height to prevent layout shift */
    height: 60px; /* Fixed height */
    min-height: 60px;
    max-height: 60px;
    position: relative;
    contain: layout style;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #ff0000;
    font-size: 1.5rem;
    font-weight: bold;
    /* CRITICAL: Fixed dimensions to prevent layout shift */
    width: 60px; /* Fixed width */
    height: 60px; /* Fixed height */
    min-width: 60px;
    min-height: 60px;
    max-width: 60px;
    max-height: 60px;
    flex-shrink: 0; /* Don't shrink */
    position: relative;
    contain: layout style;
}

.logo img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    display: block;
}

.logo-text {
    margin-left: 0.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    /* CRITICAL: Fixed dimensions to prevent layout shift */
    height: 44px; /* Fixed height: match search input height */
    min-height: 44px;
    max-height: 44px;
    min-width: 350px; /* Reserve space for search + button */
    flex-shrink: 0; /* Don't shrink */
    position: relative;
    contain: layout style;
}

.search-container {
    display: flex;
    align-items: center;
}

.search-input {
    padding: 0.75rem 1rem;
    border: 1px solid #333;
    background: #111;
    color: #fff;
    border-radius: 4px 0 0 4px;
    min-width: 300px;
    min-height: 44px;
    font-size: 16px; /* Prevent zoom on iOS */
    -webkit-appearance: none;
    appearance: none;
}

.search-btn {
    padding: 0.5rem 1rem;
    background: #ff0000;
    color: #fff;
    border: 1px solid #ff0000;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
    touch-action: manipulation;
}

/* Categories Navigation */
.categories-nav {
    background-color: #111;
    border-bottom: 1px solid #333;
    padding: 0.5rem 0;
    /* CRITICAL: Fixed height to prevent layout shift */
    height: 60px; /* Fixed height: padding (0.5rem top + 0.5rem bottom = 16px) + container (44px) = ~60px */
    min-height: 60px;
    max-height: 60px;
    /* Prevent layout shift when categories are added */
    contain: layout style;
    position: relative;
}

.categories-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    /* CRITICAL: Reserve space to prevent layout shift */
    min-height: 44px; /* Match category button height */
    height: 44px; /* Fixed height to prevent layout shift */
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #333 #000;
    -webkit-overflow-scrolling: touch;
}

.category-btn {
    padding: 0.5rem 1rem;
    background: #222;
    color: #fff; /* White text on dark background - good contrast */
    border: 1px solid #444; /* Lighter border for better visibility */
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    font-size: 0.9rem;
}

.category-btn:hover,
.category-btn.active {
    background: #ff0000;
    border-color: #ff0000;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    min-height: 900px; /* Reserve more space to prevent layout shift (24 videos * ~37px height) */
    flex: 1; /* Take remaining space in flex container */
    contain: layout; /* Prevent layout shifts from affecting parent */
    position: relative; /* Create stacking context for absolute skeleton */
    /* Prevent layout shifts during content load */
    will-change: contents;
}

/* Skeleton removed - using video grid with reserved space instead */

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem; /* Match skeleton-grid gap exactly */
    margin-bottom: 2rem;
    min-height: 900px; /* Match skeleton-grid height exactly to prevent layout shift */
    opacity: 1;
    transition: opacity 0.3s ease;
    contain: layout; /* Prevent layout shifts */
    /* Reserve exact space */
    content-visibility: auto;
    /* Ensure grid maintains structure */
    align-items: start;
    /* CRITICAL: Position relative to allow absolute skeleton to overlap */
    position: relative;
    z-index: 0; /* Below skeleton */
}

.video-card {
    background: #111;
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.2s;
    /* CRITICAL: Fixed height to prevent layout shift */
    /* Thumbnail (16:9 aspect ratio) + info section = fixed total height */
    /* For 200px width card: thumbnail ~113px + info ~80px = ~193px */
    height: 193px; /* Fixed height: 113px (thumbnail) + 80px (info) */
    display: flex;
    flex-direction: column;
    /* Prevent card from overflowing */
    max-width: 100%;
    min-width: 0; /* Allow flex items to shrink */
    /* Prevent layout shift */
    contain: layout style;
}

.video-card:hover {
    transform: scale(1.05);
}

.video-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.video-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: #111; /* Placeholder background */
    /* CRITICAL: Fixed height to prevent layout shift */
    height: 113px; /* Fixed height for 200px width card (16:9 = 200/1.78 = 113px) */
    flex-shrink: 0; /* Don't shrink thumbnail */
    /* Prevent layout shift when image loads */
    contain: layout style paint;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block; /* Remove inline spacing */
    background: #111; /* Fallback background while loading */
    /* Prevent layout shift */
    aspect-ratio: 16/9;
}

.video-duration {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.video-info {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    /* CRITICAL: Fixed height to prevent layout shift */
    height: 80px; /* Fixed height: 2.4em (title) + 0.5rem (margin) + 1.2em (meta) = ~80px */
    min-height: 80px; /* Ensure minimum height */
    max-height: 80px; /* Ensure maximum height */
    min-width: 0; /* Allow flex items to shrink */
    overflow: hidden; /* Prevent content overflow */
    /* Prevent layout shift */
    contain: layout style;
}

.video-title {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* CRITICAL: Fixed height to prevent layout shift */
    height: 2.4em; /* Fixed height for 2 lines: 0.9rem * 1.2 (line-height) * 2 = 2.16em, round to 2.4em */
    min-height: 2.4em;
    max-height: 2.4em;
    line-height: 1.2;
    /* Prevent layout shift */
    contain: layout style;
}

.video-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #999;
    /* CRITICAL: Fixed height to prevent layout shift */
    height: 1.2em; /* Fixed height: 0.75rem * 1.6 (line-height) = 1.2em */
    min-height: 1.2em;
    max-height: 1.2em;
    min-width: 0; /* Allow flex items to shrink */
    width: 100%; /* Ensure full width */
    overflow: hidden; /* Prevent overflow */
    /* Prevent layout shift */
    contain: layout style;
}

.video-views {
    white-space: nowrap; /* Prevent text wrapping */
    flex-shrink: 0; /* Don't shrink views */
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #999;
}

/* Pagination */
.pagination {
    margin: 2rem 0;
    display: flex;
    justify-content: center;
}

.pagination-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    background: #222;
    color: #fff;
    border: 1px solid #333;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
}

.pagination-btn:hover,
.pagination-btn.active {
    background: #ff0000;
    border-color: #ff0000;
}

.pagination-ellipsis {
    padding: 0 0.5rem;
    color: #999;
}

/* Footer */
.site-footer {
    background-color: #111;
    border-top: 1px solid #333;
    padding: 2rem 0;
    margin-top: 4rem;
    min-height: 300px; /* Reserve space to prevent layout shift */
    visibility: visible; /* Visible from start to reserve space */
    opacity: 0; /* Start transparent */
    transition: opacity 0.3s ease;
    flex-shrink: 0; /* Prevent footer from shrinking */
}

/* Advertisement Banner Container - In Header */
.header .ad-banner-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #111;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    /* CRITICAL: Reserve space to prevent layout shift */
    min-height: 80px; /* Reserve space for banner (60px) + padding */
    height: 80px;
    position: relative;
    contain: layout style;
    /* Add spacing and visual separation */
    margin-top: 0;
    margin-bottom: 0;
}

.header .ad-banner {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 468px;
    /* CRITICAL: Reserve space to prevent layout shift */
    min-height: 60px;
    height: 60px;
    position: relative;
    contain: layout style;
    /* Add visual styling */
    background-color: #1a1a1a;
    border-radius: 4px;
    padding: 0;
    overflow: hidden;
}

.header .ad-banner iframe {
    display: block;
    border: none;
    width: 100%;
    max-width: 468px;
    height: 60px;
    margin: 0 auto;
    border-radius: 4px;
}

.footer-grid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.footer-column h3,
.footer-column h4 {
    margin-bottom: 1rem;
    color: #ff0000;
}

.footer-list {
    list-style: none;
}

.footer-list li {
    margin-bottom: 0.5rem;
    color: #999;
}

/* Footer links - improve color contrast for accessibility */
.footer-column a {
    color: #ff6b6b; /* Brighter red for better contrast (WCAG AA compliant) */
    text-decoration: underline;
    transition: color 0.2s;
}

.footer-column a:hover {
    color: #ff9999; /* Lighter on hover */
}

.footer-column a:visited {
    color: #ff6b6b; /* Keep same color for visited links */
}

.footer-age {
    color: #ff0000;
    font-weight: bold;
    margin-top: 0.5rem;
}

.footer-copy {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #333;
    margin-top: 2rem;
    color: #999;
}

/* Video Page Styles */
.video-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
    /* CRITICAL: Reserve space to prevent layout shift */
    min-height: 100vh; /* Reserve full viewport height */
    position: relative;
}

.video-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Video Player Section */
.video-player-section {
    background: #111;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.5s ease-in;
    /* CRITICAL: Reserve space to prevent layout shift */
    min-height: 600px; /* Reserve space for video player + info */
    position: relative;
    contain: layout style;
}

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

.video-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    aspect-ratio: 16/9;
    /* CRITICAL: Fixed height to prevent layout shift */
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio (9/16 = 0.5625) */
    overflow: hidden;
    contain: layout style paint;
}

.video-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    border-radius: 0;
    /* CRITICAL: Fixed positioning to prevent layout shift */
    object-fit: contain;
}

/* Custom video controls styling */
.video-player::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.7);
}

.video-player::-webkit-media-controls-play-button {
    background-color: rgba(255, 0, 0, 0.8);
    border-radius: 50%;
}

/* Video Info */
.video-info {
    padding: 1.5rem;
    /* CRITICAL: Reserve space to prevent layout shift */
    min-height: 200px; /* Reserve space for title, meta, description */
    position: relative;
    contain: layout style;
}

.video-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    line-height: 1.4;
    color: #fff;
}

.video-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.views-count {
    color: #999;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.views-count::before {
    content: "👁️";
}

.video-category {
    background: #ff0000;
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: capitalize;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%; /* Prevent overflow */
    flex-shrink: 1; /* Allow shrinking if needed */
    min-width: 0; /* Allow flex item to shrink below content size */
}

/* Video Description */
.video-description-container {
    margin-bottom: 1.5rem;
}

.video-description {
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 0.5rem;
    max-height: 100px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.video-description.expanded {
    max-height: none;
}

.expand-description {
    background: #222;
    color: #fff;
    border: 1px solid #333;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    min-height: 44px;
    touch-action: manipulation;
    border: none;
    color: #ff0000;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.5rem 0;
    display: none;
}

.expand-description:hover {
    text-decoration: underline;
}

/* Video Tags & Actors */
.video-tags {
    margin-bottom: 1.5rem;
}

.actors-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.actors-section strong {
    color: #fff;
    font-size: 0.95rem;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.actor-tag {
    background: #222;
    color: #fff;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid #333;
    transition: all 0.2s;
}

.actor-tag:hover {
    background: #333;
    border-color: #ff0000;
    transform: translateY(-2px);
}

/* Share Buttons */
.share-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid #333;
}

.share-btn {
    background: #222;
    color: #fff;
    border: 1px solid #333;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.share-btn:hover {
    background: #ff0000;
    border-color: #ff0000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.3);
}

.share-btn[data-platform="facebook"]:hover {
    background: #1877f2;
    border-color: #1877f2;
}

.share-btn[data-platform="twitter"]:hover {
    background: #1da1f2;
    border-color: #1da1f2;
}

/* Suggested Videos */
.suggested-videos {
    margin-top: 2rem;
    /* CRITICAL: Reserve space to prevent layout shift */
    min-height: 400px; /* Reserve space for suggested videos grid */
    position: relative;
    contain: layout style;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #fff;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #ff0000;
}

.suggested-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.suggested-video-card {
    background: #111;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #222;
    animation: fadeInUp 0.5s ease-out;
    animation-fill-mode: both;
}

.suggested-video-card:nth-child(1) { animation-delay: 0.1s; }
.suggested-video-card:nth-child(2) { animation-delay: 0.2s; }
.suggested-video-card:nth-child(3) { animation-delay: 0.3s; }
.suggested-video-card:nth-child(4) { animation-delay: 0.4s; }
.suggested-video-card:nth-child(5) { animation-delay: 0.5s; }
.suggested-video-card:nth-child(6) { animation-delay: 0.6s; }

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

.suggested-video-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(255, 0, 0, 0.2);
    border-color: #ff0000;
}

.suggested-video-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.suggested-video-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: #111; /* Placeholder background */
}

.suggested-video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block; /* Remove inline spacing */
}

.suggested-video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.suggested-video-card:hover .suggested-video-thumbnail img {
    transform: scale(1.1);
}

.suggested-video-duration {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.9);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.suggested-video-info {
    padding: 1rem;
}

.suggested-video-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    color: #fff;
}

.suggested-video-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #999;
}

.suggested-video-views {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Breadcrumbs */
.breadcrumbs {
    max-width: 1400px;
    margin: 1rem auto;
    padding: 0 1rem;
    font-size: 0.9rem;
    color: #999;
}

.breadcrumbs a {
    color: #ff0000;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumbs a:hover {
    color: #ff3333;
    text-decoration: underline;
}

.breadcrumbs span {
    margin: 0 0.5rem;
}

/* Back Button */
.back-btn {
    background: #222;
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    border: 1px solid #333;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    min-height: 44px;
    touch-action: manipulation;
}

.back-btn:hover {
    background: #ff0000;
    border-color: #ff0000;
    transform: translateX(-3px);
}

/* Loading State for Video Page */
.video-main .loading-skeleton {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .search-input {
        min-width: 150px;
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .skeleton-grid,
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem; /* Match exactly between skeleton and video-grid */
    }
    
    .video-main {
        padding: 1rem 0.5rem;
    }
    
    .video-title {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .logo {
        /* CRITICAL: Fixed dimensions on mobile to prevent layout shift */
        width: 50px; /* Fixed width */
        height: 50px; /* Fixed height */
        min-width: 50px;
        min-height: 50px;
        max-width: 50px;
        max-height: 50px;
        contain: layout style;
    }
    
    .logo img {
        width: 50px;
        height: 50px;
    }
    
    .header-container {
        /* CRITICAL: Fixed height on mobile to prevent layout shift */
        height: 50px; /* Fixed height */
        min-height: 50px;
        max-height: 50px;
        padding: 0 0.5rem;
        flex-wrap: wrap;
        contain: layout style;
    }
    
    .main-content {
        /* CRITICAL: Fixed min-height on mobile to prevent layout shift */
        min-height: 800px; /* Reserve space for mobile */
        padding: 1rem 0.5rem;
        contain: layout style; /* Prevent layout shifts */
    }
    
    .skeleton-grid,
    .video-grid {
        min-height: 800px; /* Match exactly */
        gap: 0.75rem; /* Match exactly */
    }
    
    .video-info {
        padding: 1rem;
    }
    
    .video-wrapper {
        aspect-ratio: 16/9;
        width: 100%;
    }
    
    .video-player {
        width: 100%;
        height: 100%;
    }
    
    .suggested-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
    
    .share-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .share-btn {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1.5rem;
    }
    
    .categories-nav {
        /* CRITICAL: Fixed height on mobile to prevent layout shift */
        height: 60px; /* Fixed height */
        min-height: 60px;
        max-height: 60px;
        padding: 0.5rem 0;
        contain: layout style;
    }
    
    .categories-container {
        padding: 0 0.5rem;
        gap: 0.5rem;
        /* CRITICAL: Fixed height on mobile */
        height: 44px; /* Fixed height */
        min-height: 44px;
        max-height: 44px;
    }
    
    .category-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .video-card {
        font-size: 0.85rem;
    }
    
    .video-title {
        font-size: 0.85rem;
    }
    
    .header .ad-banner-container {
        padding: 0.75rem 0.5rem;
        min-height: 70px; /* Smaller on mobile */
        height: 70px;
    }
    
    .header .ad-banner {
        max-width: 100%;
        min-height: 50px; /* Smaller on mobile */
        height: 50px;
        border-radius: 4px;
    }
    
    .header .ad-banner iframe {
        max-width: 100%;
        height: 50px;
        border-radius: 4px;
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0 1rem;
    }
    
    .pagination-container {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
    }
    
    .pagination-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .search-input {
        min-width: 120px;
        font-size: 16px;
    }
    
    .skeleton-grid,
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.5rem; /* Match exactly */
    }
    
    .suggested-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.75rem;
    }
    
    .video-title {
        font-size: 0.95rem;
    }
    
    .video-info {
        padding: 0.75rem;
    }
    
    .header-container {
        padding: 0.5rem;
    }
    
    .main-content {
        padding: 0.75rem 0.5rem;
    }
}

