/* Compact themed navigation; mobile disclosure grows the header, never covers the view. */
#gameHeader {
    --navigation-fill: color-mix(in srgb, var(--panel) 82%, transparent);
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 0;
    background: var(--panel);
}
#gameHeader #menu {
    grid-column: 1;
    grid-row: 1;
}
#gameHeader #menu svg {
    display: block;
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
}
#gameHeader #menu .menu-legacy,
#gameHeader #navigationToggle .navigation-legacy {
    display: none;
}
#gameHeader.legacy-vitals #menu svg,
#gameHeader.legacy-vitals #navigationToggle svg:not(.navigation-legacy) {
    display: none;
}
#gameHeader.legacy-vitals #menu .menu-legacy {
    display: block;
    font-size: 30px;
    line-height: 1;
}
#gameHeader.legacy-vitals #navigationToggle .navigation-legacy {
    display: block;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}
#gameHeader #chatOnlineToggle {
    grid-column: 2;
    grid-row: 1;
}
#gameHeader #menu,
#gameHeader #chatOnlineToggle {
    border: 0;
    background: transparent;
    box-shadow: none;
}
#gameHeader #playerStatus {
    grid-column: 4;
    grid-row: 1;
    justify-content: flex-end;
}
#gameHeader #vitals {
    flex: 1 1 260px;
    width: 260px;
    max-width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    gap: 8px;
}
#gameHeader .vital .vital-meter {
    position: relative;
    display: grid;
    place-items: center;
    justify-content: center;
    width: 100%;
    height: 22px;
    overflow: hidden;
    border: 1px solid #263a30;
    border-radius: 4px;
    background: #24342e;
    isolation: isolate;
}
#gameHeader .vital-action {
    display: grid;
    align-items: center;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
}
#gameHeader .vital-action:disabled {
    opacity: 1;
}
#gameHeader .vital-action .vital {
    display: block;
    width: 100%;
}
#gameHeader .vital-fill {
    position: absolute;
    inset: 0;
    background: #983b3b;
    transform-origin: left;
    transition: transform 350ms linear;
    z-index: -1;
}
#gameHeader [data-vital='mana'] .vital-fill {
    background: #385f9a;
}
#gameHeader .vital b {
    display: block;
    max-width: 100%;
    color: #fff;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1;
}
#gameHeader .vital-legacy-icon {
    display: none;
}
#gameHeader .vital-legacy .vital-meter {
    display: flex;
    gap: 4px;
    border: 0;
    background: transparent;
    overflow: visible;
}
#gameHeader .vital-legacy .vital-fill {
    display: none;
}
#gameHeader .vital-legacy .vital-legacy-icon {
    display: inline;
    font-size: 17px;
    line-height: 1;
}
#gameHeader .vital-legacy b {
    color: inherit;
}
#gameHeader #close {
    grid-column: 5;
    grid-row: 1;
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 8px;
}
#close .chat-close-modern {
    display: block;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
