/* =====================================================================
   Phone layout (≤ 760px). Loaded last, after style.css and site-fx.css.
   Navigation lives in the bottom bar (+ «Ещё» sheet); the header is one
   compact row: logo · online · search · account.
   ===================================================================== */

.m-more-sheet,
.m-more-backdrop,
.lang-pick {
    display: none;
}

@media (max-width: 760px) {
    html { -webkit-text-size-adjust: 100%; }

    body {
        padding-bottom: calc(68px + env(safe-area-inset-bottom));
    }

    /* ---------- header ---------- */
    header,
    .site-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: calc(10px + env(safe-area-inset-top)) 14px 6px;
    }

    .brand { gap: 10px; flex-shrink: 1; }
    .brand-logo {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }
    .brand h1 {
        font-size: 17px;
        line-height: 1;
        letter-spacing: .05em;
        margin: 0 0 15px;
    }

    /* online count sits under the wordmark instead of floating over it */
    .online-badge {
        position: absolute;
        top: calc(34px + env(safe-area-inset-top));
        left: 64px;
        right: auto;
        z-index: 5;
        padding: 0;
        gap: 6px;
        font-size: 11px;
        font-weight: 700;
        color: var(--text-muted);
        background: none;
        border: 0;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .online-badge::before { width: 6px; height: 6px; }
    .online-badge:hover { transform: none; box-shadow: none; }

    .auth-block {
        flex-wrap: nowrap;
        justify-content: flex-end;
        gap: 8px;
        min-height: 0;
        min-width: 0;
    }
    .auth-block > .lang-switch { display: none; }

    /* language: a bright chip in the header (flag-less globe + code) with a dropdown */
    .lang-pick {
        display: block;
        position: relative;
        flex-shrink: 0;
    }
    .lang-chip {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        height: 38px;
        padding: 0 11px 0 9px;
        border-radius: 10px;
        border: 1px solid rgba(129, 140, 248, .55);
        background: linear-gradient(135deg, rgba(99, 102, 241, .28), rgba(59, 130, 246, .16));
        color: #e0e7ff;
        font: inherit;
        font-size: 13px;
        font-weight: 800;
        letter-spacing: .04em;
        cursor: pointer;
        box-shadow: 0 0 0 0 rgba(99, 102, 241, .5), 0 4px 14px rgba(79, 70, 229, .25);
        -webkit-tap-highlight-color: transparent;
    }
    .lang-chip i,
    .lang-chip svg { width: 17px; height: 17px; }
    .lang-chip:active { transform: scale(.96); }
    body.lang-menu-open .lang-chip { border-color: #a5b4fc; }
    .lang-menu {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        z-index: 10002;
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 170px;
        padding: 6px;
        border-radius: 14px;
        background: #12151d;
        border: 1px solid rgba(255, 255, 255, .1);
        box-shadow: 0 18px 40px rgba(0, 0, 0, .6);
        opacity: 0;
        transform: translateY(-6px);
        pointer-events: none;
        transition: opacity .18s ease, transform .18s ease;
    }
    body.lang-menu-open .lang-menu {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }
    .lang-menu .lang-btn {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 11px 12px;
        border-radius: 10px;
        border: 0;
        background: none;
        color: var(--text-main);
        font: inherit;
        font-size: 14px;
        font-weight: 600;
        text-align: left;
        cursor: pointer;
    }
    .lang-menu .lang-btn b {
        min-width: 26px;
        font-size: 12px;
        color: var(--text-muted);
    }
    .lang-menu .lang-btn.active {
        background: rgba(99, 102, 241, .2);
        color: #fff;
    }
    .lang-menu .lang-btn.active b { color: #a5b4fc; }
    /* search moves into the «Ещё» sheet: the header keeps logo · language · account */
    .btn-cmd-palette { display: none; }
    .btn-auth .auth-long { display: none; }
    .btn-auth .auth-short { display: inline; }

    .btn-auth {
        padding: 9px 14px;
        font-size: 13px;
        border-radius: 10px;
        white-space: nowrap;
    }

    .user-profile {
        padding: 4px 10px 4px 4px;
        gap: 8px;
        min-width: 0;
        max-width: 150px;
    }
    .user-profile .user-avatar { width: 30px; height: 30px; }
    .user-profile .user-name {
        font-size: 13px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }
    .user-profile .rank-badge { display: none !important; }

    /* ---------- page frame ---------- */
    .main-nav { display: none !important; }

    main {
        padding: 8px 12px 24px;
        gap: 16px;
    }

    .block-section {
        padding: 18px 14px;
        border-radius: 16px;
    }

    footer { display: none; }

    /* ---------- bottom bar ---------- */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: rgba(12, 14, 20, 0.92);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        justify-content: space-around;
        box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.5);
    }
    .mobile-nav-btn {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        min-width: 0;
        background: none;
        border: none;
        color: var(--text-muted);
        text-decoration: none;
        font: inherit;
        font-size: 10.5px;
        font-weight: 600;
        padding: 6px 2px;
        border-radius: 10px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: color .2s ease, background .2s ease;
    }
    .mobile-nav-btn span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .mobile-nav-btn i,
    .mobile-nav-btn svg { width: 20px; height: 20px; }
    .mobile-nav-btn.active { color: #a5b4fc; }
    .mobile-nav-btn.active i,
    .mobile-nav-btn.active svg { filter: drop-shadow(0 0 8px rgba(99, 102, 241, .7)); }
    .mobile-nav-btn:active { background: rgba(255, 255, 255, .06); }

    /* ---------- «Ещё» sheet ---------- */
    .m-more-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 10000;
        background: rgba(0, 0, 0, .55);
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }
    .m-more-sheet {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10001;
        max-height: 85dvh;
        overflow-y: auto;
        padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
        border-radius: 20px 20px 0 0;
        background: #10131a;
        border-top: 1px solid rgba(255, 255, 255, .1);
        box-shadow: 0 -20px 50px rgba(0, 0, 0, .6);
        transform: translateY(105%);
        transition: transform .3s cubic-bezier(.2, .8, .2, 1);
    }
    body.m-more-open .m-more-backdrop { opacity: 1; pointer-events: auto; }
    body.m-more-open .m-more-sheet { transform: none; }
    body.m-more-open { overflow: hidden; }
    /* modals (order, payment) sit above everything — the bottom bar would cover their buttons */
    body:has(.modal-overlay.open) .mobile-bottom-nav { display: none; }

    .m-more-grip {
        width: 40px;
        height: 4px;
        margin: 0 auto 14px;
        border-radius: 4px;
        background: rgba(255, 255, 255, .18);
    }
    .m-more-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }
    .m-more-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 76px;
        padding: 10px 6px;
        border-radius: 14px;
        background: rgba(255, 255, 255, .04);
        border: 1px solid rgba(255, 255, 255, .08);
        color: var(--text-main);
        text-decoration: none;
        font: inherit;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .m-more-item:active { background: rgba(255, 255, 255, .09); }
    .m-more-item i,
    .m-more-item svg { width: 22px; height: 22px; }
    .m-more-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-top: 14px;
        padding: 12px 14px;
        border-radius: 14px;
        background: rgba(255, 255, 255, .03);
        border: 1px solid rgba(255, 255, 255, .07);
        font-size: 14px;
        font-weight: 700;
    }
    .m-more-row .lang-switch { display: inline-flex; }
    .m-more-links {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px 16px;
        margin-top: 14px;
    }
    .m-more-links a {
        color: var(--text-muted);
        font-size: 12px;
        text-decoration: none;
    }

    /* ---------- home ---------- */
    .home-visit { padding: 20px 14px; }
    .home-visit-chips { gap: 6px; }

    /* ---------- tab strips scroll sideways instead of stacking ---------- */
    .mode-tabs {
        flex-direction: row !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        margin: 0 -14px;
        padding: 0 14px 4px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .mode-tabs::-webkit-scrollbar { display: none; }
    .mode-tab-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* grid items default to min-width:auto, so a long tab strip used to stretch the whole page */
    .store-shell,
    .wiki-shell,
    .profile-shell {
        grid-template-columns: minmax(0, 1fr);
    }
    .store-shell > *,
    .wiki-shell > *,
    .profile-shell > * { min-width: 0; }

    .store-rail-nav,
    .profile-nav {
        margin: 0 -10px;
        padding: 0 10px 2px;
    }
    .store-tab { min-width: 0; padding: 10px 12px; }

    /* ---------- profile ---------- */
    .profile-shell { gap: 12px; }
    .profile-aside { padding: 16px 12px; }
    .profile-skin-wrap { max-width: 140px; max-height: 170px; }
    .widgets-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .widget-box { padding: 14px 12px; min-width: 0; }
    .widget-val {
        font-size: clamp(18px, 6vw, 24px);
        overflow-wrap: anywhere;
    }
    .widget-box .btn-action {
        width: 100%;
        justify-content: center;
        padding-left: 8px;
        padding-right: 8px;
    }
    .season-banner { padding: 14px; }
    .season-banner .season-info { flex-wrap: wrap; }
    .season-timer-box {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 4px 10px;
    }
    .season-timer-box > * { white-space: nowrap; }
    .season-timer-val { font-size: 15px; }
    .season-badge { font-size: 15px; padding: 6px 12px; }

    /* ---------- generic overflow guards ---------- */
    img, video { max-width: 100%; }
    table { max-width: 100%; }
    .compare-table-wrap,
    .prime-matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .toast {
        bottom: calc(80px + env(safe-area-inset-bottom));
        left: 12px;
        right: 12px;
        max-width: none;
    }
}

@media (max-width: 380px) {
    .brand h1 { font-size: 15px; }
    .btn-auth { padding: 9px 10px; }
    .widgets-grid { grid-template-columns: 1fr; }
    .m-more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
