:root {
    --primary: #336e78;
    --primary-dark: #2980b9;
    --accent: #3498db;
}

* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
}

.top-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 10px 12px;
    background-color: var(--primary);
    color: white;
    padding: 10px 24px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 200;
}

.top-bar__row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.top-bar__row--brand {
    flex: 1 1 auto;
    min-width: 0;
}

.top-bar__row--nav,
.top-bar__row--live {
    flex: 0 1 auto;
    margin-left: auto;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.top-bar__row--club {
    flex: 1 1 12rem;
    justify-content: center;
    text-align: center;
}

.top-bar__row--live:has(.active-tournaments-nav:empty) {
    display: none;
}

.top-bar .brand,
.top-bar .brand-sport-picker__btn.brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
    line-height: 0;
    background: #fff;
    border-radius: 8px;
    padding: 3px 10px;
}

.top-bar .brand__logo {
    display: block;
    height: 32px;
    width: auto;
    max-width: min(340px, 72vw);
    object-fit: contain;
}

.site-sport-select {
    display: none !important;
}

.brand-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 0 1 auto;
}

.site-country-select {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
}

.site-country-select__label {
    display: none;
}

.site-country-select__input {
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background-color: rgba(255, 255, 255, 0.15);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ffffff' d='M1.1 0.4L6 5.3 10.9 0.4 12 1.5 6 7.5 0 1.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 30px;
    padding: 10px 36px 10px 22px;
    max-width: min(240px, 46vw);
    cursor: pointer;
    transition: all 0.25s ease;
}