#close .chat-close-legacy {
    display: none;
}
.legacy-vitals #close .chat-close-modern {
    display: none;
}
.legacy-vitals #close .chat-close-legacy {
    display: block;
    font-size: 24px;
    line-height: 1;
}
#navigationPanel {
    grid-column: 3;
    grid-row: 1;
}
#navigationToggle {
    display: none;
}
#tabs {
    padding: 0;
    gap: 6px;
    overflow: visible;
}
#tabs button {
    display: inline-flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: inherit;
    background: var(--navigation-fill);
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        transform 160ms ease;
}
#tabs button:hover,
#tabs button[aria-current='page'] {
    border-color: var(--muted);
    background: color-mix(in srgb, var(--muted) 10%, var(--panel));
}
#tabs button:active {
    transform: translateY(1px);
}
#tabs button[aria-current='page'] {
    display: none;
}
#tabs svg,
#gameHeader #close svg,
#navigationToggle svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#tabs svg {
    display: block;
    width: 30px;
    height: 30px;
}
#tabs .navigation-label {
    display: none;
}
/* Режимы верхнего меню из настроек: icons (по умолчанию), both, labels. */
#tabs[data-nav-display='both'] button,
#tabs[data-nav-display='labels'] button {
    flex: 0 1 auto;
}
#tabs[data-nav-display='both'] button {
    gap: 8px;
    padding: 6px 12px;
}
#tabs[data-nav-display='labels'] button {
    padding: 6px 14px;
}
#tabs[data-nav-display='both'] .navigation-label,
#tabs[data-nav-display='labels'] .navigation-label {
    display: inline;
}
#tabs[data-nav-display='both'] svg {
    width: 22px;
    height: 22px;
}
#tabs[data-nav-display='labels'] svg {
    display: none;
}
#navigationToggle:focus-visible,
#tabs button:focus-visible {
    outline: 2px solid var(--muted);
    outline-offset: 3px;
}
body.chat-open #navigationPanel,
body.chat-open #navigationToggle {
    display: none;
}
body.in-battle #gameHeader,
body.auth-required #gameHeader {
    display: none;
}
/* Native dialog transitions retain the top layer during closing, without a white overlay. */
#equipmentAdminSettingsTabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
#equipmentAdminSettingsTabs button {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 8px;
}
#equipmentAdminSettingsTabs [aria-selected='true'] {
    border-color: var(--gold);
    font-weight: 700;
}
dialog {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
    transition:
        opacity 160ms ease,
        transform 160ms ease,
        overlay 160ms allow-discrete,
        display 160ms allow-discrete;
}
dialog[open] {
    opacity: 1;
    transform: translateY(0) scale(1);
}
#help,
#settings {
    transform: translateX(-16px);
}
#help[open],
#settings[open] {
    transform: translateX(0);
}
dialog::backdrop {
    opacity: 0;
    transition:
        opacity 160ms ease,
        overlay 160ms allow-discrete,
        display 160ms allow-discrete;
}
dialog[open]::backdrop {
    opacity: 1;
}
@starting-style {
    dialog[open] {
        opacity: 0;
        transform: translateY(6px) scale(0.99);
    }
    #help[open],
    #settings[open] {
        transform: translateX(-16px);
    }
    dialog[open]::backdrop {
        opacity: 0;
    }
}
@media (max-width: 640px) {
    #gameHeader {
        grid-template-columns: auto auto minmax(0, 1fr) auto;
        gap: 0 2px;
        padding: 8px 8px 0;
        touch-action: pan-x;
    }
    #gameHeader #playerStatus {
        grid-column: 3;
        justify-content: flex-start;
        min-width: 0;
    }
    #gameHeader #close {
        grid-column: 4;
    }
    #gameHeader #vitals {
        gap: 4px;
    }
    #gameHeader .vital {
        font-size: clamp(10px, 2.8vw, 12px);
    }
    #gameHeader .vital > span {
        gap: 3px;
    }
    #gameHeader .vital-icon {
        font-size: 15px;
    }
    #navigationPanel {
        display: grid;
        grid-column: 1 / -1;
        grid-row: 2;
        grid-template-rows: 0fr;
        visibility: hidden;
        transition:
            grid-template-rows 220ms cubic-bezier(0.2, 0.7, 0.2, 1),
            visibility 220ms;
    }
    #navigationPanel .navigation-inner {
        min-height: 0;
        overflow: hidden;
    }
    #gameHeader[data-expanded='true'] #navigationPanel {
        grid-template-rows: 1fr;
        visibility: visible;
    }
    #tabs {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        padding: 0;
    }
    #tabs button,
    #tabs [data-tab='Крафт'] {
        display: flex;
        flex-direction: column;
        gap: 0;
        height: 56px;
        min-height: 56px;
        padding: 1px 3px;
        border: 0;
        border-radius: 0;
        background: transparent;
        font-size: 11px;
        align-items: center;
        justify-content: center;
    }
    #tabs button:hover,
    #tabs button[aria-current='page'] {
        border: 0;
        background: transparent;
    }
    #tabs .navigation-label {
        display: none;
    }
    #tabs svg {
        display: block;
        width: 100%;
        height: 100%;
    }
    /* Режимы меню на узкой шапке: подписи под иконкой или вместо неё. */
    #tabs[data-nav-display='both'] button,
    #tabs[data-nav-display='labels'] button {
        gap: 3px;
        padding: 3px 4px;
    }
    #tabs[data-nav-display='both'] svg {
        width: 26px;
        height: 26px;
        flex-shrink: 0;
    }
    #tabs[data-nav-display='labels'] svg {
        display: none;
    }
    #tabs[data-nav-display='both'] .navigation-label,
    #tabs[data-nav-display='labels'] .navigation-label {
        display: inline;
    }
    #navigationToggle {
        display: flex;
        grid-column: 4;
        grid-row: 1;
        justify-self: end;
        align-items: center;
        justify-content: center;
        width: 44px;
        min-height: 44px;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--muted);
        touch-action: pan-x;
    }
    #navigationToggle svg {
        width: 12px;
        height: 12px;
        fill: currentColor;
        stroke: none;
        transition: transform 220ms ease;
    }
    #navigationToggle[aria-expanded='true'] svg {
        transform: rotate(180deg);
    }
    body.chat-open #gameHeader {
        padding-bottom: 8px;
    }
}
@media (prefers-reduced-motion: reduce) {
    #gameHeader .vital-fill,
    #navigationPanel,
    #navigationToggle svg,
    #tabs button,
    dialog,
    dialog::backdrop {
        transition: none;
    }
}

/* Icon-only navigation fills its existing touch target without a button frame. */
#tabs:not([data-nav-display='both']):not([data-nav-display='labels']) button {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
#tabs:not([data-nav-display='both']):not([data-nav-display='labels']) svg {
    width: 44px;
    height: 44px;
}
