/* ==================== RESPONSIVE STYLES ==================== */
/* Desktop-focused game - mobile shows gate, can browse menus/records */

/* ==================== MOBILE GATE ==================== */
/* Play button disabled on small screens / touch devices */

/* Play button needs position relative for the ? button */
#btn-new-game {
    position: relative;
}

/* Info button - hidden on desktop, shown on mobile */
.mobile-info-btn {
    display: none;
    position: absolute;
    right: -38px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: var(--bg-medium);
    border: 3px solid var(--border-color);
    color: var(--text-dim);
    font-family: var(--font-pixel);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow:
        inset -2px -2px 0 0 rgba(0,0,0,0.3),
        inset 2px 2px 0 0 rgba(255,255,255,0.1),
        0 2px 4px rgba(0,0,0,0.3);
}

.mobile-info-btn:hover {
    background: var(--bg-light);
    color: var(--text-primary);
    border-color: var(--gold);
}

.mobile-info-btn:active {
    transform: translateY(-50%) scale(0.95);
    box-shadow:
        inset 2px 2px 0 0 rgba(0,0,0,0.3),
        inset -2px -2px 0 0 rgba(255,255,255,0.1);
}

/* Mobile info popup - matches existing modal styling */
.mobile-info-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modal-fade-in 0.2s ease;
}

.mobile-info-popup.hidden {
    display: none;
}

.mobile-info-content {
    background: var(--bg-medium);
    max-width: min(360px, 90vw);
    width: 100%;
    text-align: center;
    box-shadow:
        inset -4px -4px 0 0 #0a0a0f,
        inset 4px 4px 0 0 #2a2a3a,
        0 0 0 4px var(--gold),
        8px 8px 0 0 rgba(0, 0, 0, 0.5),
        0 0 60px rgba(255, 215, 0, 0.15);
}

/* Popup header */
.mobile-info-content h3 {
    font-family: var(--font-pixel);
    font-size: clamp(10px, 1.5vh, 14px);
    color: var(--gold);
    letter-spacing: 2px;
    margin: 0;
    padding: var(--gap-md) var(--gap-lg);
    border-bottom: 3px solid var(--border-color);
    text-shadow: 2px 2px 0 #8B4513;
    text-transform: uppercase;
}

/* Popup body */
.mobile-info-content p {
    font-family: var(--font-body);
    font-size: clamp(12px, 1.8vh, 16px);
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
    padding: var(--gap-sm) var(--gap-lg);
}

.mobile-info-content p:first-of-type {
    padding-top: var(--gap-md);
}

.mobile-info-content p:last-of-type {
    padding-bottom: var(--gap-md);
}

/* Popup footer with button */
.mobile-info-content .crt-button {
    margin: var(--gap-sm) var(--gap-lg) var(--gap-lg);
    min-width: 120px;
}

/* ==================== MOBILE DETECTION ==================== */
/* Show gate on small screens OR touch-only devices */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
    /* Show the info button */
    .mobile-info-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Disable and gray out the play button */
    #btn-new-game {
        opacity: 0.4;
        pointer-events: none;
        filter: grayscale(0.6);
    }

    /* Hide keyboard hints on touch */
    .hotkey-bar,
    .hotkey-hint,
    .slot-hotkey {
        display: none !important;
    }
}

/* ==================== BASIC LAYOUT FOR MENU BROWSING ==================== */
/* Allow users to still see menus, records, how-to-play on mobile */

@media (max-width: 900px) {
    /* Menu adjustments */
    .game-title {
        font-size: clamp(20px, 7vw, 40px);
        letter-spacing: clamp(2px, 1vw, 6px);
    }

    .subtitle {
        font-size: clamp(10px, 3.5vw, 16px);
    }

    .menu-buttons .crt-button {
        min-width: clamp(140px, 50vw, 220px);
        font-size: clamp(10px, 3vw, 14px);
    }

    /* Mode selection */
    .mode-buttons {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
    }

    .mode-button {
        min-width: clamp(90px, 28vw, 140px);
        padding: 12px;
    }

    .mode-icon {
        width: clamp(24px, 7vw, 36px);
        height: clamp(24px, 7vw, 36px);
    }

    .mode-name {
        font-size: clamp(9px, 2.5vw, 13px);
    }

    .mode-desc {
        font-size: clamp(8px, 2vw, 11px);
    }

    /* Records screen - make it usable */
    .records-layout {
        padding: 16px;
    }

    .records-logo {
        font-size: clamp(16px, 5vw, 28px);
    }

    .records-tabs {
        flex-wrap: wrap;
        gap: 6px;
    }

    .records-tab {
        font-size: clamp(9px, 2.5vw, 12px);
        padding: 6px 10px;
    }

    .leaderboard-entry {
        grid-template-columns: 30px 1fr 70px;
        gap: 8px;
        padding: 8px;
        font-size: clamp(10px, 3vw, 13px);
    }

    .leaderboard-mode {
        display: none;
    }

    /* How to play */
    .howto-content {
        padding: 16px;
    }

    .howto-sections {
        grid-template-columns: 1fr;
    }

    .howto-section h3 {
        font-size: clamp(9px, 2.5vw, 12px);
    }

    .howto-section p,
    .howto-section li {
        font-size: clamp(11px, 3vw, 14px);
    }

    /* Settings */
    .settings-layout {
        padding: 16px;
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .setting-control {
        width: 100%;
    }

    /* Modals */
    .modal-content {
        max-width: 95vw;
        max-height: 90vh;
    }

    /* Buttons - touch-friendly */
    .crt-button {
        min-height: 42px;
    }
}

/* ==================== PREVENT OVERFLOW ==================== */
html, body {
    overscroll-behavior: none;
}

.crt-container {
    overscroll-behavior: contain;
}

/* Scrollable areas */
.records-content,
.howto-sections,
.help-content,
.settings-layout {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

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