/* Mobile game shell — two-level header (58px brand bar + 48px resource strip) */

@media (max-width: 767.98px) {
    :root {
        --topbar-h: 58px;
        --mobile-header-h: 58px;
        --mobile-resource-h: 48px;
        --mobile-header-total: calc(var(--mobile-header-h) + var(--mobile-resource-h) + var(--safe-top));
    }

    .main-content-area {
        padding-top: 0 !important;
    }

    .layout-pc .main-content-below-bars {
        margin-top: var(--mobile-header-total) !important;
        padding: var(--s-3) var(--s-3) var(--s-4) !important;
    }

    .global-deployments-bar {
        top: var(--mobile-header-total) !important;
    }
}

/* ── Top brand bar (58px) ── */
.cg-top-bar-mobile {
    box-sizing: border-box;
    height: calc(var(--mobile-header-h, 58px) + var(--safe-top));
    min-height: calc(var(--mobile-header-h, 58px) + var(--safe-top));
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--s-2);
    padding: 0 var(--s-3);
    padding-top: var(--safe-top);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 32;
    background: linear-gradient(180deg, #1a2330 0%, #131a22 100%);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: var(--sh-2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.cg-mobile-menu-btn {
    grid-column: 1;
}

.cg-mobile-brand {
    grid-column: 2;
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-width: 0;
    text-decoration: none;
    color: var(--text-primary);
}

.cg-mobile-brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.cg-mobile-brand-name {
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
}

.cg-mobile-header-actions {
    grid-column: 3;
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    flex-shrink: 0;
}

.cg-mobile-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(0, 0, 0, 0.12) 100%);
    color: var(--text-secondary);
    box-shadow: var(--sh-1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.cg-mobile-icon-btn:hover,
.cg-mobile-icon-btn[aria-expanded="true"] {
    color: var(--accent-primary);
    border-color: color-mix(in srgb, var(--accent-primary) 35%, var(--border-subtle));
    background: linear-gradient(180deg, rgba(214, 168, 9, 0.1) 0%, rgba(0, 0, 0, 0.15) 100%);
}

.cg-mobile-icon-btn .bi {
    font-size: 1.15rem;
}

.cg-top-bar-mobile .notification-bell-btn {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(0, 0, 0, 0.12) 100%);
    border: 1px solid var(--border-subtle);
    padding: 0;
}

.cg-mobile-profile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--accent-primary) 30%, var(--border-subtle));
    border-radius: 0;
    background: linear-gradient(180deg, #243040 0%, #1a2330 100%);
    box-shadow: var(--sh-1), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    cursor: pointer;
    overflow: hidden;
    text-decoration: none;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.cg-mobile-profile-btn:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-primary) 25%, transparent), var(--sh-1);
}

.cg-mobile-profile-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cg-mobile-profile-initial {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--accent-primary);
}

.cg-mobile-notification-dropdown {
    position: fixed;
    top: calc(var(--mobile-header-h, 58px) + var(--safe-top) + var(--s-2));
    left: var(--s-3);
    right: var(--s-3);
    width: auto;
    max-width: none;
}

