a.nav-btn {
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.tournaments-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 0 16px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.tournaments-filter select {
    min-width: 120px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font: inherit;
}

.club-switcher {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

.club-switcher__prefix {
    white-space: nowrap;
}

.clubs-modal {
    max-width: 720px;
    width: calc(100% - 32px);
}

.clubs-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.clubs-modal__header h2 {
    text-align: left;
    color: var(--primary, #336e78);
}

.club-usb-block {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(51, 110, 120, 0.18);
}

.club-import-preview {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(51, 110, 120, 0.06);
    border-radius: 8px;
}

.club-import-changes {
    margin: 0;
    padding-left: 18px;
    max-height: 220px;
    overflow: auto;
    font-size: 13px;
    line-height: 1.45;
    color: #333;
}

.club-import-changes .club-import-add {
    color: #1b6b3a;
}

.club-import-changes .club-import-del {
    color: #8a3030;
}

.club-switcher__select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary, #336e78);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 30px;
    padding: 9px 36px 9px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    max-width: min(240px, 42vw);
    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 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.club-switcher__select:disabled {
    opacity: 0.75;
    cursor: default;
}

.club-switcher__select:focus {
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: 2px;
}

.app-panel {
    max-width: 960px;
    margin: 28px auto;
    background: #fff;
    padding: 28px 32px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.app-panel h1 {
    margin-top: 0;
    color: var(--primary);
    font-size: 1.6rem;
}

.app-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.app-toolbar #page-title {
    flex: 1 1 auto;
    min-width: 0;
}

.app-toolbar-back {
    flex: 0 0 auto;
    margin-left: auto;
}

.app-panel.tournament-view .app-toolbar {
    margin-bottom: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

.app-panel.tournament-view .tournament-head {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px 14px;
}

.app-panel.tournament-view .app-toolbar #page-title {
    font-size: 1.35rem;
    line-height: 1.35;
    margin: 0;
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-panel.tournament-view .page-round {
    font-weight: 700;
    font-size: 1.15rem;
    color: #222;
    white-space: nowrap;
    flex: 0 0 auto;
}

.app-panel.tournament-view .tournament-actions {
    flex: 0 1 auto;
    min-width: 0;
}

.page-round {
    font-weight: 700;
    font-size: 1.15rem;
    color: #222;
}

.modal.modal--params {
    max-width: 440px;
}

.modal.modal--export {
    max-width: 420px;
}

.export-format-buttons {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.params-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.params-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    align-items: baseline;
}

.params-key {
    color: #666;
    font-size: 0.95rem;
}

.params-val {
    font-weight: 600;
    color: #222;
    word-break: break-word;
}

.app-panel.tournament-view .tournament-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 0 !important;
}

.app-panel.tournament-view .app-meta {
    display: none;
    margin: 0;
    min-height: 0;
}

.app-panel.tournament-view #form-error:empty {
    display: none;
    margin: 0;
    min-height: 0;
    padding: 0;
}

.app-panel.tournament-view #view-actions .work-btn {
    margin: 0;
    padding: 8px 16px;
    font-size: 14px;
}

.tournament-head {
    flex: 1 1 auto;
    min-width: 0;
}

.app-panel.tournament-view #standings.pairings-board {
    margin-top: 0;
}

.app-panel.tournament-view #pairings.pairings-board,
.tournament-view #pairings.pairings-board {
    margin-top: 12px;
}

.app-panel.tournament-view .round-block,
.tournament-view .round-block {
    margin-top: 14px;
}

.app-panel.tournament-view .round-block:first-child,
.tournament-view .round-block:first-child {
    margin-top: 0;
}

.app-panel.tournament-view .round-block h2,
.tournament-view .round-block h2 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.app-toolbar .spacer {
    flex: 1;
}

.app-panel--tournaments .app-toolbar {
    margin-bottom: 6px;
}

.app-panel--tournaments #tournaments-table .data-table {
    font-size: 18px;
}

.app-panel--tournaments #tournaments-table .data-table td,
.app-panel--tournaments #tournaments-table .data-table th {
    padding: 14px 16px;
}

