/* Clash Arena - Responsive overrides only */

/* Global scroll fix - ensure all pages scroll on all devices */
html {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
}

body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: auto !important;
}

/* Prevent any page wrapper from blocking scroll */
body > .lobby-layout,
body > .shop-page,
body > .deck-page,
body > .friends-page,
body > .campaign-container {
    overflow: visible !important;
    height: auto !important;
    min-height: auto !important;
}

@media (max-width: 1024px) {
    html, body {
        overflow-x: hidden;
    }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .grid-4,
    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .lobby-layout {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
        min-height: auto;
    }

    .sidebar-left,
    .sidebar-right {
        display: none;
    }

    .main-content {
        max-width: 100%;
    }

    .mobile-header {
        display: block;
    }
}

@media (max-width: 768px) {
    html, body {
        overflow-y: auto !important;
        overflow-x: hidden;
    }

    body {
        -webkit-text-size-adjust: 100%;
        background-color: var(--bg-primary, #1a1a1b);
    }

    body.lobby-body {
        background-color: #1a1a1b;
        overflow-y: auto !important;
    }

    .btn,
    .btn-sm,
    .btn-lg,
    button,
    input,
    select,
    textarea,
    .nav-tab,
    .quick-action-btn,
    .action-btn,
    .friends-tab,
    .search-btn,
    .tier-btn,
    .btn-submit,
    .bottom-nav-item,
    .currency-add {
        min-height: 44px;
    }

    .form-input,
    input,
    select,
    textarea {
        font-size: 16px;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .modal,
    .overlay .modal,
    .modal-overlay .modal {
        width: 100%;
        max-width: 100%;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
    }

    .navbar {
        padding: 6px 10px;
        min-height: 48px;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    .navbar-nav .btn {
        padding: 6px 10px;
    }

    .bottom-nav {
        display: block;
    }

    body {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    .lobby-layout {
        display: flex;
        flex-direction: column;
        min-height: 0;
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    .main-content {
        flex: 1;
    }

    .quick-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .battle-card {
        padding: 12px 14px;
    }

    .battle-btn {
        width: 100%;
    }

    /* Daily rewards: prevent day 5 cutoff */
    .daily-rewards-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 6px;
        padding-bottom: 4px;
    }

    .daily-rewards-grid .reward-day {
        min-width: 56px;
        flex-shrink: 0;
    }

    /* Navbar: keep logout in header */
    .navbar-nav {
        align-items: center;
    }

    .navbar-nav .btn-danger {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .matchmaking-overlay,
    .campaign-overlay,
    .game-result-overlay,
    .profile-overlay,
    .ad-overlay,
    .modal-overlay {
        padding: 0;
    }

    .matchmaking-content,
    .campaign-overlay-content,
    .profile-modal,
    .ad-container {
        width: 100%;
        max-width: 100%;
        max-height: 100dvh;
        border-radius: 0;
    }

    .admin-tabs {
        padding: 0 8px;
    }

    .admin-content {
        padding: 12px;
    }

    .admin-container .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-container .search-bar,
    .admin-container .action-row,
    .admin-container .tab-toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }

    .admin-container .search-bar input,
    .admin-container .search-bar .btn,
    .admin-container .action-row input,
    .admin-container .action-row select,
    .admin-container .action-row .btn {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .navbar-brand span:last-child {
        display: none;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .toast-container {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .toast {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 390px) {
    .container {
        padding-left: 0.625rem;
        padding-right: 0.625rem;
    }

    .navbar {
        padding: 6px 8px;
    }

    .bottom-nav-item {
        font-size: 0.5rem;
        min-width: 44px;
        padding: 4px 2px;
    }

    .bottom-nav-icon {
        font-size: 1rem;
    }

    .lobby-layout {
        padding: 10px;
    }

    .battle-card,
    .section-card,
    .glass-card {
        border-radius: 12px;
    }
}

@media (max-width: 360px) {
    .navbar {
        padding: 6px;
    }

    .btn,
    .btn-sm,
    .btn-lg {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .bottom-nav-item {
        min-width: 42px;
    }

    .lobby-layout {
        padding: 8px;
    }
}

@media (display-mode: standalone), (display-mode: fullscreen) {
    .pwa-install-banner {
        display: none !important;
    }
}
