/* =====================================================
   TERY: COLLAPSE
   LAYOUT
===================================================== */


/* =====================================================
   ROOT
===================================================== */

:root {
    --bg: #0b0e0f;

    --panel: rgba(16, 22, 24, 0.96);
    --panel-2: rgba(24, 30, 31, 0.96);

    --line: #394246;
    --line-soft: rgba(255,255,255,.08);

    --text: #e5e5df;
    --muted: #8d9493;

    --accent: #d87522;
    --accent-2: #f19a37;

    --danger: #9f342a;

    --header-h: 58px;
    --nav-h: 70px;

    --map-system-safe:
        max(
            env(safe-area-inset-left),
            env(safe-area-inset-right)
        );

    --map-side-safe:
        max(
            28px,
            calc(
                var(--map-system-safe) + 14px
            )
        );
}


/* =====================================================
   RESET
===================================================== */

* {
    box-sizing: border-box;

    -webkit-tap-highlight-color:
        transparent;
}


html,
body {
    margin: 0;

    width: 100%;
    height: 100%;

    overflow: hidden;

    overscroll-behavior: none;

    background:
        var(--bg);

    color:
        var(--text);

    font-family:
        Arial,
        sans-serif;
}


body {
    position: fixed;

    inset: 0;

    touch-action: none;
}


button {
    font: inherit;

    color: inherit;
}


button:focus {
    outline: none;
}


/* =====================================================
   APP
===================================================== */

#app {
    position: fixed;

    inset: 0;

    display: flex;

    flex-direction: column;

    overflow: hidden;

    background:
        #0b0e0f;
}


/* =====================================================
   HEADER
===================================================== */

.game-header {
    height:
        calc(
            var(--header-h) +
            env(safe-area-inset-top)
        );

    min-height:
        calc(
            var(--header-h) +
            env(safe-area-inset-top)
        );

    padding:
        env(safe-area-inset-top)
        calc(
            10px +
            env(safe-area-inset-right)
        )
        0
        calc(
            12px +
            env(safe-area-inset-left)
        );

    display: grid;

    grid-template-columns:
        minmax(180px, 1fr)
        auto
        auto
        42px;

    align-items: center;

    gap: 10px;

    border-bottom:
        1px solid #3a3f3f;

    background:
        linear-gradient(
            180deg,
            #1a1f20 0%,
            #0f1314 100%
        );

    box-shadow:
        0 2px 10px
        rgba(0,0,0,.45);

    z-index: 100;

    flex-shrink: 0;
}


/* =====================================================
   BRAND
===================================================== */

.brand-block {
    min-width: 0;

    grid-column: 1;
}


.header-spacer {
    display: none;
}


.brand-title {
    font-weight: 900;

    font-size: 22px;

    letter-spacing: 1px;

    white-space: nowrap;

    text-shadow:
        0 2px 0 #000;

    color:
        var(--accent);
}


.brand-title span {
    color:
        #deded7;
}


