/* ================================================================
   MOBILE & RESPONSIVE STYLESHEET (RICOCHET DIAMOND)
   Dedicated styling for smartphones, tablets, touch devices & mobile HUD
   ================================================================ */

/* Touch-action and prevent unwanted gestures on mobile */
html, body {
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body.is-mobile {
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    margin: 0;
    justify-content: center;
}

/* ----------------------------------------------------------------
   1. RESPONSIVE CABINET & CANVAS SCALING
   Preserves crisp 900x600 (3:2) aspect ratio on any mobile viewport
   ---------------------------------------------------------------- */
@media (max-width: 960px), (max-height: 680px), (pointer: coarse) {
    body {
        padding: 4px 0;
        justify-content: center;
    }

    .arcade-cabinet {
        padding: 2px;
        width: 100vw;
        max-width: 100vw;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .crt-monitor {
        padding: 6px 8px 8px 8px;
        border-radius: 18px;
        box-shadow:
            0 0 0 1px #44474d,
            0 0 0 3px #18191b,
            0 8px 24px rgba(0, 0, 0, 0.9),
            inset 0 1px 2px rgba(255, 255, 255, 0.35);
        max-width: 98vw;
        max-height: calc(100vh - 36px);
        max-height: calc(100dvh - 36px);
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .crt-bezel {
        padding: 3px;
        border-radius: 14px;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .screen-frame {
        border-radius: 12px;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
    }

    canvas#game {
        width: min(96vw, calc((100vh - 65px) * 1.5)) !important;
        width: min(96vw, calc((100dvh - 65px) * 1.5)) !important;
        height: auto !important;
        aspect-ratio: 900 / 600;
        max-width: 900px;
        max-height: 600px;
        object-fit: contain;
        border-radius: 10px;
        touch-action: none; /* Crucial: gives pointer events directly to game without browser scroll interference */
    }

    .crt-scanlines {
        opacity: 0.55; /* Slightly lighter scanlines on dense mobile screens */
    }

    .crt-vignette {
        box-shadow:
            inset 0 0 35px rgba(0, 0, 0, 0.75),
            inset 0 0 15px rgba(0, 0, 0, 0.85);
    }

    .arcade-footer {
        gap: 6px 12px;
        padding: 3px 10px;
        font-size: 10px;
        flex-wrap: wrap;
        margin-top: 3px;
    }
}

/* On very small screens or landscape phones */
@media (max-height: 500px) {
    body {
        padding: 0;
    }

    .arcade-cabinet {
        padding: 0;
    }

    .crt-monitor {
        padding: 2px 4px;
        border-radius: 8px;
        max-height: 100vh;
        max-height: 100dvh;
        box-shadow: 0 0 10px rgba(0,0,0,0.8);
    }

    .crt-bezel {
        padding: 1px;
        border-radius: 6px;
    }

    .screen-frame {
        border-radius: 5px;
    }

    canvas#game {
        width: min(98vw, calc(96vh * 1.5)) !important;
        width: min(98vw, calc(96dvh * 1.5)) !important;
        max-height: 98vh;
        max-height: 98dvh;
        border-radius: 5px;
    }

    .arcade-footer {
        display: none; /* Hide footer in tight landscape to maximize game canvas */
    }
}

/* ----------------------------------------------------------------
   2. MOBILE FLOATING ACTION HUD
   Retro sci-fi touch buttons for Retry, Fire, Fullscreen & Audio
   ---------------------------------------------------------------- */
.mobile-action-bar {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: none; /* Revealed by mobile.js when on touch device / in-game */
    align-items: center;
    gap: 8px;
    background: rgba(10, 16, 28, 0.88);
    border: 1.5px solid rgba(0, 229, 255, 0.45);
    border-radius: 30px;
    padding: 6px 14px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.7),
        0 0 15px rgba(0, 229, 255, 0.25);
    z-index: 45;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mobile-action-bar.visible {
    display: flex;
}

.mobile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: rgba(18, 28, 48, 0.95);
    border: 1px solid rgba(85, 204, 255, 0.4);
    border-radius: 20px;
    color: #e0f2fe;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    padding: 7px 12px;
    min-height: 36px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.12s ease;
    touch-action: manipulation;
}

.mobile-btn:active {
    transform: scale(0.94);
    background: rgba(0, 229, 255, 0.25);
    border-color: #00e5ff;
}

.mobile-btn-icon {
    font-size: 13px;
    line-height: 1;
}

/* Highlighted Fire Button */
.mobile-btn-fire {
    background: linear-gradient(135deg, #be185d 0%, #e11d48 100%);
    border-color: #fb7185;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(225, 29, 72, 0.5);
    padding: 7px 16px;
    font-weight: 800;
}

.mobile-btn-fire:active {
    background: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%);
    box-shadow: 0 0 16px rgba(244, 63, 94, 0.8);
}

/* ----------------------------------------------------------------
   3. SMART ORIENTATION HELPER BANNER
   Sleek sci-fi recommendation when held in portrait
   ---------------------------------------------------------------- */
.mobile-orientation-banner {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 10px;
    background: rgba(14, 22, 38, 0.94);
    border: 1.5px solid rgba(0, 229, 255, 0.6);
    border-radius: 24px;
    padding: 6px 14px 6px 12px;
    box-shadow:
        0 4px 18px rgba(0, 0, 0, 0.8),
        0 0 14px rgba(0, 229, 255, 0.35);
    z-index: 60;
    color: #e0f2fe;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.4px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeInDown 0.3s ease-out;
}

.mobile-orientation-banner.visible {
    display: flex;
}

.mobile-rotate-icon {
    font-size: 15px;
    display: inline-block;
    animation: rotateHint 2.4s infinite ease-in-out;
}

@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
}

