/* ==========================================================================
   mobile.css — phone / small-screen fixes ONLY.
   Every rule lives inside a max-width media query, so desktop (PC) layout
   is untouched. Loaded last in <head> so it can override page styles.
   ========================================================================== */

/* ---------- Phones & small tablets (<= 768px) ---------- */
@media (max-width: 768px) {

    /* Stop sideways scrolling caused by over-wide elements */
    html, body {
        overflow-x: clip;
        max-width: 100%;
    }
    img {
        max-width: 100%;
    }

    /* ---- Emulator game lists (GBA / PS1 / SNES / N64) ---- */
    .gallery-1 .gallery-grid {
        float: none !important;
        display: inline-block;
        vertical-align: top;
        width: 50% !important;
        padding: 0 6px !important;
        margin: 0 0 18px 0 !important;
    }
    .gallery-1 .gallery-grid .card {
        width: 100%;
    }
    .gallery-1 .gallery-grid .card .card-image {
        width: 100%;
        aspect-ratio: auto;
    }
    .gallery-1 .gallery-grid img {
        width: 100%;
        height: auto;
        max-height: none !important;
    }
    .gallery-1 .game-name {
        position: static !important;
        margin: 6px 0 0 0 !important;
        font-size: 13px;
        line-height: 1.3;
        overflow-wrap: anywhere;
        text-shadow: 0 1px 3px #000, 0 0 6px #000;
    }

    /* Search bar + region select stack neatly */
    .gallery-1 form input[type="text"] {
        width: 100%;
        max-width: 320px;
        padding: 8px 10px;
        font-size: 16px;            /* 16px stops iOS zooming on focus */
        margin-bottom: 8px;
        border-radius: 5px;
        border: 1px solid #ccc;
    }
    .gallery-1 .region-select {
        margin-left: 0;
        font-size: 16px;
        padding: 8px 10px;
    }
    .gallery-1 form button[type="submit"] {
        padding: 8px 14px;
        font-size: 16px;
    }

    /* A–Z letter picker: bigger tap targets */
    .alphabet-container {
        max-width: 100%;
        gap: 4px;
    }
    .alphabet-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }
    .alphabet-buttons a {
        min-width: 36px;
        padding: 8px 6px;
        text-align: center;
    }

    /* Pagination wraps instead of running off screen */
    .pagination {
        display: inline-flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
        max-width: 100%;
    }
    .pagination a {
        padding: 8px 12px;
    }

    /* Hold-to-scroll arrows are mouse-only and cover the games; phones swipe */
    #scrollUpButton,
    #scrollDownButton {
        display: none !important;
    }

    /* Save / load pop-ups and toasts fit the screen */
    .save-load-ui {
        width: 90%;
        max-width: 360px;
    }
    .notification {
        left: 16px;
        right: 16px;
        text-align: center;
    }
}

/* ---------- Phones (<= 640px, where the hamburger menu shows) ---------- */
@media (max-width: 640px) {

    /* Give the opened hamburger menu a solid backdrop so links are readable */
    ul.nav1 {
        background-color: rgba(18, 18, 26, 0.96) !important;
        border-radius: 0 0 12px 12px !important;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
        z-index: 1000 !important;
        padding: 6px 0 !important;
    }
    ul.nav1 li {
        display: block !important;
        margin-right: 0 !important;
    }
    ul.nav1 li a {
        color: #fff !important;
        display: block;
    }

    /* Account / Login sub-menu opens inline inside the menu */
    ul.nav1 .dropdown-content {
        position: static !important;
        margin: 0 !important;
        min-width: 0 !important;
        border-radius: 0 !important;
        background-color: rgba(255, 255, 255, 0.08) !important;
    }
    ul.nav1 .dropdown-content a {
        font-weight: normal;
    }
}
