/* Mobile-specific styles for tablet and smaller devices */
@media (max-width: 768px) {
    /* === VIEWPORT & DISPLAY OPTIMIZATION === */
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        scroll-behavior: smooth;
    }

    body {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding: 0;
        height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Momentum scrolling for iOS */
        overscroll-behavior: contain;
        /* Prevent bounce scrolling */
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    /* === SCENE CONTAINER === */
    .scene {
        width: 100%;
        height: auto;
        background: none;
        padding: 0;
        flex-direction: column;
        max-width: 100vw;
    }

    /* === TV CONTAINER MOBILE === */
    .tv-container {
        width: 100%;
        max-width: 90vw;
        aspect-ratio: 16 / 9;
        transform: none;
        box-shadow: 0 0 20px rgba(0, 136, 204, 0.15);
        border-radius: 16px;
        padding: 0;
        border: none;
        background: #0d0d0d;
        margin: 8px auto;
        will-change: opacity;
        /* GPU acceleration */
        transform: translateZ(0);
    }

    .tv-container::before,
    .tv-container::after {
        display: none;
    }

    /* === VIDEO OPTIMIZATION === */
    video {
        border-radius: 16px;
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        /* Optimize video rendering */
        -webkit-user-select: none;
        user-select: none;
        pointer-events: none;
    }

    /* === GLOW EFFECT === */
    .tv-glow {
        display: none;
    }

    /* === OVERLAY UI === */
    .overlay-ui {
        position: static;
        display: flex;
        flex-direction: column;
        gap: 6px;
        width: 100%;
        max-width: 90vw;
        padding: 0 10px 10px 10px;
        margin: 0 auto;
    }

    /* === LOGO CONTAINER === */
    .logo-container {
        background: var(--glass-bg);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid var(--glass-border);
        padding: 12px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        animation: fadeIn 1.5s ease-out;
        min-height: 70px;
        /* Touch-friendly size */
    }

    .logo-container img {
        height: 45px;
        width: auto;
        -webkit-user-drag: none;
        user-select: none;
    }

    /* === CONTROLS & BUTTONS === */
    .controls {
        flex-direction: column;
        gap: 8px;
        display: flex;
    }

    .btn-glass {
        width: 100%;
        padding: 14px 16px;
        background: var(--glass-bg);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        border: 1px solid var(--glass-border);
        color: white;
        border-radius: 12px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        transition: all 0.2s ease;
        min-height: 44px;
        /* iOS touch target minimum */
        touch-action: manipulation;
        /* Disable double-tap zoom */
        -webkit-appearance: none;
        /* Remove default styling */
        appearance: none;
        -webkit-user-select: none;
        user-select: none;
    }

    .btn-glass:active {
        background: rgba(255, 255, 255, 0.2);
        border-color: var(--accent-color);
        box-shadow: 0 0 10px rgba(0, 136, 204, 0.2);
    }

    .btn-glass:focus {
        outline: 2px solid var(--accent-color);
        outline-offset: 2px;
    }

    /* === ANIMATIONS === */
    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* === LANDSCAPE MODE (>=900px height) === */
    @media (min-height: 900px) {
        body {
            justify-content: center;
            padding-top: max(20px, env(safe-area-inset-top));
        }

        .overlay-ui {
            gap: 10px;
        }
    }

    /* === SMALL DEVICES (<360px) === */
    @media (max-width: 360px) {
        body {
            padding-top: max(8px, env(safe-area-inset-top));
        }

        .tv-container {
            max-width: 95vw;
            border-radius: 12px;
        }

        .logo-container {
            padding: 8px;
            min-height: 60px;
        }

        .logo-container img {
            height: 40px;
        }

        .btn-glass {
            font-size: 12px;
            padding: 12px 14px;
        }
    }

    /* === REDUCED MOTION SUPPORT === */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }

        body {
            scroll-behavior: auto;
        }
    }

    /* === DARK MODE SUPPORT === */
    @media (prefers-color-scheme: dark) {
        .btn-glass {
            background: rgba(255, 255, 255, 0.03);
        }

        .btn-glass:active {
            background: rgba(255, 255, 255, 0.1);
        }
    }

    /* === HIGH DPI SCREENS === */
    @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
        .btn-glass {
            border-width: 1px;
        }
    }
}