.app-panel--tournaments .tournaments-filter {
    font-size: 15px;
}

.app-panel--tournaments .tournaments-filter select {
    padding: 8px 10px;
    min-width: 140px;
}

.app-panel--players #players-table .data-table {
    font-size: 18px;
}

.app-panel--players #players-table .data-table td,
.app-panel--players #players-table .data-table th {
    padding: 14px 16px;
}

.app-panel--players .players-sort {
    font-size: 15px;
    padding: 8px 10px;
}

.app-panel--players .app-toolbar--players {
    margin-bottom: 6px;
}

.app-toolbar--players .players-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.app-panel--players #players-error:empty {
    display: none;
}

.app-panel--tournaments #tournaments-error:empty {
    display: none;
}

.app-meta {
    color: #666;
    font-size: 14px;
    margin-bottom: 14px;
}

/* Шапка в #app-shell: sticky на обёртке, иначе уезжает вместе с коротким родителем */
#app-shell {
    position: sticky;
    top: 0;
    z-index: 200;
}

#app-shell:empty {
    display: none;
}

/* Гостевая шапка: бренд | клуб | меню */
.top-bar.top-bar--guest {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}

.top-bar--guest .guest-club-title {
    display: block;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
}

.top-bar--guest .top-bar__row--nav {
    flex: 0 1 auto;
    margin-left: auto;
    justify-content: flex-end;
}

@media (max-width: 900px) {
    .top-bar.top-bar--guest {
        gap: 10px 12px;
    }

    .top-bar--guest .top-bar__row--club {
        flex: 1 1 100%;
        text-align: left;
        justify-content: flex-start;
    }
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.data-table th {
    color: var(--primary);
    font-weight: 700;
}

.data-table tr:hover td {
    background: #f7fbfd;
}

.data-table .actions {
    white-space: nowrap;
    text-align: right;
}

.btn-sm {
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 16px;
    padding: 6px 12px;
    margin: 0 2px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.btn-sm.danger {
    background: #e74c3c;
}

.btn-sm.secondary {
    background: #5d6d7e;
}

.btn-sm:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.player-check-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 8px 0 14px;
}

.modal.modal--tournament-edit {
    max-width: 640px;
    width: calc(100% - 32px);
}

.modal.modal--tournament-edit .player-check-list {
    max-height: min(280px, 40vh);
}

.modal.modal--tournament-edit.edit-form--page {
    position: static;
    top: auto;
    left: auto;
    transform: none;
    max-width: none;
    width: auto;
    max-height: none;
    overflow: visible;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
    z-index: auto;
}

.modal.modal--tournament-edit.edit-form--page h2 {
    display: none;
}

.player-check-list label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 4px;
    cursor: pointer;
    font-weight: normal;
}

.player-check-list label:hover {
    background: #f0f7fa;
}

.pairings-board {
    margin-top: 18px;
}

.pairings-board h2 {
    color: var(--primary);
    font-size: 1.2rem;
}

.status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    background: #e8f4f6;
    color: var(--primary);
}

.status-pill.inprogress {
    background: #e8f8e8;
    color: #1e7a2e;
}

.status-pill.finished {
    background: #eee;
    color: #555;
}

.empty-hint {
    color: #777;
    padding: 24px 0;
    text-align: center;
}

.result-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.tournament-flag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 4px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.tournament-flag input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.btn-result {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #c5d5da;
    border-radius: 12px;
    padding: 10px 16px;
    min-width: 56px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
}

.btn-result:hover:not(:disabled) {
    background: #e8e8e8;
}

.btn-result:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: default;
    opacity: 0.85;
}

.btn-result.active {
    /* Как в desktop: зелёная подсветка выбранного результата */
    background: #64b464;
    color: #fff;
    border-color: #4a9a4a;
}

.result-cell {
    min-width: 240px;
}

.round-block .data-table td,
.round-block .data-table th {
    font-size: 16px;
    padding: 12px 10px;
}

.round-block .data-table td:nth-child(2),
.round-block .data-table td:nth-child(4) {
    font-size: 17px;
    font-weight: 700;
}

.modal.modal--result-confirm {
    max-width: 560px;
    text-align: center;
}

