.mast {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "brand games account language controls";
    align-items: center;
    gap: 12px clamp(10px, 1.7vw, 28px);
    padding: 10px clamp(14px, 2.8vw, 46px);
}
.site-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}
.site-brand img { display: block; width: clamp(132px, 12vw, 170px); height: auto; }
.site-brand .brand-dark, [data-theme="dark"] .site-brand .brand-light { display: none; }
[data-theme="dark"] .site-brand .brand-dark { display: block; }
.mast .mast-brand { grid-area: brand; }
.sitefoot .footer-brand { min-height: 44px; }
.footer-brand img { width: 144px; }
.mast > .language-switch { grid-area: language; }
.mast-controls { grid-area: controls; }
.mast-account-row { grid-area: account; }
.mast-games { grid-area: games; }
.mast-drawer { display: contents; }
.mast-controls,.mast-account-row,.mast-games {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.mast-games,.mast-account-row { flex-wrap: wrap; }
.mast-account-row form { margin: 0; }
.mast-balance { white-space: nowrap; color: var(--muted); font-size: .9rem; }
.mast .mast-account,.mast .mast-games a,.mast .language-switch a,.mast button {
    min-height: 44px;
    min-width: 44px;
}
.mast .mast-account,.mast .mast-games a,.mast button {
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 7px 12px;
    line-height: 1.4;
}
.mast .mast-account {
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 750;
    text-align: center;
}
.mast .mast-games a {
    background: var(--bg);
    color: var(--text);
    max-inline-size: 100%;
    overflow-wrap: anywhere;
}
.mast .mast-games a[aria-current="page"] {
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 750;
}
.mast .mast-games a:hover,.mast .language-switch a:hover { text-decoration: underline; }
.mast button {
    display: inline-flex;
    align-items: center;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.mast .mast-theme { padding: 0; font-size: 21px; }
.mast .mast-toggle { display: none; padding: 0; }
.mast .language-switch { flex-wrap: nowrap; padding-inline: 8px; gap: 5px; }
.mast .language-switch a { justify-content: center; padding-inline: 4px; border-radius: 8px; }
.mast :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.form-card .auth-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 14px;
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}
.form-card .auth-switch:hover { background: var(--bg); }
@media (max-width: 860px) {
    .mast {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        grid-template-areas: "language brand controls";
        gap: 6px;
        padding-block: 10px;
        padding-inline: max(10px, env(safe-area-inset-left), env(safe-area-inset-right));
    }
    [dir="ltr"] .mast { grid-template-areas: "controls brand language"; }
    .mast .mast-brand { justify-self: center; padding-inline: 5px; }
    .mast .mast-brand img { width: clamp(78px, 27vw, 138px); }
    .mast > .language-switch { justify-self: right; }
    .mast-controls { justify-self: left; gap: 4px; }
    .mast[data-nav-ready] .mast-toggle { display: grid; place-items: center; }
    .mast-menu-bars,.mast-menu-bars::before,.mast-menu-bars::after {
        width: 17px;
        height: 2px;
        border-radius: 2px;
        background: currentColor;
    }
    .mast-menu-bars { position: relative; }
    .mast-menu-bars::before,.mast-menu-bars::after { content: ""; position: absolute; inset-inline-start: 0; }
    .mast-menu-bars::before { top: -5px; }
    .mast-menu-bars::after { top: 5px; }
    .mast-toggle[aria-expanded="true"] .mast-menu-bars { background: transparent; }
    .mast-toggle[aria-expanded="true"] .mast-menu-bars::before { top: 0; transform: rotate(45deg); }
    .mast-toggle[aria-expanded="true"] .mast-menu-bars::after { top: 0; transform: rotate(-45deg); }
    .mast-drawer {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        border-top: 1px solid var(--line);
        padding-top: 10px;
    }
    .mast[data-nav-ready] .mast-drawer[data-open="false"] { display: none; }
    .mast .mast-account-row,.mast .mast-games { grid-area: auto; }
    .mast .mast-account { flex: 1; }
    .mast-games {
        display: grid;
        gap: 6px;
        max-height: 55vh;
        overflow-y: auto;
        padding: 4px;
    }
    .mast .mast-games a { justify-content: start; }
}
@media (max-width: 540px) {
    .mast .language-label { display: none; }
    .mast .language-switch { padding-inline: 4px; }
}