/* ── Resource strip (48px) ── */
.cg-resource-strip {
    height: var(--mobile-resource-h, 48px);
    min-height: var(--mobile-resource-h, 48px);
    padding: 0;
    position: fixed;
    top: calc(var(--mobile-header-h, 58px) + var(--safe-top));
    left: 0;
    right: 0;
    z-index: 29;
    background: linear-gradient(180deg, #151c26 0%, #0f141c 100%);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: var(--sh-1), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    transition: transform var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease);
}

@media (max-width: 767.98px) {
    .battle-top-bar.cg-resource-strip.top-bar-pc {
        position: fixed !important;
        top: calc(var(--mobile-header-h) + var(--safe-top)) !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: var(--mobile-resource-h) !important;
        min-height: var(--mobile-resource-h) !important;
        padding: 0 !important;
        backdrop-filter: none;
        box-shadow: var(--sh-1), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    }

    .cg-resource-strip .battle-top-bar-center,
    .cg-resource-strip .cg-resource-pills {
        flex: 1;
        width: 100%;
        max-width: 100%;
        height: 100%;
        margin: 0;
        padding: 0 var(--s-3);
        gap: var(--s-2);
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        mask-image: linear-gradient(to right, transparent, black 12px, black calc(100% - 12px), transparent);
    }

    .cg-resource-strip .battle-top-bar-center::-webkit-scrollbar,
    .cg-resource-strip .cg-resource-pills::-webkit-scrollbar {
        display: none;
    }

    .cg-resource-strip .cg-resource-pill {
        scroll-snap-align: start;
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        height: 32px;
        padding: 0 10px;
        border-radius: var(--r-sm);
        border: 1px solid var(--border-subtle);
        background: linear-gradient(180deg, #1e2836 0%, #151c26 100%);
        box-shadow: var(--sh-1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
        font-family: var(--font-mono);
        font-size: var(--fs-xs);
        font-weight: 600;
        color: var(--text-primary);
        white-space: nowrap;
        cursor: default;
    }

    .cg-resource-strip .cg-resource-pill .battle-resource-icon,
    .cg-resource-strip .cg-resource-pill .rss-icon {
        filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.12)) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
    }

    .cg-resource-strip .cg-resource-pill.food {
        color: var(--res-food);
        border-color: color-mix(in srgb, var(--res-food) 25%, var(--border-subtle));
    }

    .cg-resource-strip .cg-resource-pill.ore {
        color: var(--res-ore);
        border-color: color-mix(in srgb, var(--res-ore) 25%, var(--border-subtle));
    }

    .cg-resource-strip .cg-resource-pill.wood {
        color: var(--res-wood);
        border-color: color-mix(in srgb, var(--res-wood) 25%, var(--border-subtle));
    }

    .cg-resource-strip .cg-resource-pill.oil,
    .cg-resource-strip .cg-resource-pill.energy {
        color: var(--res-petrol);
        border-color: color-mix(in srgb, var(--res-petrol) 25%, var(--border-subtle));
    }

    .cg-resource-pill-value {
        font-variant-numeric: tabular-nums;
        letter-spacing: 0.02em;
    }

    .cg-resource-strip.cg-resource-strip--hidden {
        transform: translateY(calc(-100% - var(--mobile-header-h, 58px)));
        opacity: 0;
        pointer-events: none;
    }
}

.battle-nav-icon .bi {
    font-size: 1.1rem;
    vertical-align: -0.125em;
    opacity: 0.92;
}

.cg-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--bottomnav-h) + var(--safe-bot));
    padding-bottom: var(--safe-bot);
    background: var(--bg-surface-2);
    border-top: 1px solid var(--border-subtle);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 40;
}

.cg-bottom-nav-item {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    font-size: var(--fs-xs);
}

.cg-bottom-nav-item.active,
.cg-bottom-nav-item:hover {
    color: var(--text-primary);
}

.cg-bottom-nav-item.active {
    color: var(--accent-primary);
}

.main-content-below-bars {
    padding-bottom: calc(var(--bottomnav-h) + var(--safe-bot) + var(--s-2));
}

.global-deployments-bar {
    max-height: 120px;
    overflow: auto;
}

.global-deployment-row {
    min-height: 34px;
}

@media (min-width: 768px) {
    .cg-top-bar-mobile {
        display: none !important;
    }

    .cg-bottom-nav {
        display: none !important;
    }

    .main-content-below-bars {
        padding-bottom: var(--s-2);
    }

    .cg-resource-strip {
        position: sticky;
        top: var(--topbar-h);
        height: auto;
        min-height: var(--topbar-h);
    }

    .cg-resource-strip.cg-resource-strip--hidden {
        transform: none;
        opacity: 1;
        pointer-events: auto;
    }
}
