/* Mobile hardening layer shared by home, /games, and emulator pages. */
:root {
    --og-vh: 1vh;
    --og-safe-top: env(safe-area-inset-top, 0px);
    --og-safe-right: env(safe-area-inset-right, 0px);
    --og-safe-bottom: env(safe-area-inset-bottom, 0px);
    --og-safe-left: env(safe-area-inset-left, 0px);
}

.og-ad-empty,
[data-ad-status="empty"] {
    display: none !important;
    min-height: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
}

.og-mobile-update-toast {
    position: fixed;
    left: max(12px, var(--og-safe-left));
    right: max(12px, var(--og-safe-right));
    bottom: max(14px, calc(var(--og-safe-bottom) + 12px));
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 520px;
    margin: 0 auto;
    padding: 12px;
    border: 1px solid rgba(255, 204, 0, 0.45);
    border-radius: 12px;
    background: rgba(10, 12, 18, 0.96);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    color: #fff;
    font: 700 13px Rajdhani, Inter, Arial, sans-serif;
}

.og-mobile-update-toast button {
    min-height: 40px;
    border: 0;
    border-radius: 9px;
    padding: 8px 12px;
    background: #ffcc00;
    color: #111;
    font: 900 12px Rajdhani, Inter, Arial, sans-serif;
    cursor: pointer;
    white-space: nowrap;
}

.og-mobile-health-panel {
    position: fixed;
    top: max(12px, var(--og-safe-top));
    left: max(12px, var(--og-safe-left));
    right: max(12px, var(--og-safe-right));
    z-index: 2147482500;
    max-height: min(60vh, calc(var(--og-vh) * 60));
    overflow: auto;
    border: 1px solid rgba(255, 0, 64, 0.45);
    border-radius: 12px;
    background: rgba(8, 8, 12, 0.96);
    color: #fff;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.og-mobile-health-panel header {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(12, 12, 18, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.og-mobile-health-panel button {
    min-height: 34px;
    border: 0;
    border-radius: 8px;
    padding: 6px 10px;
    background: #ffcc00;
    color: #111;
    font-weight: 900;
}

.og-mobile-health-panel pre {
    margin: 0;
    padding: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 768px), (pointer: coarse) {
    html.og-mobile-runtime {
        min-height: calc(var(--og-vh) * 100);
        overscroll-behavior-y: contain;
        -webkit-text-size-adjust: 100%;
    }

    body.og-mobile-runtime {
        min-height: calc(var(--og-vh) * 100);
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    body.og-favorites-open {
        overflow: hidden !important;
    }

    .og-game-card {
        content-visibility: auto;
        contain-intrinsic-size: 210px 300px;
    }

    .og-card-cover {
        aspect-ratio: 3 / 4;
        min-height: 0;
    }

    .og-card-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .favorites-modal {
        display: none;
        align-items: flex-end !important;
        justify-content: center !important;
        padding: 0 !important;
        background: rgba(0, 0, 0, 0.74) !important;
        backdrop-filter: blur(6px);
        overflow: hidden !important;
    }

    .favorites-modal[style*="block"],
    .favorites-modal[style*="flex"] {
        display: flex !important;
    }

    .favorites-modal .favorites-container {
        width: 100% !important;
        max-width: none !important;
        max-height: min(86vh, calc(var(--og-vh) * 86)) !important;
        margin: auto 0 0 !important;
        padding: 16px max(14px, var(--og-safe-right)) calc(16px + var(--og-safe-bottom)) max(14px, var(--og-safe-left)) !important;
        border-radius: 18px 18px 0 0 !important;
        background: linear-gradient(180deg, rgba(22, 16, 28, 0.99), rgba(7, 7, 10, 0.99)) !important;
        box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.65) !important;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .favorites-modal .favorites-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 2 !important;
        gap: 10px !important;
        padding: 0 0 12px !important;
        margin-bottom: 12px !important;
        background: linear-gradient(180deg, rgba(22, 16, 28, 0.99), rgba(22, 16, 28, 0.92)) !important;
    }

    .favorites-modal .favorites-header h2 {
        font-size: clamp(1.35rem, 8vw, 2rem) !important;
        line-height: 1 !important;
        margin: 0 !important;
    }

    .favorites-modal .favorites-header button,
    .favorites-modal button {
        min-height: 44px !important;
        touch-action: manipulation;
    }

    .favorites-grid,
    #favoritesGrid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
        justify-content: stretch !important;
    }

    .favorite-card {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        transform: none !important;
    }

    .favorite-card h3 {
        min-height: 2.4rem !important;
        overflow: hidden !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .favorite-card img {
        transform: none !important;
    }

    .ad-wrapper,
    .ad-container,
    .og-content-banner {
        max-width: 100% !important;
    }

    .emu-action-btn,
    .emu-icon-btn,
    .fullscreen-btn,
    .arcade-header-btn,
    .mobile-control-btn,
    .mobile-controls button {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }

    .mobile-gamepad,
    .mobile-controls,
    .arcade-mobile-pad,
    .touch-controls,
    .virtual-gamepad {
        touch-action: none;
        user-select: none;
        -webkit-user-select: none;
    }

    body.controls-visible .og-ingame-ad,
    body.mobile-controls-visible .og-ingame-ad {
        top: max(4px, var(--og-safe-top)) !important;
    }

    body.app-fullscreen-emu .og-ingame-ad,
    body.game-fullscreen .og-ingame-ad,
    body.is-fullscreen .og-ingame-ad {
        display: none !important;
    }
}

@media (max-width: 420px) {
    .favorites-grid,
    #favoritesGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .favorites-modal .favorites-container {
        padding-left: max(10px, var(--og-safe-left)) !important;
        padding-right: max(10px, var(--og-safe-right)) !important;
    }
}
