/* ===========================================
   📱 POKÉVAULT MOBILE STYLESHEET
   Separat fil for alle mobile-specifikke styles
   Kun indlæst på skærme under 768px
   =========================================== */

/* --- SAFE AREA FOR MODERN PHONES --- */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .controls-container {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* --- UNIVERSAL TOUCH FEEDBACK --- */
.btn-action,
.nav-btn,
.music-btn,
.set-btn,
.sidebar-card {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-action:active,
.nav-btn:active {
    transform: scale(0.95) !important;
    opacity: 0.9;
}

/* --- MINI STREAK INDICATOR (For Mobile Header) --- */
.mini-streak-mobile {
    display: none;
    align-items: center;
    gap: 6px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
    font-family: 'Righteous', sans-serif;
    transition: all 0.3s ease;
}

.mini-streak-mobile.on-fire {
    background: linear-gradient(135deg, rgba(255, 149, 0, 0.2), rgba(255, 217, 61, 0.2));
    border-color: #ffd93d;
    box-shadow: 0 0 15px rgba(255, 217, 61, 0.3);
}

.mini-streak-mobile .streak-num {
    font-size: 18px;
    color: #ef4444;
    min-width: 24px;
    text-align: center;
}

.mini-streak-mobile.on-fire .streak-num {
    color: #ffd93d;
    text-shadow: 0 0 10px #ffd93d;
}

.mini-streak-mobile .streak-icon {
    font-size: 16px;
}

/* --- MOBILE NEWS TICKER - DISABLED --- */
.mobile-news-bar {
    display: none !important;
}

/* --- MOBILE UPGRADES BAR --- */
.mobile-upgrades-bar {
    display: none;
}

/* --- MOBILE BOTTOM NAVIGATION BAR --- */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(180deg, rgba(18, 18, 42, 0.95), rgba(10, 10, 26, 0.98));
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #aaa;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
}

.mobile-nav-btn span {
    font-size: 22px;
    margin-bottom: 2px;
}

.mobile-nav-btn small {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-nav-btn:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
}

.mobile-nav-btn.active {
    color: var(--accent-yellow);
}

/* Sidebar Toggle Button (visible only on mobile) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 10px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: rgba(18, 18, 42, 0.9);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.sidebar-toggle.left {
    left: 10px;
}

.sidebar-toggle.right {
    right: 10px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 998;
}

.sidebar-overlay.active {
    display: block;
}

/* Mobile More Menu Popup */
.mobile-more-menu {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 10px;
    background: rgba(18, 18, 42, 0.98);
    backdrop-filter: blur(15px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    z-index: 1001;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.5);
    min-width: 160px;
}

.mobile-more-menu.open {
    display: flex;
    animation: mobileSlideUp 0.2s ease;
}

@keyframes mobileSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-more-menu button {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.mobile-more-menu button:hover,
.mobile-more-menu button:active {
    background: rgba(255, 255, 255, 0.15);
}

/* ===========================================
   📱 MOBILE BREAKPOINT (<768px)
   =========================================== */
@media (max-width: 767px) {

    /* --- MOBILE UPGRADES BAR --- */
    .mobile-upgrades-bar {
        display: block;
        margin: 0 -10px;
        padding: 10px 0;
        background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.3));
    }

    .mobile-upgrades-scroll {
        display: flex;
        gap: 8px;
        padding: 0 10px;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-upgrades-scroll::-webkit-scrollbar {
        display: none;
    }

    .mobile-upgrade-item {
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        background: var(--bg-card);
        border: 1px solid var(--border-subtle);
        border-radius: 10px;
        padding: 8px 12px;
        min-width: 65px;
        cursor: pointer;
        transition: all 0.2s;
    }

    .mobile-upgrade-item:active {
        transform: scale(0.95);
        background: var(--bg-hover);
    }

    .mobile-upgrade-item.affordable {
        border-color: var(--accent-green);
        background: rgba(74, 222, 128, 0.1);
    }

    .mobile-upgrade-item.locked {
        opacity: 0.5;
    }

    .mobile-up-icon {
        font-size: 18px;
    }

    .mobile-up-name {
        font-size: 10px;
        color: #aaa;
        font-weight: 600;
    }

    .mobile-up-price {
        font-size: 11px;
        color: #4ade80;
        font-family: 'Righteous', sans-serif;
    }

    .mobile-upgrade-item.locked .mobile-up-price {
        color: #ef4444;
    }

    /* --- GRUNDLÆGGENDE LAYOUT --- */
    body {
        padding-bottom: 20px;
    }

    .container {
        padding: 10px !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden;
    }

    /* Skjul sidebars */
    .unified-sidebar,
    .upgrade-sidebar {
        display: none !important;
    }

    /* --- HEADER REDESIGN --- */
    header {
        padding: 10px 0;
        gap: 10px;
    }

    .header-tools {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
        gap: 8px;
        margin-bottom: 0;
    }

    /* Skjul desktop news ticker, vis mobil version */
    .news-ticker-container {
        display: none !important;
    }

    .mobile-news-bar {
        display: block;
    }

    /* Vis mini streak i header */
    .mini-streak-mobile {
        display: flex !important;
    }

    .tools-left,
    .tools-right {
        display: flex;
        gap: 6px;
        flex-shrink: 0;
    }

    /* Mindre navigation knapper */
    .nav-btn,
    .music-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
        border-radius: 10px;
    }

    /* Skjul nogle knapper på mobil for at spare plads */
    .tools-right .nav-btn:nth-child(n+5) {
        display: none;
    }

    /* --- DASHBOARD REDESIGN --- */
    .merged-dashboard {
        flex-direction: column;
        background: transparent;
        border: none;
        gap: 8px;
        margin-bottom: 0;
    }

    .dashboard-left {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
        padding: 12px !important;
        background: var(--bg-elevated);
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.05);
    }

    .stat-box {
        text-align: center !important;
    }

    .stat-box h2 {
        font-size: 9px;
        margin-bottom: 2px;
    }

    .stat-value {
        font-size: 15px !important;
    }

    .dashboard-divider {
        display: none;
    }

    /* XP Bar - kompakt inline version */
    .xp-dashboard-integrated {
        display: flex !important;
        padding: 10px 12px !important;
        background: var(--bg-elevated);
        border-radius: 12px;
        border: 1px solid rgba(217, 70, 239, 0.2);
        gap: 10px;
    }

    .level-badge-mini {
        width: 36px;
        height: 36px;
    }

    .level-badge-mini span:last-child {
        font-size: 16px !important;
    }

    /* Skjul desktop streak, brug mini version i header */
    .dashboard-right {
        display: none !important;
    }

    /* --- GAME TITLE --- */
    .game-area {
        margin-top: 0 !important;
    }

    .game-title {
        font-size: 24px !important;
        margin: 0 0 2px 0 !important;
    }

    #set-info-text {
        font-size: 20px !important;
        margin-bottom: 0 !important;
        color: #666;
    }

    /* --- ROULETTE FULL-BLEED --- */
    .roulette-wrapper {
        width: 100vw !important;
        margin-left: -10px !important;
        margin-right: -10px !important;
        margin-top: 5px !important;
        margin-bottom: 10px !important;
        height: 200px !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }

    .roulette-card {
        width: 115px !important;
        height: 160px !important;
        margin: 0 4px !important;
    }

    .roulette-indicator::before,
    .roulette-indicator::after {
        font-size: 16px !important;
    }

    .card-price-tag {
        font-size: 10px;
        padding: 1px 4px;
    }

    /* --- CONTROLS REDESIGN --- */
    .controls-container {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 12px !important;
        margin-bottom: 15px !important;
        padding: 0 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Skjul manuel spin på mobil */
    #spin-btn {
        display: none !important;
    }

    /* Skjul sæt-knap på mobil */
    .controls-container>button[onclick="openSetMenu()"] {
        display: none !important;
    }

    /* Basis styling for alle knapper */
    .btn-action {
        height: 65px !important;
        font-size: 15px !important;
        border-radius: 14px !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        flex: none !important;
    }

    /* Auto og Turbo - hver 50% minus gap */
    .auto-btn,
    .turbo-btn {
        width: calc(50% - 6px) !important;
        flex: none !important;
    }

    /* Stop knap - 100% bredde */
    .stop-btn {
        width: 100% !important;
        flex: none !important;
    }

    /* Når STOP vises, skjul AUTO og TURBO via CSS */
    .controls-container:has(.stop-btn[style*="display: flex"]) .auto-btn,
    .controls-container:has(.stop-btn[style*="display: flex"]) .turbo-btn,
    .controls-container:has(.stop-btn[style*="display: block"]) .auto-btn,
    .controls-container:has(.stop-btn[style*="display: block"]) .turbo-btn {
        display: none !important;
    }

    /* --- MODALS FORBEDRING --- */
    .modal {
        padding: 15px;
        align-items: flex-end;
    }

    .modal-content {
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        padding: 20px 15px 30px 15px;
        width: 100%;
        max-width: 100%;
        animation: modalSlideUp 0.3s ease-out;
    }

    @keyframes modalSlideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* Modal close button - større touch target */
    .btn-close {
        padding: 14px 30px;
        font-size: 16px;
        min-height: 48px;
    }

    /* Winner modal */
    .winner-image {
        width: 200px;
    }

    /* Leaderboard tabel scroll */
    .leaderboard-table {
        font-size: 11px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 5px;
    }

    /* Shop grid */
    .shop-grid {
        gap: 6px;
    }

    /* Game Over modal */
    .gameover-popup {
        padding: 15px !important;
    }

    .gameover-popup h2 {
        font-size: 28px !important;
    }

    .go-stat-box {
        padding: 8px 5px;
    }

    .go-stat-value {
        font-size: 18px;
    }

    /* Achievements grid */
    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .ach-card {
        padding: 12px 8px;
    }

    /* Loot grid */
    .loot-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 8px;
    }

    /* --- MOBILE BOTTOM NAV --- */
    .mobile-bottom-nav {
        display: flex;
    }

    body {
        padding-bottom: 80px;
    }

    /* Hide desktop controls on mobile - use bottom nav instead */
    .controls-container {
        display: none !important;
    }

    /* Hide some desktop controls on mobile */
    .turbo-btn,
    .auto-btn,
    .stop-btn {
        display: none;
    }

    .game-header {
        flex-direction: column;
        gap: 5px;
        padding: 5px 0;
    }

    .game-title {
        font-size: 1.5rem;
        margin: 0;
    }

    .game-subtitle {
        font-size: 11px;
        margin: 0;
    }

    .spin-zone {
        padding: 10px 5px;
    }

    /* Kompakt header tools */
    .header-tools {
        flex-wrap: wrap;
        gap: 5px;
        padding: 5px;
    }

    .header-tools button {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Stats bar mere kompakt */
    .stats-dashboard {
        padding: 8px;
        gap: 5px;
        margin: 5px 0;
    }

    .stat-item {
        padding: 5px 8px;
    }

    /* XP bar mere kompakt */
    .xp-dashboard-integrated {
        padding: 5px 10px;
        margin: 5px 0;
    }

    /* Roulette tættere på */
    .roulette-window {
        margin: 5px 0;
    }

    /* Upgrade bar skjules - brugeren kan åbne shop */
    .mobile-upgrades-bar {
        display: none !important;
    }

    /* Pity bar kompakt */
    .pity-container {
        padding: 8px;
        margin: 5px 0 10px 0;
    }

    /* Game area - fjern tomt rum */
    .game-area {
        padding: 0 10px;
        margin: 0;
    }

    .game-area h1 {
        font-size: 1.5rem;
        margin: 10px 0 5px 0;
    }

    .game-area p {
        margin: 0 0 20px 0;
        font-size: 12px;
    }

    /* Roulette wrapper tættere */
    .roulette-wrapper {
        margin-top: 15px;
    }

    /* Skjul news bar på mobil */
    .mobile-news-bar {
        display: none;
    }

    /* Header mere kompakt */
    header {
        padding: 5px 0;
    }

    /* Better Touch Targets (fra index.html inline styles) */
    .nav-btn,
    .music-btn {
        width: 44px !important;
        height: 44px !important;
        font-size: 20px !important;
    }

    /* Full Width Modals at Bottom */
    .modal {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .modal-content {
        border-radius: 25px 25px 0 0 !important;
        padding-bottom: 40px !important;
        max-height: 90vh !important;
    }

    /* Larger Action Buttons */
    .btn-action {
        height: 70px !important;
        font-size: 18px !important;
    }

    /* Sell All Button Visibility */
    .btn-sell-all {
        width: 100%;
        justify-content: center;
        padding: 12px !important;
        margin-top: 10px;
    }

    /* Pity Bar Visibility */
    .pity-container {
        margin-bottom: 20px !important;
    }
}

/* ===========================================
   📱 EXTRA SMALL SCREENS (iPhone SE, etc.)
   =========================================== */
@media (max-width: 380px) {
    .container {
        padding: 8px !important;
    }

    .stat-value {
        font-size: 13px !important;
    }

    .game-title {
        font-size: 22px !important;
    }

    .roulette-wrapper {
        height: 170px !important;
    }

    .roulette-card {
        width: 95px !important;
        height: 132px !important;
    }

    .btn-action {
        height: 55px !important;
        font-size: 13px !important;
    }

    .nav-btn,
    .music-btn {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    .mini-streak-mobile {
        padding: 4px 8px;
    }

    .mini-streak-mobile .streak-num {
        font-size: 14px;
    }
}

/* ===========================================
   📱 SMALL MOBILE (480px)
   =========================================== */
@media (max-width: 480px) {
    .mobile-nav-btn {
        padding: 8px 12px;
    }

    .mobile-nav-btn span {
        font-size: 20px;
    }

    .roulette-container {
        height: 160px;
    }

    .roulette-card {
        width: 110px;
        height: 154px;
        margin: 0 4px;
    }

    .game-title {
        font-size: 1.3rem;
    }

    /* Skjul XP bar på meget små skærme */
    .xp-dashboard-integrated {
        display: none;
    }

    .stats-dashboard {
        font-size: 11px;
    }

    .stat-value {
        font-size: 14px;
    }

    /* Skjul header tools-right på mobil */
    .tools-right {
        display: none !important;
    }
}

/* ===========================================
   🔄 LANDSCAPE MOBILE FIX
   =========================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .roulette-wrapper {
        height: 150px !important;
        margin: 5px -10px !important;
    }

    .roulette-card {
        width: 90px !important;
        height: 125px !important;
    }

    .controls-container {
        margin-bottom: 10px !important;
    }

    .btn-action {
        height: 45px !important;
    }

    .modal-content {
        max-height: 95vh;
    }

    .dashboard-left {
        padding: 8px !important;
    }

    .game-title {
        display: none !important;
    }
}