.modal.modal--result-confirm .result-confirm-text {
    margin: 8px 0 28px;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.35;
    color: #1e1e23;
}

.modal.modal--result-confirm .buttons .work-btn {
    min-width: 120px;
    font-size: 16px;
    padding: 12px 24px;
}

/* «Нет» — серый, как в desktop ConfirmResultForm */
.modal.modal--result-confirm .buttons .work-btn#result-confirm-no {
    background: #78787d;
    border-color: #78787d;
    color: #fff;
}

.modal.modal--result-confirm .buttons .work-btn#result-confirm-no:hover {
    background: #6a6a6f;
    border-color: #6a6a6f;
}

.ct-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin-top: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.crosstable {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
    font-size: 14px;
    background: #fff;
}

.crosstable th {
    background: #2d2d30;
    color: #fff;
    font-weight: 700;
    padding: 5px 2px;
    text-align: center;
    white-space: nowrap;
    border: 1px solid #1f1f22;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crosstable td {
    border: 1px solid #e0e0e0;
    text-align: center;
    padding: 3px 1px;
    vertical-align: middle;
    height: 28px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crosstable tr.ct-alt td {
    background: #f8f8f8;
}

.crosstable .ct-place {
    width: 28px;
}

.crosstable .ct-name {
    text-align: left !important;
    font-weight: 700;
    font-size: 15px;
    padding-left: 6px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crosstable thead .ct-name {
    text-align: center !important;
    font-size: 13px;
}

.crosstable .ct-num {
    width: 36px;
}

.crosstable .ct-opp,
.crosstable .ct-cell {
    width: 28px;
    font-weight: 600;
    font-size: 12px;
}

.crosstable .ct-diag {
    background: #3c3c3c !important;
    color: #3c3c3c !important;
}

.crosstable .ct-diag.ct-diag-bye {
    color: #fff !important;
    font-weight: 700;
}

.crosstable .ct-black {
    background: #bebebe !important;
}

.crosstable tr.ct-alt .ct-black {
    background: #b0b0b0 !important;
}

.crosstable .ct-pending {
    background: #ffeca0 !important;
    color: #503200 !important;
    font-size: 12px;
    font-weight: 700;
}

.crosstable .ct-bold {
    font-weight: 700;
}

.crosstable .ct-delta-up {
    color: #2e7d32;
}

.crosstable .ct-delta-down {
    color: #c62828;
}

/* Подмигивание свежих результатов (онлайн-просмотр).
   Не через @keyframes background: у .ct-black фон с !important, анимация его не перебивает
   (!important в keyframes браузеры игнорируют). Класс on/off ставит JS раз в ~0.55 с. */
.crosstable td.ct-blink {
    font-weight: 700;
}

.crosstable td.ct-blink-on,
.crosstable tr.ct-alt td.ct-blink-on,
.crosstable td.ct-blink-on.ct-black,
.crosstable tr.ct-alt td.ct-blink-on.ct-black {
    background: #ff9800 !important;
    color: #fff !important;
}

.crosstable td.ct-blink-off,
.crosstable tr.ct-alt td.ct-blink-off,
.crosstable td.ct-blink-off.ct-black,
.crosstable tr.ct-alt td.ct-blink-off.ct-black {
    background: #fff59d !important;
    color: #3e2723 !important;
}

/* Полноэкранный онлайн-просмотр шахматки (гость). */
.online-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: none;
    flex-direction: column;
    background: #f4f6f7;
}

body.online-mode-active {
    overflow: hidden;
}

.online-overlay__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
    padding: 12px 18px;
    background: var(--primary, #336e78);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.online-overlay__titles {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.online-overlay__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.online-overlay__round {
    font-size: 0.95rem;
    opacity: 0.92;
}

.online-overlay__exit {
    flex: 0 0 auto;
    background: #fff;
    color: var(--primary, #336e78);
    border-color: #fff;
    font-weight: 700;
}

.online-overlay__exit:hover {
    background: #e8f3f5;
}

.online-overlay__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 14px 16px 24px;
}

.online-overlay__body .ct-wrap {
    margin-top: 0;
    background: #fff;
}

@media (max-width: 768px) {
    .online-overlay__bar {
        padding: 10px 12px;
        gap: 10px;
    }

    .online-overlay__title {
        font-size: 1.05rem;
    }

    .online-overlay__body {
        padding: 10px;
    }
}

.rating-delta-up {
    color: #2e7d32;
    font-weight: 700;
}

.rating-delta-down {
    color: #c62828;
    font-weight: 700;
}

.rating-delta-zero {
    color: #666;
    font-weight: 600;
}

.ct-legend {
    margin-top: 6px;
    padding: 8px 10px;
    font-size: 13px;
    color: #643c00;
    background: #fff8dc;
    border-radius: 4px;
}

.stats-page {
    max-width: 1200px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    grid-template-rows: auto auto;
    gap: 16px;
}

.stats-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 14px 16px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    min-width: 0;
}

