/* Каркас: сайдбар (десктоп) и нижние вкладки (Telegram / телефон) */

.app {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
}

/* ------------------------------------------------------------- сайдбар */

.sidebar {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 16px 14px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100dvh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 19px;
    font-weight: 900;
    padding: 6px 8px 14px;
    letter-spacing: -.02em;
}

.brand span {
    font-size: 22px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    border-radius: 13px;
    font-weight: 700;
    font-size: 14.5px;
    color: var(--text-2);
    transition: background .15s ease, color .15s ease;
    text-align: left;
}

.nav-item .nav-ico {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.nav-item:hover {
    background: var(--panel-2);
}

.nav-item.active {
    background: var(--green-soft);
    color: #3B7C24;
}

:root[data-theme="dark"] .nav-item.active {
    color: #9BD87A;
}

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: grid;
    place-items: center;
}

.sidebar-player {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px;
    border-radius: 16px;
    background: var(--panel-2);
    border: 1px solid var(--line-soft);
}

.sidebar-player .avatar {
    width: 40px;
    height: 40px;
    flex: none;
}

.sidebar-player .sp-name {
    font-weight: 800;
    font-size: 14px;
    line-height: 1.2;
}

.sidebar-player .sp-level {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
}

.sidebar-player .sp-body {
    min-width: 0;
    flex: 1;
}

.sidebar-player .bar {
    height: 8px;
}

.sp-xp {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--muted);
    margin-top: 3px;
}

/* -------------------------------------------------------------- верх */

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
    min-height: var(--header-h);
    background: color-mix(in srgb, var(--panel) 82%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line-soft);
}

.res {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 6px 8px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--line);
    font-weight: 800;
    font-size: 13.5px;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.res i {
    font-style: normal;
    font-size: 15px;
    line-height: 1;
}

.res.coins { color: #A97A12; }
.res.gems { color: #1D7FA8; }
.res.energy { color: #4E8A2C; }

:root[data-theme="dark"] .res.coins { color: #F2C33F; }
:root[data-theme="dark"] .res.gems { color: #7FD6F5; }
:root[data-theme="dark"] .res.energy { color: #9BD87A; }

.res .res-add {
    margin-left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--green);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    display: grid;
    place-items: center;
    line-height: 1;
}

.res-value.bump {
    animation: bump .35s ease;
}

@keyframes bump {
    40% { transform: scale(1.28); }
}

.content {
    flex: 1;
    padding: 14px;
    padding-bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom));
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
}

/* ------------------------------------------------------- нижние вкладки */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    position: relative;
    transition: color .15s ease;
}

.tab .tab-ico {
    font-size: 21px;
    line-height: 1;
    transition: transform .18s ease;
}

.tab.active {
    color: #3B7C24;
}

:root[data-theme="dark"] .tab.active {
    color: #9BD87A;
}

.tab.active .tab-ico {
    transform: translateY(-2px) scale(1.08);
}

.tab .dot {
    position: absolute;
    top: 8px;
    right: calc(50% - 18px);
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--red);
    border: 2px solid var(--panel);
}

/* ------------------------------------------------------------ десктоп */

@media (min-width: 900px) {
    .app {
        grid-template-columns: var(--sidebar-w) 1fr;
    }

    .sidebar {
        display: flex;
    }

    .tabbar {
        display: none;
    }

    .content {
        padding: 20px 24px 40px;
    }

    .toast-host {
        bottom: 26px;
    }

    .topbar {
        padding: 12px 24px;
    }
}

/* Двухколоночная раскладка фермы на большом экране */
@media (min-width: 1000px) {
    .farm-layout {
        display: grid;
        grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
        gap: 18px;
        align-items: start;
    }
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}