.brand-status {
    margin-top: 2px;

    color:
        #707878;

    font-size: 8px;

    letter-spacing: 1.3px;

    text-transform: uppercase;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


/* =====================================================
   HEADER POPULATION
===================================================== */

.header-population {
    grid-column: 2;

    height: 38px;

    min-width: 118px;

    padding:
        0 13px;

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 7px;

    border:
        1px solid
        var(--line);

    border-radius: 4px;

    background:
        linear-gradient(
            180deg,
            #202728,
            #14191a
        );

    box-shadow:
        inset
        0 0 0 1px
        rgba(255,255,255,.025);

    font-size: 15px;
}


.header-population-icon {
    font-size: 17px;

    filter:
        grayscale(.4);
}


.population-slash {
    color:
        #717979;
}


/* =====================================================
   PLAYER BLOCK
===================================================== */

.player-block {
    grid-column: 3;

    min-width: 132px;

    height: 40px;

    display: flex;

    align-items: center;

    gap: 8px;

    padding:
        4px 9px;

    border-left:
        1px solid
        var(--line-soft);
}


.player-avatar {
    width: 32px;
    height: 32px;

    display: grid;

    place-items: center;

    border:
        1px solid #626767;

    background:
        #242a2b;

    border-radius: 3px;

    color:
        var(--accent);
}


.player-meta {
    min-width: 0;

    display: flex;

    flex-direction: column;
}


.player-meta strong {
    max-width: 110px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    font-size: 12px;
}


.player-meta small {
    margin-top: 2px;

    color:
        #707878;

    font-size: 8px;

    text-transform: uppercase;
}


/* =====================================================
   HEADER SETTINGS
===================================================== */

.header-settings {
    grid-column: 4;

    width: 36px;
    height: 36px;

    border:
        1px solid
        var(--line);

    border-radius: 4px;

    background:
        #202627;

    cursor: pointer;

    font-size: 18px;

    touch-action: manipulation;
}


.header-settings:active {
    background:
        #2a3031;
}


/* =====================================================
   GAME AREA
===================================================== */

.game-layout {
    position: relative;

    flex: 1;

    min-width: 0;
    min-height: 0;

    overflow: hidden;
}


.map-area {
    position: absolute;

    inset: 0;

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    touch-action: none;

    background:
        #090b0b;
}


.map-panel {
    position: absolute;

    inset: 0;

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    border: 0;

    background:
        #111;

    touch-action: none;
}


/* =====================================================
   BOTTOM NAVIGATION
===================================================== */

.bottom-navigation {
    height:
        calc(
            var(--nav-h) +
            env(safe-area-inset-bottom)
        );

    min-height:
        calc(
            var(--nav-h) +
            env(safe-area-inset-bottom)
        );

    padding:
        5px
        calc(
            8px +
            env(safe-area-inset-right)
        )
        env(safe-area-inset-bottom)
        calc(
            8px +
            env(safe-area-inset-left)
        );

    display:
        flex !important;

    flex-wrap:
        nowrap;

    align-items:
        stretch;

    gap: 4px;

    border-top:
        1px solid
        #3c4142;

    background:
        linear-gradient(
            180deg,
            #171c1d,
            #0c1011
        );

    box-shadow:
        0 -3px 12px
        rgba(0,0,0,.5);

    z-index: 120;

    flex-shrink: 0;

    touch-action:
        manipulation;
}


/* =====================================================
   NAV BUTTON
===================================================== */

.nav-button {
    position: relative;

    flex:
        1 1 0;

    min-width: 0;

    min-height: 54px;

    padding:
        4px 3px;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    gap: 3px;

    border:
        1px solid transparent;

    border-radius: 4px;

    background:
        transparent;

    color:
        #a5aaaa;

    cursor: pointer;

    font-size: 9px;

    line-height: 1;

    touch-action:
        manipulation;
}


.nav-button .nav-icon {
    font-size: 20px;

    line-height: 1;

    color:
        #b9bdbd;
}


.nav-badge {
    position: absolute;

    top: 3px;

    right:
        calc(
            50% - 24px
        );

    min-width: 16px;

    height: 16px;

    padding:
        0 4px;

    display: grid;

    place-items: center;

    border:
        1px solid #66523d;

    border-radius: 9px;

    background:
        #181d1e;

    color:
        #d7a060;

    font-size: 8px;

    line-height: 1;
}


.nav-button.active {
    border-color:
        #8d541f;

    background:
        linear-gradient(
            180deg,
            rgba(121,66,20,.34),
            rgba(68,38,15,.28)
        );

    color:
        #f0a148;

    box-shadow:
        inset
        0 0 12px
        rgba(216,117,34,.12);
}


.nav-button.active
.nav-icon {
    color:
        #f0a148;
}


.nav-button:active {
    transform:
        translateY(1px);
}


/* =====================================================
   OLD / UNUSED UI
===================================================== */

.left-sidebar,
.right-sidebar,
.game-menu,
.menu-overlay,
.menu-toggle {
    display:
        none !important;
}


.panel {
    margin: 0;

    padding: 0;

    background:
        transparent;

    border: 0;
}


body::before {
    display:
        none !important;

    content:
        none !important;
}


/* =====================================================
   ANDROID / MOBILE
===================================================== */

@media (max-width: 900px) {

    :root {
        --header-h: 52px;
        --nav-h: 62px;

        --android-side-safe: 20px;

        --map-side-safe:
            max(
                28px,
                calc(
                    var(--map-system-safe) + 14px
                )
            );
    }


    .game-header {
        grid-template-columns:
            minmax(126px, 1fr)
            auto
            auto
            34px;

        gap: 6px;

        padding-left:
            calc(
                14px +
                env(safe-area-inset-left)
            );

        /*
         * Оставляем справа место под Telegram UI.
         */
        padding-right:
            calc(
                126px +
                env(safe-area-inset-right)
            );
    }


    .brand-title {
        font-size: 16px;
    }


    .brand-status {
        display: none;
    }


    .header-population {
        min-width: 86px;

        height: 32px;

        padding:
            0 8px;

        font-size: 12px;
    }


    .header-population-icon {
        font-size: 14px;
    }


    .player-block {
        min-width: 100px;

        height: 34px;

        padding:
            2px 5px;

        gap: 5px;
    }


    .player-avatar {
        width: 28px;

        height: 28px;
    }


    .player-meta strong {
        max-width: 76px;

        font-size: 10px;
    }


    .player-meta small {
        display: none;
    }


    .header-settings {
        width: 30px;

        height: 30px;

        font-size: 15px;

        flex-shrink: 0;
    }


    .bottom-navigation {
        gap: 3px;

        padding-top: 5px;

        padding-left:
            calc(
                14px +
                env(safe-area-inset-left)
            );

        padding-right:
            calc(
                14px +
                env(safe-area-inset-right)
            );

        padding-bottom:
            max(
                4px,
                env(safe-area-inset-bottom)
            );
    }


    .nav-button {
        min-height: 48px;

        padding:
            4px 3px;

        font-size: 8px;

        gap: 2px;
    }


    .nav-button .nav-icon {
        font-size: 18px;
    }


    .nav-badge {
        top: 2px;

        min-width: 17px;

        height: 17px;

        font-size: 8px;
    }
}


/* =====================================================
   SHORT LANDSCAPE
===================================================== */

@media (max-height: 430px) {

    :root {
        --header-h: 44px;
        --nav-h: 52px;
    }


    .brand-title {
        font-size: 14px;
    }


    .header-population {
        height: 29px;
    }


    .player-block {
        height: 30px;
    }


    .player-avatar {
        width: 25px;
        height: 25px;
    }


    .header-settings {
        width: 28px;
        height: 28px;
    }


    .nav-button {
        min-height: 40px;
    }


    .nav-button .nav-icon {
        font-size: 15px;
    }
}


/* =====================================================
   VERY NARROW LANDSCAPE
===================================================== */

@media
(
    max-width: 700px
)
and
(
    orientation: landscape
) {

    .game-header {
        grid-template-columns:
            minmax(110px, 1fr)
            auto
            auto
            32px;

        gap: 4px;

        padding-left:
            calc(
                10px +
                env(safe-area-inset-left)
            );

        padding-right:
            calc(
                108px +
                env(safe-area-inset-right)
            );
    }


    .brand-title {
        font-size: 13px;
    }


    .header-population {
        min-width: 76px;

        padding:
            0 6px;

        font-size: 11px;
    }


    .player-block {
        min-width: 88px;
    }


    .player-meta strong {
        max-width: 62px;

        font-size: 9px;
    }


    .bottom-navigation {
        padding-left:
            calc(
                10px +
                env(safe-area-inset-left)
            );

        padding-right:
            calc(
                10px +
                env(safe-area-inset-right)
            );
    }


    .nav-button {
        font-size: 7px;
    }
}