@media (max-width: 1024px) {
    .nav-container {
        padding: 0 1.5rem;
    }

    /* Do NOT override content-card width here - it breaks sliders */
    .hero-banner {
        height: 60vh;
        padding: 2rem;
    }

    .hero-content h1 {
        font-size: 2.5rem;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .slider-btn {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 768px) {
    /* Hide Desktop Nav Elements */
    .nav-links-right {
        display: none;
    }

    body {
        min-height: 100dvh;
        overflow-x: hidden;
        overscroll-behavior-y: none;
        padding-bottom: 80px; /* Space for the bottom nav */
    }

    .nav-container {
        padding: 0 1.5rem;
        height: 70px;
        justify-content: center;
    }

    .navbar {
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border-bottom: none !important;
        box-shadow: none !important;
        padding: 0.8rem 0;
    }

    .navbar.scrolled {
        background: rgba(8, 8, 12, 0.9) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    }

    .nav-logo h1 {
        font-size: 1.4rem;
    }

    /* Bottom Navigation Bar — Truly Fixed */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: calc(65px + env(safe-area-inset-bottom, 0px));
        background: rgba(10, 10, 15, 0.97);
        -webkit-backdrop-filter: blur(30px);
        backdrop-filter: blur(30px);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 999999;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.6);
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
        touch-action: none;
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        color: rgba(255, 255, 255, 0.6);
        text-decoration: none;
        font-size: 0.75rem;
        font-weight: 500;
        transition: all 0.3s ease;
    }

    .bottom-nav-item i {
        width: 20px;
        height: 20px;
    }

    .bottom-nav-item.active,
    .bottom-nav-item:active {
        color: var(--primary-color);
    }

    .bottom-nav-search {
        width: 50px;
        height: 50px;
        background: var(--gradient-brand);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: -25px;
        box-shadow: 0 8px 25px rgba(147, 51, 234, 0.4);
        color: white;
    }

    .user-dropdown {
        position: fixed !important;
        top: auto !important;
        bottom: 85px !important;
        right: 1.5rem !important;
        z-index: 1000000;
    }

    /* Hero Banner Mobile */
    .hero-banner {
        height: 85vh;
        padding: 1.5rem;
        background-position: center;
        align-items: flex-end; /* Align content to the bottom for cinematic feel */
        padding-bottom: 2rem;
    }

    .hero-overlay {
        background: linear-gradient(to top, var(--bg-dark) 0%, rgba(5, 5, 16, 0.8) 30%, transparent 100%) !important;
    }

    .hero-content {
        bottom: 0;
        max-width: 100%;
        text-align: center;
        width: 100%;
        left: 0;
        padding: 0 1rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        z-index: 10;
        margin-bottom: 4rem; /* Safe area above bottom nav */
    }

    .hero-content h1 {
        font-size: clamp(2rem, 10vw, 3rem);
        font-weight: 900;
        line-height: 1.05;
        margin-bottom: 0.8rem;
        text-align: center;
        text-transform: uppercase;
        letter-spacing: -1.5px;
        text-shadow: 0 4px 30px rgba(0, 0, 0, 0.9), 0 2px 10px rgba(0,0,0,0.5);
    }

    .hero-content p {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .hero-buttons {
        flex-direction: row;
        gap: 0.8rem;
        width: 100%;
        justify-content: center;
    }

    .hero-buttons .btn {
        flex: 1;
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
    }

    .hero-buttons .btn-secondary {
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border: 1px solid rgba(255, 255, 255, 0.15);
        color: white;
    }

    /* Content Layout */
    main {
        padding-bottom: 90px;
    }

    .content-section {
        padding: 1rem 1.2rem;
        margin-bottom: 5rem; /* More breathing room */
        position: relative;
        overflow: visible;
    }

    /* Restore Horizontal Sliders */
    .content-slider {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 1.2rem !important;
        overflow-x: auto !important;
        padding-bottom: 1rem !important;
        scrollbar-width: none;
    }

    .content-slider::-webkit-scrollbar {
        display: none;
    }

    /* Dedicated Grid Class for Discover/Search Hubs */
    .mobile-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.2rem !important;
        overflow: visible !important;
    }

    .content-card {
        width: 155px !important;
        min-width: 155px !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
    }

    .mobile-grid .content-card {
        width: 100% !important;
        min-width: 0 !important;
    }

    .content-card img {
        height: auto !important;
        aspect-ratio: 2/3 !important;
        border-radius: 12px !important;
    }

    .content-card h3 {
        font-size: 0.85rem !important;
        margin-top: 8px !important;
        line-height: 1.3 !important;
    }

    /* Search Overlay Mobile */
    .search-overlay {
        padding: 2rem 1.5rem;
    }

    .search-overlay input {
        font-size: 1.8rem;
        padding: 1rem 0;
    }

    .search-overlay-close {
        top: 1.5rem;
        right: 1.5rem;
    }

    /* Floating Profile FAB adjustments */
    .bottom-actions {
        bottom: 100px; /* Adjust to stay above bottom nav */
        right: 1.5rem;
    }

    .profile-fab {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .content-slider {
        gap: 1rem !important;
    }
    
    .hero-content h1 {
        font-size: clamp(1.2rem, 7vw, 1.6rem);
    }
}

/* Player Awareness & Unblocking */
@media (max-height: 700px) and (max-width: 768px) {
    .player-extra-content {
        display: none !important;
    }
    
    .player-modal-content {
        height: 100vh !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .player-container {
        height: auto !important;
        aspect-ratio: 16/9;
    }
}


/* =============================================
   MOBILE PLAYER - COMPLETE OVERHAUL
   ============================================= */
@media (max-width: 768px) {
    /* Player Modal: Full screen takeover */
    .player-modal.active {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .player-container {
        width: 100% !important;
        max-width: 100% !important;
        position: relative;
        border-radius: 0;
    }

    /* Close button: always visible, inside the container */
    .player-close {
        position: fixed !important;
        top: 10px !important;
        right: 12px !important;
        z-index: 9999 !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 1.5rem !important;
        background: rgba(0,0,0,0.85) !important;
        border: 1px solid rgba(255,255,255,0.2) !important;
        border-radius: 50% !important;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: white;
        line-height: 1;
    }

    /* Video: 16:9 ratio, full width */
    .player-wrapper {
        border-radius: 0 !important;
        padding-bottom: 56.25%;
        height: 0;
        position: relative;
        overflow: hidden;
        background: #000;
        margin-top: 0;
    }

    .player-wrapper iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
        border: none;
    }

    /* Controls: clean vertical stack, scrollable */
    .player-controls {
        padding: 1rem !important;
        gap: 1rem !important;
        display: flex;
        flex-direction: column;
        background: #0a0a0f;
    }

    /* TV Controls: stack vertically */
    .tv-controls {
        flex-direction: column !important;
        gap: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    .control-group {
        width: 100%;
    }

    .control-group select {
        width: 100%;
        font-size: 1rem;
        padding: 0.85rem 1rem;
        border-radius: 10px;
    }

    /* Server selector: stack vertically */
    .server-selector {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    .server-selector label {
        font-size: 0.85rem;
        color: rgba(255,255,255,0.6);
    }

    .server-selector select {
        width: 100% !important;
        font-size: 1rem;
        padding: 0.85rem 1rem;
        border-radius: 10px;
    }

    /* Action buttons: tappable size */
    #trailerPlayBtn,
    #shareBtn,
    #downloadBtn {
        width: 100% !important;
        justify-content: center !important;
        padding: 1rem !important;
        font-size: 1rem !important;
        border-radius: 12px !important;
        min-height: 48px !important;
    }

    /* Recommendations: hide on mobile to keep player clean */
    .player-extra-content {
        display: none !important;
    }

    /* Detail Modal: full screen, scrollable */
    .modal.active {
        padding: 0 !important;
        align-items: flex-start !important;
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .detail-backdrop {
        height: 220px !important;
        border-radius: 0 !important;
    }

    .detail-info {
        padding: 1.2rem !important;
    }

    .detail-title {
        font-size: clamp(1.4rem, 6vw, 2rem) !important;
    }

    .detail-meta {
        gap: 0.75rem !important;
        font-size: 0.85rem !important;
    }

    .detail-actions {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .detail-actions .btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 1rem !important;
        font-size: 1rem !important;
        min-height: 52px !important;
        border-radius: 12px !important;
    }

    /* Modal close: bigger tap target */
    .modal-close {
        width: 48px !important;
        height: 48px !important;
        top: 0.75rem !important;
        right: 0.75rem !important;
        font-size: 1.4rem !important;
    }
}