.stats-card h2 {
    margin: 0 0 12px;
    color: var(--primary, #336e78);
    font-size: 1.05rem;
}

.stats-card--h2h {
    grid-row: 1 / span 2;
    grid-column: 2;
}

.stats-card--tournaments {
    grid-column: 1;
    overflow: hidden;
}

/* Таблица турниров влезает в карточку — без лишнего горизонтального скролла. */
.stats-card--tournaments .table-scroll {
    overflow-x: hidden;
}

.stats-card--tournaments .table-scroll > .data-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.stats-card--tournaments .data-table th,
.stats-card--tournaments .data-table td {
    padding: 8px 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Дата | Категория | Статус | Место | Очки | Коэфф. | Бх1 | Рейтинг —
   ширины в ch, чтобы «dd.MM.yyyy» и «1234 → 1256» не обрезались. */
.stats-card--tournaments .data-table th:nth-child(1),
.stats-card--tournaments .data-table td:nth-child(1) { width: 10.5ch; }
.stats-card--tournaments .data-table th:nth-child(2),
.stats-card--tournaments .data-table td:nth-child(2) { width: 9ch; }
.stats-card--tournaments .data-table th:nth-child(3),
.stats-card--tournaments .data-table td:nth-child(3) { width: 9ch; }
.stats-card--tournaments .data-table th:nth-child(4),
.stats-card--tournaments .data-table td:nth-child(4) { width: 7ch; }
.stats-card--tournaments .data-table th:nth-child(5),
.stats-card--tournaments .data-table td:nth-child(5) { width: 5ch; }
.stats-card--tournaments .data-table th:nth-child(6),
.stats-card--tournaments .data-table td:nth-child(6) { width: 8ch; }
.stats-card--tournaments .data-table th:nth-child(7),
.stats-card--tournaments .data-table td:nth-child(7) { width: 5ch; }
.stats-card--tournaments .data-table th:nth-child(8),
.stats-card--tournaments .data-table td:nth-child(8) {
    width: 12ch;
    font-variant-numeric: tabular-nums;
}

.chart-wrap {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

#rating-chart {
    display: block;
    width: 100%;
    height: 320px;
}

.chart-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #777;
    min-height: 1.4em;
}

.h2h-summary {
    font-weight: 700;
    font-size: 15px;
    margin: 4px 0 12px;
    color: #333;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.table-scroll > .data-table {
    width: max-content;
    min-width: 100%;
}

#opponent-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

tr.clickable {
    cursor: pointer;
}

tr.clickable:hover td {
    background: #eef6f8;
}

tr.clickable.selected td {
    background: #dceef5;
}

.players-show-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    user-select: none;
}

.players-show-all input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.player-check-list label.player-inactive {
    background: #fffacd;
}

.player-check-list label.player-inactive:hover {
    background: #fff3b0;
}

/* Разделители как в десктопе: тонкая №|ФИО, толстая между категориями, тонкая Рейтинг|Партий. */
.players-table {
    --players-line-thin: #d2dce0;
    --players-line-group: #9bb4ba;
    border-collapse: collapse;
    border: none;
}

.players-table th,
.players-table td {
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 1px solid var(--players-line-thin);
}

.players-table thead th {
    text-align: center;
}