.mobile-banner-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 4px;
    margin-left: 4px;
    line-height: 1;
}

.mobile-banner-close:active {
    color: #ffffff;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate(-50%, -15px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ----------------------------------------------------------------
   4. RESPONSIVE MODAL ADAPTATIONS FOR MOBILE
   Stacked columns, enlarged touch targets, smooth scrolling
   ---------------------------------------------------------------- */
#diamond-modal.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
}

@media (max-width: 680px) {
    #diamond-modal.modal-overlay {
        padding: 8px;
        align-items: center;
    }

    .diamond-modal-card {
        width: 96vw;
        max-width: 440px;
        max-height: 94vh;
        max-height: 94dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px 12px 14px 12px;
        margin: auto;
    }

    .diamond-header-badge {
        margin-bottom: 2px;
    }

    .diamond-badge-text {
        font-size: 14.5px;
    }

    .diamond-gem-wrapper {
        margin: 2px auto;
    }

    .diamond-gem-svg {
        width: 30px;
        height: 25px;
    }

    .diamond-modal-title {
        font-size: 16px;
        margin: 0 0 2px 0;
    }

    .diamond-modal-subtitle {
        font-size: 11px;
        margin-bottom: 12px;
        line-height: 1.35;
        padding: 0 4px;
    }

    .diamond-columns-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0;
        margin-bottom: 6px;
    }

    .diamond-column {
        min-height: auto;
        padding: 12px 10px;
        background: rgba(14, 25, 45, 0.65);
        border: 1px solid rgba(85, 204, 255, 0.25);
        border-radius: 12px;
    }

    .diamond-column-icon {
        height: 32px;
        margin-bottom: 6px;
    }

    .neon-gamepad-svg {
        width: 36px;
        height: 26px;
    }

    .neon-tv-svg {
        width: 34px;
        height: 28px;
    }

    .diamond-column-title {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .diamond-ad-slot-wrapper {
        margin-top: 2px;
        margin-bottom: 8px;
    }

    .ad-slot-header-label,
    .ad-slot-footer-label {
        font-size: 9.5px;
    }

    .ad-placement-slot {
        max-width: 100%;
        padding: 6px 10px;
    }

    .ad-preview-text {
        font-size: 10.5px;
        white-space: normal;
        text-align: center;
    }

    .diamond-primary-btn {
        max-width: 100%;
    }

    .diamond-btn {
        width: 100%;
        min-height: 44px;
        padding: 10px 14px;
        font-size: 12px;
        touch-action: manipulation;
    }

    .diamond-modal-footer {
        flex-direction: column;
        gap: 8px;
        margin-top: 8px;
        padding-top: 8px;
    }

    .current-pts-badge {
        font-size: 12px;
        text-align: center;
    }

    .diamond-close-btn {
        width: 100%;
        min-height: 42px;
    }

    /* Nickname Modal on Mobile */
    .modal-card {
        width: 92vw;
        max-width: 92vw;
        padding: 22px 16px;
    }

    .modal-card h2 {
        font-size: 16px;
    }

    .modal-card p {
        font-size: 12px;
        line-height: 1.4;
    }

    #nickname-input {
        font-size: 16px; /* Prevents auto-zoom in iOS Safari */
        min-height: 44px;
        padding: 10px 14px;
    }

    #nickname-submit {
        min-height: 44px;
        font-size: 13px;
    }

    /* Privacy Modal on Mobile */
    .privacy-modal-card {
        width: 95vw;
        max-width: 95vw;
        max-height: 88vh;
        max-height: 88dvh;
        padding: 18px 14px;
    }

    .privacy-modal-card h2 {
        font-size: 16px;
    }

    .privacy-modal-content {
        max-height: 55vh;
        font-size: 11.5px;
        padding-right: 4px;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .policy-link-btn, .modal-close-btn {
        width: 100%;
        text-align: center;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Landscape Phone Adaptation for Modals */
@media (max-height: 520px) {
    #diamond-modal.modal-overlay,
    #privacy-modal.modal-overlay,
    #nickname-modal.modal-overlay {
        padding: 6px;
        align-items: center;
    }

    .diamond-modal-card {
        width: 96vw;
        max-width: 620px;
        max-height: 96vh;
        max-height: 96dvh;
        padding: 10px 14px 8px 14px;
        margin: auto;
    }

    .diamond-header-badge {
        display: none;
    }

    .diamond-gem-wrapper {
        display: none;
    }

    .diamond-modal-title {
        font-size: 15px;
        margin: 0;
    }

    .diamond-modal-subtitle {
        font-size: 10px;
        margin-bottom: 6px;
    }

    .diamond-columns-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 4px;
        padding: 0;
    }

    .diamond-column {
        min-height: auto;
        padding: 8px;
    }

    .diamond-column-icon {
        height: 24px;
        margin-bottom: 2px;
    }

    .neon-gamepad-svg,
    .neon-tv-svg {
        height: 22px;
        width: 30px;
    }

    .diamond-column-title {
        font-size: 10.5px;
        margin-bottom: 4px;
    }

    .diamond-ad-slot-wrapper {
        margin: 2px 0 4px 0;
    }

    .ad-placement-slot {
        height: 26px;
        padding: 2px 6px;
    }

    .ad-preview-text {
        font-size: 9.5px;
    }

    .ad-slot-header-label,
    .ad-slot-footer-label {
        font-size: 8px;
        margin: 1px 0;
    }

    .diamond-btn {
        min-height: 34px;
        padding: 6px 8px;
        font-size: 10.5px;
    }

    .diamond-modal-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-top: 6px;
        padding-top: 6px;
    }

    .current-pts-badge {
        font-size: 11px;
    }

    .diamond-close-btn {
        width: auto;
        min-height: 30px;
        padding: 4px 14px;
    }
}

/* ----------------------------------------------------------------
   5. VISUAL TOUCH AIM RETICLE
   Renders a subtle glowing reticle under finger during touch aiming
   ---------------------------------------------------------------- */
.touch-aim-reticle {
    position: fixed;
    width: 48px;
    height: 48px;
    border: 2px solid #00e5ff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 40;
    opacity: 0;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
    transition: opacity 0.15s ease;
}

.touch-aim-reticle.active {
    opacity: 0.85;
}

.touch-aim-reticle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    background: #ffffff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px #00e5ff;
}