.site-country-select__input:hover {
    background-color: #fff;
    color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23336e78' d='M1.1 0.4L6 5.3 10.9 0.4 12 1.5 6 7.5 0 1.5z'/%3E%3C/svg%3E");
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.site-country-select__input:focus {
    outline: none;
    background-color: #fff;
    color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23336e78' d='M1.1 0.4L6 5.3 10.9 0.4 12 1.5 6 7.5 0 1.5z'/%3E%3C/svg%3E");
}

.site-country-select__input option {
    color: #234;
    background: #fff;
}

.brand-sport-picker {
    position: relative;
    flex-shrink: 0;
    z-index: 40;
}

.brand-sport-picker__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    cursor: pointer;
    font: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.brand-sport-picker__caret {
    color: #234;
    font-size: 14px;
    line-height: 1;
    opacity: 0.7;
    margin-right: 2px;
}

.brand-sport-picker.is-open .brand-sport-picker__caret {
    opacity: 1;
}

.brand-sport-picker__menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: max(100%, 160px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    z-index: 250;
}

.brand-sport-picker__menu[hidden] {
    display: none !important;
}

.brand-sport-picker__option {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 0;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    line-height: 0;
}

.brand-sport-picker__option:hover,
.brand-sport-picker__option:focus-visible {
    border-color: rgba(35, 68, 100, 0.28);
    background: #f4f7fb;
    outline: none;
}

.brand-sport-picker__option.is-active {
    border-color: rgba(35, 68, 100, 0.45);
    background: #eaf1f8;
}

.brand-sport-picker__option .brand__logo,
.brand-sport-picker__option-logo {
    height: 28px;
    width: auto;
    max-width: min(300px, 70vw);
}

.site-sport-invite {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        linear-gradient(160deg, rgba(25, 55, 70, 0.92), rgba(40, 90, 70, 0.88)),
        radial-gradient(ellipse at 20% 10%, rgba(120, 200, 160, 0.35), transparent 55%);
}

.site-sport-invite[hidden] {
    display: none !important;
}

.site-sport-invite__card {
    max-width: 36rem;
    width: 100%;
    background: rgba(255, 255, 255, 0.97);
    color: #1e2a32;
    border-radius: 16px;
    padding: 28px 28px 24px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.site-sport-invite__eyebrow {
    margin: 0 0 6px;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #4a6b5c;
    font-weight: 700;
}

.site-sport-invite__title {
    margin: 0 0 12px;
    font-size: 1.75rem;
    line-height: 1.2;
}

.site-sport-invite__text {
    margin: 0 0 20px;
    font-size: 1.05rem;
    line-height: 1.5;
    color: #334;
}

.site-sport-invite__btn {
    min-width: 12rem;
}

/* Пока для НТ только приглашение — прячем основной контент (кроме каталога клубов). */
html[data-site-sport="table-tennis"] body:not([data-page="browse-hub"]) > .app-panel,
html[data-site-sport="table-tennis"] body:not([data-page="browse-hub"]) > main.container,
html[data-site-sport="table-tennis"] body:not([data-page="browse-hub"]) > main.app-panel {
    visibility: hidden;
}

/* Каталог клубов всегда видим, даже если в шапке выбран НТ. */
html[data-site-sport="table-tennis"] body[data-page="browse-hub"] > .app-panel,
html[data-site-sport="table-tennis"] body[data-page="browse-hub"] > main.app-panel {
    visibility: visible;
}

@media (max-width: 720px) {
}

.nav-btn__short {
    display: none;
}

.top-actions {
    display: flex;
    flex: 1 1 auto;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.nav-btn {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 10px 22px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.25s ease;
}

.nav-btn:hover {
    background-color: white;
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.nav-btn:hover .club-switcher__prefix,
.nav-btn:hover .club-switcher__name {
    color: var(--primary);
}

.nav-btn.primary {
    background-color: var(--accent);
    border-color: var(--accent);
}

.nav-btn.primary:hover {
    background-color: white;
    color: var(--accent);
}

.nav-btn:disabled,
.nav-btn[disabled] {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
    transform: none;
    box-shadow: none;
}

.active-tournaments-nav {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

/* Пустой слот не участвует в flex-gap — иначе между «Турниры» и «Сервис» двойной зазор. */
.active-tournaments-nav:empty {
    display: none;
}

.nav-btn--tournament {
    padding: 8px 14px;
    font-size: 13px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.container {
    max-width: 900px;
    margin: 40px auto;
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

h1 {
    color: var(--primary);
    text-align: center;
    margin-top: 0;
}

p {
    line-height: 1.7;
    color: #555;
    font-size: 16px;
}

ul {
    line-height: 1.9;
    color: #555;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.session-label {
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    white-space: nowrap;
}

.top-bar .club-switcher {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}

.club-switcher__prefix {
    white-space: nowrap;
    font-size: 18px;
    font-weight: 700;
}

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: white;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    min-width: 240px;
    padding: 8px 0;
    z-index: 1100;
}

.dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
}

.dropdown-menu button:hover:not(:disabled) {
    background: #f0f7fa;
    color: var(--primary);
}

.dropdown-menu button:disabled {
    color: #999;
    cursor: not-allowed;
    opacity: 0.55;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 900;
}

.modal {
    z-index: 1200;
}

.accounts-list {
    max-height: 60vh;
    overflow-x: hidden;
    overflow-y: auto;
    margin-bottom: 12px;
}

.accounts-tree {
    font-size: 14px;
}

.accounts-tree__account {
    display: grid;
    grid-template-columns:
        minmax(90px, 0.85fr)
        minmax(100px, 1.1fr)
        auto
        minmax(120px, 1.2fr)
        auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    list-style: none;
}

.accounts-tree__account:hover {
    background: #f3f7f8;
}

.accounts-tree__name {
    font-weight: 600;
    color: #244;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.accounts-tree__club {
    color: #244;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.accounts-tree__tournaments {
    color: #5a7076;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.accounts-tree__email {
    color: #5a7076;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.accounts-tree__actions {
    justify-self: end;
    white-space: nowrap;
}

.accounts-list .btn-delete {
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 16px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

/* Нетбук (~1024 ширина): шапка в одну строку. Только по ширине — не по высоте окна. */
@media (min-width: 769px) and (max-width: 1100px) {
    .top-bar {
        flex-wrap: nowrap;
        gap: 6px;
        padding: 5px 10px;
        align-items: center;
    }

    .top-bar__row {
        gap: 5px;
    }

    .top-bar__row--brand {
        flex: 0 0 auto;
    }

    .top-bar__row--nav,
    .top-bar__row--live,
    .top-actions {
        flex: 1 1 auto;
        flex-wrap: nowrap;
        margin-left: 0;
        justify-content: flex-end;
        gap: 5px;
        min-width: 0;
    }

    .top-bar .brand {
        padding: 2px 6px;
        border-radius: 6px;
    }

    .top-bar .brand__logo {
        height: 22px;
        max-width: min(220px, 58vw);
    }

    .nav-btn {
        padding: 8px 14px;
        font-size: 14px;
        border-radius: 30px;
        line-height: 1.2;
        white-space: nowrap;
        flex: 0 0 auto;
        box-sizing: border-box;
    }

    .top-bar .site-country-select__input {
        padding: 8px 32px 8px 14px;
        font-size: 14px;
        border-radius: 30px;
        line-height: 1.2;
        min-height: 0;
        box-sizing: border-box;
        background-position: right 12px center;
    }

    .nav-btn__full {
        display: none;
    }

    .nav-btn__short {
        display: inline;
    }

    .nav-btn:hover {
        transform: none;
    }

    .nav-btn--tournament {
        max-width: 140px;
        padding: 8px 14px;
        font-size: 14px;
        line-height: 1.2;
        border-radius: 30px;
        box-sizing: border-box;
    }

    .active-tournaments-nav {
        gap: 4px;
        flex-wrap: nowrap;
        min-width: 0;
        overflow: hidden;
    }

    .top-bar .club-switcher,
    .club-switcher--after-home {
        flex: 0 1 auto;
        max-width: min(150px, 16vw);
        gap: 4px;
        font-size: 13px;
        min-width: 0;
        margin-right: 0;
    }

    .top-bar .club-switcher__name,
    .club-switcher__name {
        font-size: 13px;
    }

    .session-info {
        gap: 5px;
        flex-wrap: nowrap;
        min-width: 0;
    }

    .session-label {
        font-size: 12px;
        padding: 4px 8px;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 768px) {
    /*
     * Один поток: логотип + сколько кнопок влезет справа в 1-й ряд,
     * дальше — перенос на всю ширину (в т.ч. под логотипом).
     */
    .top-bar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        align-content: flex-start;
        gap: 6px 6px;
        padding: 8px 10px;
    }

    .top-bar.top-bar--guest {
        display: flex;
        flex-wrap: wrap;
    }

    /*
     * Нав/клуб/live — display:contents (общий поток переноса).
     * Brand НЕ contents: иначе на WebKit absolute-меню селекта спорта
     * теряет containing block и «мелькает» / уезжает.
     */
    .top-bar__row--brand {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        min-width: 0;
        position: relative;
        z-index: 60;
    }

    .top-bar__row--nav,
    .top-bar__row--club,
    .top-bar__row--live,
    .top-bar > .top-actions {
        display: contents;
    }

    .top-bar__row--club[aria-hidden="true"] {
        display: none;
    }

    .top-bar .brand-sport-picker {
        position: relative;
        z-index: 60;
    }

    .top-bar .brand-bar {
        gap: 6px;
        max-width: 100%;
    }

    .top-bar .site-country-select__input {
        font-size: 14px;
        padding: 8px 32px 8px 14px;
        max-width: min(160px, 40vw);
        border-radius: 30px;
        line-height: 1.2;
        background-position: right 12px center;
        background-size: 10px 7px;
        transform: none;
        box-shadow: none;
        box-sizing: border-box;
    }

    .top-bar .site-country-select__input:hover {
        transform: none;
        box-shadow: none;
    }

    .top-bar .brand {
        flex: 0 0 auto;
        align-self: center;
        padding: 2px 6px;
    }

    .top-bar .brand__logo {
        height: 24px;
        max-width: min(240px, 62vw);
    }

    /*
     * Порядок как на ПК (DOM): Главная → Клубы → клуб → Игроки → Турниры →
     * незавершённые → Сервис → Выйти. Без CSS order.
     */
    .top-bar .nav-btn,
    .top-bar .dropdown,
    .top-bar .session-info {
        flex: 0 0 auto;
        min-width: auto;
    }

    .top-bar .club-switcher,
    .top-bar .club-switcher--after-home {
        flex: 0 1 auto;
        max-width: min(42vw, 160px);
        min-width: 0;
        margin: 0;
        font-size: 14px;
    }

    .top-bar .club-switcher__name {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* На смартфоне в шапке только название клуба */
    .top-bar .club-place,
    .top-bar .guest-club-title .club-place {
        display: none;
    }

    .top-bar .active-tournaments-nav {
        flex: 0 1 auto;
        display: inline-flex;
        flex-wrap: wrap;
        gap: 5px;
        min-width: 0;
        max-width: 100%;
    }

    .nav-btn {
        flex: 0 0 auto;
        padding: 8px 14px;
        font-size: 14px;
        border-radius: 30px;
        line-height: 1.2;
        white-space: nowrap;
        box-sizing: border-box;
    }

    .top-bar .site-country-select__input {
        padding: 8px 32px 8px 14px;
        font-size: 14px;
        border-radius: 30px;
        line-height: 1.2;
        min-height: 0;
        box-sizing: border-box;
        background-position: right 12px center;
    }

    /* Длинная подпись каталога — можно переносить, без урезания до «Клубы». */
    .top-bar a.nav-btn[href="/browse"],
    .top-bar #btn-tournaments,
    .top-bar .nav-btn--guest-browse {
        white-space: normal;
        text-align: center;
        max-width: min(52vw, 200px);
        line-height: 1.15;
    }

    /* После авторизации на смартфоне «Главная» и каталог гостя в меню не нужны. */
    body.is-authenticated .top-bar .nav-btn--home,
    body.is-authenticated .top-bar #btn-home,
    body.is-authenticated .top-bar .nav-btn--guest-browse,
    body.is-authenticated .top-bar a.nav-btn[href="/browse"],
    body.is-authenticated .top-bar #btn-tournaments {
        display: none !important;
    }

    .nav-btn__full {
        display: none;
    }

    .nav-btn__short {
        display: inline;
    }

    .nav-btn:hover {
        transform: none;
    }

    .nav-btn--tournament {
        max-width: min(160px, 46vw);
        padding: 8px 14px;
        font-size: 14px;
        line-height: 1.2;
        border-radius: 30px;
        box-sizing: border-box;
    }

    .session-info {
        flex: 0 0 auto;
        flex-wrap: nowrap;
        width: auto;
        gap: 5px;
    }

    .session-label {
        white-space: normal;
        max-width: 100%;
        font-size: 13px;
        padding: 6px 10px;
    }

    .container {
        margin: 12px 10px 24px;
        padding: 18px 16px;
        border-radius: 8px;
    }

    h1 {
        font-size: 1.35rem;
        line-height: 1.3;
    }

    p,
    ul {
        font-size: 15px;
        line-height: 1.55;
    }

    .dropdown-menu {
        right: auto;
        left: 0;
        min-width: min(260px, calc(100vw - 24px));
    }
}