.players-table .players-corner {
    vertical-align: middle;
    text-align: left;
}

.players-table .players-cat {
    font-size: 18px;
    letter-spacing: 0.01em;
}

.players-table .players-sub {
    font-size: 15px;
    font-weight: 600;
    color: #4a6b72;
    white-space: nowrap;
}

.players-table .players-num {
    border-right: 1px solid var(--players-line-thin);
    text-align: center;
}

.players-table .players-name {
    border-right: 1px solid var(--players-line-thin);
}

.players-table .players-sex {
    border-right: 2px solid var(--players-line-group);
    text-align: center;
    width: 48px;
}

.players-table .players-rating {
    border-right: 1px solid var(--players-line-thin);
    text-align: center;
}

.players-table .players-games {
    text-align: center;
}

/* Толстые стыки категорий (Блиц, Классика); у Рапид линия на правом крае «Пол». */
.players-table tbody td.players-group-start:not(:nth-child(4)),
.players-table thead tr:first-child th.players-group-start:not(:nth-child(4)),
.players-table thead tr:last-child th.players-group-start:nth-child(3),
.players-table thead tr:last-child th.players-group-start:nth-child(5) {
    border-left: 2px solid var(--players-line-group);
}

.data-table tr.pairing-row-waiting td {
    color: #8a8a8a;
    background: #f7f7f7;
}

.pairing-waiting {
    color: #8a8a8a;
    font-style: italic;
}

.data-table tr.player-inactive td {
    background: #fffacd;
}

.data-table tr.player-inactive:hover td {
    background: #fff3b0;
}

/* Неактивный (в т.ч. только что добавленный) остаётся бледно-жёлтым и при выборе. */
.data-table tr.player-inactive.selected td,
.data-table tr.clickable.player-inactive.selected td {
    background: #fffacd;
}

.data-table tr.clickable.player-inactive.selected:hover td {
    background: #fff3b0;
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .stats-card--h2h,
    .stats-card--tournaments {
        grid-column: 1;
        grid-row: auto;
    }
}

/* Смартфоны: компактная вёрстка панелей, шапки и таблиц */
@media (max-width: 768px) {
    .app-panel {
        margin: 12px 10px 24px;
        padding: 16px 14px;
        border-radius: 8px;
        max-width: none;
    }

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

    .app-toolbar {
        gap: 8px;
        margin-bottom: 12px;
        align-items: flex-start;
    }

    .app-toolbar-back {
        margin-left: 0;
        width: 100%;
    }

    .app-panel.tournament-view .app-toolbar {
        flex-wrap: wrap;
    }

    .app-panel.tournament-view .tournament-head {
        flex-wrap: wrap;
    }

    .app-panel.tournament-view .app-toolbar #page-title {
        font-size: 1.1rem;
        line-height: 1.35;
        white-space: normal;
    }

    .app-panel.tournament-view .page-round,
    .page-round {
        font-size: 1.05rem;
    }

    .params-row {
        grid-template-columns: 100px 1fr;
    }

    .top-bar--guest .guest-club-title {
        font-size: 16px;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .top-bar--guest .top-bar__row--nav {
        margin-left: 0;
    }

    .club-switcher {
        max-width: 100%;
        font-size: 15px;
    }

    .club-switcher__name {
        max-width: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .work-btn,
    .btn-sm {
        padding: 8px 14px;
        font-size: 14px;
    }

    .data-table {
        font-size: 13px;
        width: 100%;
        max-width: 100%;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
        white-space: nowrap;
    }

    .stats-page,
    .stats-grid,
    .stats-card {
        min-width: 0;
        max-width: 100%;
    }

    .stats-card--h2h,
    .stats-card--tournaments {
        overflow: hidden;
    }

    .table-scroll,
    #players-table,
    #tournaments-table,
    #h2h-table,
    .round-block .table-scroll,
    .ct-wrap {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-scroll > .data-table,
    #h2h-table > .data-table,
    .round-block .table-scroll > .data-table {
        width: max-content;
        min-width: 100%;
    }

    .stats-card--tournaments #tournaments-table {
        overflow-x: hidden;
    }

    .stats-card--tournaments #tournaments-table > .data-table {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    .app-panel.tournament-view,
    #view-panel,
    #standings,
    #pairings {
        min-width: 0;
        max-width: 100%;
    }

    .crosstable .ct-name {
        max-width: none;
    }

    .browse-tree__children {
        padding-left: 12px;
    }

    .browse-tree__toggle,
    .browse-tree__club-link {
        padding: 10px 8px;
        gap: 6px;
        align-items: flex-start;
    }

    .browse-tree__label {
        font-size: 15px;
        white-space: normal;
        word-break: break-word;
    }

    .browse-tree__meta {
        font-size: 12px;
        white-space: normal;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form .form-group {
        min-width: 0;
        width: 100%;
    }

    .players-sort {
        min-width: 0;
        width: 100%;
    }

    .stats-card {
        padding: 14px;
    }

    .chart-wrap {
        overflow-x: auto;
    }

    .buttons {
        gap: 8px;
    }

    .buttons .work-btn {
        flex: 1 1 auto;
        text-align: center;
    }
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.inline-form .form-group {
    margin-bottom: 0;
    min-width: 160px;
}

.inline-form input[type="text"],
.inline-form input[type="number"],
.inline-form input[type="date"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Крупные стрелки шага для «Туров» / «Досок» (нативные спиннеры слишком мелкие). */
.number-step {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
}

.number-step__input {
    width: 100%;
    padding: 8px 40px 8px 8px !important;
    -moz-appearance: textfield;
    appearance: textfield;
}

.number-step__input::-webkit-outer-spin-button,
.number-step__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.number-step__spinners {
    position: absolute;
    top: 1px;
    right: 1px;
    bottom: 1px;
    width: 34px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #ddd;
    border-radius: 0 3px 3px 0;
    overflow: hidden;
    background: #f3f6f7;
}

.number-step__spin {
    flex: 1;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.number-step__spin + .number-step__spin {
    border-top: 1px solid #ddd;
}

.number-step__spin:hover {
    background: #e4eef1;
}

.number-step__spin:active {
    background: #d2e4e9;
}

.number-step__spin::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 11px solid #3d5c64;
}

.number-step__spin--down::before {
    border-bottom: none;
    border-top: 11px solid #3d5c64;
}

.number-step:has(input:disabled) .number-step__spin {
    opacity: 0.35;
    pointer-events: none;
    cursor: default;
}

.players-sort {
    appearance: auto;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    background: #fff;
    min-width: 150px;
    cursor: pointer;
}

.club-switcher__name {
    color: inherit;
    font-weight: 700;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-bar .club-switcher .club-switcher__prefix,
.top-bar .club-switcher .club-switcher__name {
    color: inherit;
}

.browse-tree {
    margin-top: 8px;
}

.browse-tree__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.browse-tree__children {
    display: none;
    padding-left: 18px;
    margin-top: 2px;
    border-left: 1px solid #e2e8ea;
}

.browse-tree__item.is-open > .browse-tree__children {
    display: block;
}

.browse-tree__toggle,
.browse-tree__club-link {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: #244;
    font: inherit;
    text-decoration: none;
}

.browse-tree__toggle:hover,
.browse-tree__club-link:hover {
    background: #f3f7f8;
}

.browse-tree__marker {
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid #6a8f96;
    flex: 0 0 auto;
    transition: transform 0.15s ease;
}

.browse-tree__item.is-open > .browse-tree__toggle > .browse-tree__marker {
    transform: rotate(90deg);
}

.browse-tree__label {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
}

.browse-tree__meta {
    flex: 0 0 auto;
    color: #7a8a8e;
    font-size: 13px;
    font-weight: 500;
}

.browse-tree__clubs {
    border-left-color: #d5e2e5;
}

.browse-tree__club-link .browse-tree__label {
    color: var(--primary, #336e78);
}

.browse-tree__club-link::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9bb7bc;
    flex: 0 0 auto;
}

.browse-tree__club-link.is-selected {
    background: #e7f2f4;
    outline: 1px solid #9bb7bc;
}

.browse-tree__club-link.is-selected::before {
    background: var(--primary, #336e78);
}
