/* === Локальные Montserrat 700/800 (vary-weight внутри одного woff2) ====
   Google Fonts CDN раньше грузился на каждой загрузке страницы и при каждом
   snapshot, добавляя 200–1500 мс. Файлы скачаны один раз в public/fonts/montserrat/,
   subset-разделение как у Google: cyrillic + cyrillic-ext + latin + latin-ext
   + vietnamese (~170 KB total). unicode-range у каждого face — браузер качает
   только нужные subset'ы по реально использованным символам. */
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 700 800;
    font-display: swap;
    src: url('fonts/montserrat/cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 700 800;
    font-display: swap;
    src: url('fonts/montserrat/cyrillic-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 700 800;
    font-display: swap;
    src: url('fonts/montserrat/latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 700 800;
    font-display: swap;
    src: url('fonts/montserrat/latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 700 800;
    font-display: swap;
    src: url('fonts/montserrat/vietnamese.woff2') format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}


body {
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 700;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: clip;
    display: flex;
    align-items: center;
    justify-content: center;
    /* На планшетах (особенно iPad Safari в desktop-mode) браузер ждал
       ~300 мс после tap, проверяя — не double-tap-zoom ли это. user-scalable=no
       в viewport помогает не везде. touch-action: manipulation на body
       снимает delay для всех click-обработчиков (онклик ячейки,
       заголовка раунда, кнопок кастомной клавиатуры). */
    touch-action: manipulation;
}


* {
    box-sizing: border-box;
}


.container {
    max-width: var(--ogr-container-max-width, 1800px);
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    padding: 10px var(--ogr-page-h-pad, 10px);
    overflow: hidden;  /* clips table to border-radius corners */
    padding-bottom: 0; /* table flush with bottom — no white space */
    width: 100%;
}

/* ===== HEADER ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 12px 15px;
    position: relative;
}

/* Logo area */
.header-logo {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 60px;
}

.header-logo .fa-burst {
    font-size: 22px;
    color: #e20713;
}

.header-version-block {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.header-version-block #appVersion {
    font-size: 9px;
    color: #999;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.header-version-block #appBuild {
    font-size: 8px;
    color: #bbb;
    white-space: pre;
}

/* Идентичность активной игры в шапке */
.game-identity {
    display: none;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #edf2f7;
    color: #2d3748;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.game-identity.visible {
    display: inline-flex;
    align-items: center;
}
.game-identity.viewing {
    background: #fef3c7;
    color: #92400e;
}

/* Бар просмотра архивной игры — поверх таблицы */
.archive-viewing-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 14px;
}
.archive-viewing-bar i { margin-right: 6px; }
.archive-viewing-close {
    background: #92400e;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: background 0.15s ease;
}
.archive-viewing-close:hover { background: #78350f; }

/* Скрываем действия, не имеющие смысла в режиме просмотра архива */
body.viewing-archive #saveGameBtn,
body.viewing-archive #newGameBtn,
body.viewing-archive #clearTableBtn,
body.viewing-archive #generatePptBtn,
body.viewing-archive #copyImageBtn {
    display: none !important;
}
body.viewing-archive #saveGameBtn + .menu-divider,
body.viewing-archive #newGameBtn + .menu-divider,
body.viewing-archive #clearTableBtn + .menu-divider,
body.viewing-archive #generatePptBtn + .menu-divider,
body.viewing-archive #copyImageBtn + .menu-divider {
    display: none !important;
}
.score-cell-readonly { cursor: default; }

/* Кнопка «Просмотр» в карточках архива */
.btn-view {
    background: #4a5568;
    color: white;
}
.btn-view:hover { background: #2d3748; }

/* Маленькая иконка статуса сохранения в шапке */
.save-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    font-size: 11px;
    width: 14px;
    height: 14px;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
    pointer-events: none;
}
.save-status.visible {
    opacity: 1;
}
.save-status.saving { color: #6b7280; }
.save-status.saved { color: #16a34a; }
.save-status.error { color: #dc2626; }
.save-status .fa-spinner {
    animation: save-status-spin 0.9s linear infinite;
}
@keyframes save-status-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Center menu area */
.header-menu {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: fit-content;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1000;
}

/* Menu toggle button */
.menu-toggle-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 28px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(180deg, #818ea1 0%, #818ea1 100%);
    color: white;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1001;
}

.menu-toggle-btn:hover {
    background: linear-gradient(180deg, #737f91 0%, #737f91 100%);
}

.menu-toggle-btn.active {
    background: linear-gradient(180deg, #e20814 0%, #87687d 100%);
    border-radius: 10px 10px 0 0;
}

/* Inverse border radius — on the button, hanging below its corners */
.menu-toggle-btn.active::before,
.menu-toggle-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 8px;
    height: 8px;
    z-index: 1002;
    pointer-events: none;
}

.menu-toggle-btn.active::before {
    left: -8px;
    background: radial-gradient(circle at 0 0, transparent 8px, #87687d 8.5px);
}

.menu-toggle-btn.active::after {
    right: -8px;
    background: radial-gradient(circle at 100% 0, transparent 8px, #87687d 8.5px);
}

.menu-toggle-icon {
    font-size: 10px;
    transition: transform 0.3s ease;
}

/* Menu dropdown — position:fixed, координаты задаются JS при открытии.
   Десктоп: горизонтальная панель (row). Мобайл (media): вертикальная (column). */
.menu-dropdown {
    display: flex;
    flex-direction: row;
    align-items: center;
    background: linear-gradient(180deg, #87687d 0%, #5b83a8 100%);
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    position: fixed;
    z-index: 2000;
    max-width: 96vw;
    max-height: 80vh;
    overflow-y: auto;
    scrollbar-width: thin;
    box-shadow: 0 8px 24px rgba(0,0,0,0.28);
    white-space: nowrap;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.menu-dropdown.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Menu items — горизонтальные на десктопе. */
.menu-item {
    background: none;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.menu-item:hover {
    background: linear-gradient(180deg, rgba(135, 104, 125, 0.6) 0%, rgba(255, 255, 255, 0.18) 100%);
}

.menu-item-danger:hover {
    background: linear-gradient(180deg, rgba(180, 40, 40, 0.5) 0%, rgba(226, 7, 19, 0.25) 100%);
}

.menu-item i {
    font-size: 14px;
}

/* Menu divider */
.menu-divider {
    width: 2px;
    height: 16px;
    background: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

/* Logout area */
.header-logout {
    min-width: 60px;
    display: flex;
    justify-content: flex-end;
}

.logout-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.logout-btn:hover {
    background: #c82333;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-family: inherit;
}



.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
}

.btn-danger {
    background: #e20713;
    color: white;
}

.btn-danger:hover {
    background: #c00610;
}

.btn-secondary {
    background: #718096;
    color: white;
}

.btn-secondary:hover {
    background: #4a5568;
}


.status-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    display: none;
    font-weight: 500;
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        bottom: -50px;
        opacity: 0;
    }

    to {
        bottom: 20px;
        opacity: 1;
    }
}

.status-message.success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
    display: block;
}

.status-message.error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #fc8181;
    display: block;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal.show {
    display: flex;
    /* align-items: center; */
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    height: fit-content;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 2px solid #e20713;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5em;
}

.close-modal {
    font-size: 32px;
    font-weight: 700;
    color: #999;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}

.close-modal:hover {
    color: #e20713;
}

.modal-body {
    padding: 20px 25px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.team-search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.team-search-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    transition: border-color 0.2s ease;
}

.team-search-input:focus {
    outline: none;
    border-color: #e20713;
}

.bulk-import-container {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
}

.bulk-import-textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    resize: vertical;
    margin-bottom: 10px;
    line-height: 1.6;
}

.bulk-import-textarea:focus {
    outline: none;
    border-color: #e20713;
}

.bulk-import-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.bulk-import-toggle {
    margin-bottom: 15px;
    text-align: center;
}

.bulk-import-stats {
    margin-top: 10px;
    padding: 10px;
    background-color: #e6fffa;
    border-left: 4px solid #38b2ac;
    border-radius: 4px;
    font-size: 14px;
    color: #234e52;
}

.bulk-import-stats.error {
    background-color: #fff5f5;
    border-left-color: #e53e3e;
    color: #742a2a;
}


.teams-list-container {
    overflow-y: auto;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    height: 75%;
}

.team-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #e2e8f0;
    transition: background-color 0.2s ease;
}

.team-list-item:last-child {
    border-bottom: none;
}

.team-list-item:hover {
    background-color: #f7fafc;
}

.team-list-item-name {
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
    flex: 1;
}

.team-list-item-name input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    color: #2d3748;
    padding: 4px;
}

.team-list-item-name input:focus {
    outline: none;
    background-color: #f0f8ff;
    border-radius: 4px;
}

.team-list-item-actions {
    display: flex;
    gap: 8px;
}

.team-list-item-actions button {
    background: #e20713;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.team-list-item-actions button:hover {
    background: #c00610;
    transform: scale(1.05);
}

.empty-teams-list {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
    font-style: italic;
}

/* Новый UI редактирования команд: «кнопка-название» + кнопка «Редактировать» */
.team-list-item {
    padding: 6px 8px; /* плотнее, чтобы кнопка-название занимала всю строку */
    gap: 8px;
}

.team-toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    color: #2d3748;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.team-toggle-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}
.team-list-item.in-table .team-toggle-btn {
    background: #ebf8ff;
    border-color: #90cdf4;
    color: #2c5282;
}
.team-list-item.in-table .team-toggle-btn:hover {
    background: #fed7d7;
    border-color: #fc8181;
    color: #9b2c2c;
}
.team-toggle-btn .toggle-icon-add { color: #48bb78; font-size: 14px; }
.team-toggle-btn .toggle-icon-remove { color: #e53e3e; font-size: 14px; }
.team-toggle-btn .team-toggle-name { flex: 1; }
.team-toggle-btn .team-games-count {
    color: #718096;
    font-size: 12px;
    font-weight: 600;
}

.team-edit-btn {
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #4a5568;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}
.team-edit-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
    color: #2d3748;
}

/* Режим правки строки */
.team-list-item.editing {
    align-items: center;
    gap: 8px;
}
.team-edit-input {
    flex: 1;
    border: 2px solid #667eea;
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    color: #2d3748;
    background: #fff;
}
.team-edit-input:focus {
    outline: none;
    border-color: #5a67d8;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}
.team-edit-actions {
    display: flex;
    gap: 6px;
}
.team-edit-actions button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.team-edit-actions button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.team-edit-actions .btn-edit-save { background: #48bb78; }
.team-edit-actions .btn-edit-save:hover:not(:disabled) { background: #38a169; }
.team-edit-actions .btn-edit-delete { background: #e53e3e; }
.team-edit-actions .btn-edit-delete:hover:not(:disabled) { background: #c53030; }
.team-edit-actions .btn-edit-cancel { background: #a0aec0; }
.team-edit-actions .btn-edit-cancel:hover:not(:disabled) { background: #718096; }

/* Скрытие на мобильных */
.desktop-only {
    display: flex;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header {
        padding: 15px 20px;
    }

    .modal-body {
        padding: 15px 20px;
    }

    .team-search-container {
        flex-direction: row;
    }
}


.table-container {
    overflow-x: auto;
}

/* Mobile: три независимых флекс-блока вместо sticky-обёрток на <table>.
   Слева — фиксированная колонка «Команда» (с местом и изменением позиции
   внутри ячейки), в центре — изолированный горизонтальный скролл раундов
   (mask-image имитирует «уходящие» ячейки у краёв, JS переключает маски
   по позиции скролла), справа — фиксированная «Счёт». Раунды никогда не
   вылезают за свой блок, обводка не скроллится, sticky-смещений нет.
   JS: buildMobileLayoutHtml() + attachMobileScrollMasks() в script.js. */
@media (max-width: 768px) {
    /* Внешний #tableContainer — прозрачная обёртка; рамку и фон даёт
       внутренний .m-table. --ogr-m-table-pad — внешний отступ из настроек. */
    .table-container {
        overflow: visible;
        padding: var(--ogr-m-table-pad, 0px);
        border: none;
        border-radius: 0;
    }

    /* Корневой контейнер мобильной таблицы. Красный фон + padding = «обводка»,
       которая не зависит от скролла раундов. Все геометрические параметры —
       из настроек (--ogr-m-*), на десктоп не влияют (только в этом @media). */
    .m-table {
        display: flex;
        gap: var(--ogr-m-cell-gap, 4px);
        background: #e20713;
        padding: var(--ogr-m-outer-border, 6px);
        border-radius: var(--ogr-m-cell-radius, 8px);
        box-sizing: border-box;
        width: 100%;
        overflow: hidden;
    }

    /* Боковые флекс-колонки одинакового шага строк — строки
       синхронны с центральным блоком, поэтому всё аккуратно выравнивается. */
    .m-teams-side,
    .m-scores-side {
        display: flex;
        flex-direction: column;
        gap: var(--ogr-m-cell-gap, 4px);
        flex-shrink: 0;
    }
    .m-teams-side  { width: var(--ogr-m-teams-width,  32%); }
    .m-scores-side { width: var(--ogr-m-scores-width, 17%); overflow: hidden; }

    /* Изолированный скролл-блок раундов. Без масок — пользователь убрал,
       раунды просто уходят за край контейнера (overflow: hidden у .m-table
       обрезает их). Скроллбар скрыт. */
    .m-rounds-area {
        flex: 1;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
    }
    .m-rounds-area::-webkit-scrollbar { display: none; }

    .m-rounds-grid {
        display: flex;
        flex-direction: column;
        gap: var(--ogr-m-cell-gap, 4px);
        width: 100%;
    }

    /* Ровно 3 колонки раундов в видимой области:
         column = (100% - (gap * 2)) / 3.
       При N раундов > 3 строка шире своего блока → горизонтальный скролл
       (overflow-x: auto у .m-rounds-area). */
    .m-rounds-row {
        display: grid;
        grid-template-columns: repeat(var(--m-rounds-count, 8),
            calc((100% - (var(--ogr-m-cell-gap, 4px) * 2)) / 3));
        gap: var(--ogr-m-cell-gap, 4px);
        width: 100%;
    }
    .m-rounds-row > .m-cell { scroll-snap-align: start; }

    /* Базовая ячейка. Существующие классы (medal-*, change-*, total-cell,
       round-dimmed, score-cell-readonly) каскадно перекрывают фон/цвет. */
    .m-cell {
        height: var(--ogr-m-cell-height, 52px);
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        background: #ffffff;
        color: #000000;
        border-radius: var(--ogr-m-cell-radius, 8px);
        position: relative;
        overflow: hidden;
        font-weight: 700;
        font-size: var(--ogr-m-score-size, 18px);
    }
    .m-header-cell {
        height: var(--ogr-m-header-height, 36px);
        background: transparent !important;
        color: #ffffff !important;
        font-size: 12px;
    }
    .m-teams-side .m-header-cell { justify-content: center; }

    /* Ячейка команды: место — слева сверху, изменение — слева снизу,
       корона — справа сверху (все position:absolute, не занимают место).
       Имя команды центрируется по всей ширине ячейки с переносом по словам,
       не «обходя» бэйджи — они визуально лежат поверх. fitTextToContainer
       ужмёт шрифт, если по вертикали не помещается. */
    .m-team-cell {
        justify-content: center;
        padding: 4px;
        text-align: center;
    }
    .m-team-place {
        position: absolute;
        top: 3px; left: 5px;
        font-size: 11px;
        font-weight: 800;
        line-height: 1;
        color: inherit;
        z-index: 2;
        pointer-events: none;
    }
    .m-team-change {
        position: absolute;
        bottom: 3px; left: 4px;
        font-size: 10px;
        font-weight: 700;
        line-height: 1;
        padding: 2px 4px;
        border-radius: 4px;
        z-index: 2;
        pointer-events: none;
    }
    .m-team-change.change-positive { background: #b6d7a8; color: #38761d; }
    .m-team-change.change-negative { background: #ea9999; color: #660000; }
    .m-team-cell .team-name-text {
        font-size: var(--ogr-m-team-name-size, 12px);
        font-weight: 700;
        line-height: 1.1;
        white-space: normal;
        overflow-wrap: break-word;
        overflow: hidden;
        max-width: 100%;
        text-align: center;
    }
    .m-team-cell .team-streak {
        position: absolute;
        top: 2px; left: 50%; transform: translateX(-50%);
        font-size: 12px;
        line-height: 1;
        z-index: 2;
        color: var(--ogr-crown-color, #FFC700);
        pointer-events: none;
        white-space: nowrap;
    }

    /* Заголовки раундов — две строки: «Раунд» сверху, номер снизу. */
    .m-rounds-row.m-header-row .m-cell {
        flex-direction: column;
        font-weight: 700;
        line-height: 1;
        padding: 4px 0;
    }
    .m-rounds-row.m-header-row .m-cell .round-label {
        font-size: 9px;
        opacity: 0.85;
    }
    .m-rounds-row.m-header-row .m-cell .round-number {
        font-size: var(--ogr-m-header-size, 14px);
        font-weight: 800;
    }
    .m-rounds-row.m-header-row .round-header-active { background: #8b0000 !important; }

    /* Тотал справа: красный фон, белые цифры. Перекрываем хардкод
       width/padding у глобального .total-cell. */
    .m-scores-side .m-body-cell.total-cell {
        background: #e20713 !important;
        color: #ffffff !important;
        font-size: var(--ogr-m-total-size, 19px);
        font-weight: 800;
        padding: 0;
        width: auto;
        min-width: 0;
    }

    /* Затенение ячеек при просмотре раунда. */
    .m-rounds-area .score-cell.round-dimmed {
        opacity: 0.25 !important;
        background: #e8e8e8 !important;
        pointer-events: none;
    }

    /* Шрифт внутри ячеек раундов — наследует от .m-cell (--ogr-m-score-size),
       а не от глобальных правил .score-value/.score-input. */
    .m-cell .score-value,
    .m-cell .score-input {
        font-size: inherit;
    }
}

/* Round history viewing mode */
.round-dimmed {
    opacity: 0.25 !important;
    background-color: #e8e8e8 !important;
    pointer-events: none;
}

.round-dimmed .score-input,
.round-dimmed .score-value {
    opacity: 0.3;
}

.round-header-active {
    background: #8b0000 !important;
    box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.7);
    position: relative;
}

th.score-header-reset {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

th.score-header-reset:hover {
    background: #b71c1c !important;
}

.round-header-clickable {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.round-header-clickable:hover {
    background: #c62828 !important;
}

/* Round viewing indicator bar */
.round-viewing-bar {
    background: #8b0000;
    color: white;
    text-align: center;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.round-viewing-bar span {
    opacity: 0.7;
    font-weight: 400;
}


table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
}

thead {
    background: #e20713;
    color: white;
}

th {
    padding: 8px 6px;
    height: var(--ogr-d-header-h, 50px);
    box-sizing: border-box;
    vertical-align: middle;
    text-align: center;
    font-weight: 700;
    font-size: var(--ogr-d-header-fs, 14px);
    letter-spacing: 0.5px;
    color: white;
    border-top: 2px solid #e20713;
    border-bottom: 2px solid #e20713;
    border-right: 2px solid #e20713;
}

th:first-child {
    border-left: 2px solid #e20713;
}

th:last-child {
    border-right: 2px solid #e20713;
}

/* Раунды: номер = header * 1.43 (≈ 20/14), «Раунд» = номер / 2 */
th.round-header {
    font-size: var(--ogr-d-header-fs, 14px);
    line-height: 1.2;
}

th.round-header .round-label {
    display: block;
    font-size: calc(var(--ogr-d-header-fs, 14px) * 0.714);
}

th.round-header .round-number {
    display: block;
    font-size: calc(var(--ogr-d-header-fs, 14px) * 1.43);
    margin-top: 2px;
}

th.place-header {
    font-size: var(--ogr-d-header-fs, 14px);
    width: var(--ogr-d-place-w, 76px);
    min-width: var(--ogr-d-place-w, 76px);
}

td {
    padding: 0;
    text-align: center;
    border-bottom: 2px solid #e20713;
    border-right: 2px solid #e20713;
    height: var(--ogr-d-min-row-h, 50px);
}

td:first-child {
    border-left: 2px solid #e20713;
}

td:last-child {
    border-right: 2px solid #e20713;
}

tbody tr {
    transition: background-color 0.2s ease;
}

.place-cell {
    font-weight: 700;
    font-size: var(--ogr-d-table-fs, 18px);
    color: #000000;
    background: white;
    border-left: 0;
    border-right: 0;
    padding: 4px 6px;
    width: var(--ogr-d-place-w, 76px);
    min-width: var(--ogr-d-place-w, 76px);
    white-space: nowrap;
    position: relative;
}

.place-number {
    font-size: var(--ogr-d-table-fs, 18px);
    font-weight: 700;
}




.team-name {
    font-weight: 700;
    color: #000000;
    text-align: center;
    padding: 0;
    width: auto;
    min-width: var(--ogr-d-team-min-w, 170px);
    max-width: var(--ogr-d-team-max-w, 240px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: sticky;
    left: 0;
    background: white;
    z-index: 10;
    border-left: 2px solid #e20713;
    border-right: 2px solid #e20713;
}


.team-name-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 4px 8px;
    font-size: var(--ogr-d-table-fs, 18px);
    white-space: normal;
    line-height: 1.1;
    overflow: hidden;
    /* max-height был 50px ⇒ при has-crown padding-top (~28px) урезал
       место под текст до 22px, длинное двухстрочное название перекрывалось
       короной. Убрано: ячейка свободно растёт под короной + текстом,
       остальные ячейки в строке тянутся через rowspan-механику table. */
}

/* Score value display (span instead of input for mobile) */
.score-value {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: var(--ogr-d-table-fs, 18px);
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    z-index: 2;
}

.score-input {
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    text-align: center;
    font-size: var(--ogr-d-table-fs, 18px);
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    background: transparent;
    transition: background-color 0.2s ease;
    /* Disable text selection and context menu on mobile */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    position: relative;
    z-index: 2;
}

.score-input:focus {
    outline: none;
    background-color: #f0f8ff;
}

td.score-cell {
    padding: 0;
    height: var(--ogr-d-min-row-h, 50px);
    position: relative;
}

/* SVG Marker Icons */
.marker-icon {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

/* Красная звёздочка (ручная метка *) - в углу */
.marker-asterisk {
    width: 14px;
    height: 14px;
    top: 3px;
    right: 3px;
    fill: #e20713;
}

/* Золотой круг (разделённый максимум) - вокруг числа */
.marker-gold-circle {
    width: var(--ogr-marker-best-size, 40px);
    height: var(--ogr-marker-best-size, 40px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    fill: #FFD700;
    opacity: 0.9;
}

/* Золотая звезда (единственный максимум) - на фоне числа */
.marker-gold-star {
    width: var(--ogr-marker-best-size, 48px);
    height: var(--ogr-marker-best-size, 48px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    fill: #FFD700;
    opacity: 0.85;
}

/* Обеспечиваем видимость текста поверх маркеров */
.score-input {
    position: relative;
    z-index: 2;
}


td.score-cell {
    padding: 0;
    height: var(--ogr-d-min-row-h, 50px);
    position: relative;
}

.total-cell {
    font-weight: 700;
    font-size: var(--ogr-d-table-fs, 18px);
    color: white;
    background: #e20713;
    padding: 12px 10px;
    width: var(--ogr-d-total-w, 92px);
    min-width: var(--ogr-d-total-w, 92px);
    border-right: 2px solid #e20713;
    border-left: 2px solid #e20713;
}


thead th:last-child {
    background: #e20713;
}

/* Медальные места */
.medal-gold {
    background: linear-gradient(180deg, #E1AC2C 0%, #F4E180 100%) !important;
    color: #783f04 !important;
}

.medal-silver {
    background: linear-gradient(180deg, #C2C2C2 0%, #E9E9E9 100%) !important;
    color: #434343 !important;
}

.medal-bronze {
    background: linear-gradient(180deg, #ce9363 0%, #EACC77 100%) !important;
    color: #783f04 !important;
}

/* Изменение позиций (новая колонка) */
.change-header {
    width: var(--ogr-d-change-w, 60px);
    min-width: var(--ogr-d-change-w, 60px);
    padding: 0;
}

.change-cell {
    width: var(--ogr-d-change-w, 44px);
    min-width: var(--ogr-d-change-w, 44px);
    padding: 0;
    text-align: center;
    vertical-align: middle;
}

/* «Пилюля» изменения позиции: компактная капсула с иконкой-стрелкой и числом.
   Мягкий цветной фон + насыщенный текст/иконка — чисто и не перегружает строку. */
.change-badge {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    padding: 3px 7px;
    border-radius: 999px;
    font-weight: 800;
    font-size: calc(var(--ogr-d-table-fs, 18px) * 0.72);
    line-height: 1;
    letter-spacing: -0.02em;
}
.change-badge i {
    font-size: 0.92em;
}
.change-badge.up {
    background: #dcfce7;
    color: #15803d;
}
.change-badge.down {
    background: #fee2e2;
    color: #dc2626;
}
/* Нейтраль — тонкое тире, ненавязчиво. */
.change-dash {
    color: #d1d5db;
    font-weight: 700;
    font-size: calc(var(--ogr-d-table-fs, 18px) * 0.8);
}

/* Фиксация колонок при прокрутке */
thead th:nth-child(3) { /* Team Name is now 3rd column */
    position: sticky;
    left: 0;
    z-index: 20;
    background: #e20713;
    border-left: 2px solid #e20713;
}

thead th:last-child {
    background: #e20713;
    border-right: 2px solid #e20713;
}

tbody tr .team-name {
    left: 0;
}

/* Адаптивный дизайн */
@media (max-width: 768px) {
    .container {
        padding: 0;
    }

    /* На мобильном — сужаем контейнер через 100vw, radius = 0 чтобы не
       было видимого зазора по углам при значении 0. */
    .container {
        padding: 0 !important;
        border-radius: 0 !important;
        max-width: none !important;
        width: calc(100vw - 2 * var(--ogr-m-page-h-pad, 0px)) !important;
    }
    .table-container {
        padding: var(--ogr-m-table-pad, 0px) !important;
    }

    /* === Мобильное меню — гамбургер в правом верхнем углу ===
       Раньше меню сидело по центру шапки и его dropdown в одну строку
       иконок перекрывал .game-identity (дату/город) у логотипа. Теперь:
       toggle-кнопка справа от кнопки экспорта (правая группа кнопок),
       dropdown — вертикальный list с видимыми подписями, плавный
       slide-down. Высота уравнена с .logout-btn (см. далее).
       Anchor dropdown'а — .header-menu (relative): dropdown приклеен к
       правому-нижнему углу самой кнопки меню, без визуального зазора. */
    header { gap: 4px; }
    .header-menu {
        position: relative;
        left: auto;
        right: auto;
        margin: 0;
        width: auto;
        align-items: flex-end;
        flex-shrink: 0;
        order: 3;
    }
    /* .header-logout — это legacy-имя контейнера правой части шапки
       (когда-то там действительно была кнопка выхода). Сейчас в нём
       сидит кнопка экспорта PNG. Margin-left:auto толкает контейнер
       и всё, что идёт за ним по order, к правому краю шапки. */
    .header-logout {
        order: 2;
        margin-left: auto;
    }
    .menu-toggle-btn {
        height: 36px;
        width: 44px;
        padding: 0 12px;
        gap: 0;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .menu-toggle-text { display: none; }
    .menu-toggle-icon { font-size: 16px; line-height: 1; }
    .menu-toggle-btn.active { border-radius: 8px 8px 0 0; }
    .menu-toggle-btn.active::before,
    .menu-toggle-btn.active::after { display: none; }
    /* .header-logout сидит правее меню — уравниваем высоту и стиль кнопок. */
    .logout-btn {
        height: 36px;
        padding: 0 12px;
        font-size: 16px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    .menu-dropdown {
        flex-direction: column;
        align-items: stretch;
        min-width: 200px;
        border-radius: 10px 0 10px 10px;
    }
    .menu-item {
        justify-content: flex-start;
        padding: 12px 16px;
        gap: 12px;
        width: 100%;
        box-sizing: border-box;
        text-align: left;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    .menu-item:last-child { border-bottom: none; }
    .menu-item:last-child { border-bottom: none; }
    .menu-item-text {
        display: inline;
        font-size: 14px;
        font-weight: 600;
    }
    .menu-item i { font-size: 15px; width: 18px; text-align: center; }
    /* Горизонтальные .menu-divider скрываем — строки разделены тонкой
       полосой в самом .menu-item (border-bottom). */
    .menu-divider { display: none; }

    th,
    td {
        font-size: 12px;
    }

    .score-input,
    .team-name input {
        font-size: 16px;
    }

    .place-cell {
        font-size: 16px;
    }

    .team-name-text {
        font-size: 12px;
    }

}

@media (max-width: 480px) {
    body {
        padding: 0;
    }

    .container {
        padding: 0;
        border-radius: 0;
    }

    h1 {
        font-size: 1.5em;
    }

    th {
        padding: 15px 5px;
    }
}

.team-name-wrapper {
    position: relative;
}

.team-autocomplete {
    position: fixed;
    background: white;
    border: 2px solid #e20713;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10000;
    display: none;
    min-width: 200px;
}

.team-autocomplete.show {
    display: block;
}


.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #e2e8f0;
    transition: background-color 0.2s ease;
}

.autocomplete-item:hover {
    background-color: #f7fafc;
}

.autocomplete-item:last-child {
    border-bottom: none;
}


.team-name input::placeholder {
    color: #a0aec0;
    font-style: italic;
}

@media (max-width: 768px) {
    td.score-cell {
        width: 60px;
        min-width: 60px;
    }

    th.round-header {
        width: 60px;
        min-width: 60px;
    }

    .team-autocomplete {
        max-height: 150px;
        font-size: 14px;
    }
}

.teams-section-header {
    font-size: 14px;
    font-weight: 700;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 15px;
    background-color: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
    margin-top: 10px;
}

.teams-section-header:first-child {
    margin-top: 0;
}

.teams-section-toggle {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}
.teams-section-toggle:hover {
    background-color: #edf2f7;
}
.teams-section-toggle .fa-chevron-down,
.teams-section-toggle .fa-chevron-right {
    margin-right: 6px;
    color: #a0aec0;
}

.team-list-item.in-table {
    background-color: #f0f8ff;
    border-left: 4px solid #667eea;
}

.team-list-item-actions .btn-add {
    background: #48bb78;
}

.team-list-item-actions .btn-add:hover {
    background: #38a169;
}

.team-list-item-actions .btn-remove {
    background: #f59e0b;
}

.team-list-item-actions .btn-remove:hover {
    background: #d97706;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: #2d3748;
    font-size: 14px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    transition: border-color 0.2s ease;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #e20713;
}

.form-select {
    cursor: pointer;
    background-color: white;
}

/* Сводка игры */
.game-summary {
    margin-top: 20px;
    padding: 15px;
    background-color: #f7fafc;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

.game-summary h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #2d3748;
}

.game-summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
}

.game-summary-item:last-child {
    border-bottom: none;
}

.game-summary-label {
    font-weight: 700;
    color: #718096;
}

.game-summary-value {
    font-weight: 700;
    color: #2d3748;
}

/* Большое модальное окно */
.modal-large .modal-content {
    max-width: 900px;
}

/* Фильтры архива */
.archive-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.archive-filters .form-select,
.archive-filters .form-input {
    flex: 1;
}

/* Контейнер архива игр */
.games-archive-container {
    max-height: 500px;
    overflow-y: auto;
}

.game-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.game-card:hover {
    border-color: #e20713;
    box-shadow: 0 4px 12px rgba(226, 7, 19, 0.1);
}

.game-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.game-card-title {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
}

.game-card-city {
    display: inline-block;
    padding: 6px 12px;
    background-color: #e20713;
    color: white;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}

.game-card-city.dubai {
    background-color: #3182ce;
}

.game-card-city.abudhabi {
    background-color: #38a169;
}

.game-card-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.game-card-stat {
    text-align: center;
}

.game-card-stat-label {
    font-size: 12px;
    color: #718096;
    margin-bottom: 5px;
}

.game-card-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
}

.game-card-teams {
    margin-top: 15px;
}

.game-card-teams-title {
    font-size: 14px;
    font-weight: 700;
    color: #718096;
    margin-bottom: 10px;
}

.game-card-top-teams {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-card-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #f7fafc;
    border-radius: 6px;
}

/* Призовые места */
.first {
    background: linear-gradient(180deg, #ffd966 0%, #fff4cc 25%, #ffd966 100%) !important;
    color: #7f6000 !important;
}

.second {
    background: linear-gradient(180deg, #d9d9d9 0%, #f0f0f0 25%, #d9d9d9 100%) !important;
    color: #434343 !important;
}

.third {
    background: linear-gradient(180deg, #f6b26b 0%, #fcd5b4 25%, #f6b26b 100%) !important;
    color: #783f04 !important;
}


.game-card-team-name {
    font-weight: 700;
}

.game-card-team-score {
    font-weight: 700;
    font-size: 18px;
}

.game-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #e2e8f0;
}

.game-card-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-load {
    background-color: #3182ce;
    color: white;
}

.btn-load:hover {
    background-color: #2c5282;
}

.btn-delete {
    background-color: #e53e3e;
    color: white;
}

.btn-delete:hover {
    background-color: #c53030;
}

.btn-export {
    background-color: #38a169;
    color: white;
}

.btn-export:hover {
    background-color: #2f855a;
}

.empty-archive {
    text-align: center;
    padding: 60px 20px;
    color: #a0aec0;
}

.empty-archive-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-archive-text {
    font-size: 18px;
    font-style: italic;
}

@media (max-width: 768px) {
    .game-card-body {
        grid-template-columns: 1fr;
    }

    .archive-filters {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 20px;
    }

    table {
        font-size: 12px;
        min-width: 450px;
    }

    th,
    td {
        padding: 6px 3px;
        font-size: 11px;
    }

    th.col-team {
        min-width: 100px;
    }

    td.team-name {
        max-width: 100px;
        font-size: 11px;
    }

    input.score-input {
        width: 35px;
        font-size: 13px;
    }

    .status {
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* Clear teams button in section header */
.clear-teams-btn {
    font-size: 12px;
    text-transform: none;
    color: #e20713;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-weight: 600;
}

.clear-teams-btn:hover {
    background-color: #fed7d7;
}

/* Clear dialog modal */
.clear-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10002;
}

.clear-dialog {
    background: white;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.clear-dialog h3 {
    margin-bottom: 20px;
    color: #2d3748;
}

.clear-dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.clear-dialog-buttons button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.clear-dialog-buttons .btn-points {
    background: #f59e0b;
    color: white;
}

.clear-dialog-buttons .btn-points:hover {
    background: #d97706;
}

.clear-dialog-buttons .btn-all {
    background: #e20713;
    color: white;
}

.clear-dialog-buttons .btn-all:hover {
    background: #c00610;
}

.clear-dialog-buttons .btn-cancel {
    background: #718096;
    color: white;
}

.clear-dialog-buttons .btn-cancel:hover {
    background: #4a5568;
}

/* =====================================================
   Custom Numeric Keyboard for Mobile
   ===================================================== */

.custom-keyboard {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #e8e8e8;
    padding: 8px;
    display: none;
    z-index: 9999;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.custom-keyboard.visible {
    display: block;
}

/* Добавить отступ к body когда клавиатура видна */
body.keyboard-open {
    padding-bottom: 130px;
}

.keyboard-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-bottom: 6px;
}

.keyboard-row:last-child {
    margin-bottom: 0;
}

.key-btn {
    height: 48px;
    border: none;
    border-radius: 10px;
    background: #e0e0e0;
    color: #444;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Neumorphic inner shadow effect */
    box-shadow: 
        inset 2px 2px 4px rgba(255, 255, 255, 0.9),
        inset -2px -2px 4px rgba(0, 0, 0, 0.1),
        1px 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.key-btn:active {
    box-shadow: 
        inset -2px -2px 4px rgba(255, 255, 255, 0.9),
        inset 2px 2px 4px rgba(0, 0, 0, 0.15);
    transform: scale(0.97);
}

/* Специальные кнопки - и * */
.key-btn.key-special {
    font-size: 24px;
    font-weight: 600;
}

/* Активная ячейка подсветка - красная внутренняя тень */
.score-cell.keyboard-active {
    box-shadow: inset 0 0 8px 2px rgba(226, 7, 19, 0.4) !important;
}

/* На десктопе скрываем клавиатуру */
@media (hover: hover) and (pointer: fine) {
    .custom-keyboard {
        display: none !important;
    }
}

/* Modal Centering Fix */
.modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex !important;
}

.modal-content {
    background-color: #fefefe;
    margin: auto; /* Fallback */
    padding: 10px;
    border: 1px solid #888;
    width: 95%;
    max-width: 600px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Настройки отображения таблицы */
:root {
    --ogr-table-pad-web: 0px;
    --ogr-cell-radius: 8px;
    --ogr-cell-gap: 4px;
    --ogr-outer-border: 6px;
    --ogr-container-max-width: 1800px;
    --ogr-table-row-scale: 1;
    --ogr-d-header-fs: 14px;
}
.table-container { padding: var(--ogr-table-pad-web); }

/* «Пряничный» вид таблицы: ячейки со скруглёнными углами, между ними красный
   зазор (на пересечении 4 ячеек получается красное перекрестье в форме звезды).
   padding на table = внешняя красная обводка (фон table красный, заполняет
   padding) — настраивается отдельно от зазора между ячейками.
   Override-ит существующие border-rules на td/th и фон table. */
.table-container table {
    border-collapse: separate !important;
    border-spacing: var(--ogr-cell-gap) !important;
    background: #e20713 !important;
    border-radius: var(--ogr-cell-radius) !important;
    /* Симметричный padding со всех сторон. По Y добавляем место для короны,
       которая выступает над верхом ячейки (см. --ogr-table-pad-extra-y).
       Так отступы сверху/снизу остаются равными — рамка симметричная. */
    padding:
        calc(var(--ogr-outer-border) + var(--ogr-table-pad-extra-y, 0px))
        var(--ogr-outer-border) !important;
}

/* Контейнер таблицы. Когда --ogr-d-table-min-h > 0, flex+flex:1 растягивают
   строки равномерно до целевой высоты. При 0 — высота по содержимому. */
.table-container {
    display: flex;
    flex-direction: column;
    min-height: var(--ogr-d-table-min-h, 0px);
}
.table-container table {
    flex: 1;
    width: 100%;
    table-layout: auto !important;
}

/* Ширины колонок из настроек (CSS-переменные --ogr-d-*).
   Каждое правило покрывает и th (заголовок), и td (данные). */
.table-container .team-name {
    min-width: var(--ogr-d-team-min-w, 170px) !important;
    max-width: var(--ogr-d-team-max-w, 240px) !important;
    width: auto;
}

.table-container .score-cell {
    width: auto;
    min-width: 30px;
}

.table-container .total-cell,
.table-container .score-header-reset {
    width: var(--ogr-d-total-w, 92px) !important;
    min-width: var(--ogr-d-total-w, 92px) !important;
    max-width: var(--ogr-d-total-w, 92px) !important;
}

.table-container .place-cell,
.table-container .place-header {
    width: var(--ogr-d-place-w, 76px) !important;
    min-width: var(--ogr-d-place-w, 76px) !important;
}

.table-container .change-cell,
.table-container .change-header {
    width: var(--ogr-d-change-w, 60px) !important;
    min-width: var(--ogr-d-change-w, 60px) !important;
}
.table-container th,
.table-container td {
    border: none !important;
    border-radius: var(--ogr-cell-radius) !important;
}
/* Шапка таблицы: bg задаётся на th явно, потому что при border-collapse:separate
   фон thead не пробивается в th-ячейки. */
.table-container th {
    background: #e20713 !important;
}
/* Дефолтный фон данных-ячеек — белый. Медальные градиенты, total-cell и
   change-* перекрывают этот дефолт собственным background. */
.table-container tbody td {
    background: #ffffff;
}
/* Итоговая ячейка («Счёт») — красный фон, белый текст. Селектор более
   специфичен, чем дефолтный белый. */
.table-container tbody td.total-cell {
    background: #e20713 !important;
    color: #ffffff !important;
}
/* Ячейка изменения позиций — белая, как остальные; цвет несёт «пилюля». */
.table-container tbody td.change-cell { background: #ffffff !important; }
/* Input в score-cell наследует радиус ячейки — иначе при фокусе углы
   срезаются (input по умолчанию прямоугольный). */
.table-container .score-input {
    border-radius: var(--ogr-cell-radius) !important;
}
/* Mobile-only элементы внутри team-name (на десктопе их рисуют change-cell
   и place-cell как отдельные колонки). */
.team-mobile-place,
.team-mobile-change {
    display: none;
}
/* Ячейка названия команды — sticky-left. Обводка обеспечивается общим
   border-spacing (красный зазор от фона таблицы), как у остальных ячеек.
   Длинное название уводим вниз от короны через padding-top (.has-crown),
   чтобы текст не пересекался с короной. */
/* Группа корона + название: flex-колонка, центрируется в ячейке.
   Заменяет padding-top хак — crown и текст теперь единый визуальный блок. */
.team-name-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
/* Внутри группы корона — статична в потоке, не absolute */
.team-name-group .team-streak {
    position: static;
    transform: none;
    left: auto;
    top: auto;
}
/* Внутри группы высота текста — auto, иначе height:100% из базового стиля
   конфликтует с flex-column и ломает margin-top */
.team-name-group .team-name-text {
    height: auto;
}
/* gap через margin-top — срабатывает только когда .team-name-text
   идёт непосредственно после .team-streak (т.е. только у команды с короной) */
.team-name-group .team-streak + .team-name-text {
    margin-top: var(--ogr-crown-name-gap, 4px);
}
/* Корона в ячейке места: номер места прижимаем к низу (vertical-align не
   растит высоту строки), корона рисуется абсолютно сверху над номером —
   название команды остаётся в полный размер. */
.table-container .place-cell.has-crown {
    vertical-align: bottom;
}

/* ==========================================================================
   Settings modal v2 — два колонки (live preview | форма с табами),
   полноэкранная на мобильном. Чистый layout без sticky-хаков прежней версии.
   ========================================================================== */

.ds-modal .ds-content {
    width: min(1100px, calc(100vw - 32px));
    max-width: 1100px !important;
    max-height: min(90vh, 760px);
    height: 90vh;
    padding: 0;
    overflow: hidden;
}
.ds-modal .ds-header {
    padding: 16px 22px;
    border-bottom: 2px solid #e20713;
    flex-shrink: 0;
}
.ds-modal .ds-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
}
.ds-modal .ds-header h2 .fa-sliders { color: #e20713; }

/* Двухколонный body: preview слева, форма справа. */
.ds-layout {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
}

/* === LEFT: live preview ================================================ */
.ds-preview-pane {
    background: #f5f7fb;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 14px;
    gap: 10px;
}
.ds-preview-switch {
    display: flex;
    gap: 4px;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 10px;
    flex-shrink: 0;
}
.ds-preview-switch-btn {
    flex: 1;
    padding: 7px 10px;
    border: none;
    background: transparent;
    color: #555;
    font-weight: 700;
    font-size: 13px;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 120ms, color 120ms;
}
.ds-preview-switch-btn:hover { color: #1a1a1a; }
.ds-preview-switch-btn.active {
    background: #fff;
    color: #e20713;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ds-preview-switch-btn i { font-size: 14px; }

.ds-preview-frame {
    flex: 1 1 auto;
    min-height: 0;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 12px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
}
.ds-preview-frame[data-view="mobile"] {
    background: #232943;
    padding: 18px 10px;
}
.ds-preview-stage {
    width: 100%;
    max-width: 100%;
}
.ds-preview-frame[data-view="mobile"] .ds-preview-stage {
    width: 280px;
    background: #ffffff;
    border-radius: 22px;
    padding: 28px 8px 18px;
    box-shadow: 0 6px 22px rgba(0,0,0,0.25);
    position: relative;
}
/* «Чёлка» в верху мобильного превью — лёгкий намёк на телефон. */
.ds-preview-frame[data-view="mobile"] .ds-preview-stage::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 6px;
    background: #232943;
    border-radius: 4px;
}
.ds-preview-caption {
    margin: 0;
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.35;
    flex-shrink: 0;
}
.ds-preview-caption i { color: #999; }

/* === RIGHT: tabs + panels ============================================== */
.ds-form-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background: #ffffff;
}
.ds-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    padding: 0 18px;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.ds-tabs::-webkit-scrollbar { display: none; }
.ds-tab {
    padding: 14px 16px;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-weight: 700;
    color: #666;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 120ms;
}
.ds-tab:hover { color: #1a1a1a; }
.ds-tab.active {
    color: #e20713;
    border-bottom-color: #e20713;
}
.ds-panel {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 22px 22px;
    flex: 1 1 auto;
    min-height: 0;
}
.ds-panel[hidden] { display: none; }

/* === Groups & fields =================================================== */
.ds-group {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.ds-group:last-child { margin-bottom: 0; }
.ds-group-title {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 800;
    color: #e20713;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.ds-group-hint {
    margin: 0 0 12px;
    font-size: 12.5px;
    color: #6b7280;
    line-height: 1.4;
}
.ds-group .ds-group-hint + .ds-fields,
.ds-group .ds-group-title + .ds-fields { margin-top: 12px; }

.ds-collapsible[open] > .ds-group-title::after { transform: rotate(180deg); }
.ds-collapsible > .ds-group-title {
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 0;
}
.ds-collapsible > .ds-group-title::-webkit-details-marker { display: none; }
.ds-collapsible > .ds-group-title::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 11px;
    color: #6b7280;
    transition: transform 160ms;
}
.ds-collapsible:not([open]) > .ds-group-title { margin-bottom: 0; }

/* Сетка полей — всегда 2 колонки. Чекбоксы/селекты — на всю ширину. */
.ds-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    align-items: center;
}
.ds-radio-cards,
.ds-field-checkbox,
.ds-field:has(.ds-select),
.ds-field:has(.ds-color) {
    grid-column: 1 / -1;
}
@media (max-width: 520px) {
    .ds-fields { grid-template-columns: 1fr; }
}

/* Каждое поле — вертикально: label сверху, stepper снизу */
.ds-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.ds-field-label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    line-height: 1.3;
}
.ds-field-label .ds-field-hint {
    font-weight: 400;
    color: #6b7280;
    font-size: 11px;
}

/* ── Stepper: [value field 100%] с кнопками по бокам ──────────────────
   Кнопки абсолютно позиционированы: на 25% своей ширины заходят ЗА
   поле значения (z-index ниже). Контейнер добавляет padding = 75%
   ширины кнопки, чтобы кнопки выступали наружу.                       */
.ds-slider {
    flex: 0 0 auto;
    position: relative;
    /* padding по бокам = видимая часть кнопки снаружи поля (75% от 24px ≈ 18px) */
    padding: 0 18px;
    box-sizing: content-box;
    min-width: 60px;
}
.ds-slider input[type="range"] {
    display: none;
}
.ds-step-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    background: #f3f4f6;
    color: #374151;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 0;          /* позади поля значения */
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: background 0.1s, color 0.1s;
}
.ds-step-minus { left: 0; }
.ds-step-plus  { right: 0; }
.ds-step-btn:hover { background: #e5e7eb; }
.ds-step-btn:active,
.ds-step-btn.ds-step-active { background: #e20713; border-color: #e20713; color: #fff; }

.ds-slider-value {
    display: block;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 1;          /* поверх кнопок — перекрывает их на 25% */
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 13px;
    color: #1a1a1a;
    background: #ffffff;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 5px 4px;
    cursor: pointer;
    white-space: nowrap;
}
.ds-slider-value:hover { border-color: #9ca3af; }
.ds-slider-value.editing {
    outline: 2px solid #e20713;
    outline-offset: -1px;
    cursor: text;
}

/* Select */
.ds-select {
    flex: 1 1 0;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 32px 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23475569' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 12px center;
    background-size: 10px 6px;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}
.ds-select:focus { outline: 2px solid #e20713; outline-offset: 0; border-color: transparent; }

/* Switch (заменяет обычный checkbox) */
.ds-field-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}
.ds-field-checkbox .ds-field-label {
    cursor: pointer;
    flex: 1;
}
.ds-switch {
    appearance: none;
    -webkit-appearance: none;
    width: 38px;
    height: 22px;
    background: #cbd5e1;
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    transition: background 160ms;
    flex-shrink: 0;
    margin: 0;
}
.ds-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: left 160ms;
}
.ds-switch:checked { background: #e20713; }
.ds-switch:checked::before { left: 18px; }

/* Color */
.ds-color {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ds-color input[type="color"] {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 32px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
}
.ds-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; border-radius: 6px; }
.ds-color input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.ds-color-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 13px;
    color: #475569;
    text-transform: uppercase;
}

/* Icon picker (4 карточки) */
.ds-icon-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.ds-icon-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 120ms, transform 100ms;
}
.ds-icon-card:hover { border-color: #cbd5e1; }
.ds-icon-card input { position: absolute; opacity: 0; pointer-events: none; }
.ds-icon-card i { font-size: 24px; color: #6b7280; transition: color 120ms; }
.ds-icon-card span { font-size: 12px; font-weight: 600; color: #6b7280; }
.ds-icon-card:has(input:checked) {
    border-color: #e20713;
    background: #fef2f3;
    transform: translateY(-1px);
}
.ds-icon-card:has(input:checked) i,
.ds-icon-card:has(input:checked) span { color: #e20713; }

/* Radio cards (Снисходительный / Строгий) */
.ds-radio-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.ds-radio-card {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 120ms;
    align-items: flex-start;
}
.ds-radio-card:hover { border-color: #cbd5e1; }
.ds-radio-card input { margin-top: 3px; flex-shrink: 0; accent-color: #e20713; }
.ds-radio-card:has(input:checked) {
    border-color: #e20713;
    background: #fef7f7;
}
.ds-radio-card-body { display: flex; flex-direction: column; gap: 3px; }
.ds-radio-card-body strong { font-size: 13px; color: #1a1a1a; }
.ds-radio-card-body span { font-size: 12px; color: #475569; line-height: 1.4; }

/* === Footer ============================================================ */
.ds-modal .ds-footer {
    padding: 12px 18px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    background: #ffffff;
}
.ds-footer-actions { display: flex; gap: 8px; }
.btn-text-secondary {
    background: transparent;
    color: #6b7280;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
    border: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
}
.btn-text-secondary:hover { background: #f1f5f9; color: #1a1a1a; }

/* === Mini-preview таблица внутри ds-preview-stage ====================== */
.dsp-table {
    --dsp-cell-h: 38px;
    --dsp-radius: 8px;
    --dsp-gap: 4px;
    --dsp-border: 6px;
    --dsp-team-w: 38%;
    --dsp-score-w: 16%;
    --dsp-header-h: 28px;
    --dsp-name-fs: 12px;
    --dsp-score-fs: 14px;
    --dsp-total-fs: 14px;
    --dsp-header-fs: 12px;
    --dsp-crown-color: #FFC700;
    --dsp-crown-size: 18px;
    --dsp-crown-shadow: none;
    display: flex;
    gap: var(--dsp-gap);
    background: #e20713;
    padding: var(--dsp-border);
    border-radius: var(--dsp-radius);
    box-sizing: border-box;
    width: 100%;
}
.dsp-col-teams,
.dsp-col-scores {
    display: flex;
    flex-direction: column;
    gap: var(--dsp-gap);
    flex-shrink: 0;
}
.dsp-col-teams  { width: var(--dsp-team-w); }
.dsp-col-scores { width: var(--dsp-score-w); }
.dsp-col-rounds {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.dsp-rounds-grid {
    display: flex;
    flex-direction: column;
    gap: var(--dsp-gap);
}
.dsp-rounds-row {
    display: grid;
    /* desktop задаёт абсолютные px колонок (по reality * ratio),
       mobile — оставляет дефолт: 3 колонки на 100% ширины контейнера. */
    grid-template-columns: var(--dsp-rounds-template, repeat(var(--dsp-rounds-count, 3), calc((100% - var(--dsp-gap) * 2) / 3)));
    gap: var(--dsp-gap);
}
.dsp-cell {
    height: var(--dsp-cell-h);
    border-radius: var(--dsp-radius);
    background: #fff;
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--dsp-score-fs);
    position: relative;
    overflow: hidden;
}
.dsp-cell.dsp-header {
    height: var(--dsp-header-h);
    background: transparent;
    color: #fff;
    font-size: var(--dsp-header-fs);
    flex-direction: column;
    line-height: 1;
    padding: 3px 0;
}
.dsp-cell.dsp-header .dsp-rh-label { font-size: 9px; opacity: 0.85; font-weight: 700; }
.dsp-cell.dsp-header .dsp-rh-number { font-weight: 800; font-size: var(--dsp-header-fs); }
.dsp-col-teams .dsp-header { justify-content: flex-start; padding-left: 8px; align-items: center; }

.dsp-cell.dsp-team {
    flex-direction: column;
    justify-content: center;
    padding: 4px;
    text-align: center;
}
.dsp-cell.dsp-team .dsp-place {
    position: absolute;
    top: 3px; left: 5px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}
.dsp-cell.dsp-team .dsp-name {
    font-size: var(--dsp-name-fs);
    font-weight: 700;
    overflow-wrap: break-word;
    line-height: 1.1;
    max-width: 100%;
}
.dsp-cell.dsp-team .dsp-change {
    position: absolute;
    bottom: 3px; left: 4px;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1;
}
.dsp-cell.dsp-team .dsp-change.up   { background: #b6d7a8; color: #38761d; }
.dsp-cell.dsp-team .dsp-change.down { background: #ea9999; color: #660000; }
.dsp-cell.dsp-team .dsp-crown {
    position: absolute;
    top: 2px; left: 50%;
    transform: translateX(-50%);
    color: var(--dsp-crown-color);
    font-size: var(--dsp-crown-size);
    text-shadow: var(--dsp-crown-shadow);
    line-height: 1;
    pointer-events: none;
}
.dsp-cell.dsp-total {
    background: #e20713;
    color: #fff;
    font-size: var(--dsp-total-fs);
    font-weight: 800;
}
.dsp-cell.dsp-medal-gold   { background: #ffd54f !important; }
.dsp-cell.dsp-medal-silver { background: #e0e0e0 !important; }
.dsp-cell.dsp-medal-bronze { background: #e6b894 !important; }

/* Полноэкранная модалка на мобильном: preview сверху, форма снизу,
   sticky-футер. */
@media (max-width: 900px) {
    .ds-modal .ds-content {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .ds-modal .ds-header { padding: 12px 16px; }
    .ds-modal .ds-header h2 { font-size: 16px; }
    .ds-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .ds-preview-pane {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding: 10px 12px;
        gap: 8px;
        max-height: 36vh;
    }
    .ds-preview-frame { padding: 8px; }
    .ds-preview-frame[data-view="mobile"] .ds-preview-stage { width: 240px; }
    .ds-tabs { padding: 0 10px; }
    .ds-tab { padding: 12px 12px; font-size: 13px; }
    .ds-panel { padding: 14px 14px 18px; }
    .ds-group { padding: 12px 12px; }
    .ds-fields { grid-template-columns: 1fr; }
    .ds-radio-cards { grid-template-columns: 1fr; }
    .ds-icon-picker { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .ds-icon-card { padding: 10px 4px; }
    .ds-icon-card i { font-size: 20px; }
    .ds-modal .ds-footer { padding: 10px 12px; gap: 6px; flex-wrap: nowrap; }
    .ds-modal .ds-footer .btn { padding: 10px 12px; font-size: 13px; white-space: nowrap; }
    .btn-text-secondary { padding: 8px 10px; }
    .btn-text-secondary span { display: none; }
}

/* Корона-страйк перед названием команды в таблице.
   Абсолютное позиционирование у левой границы ячейки — не меняет
   высоту строки и не сдвигает центрированный текст команды.
   Золотой цвет с тёмно-золотой обводкой и мягкой тенью — читается
   и на золотой медальной строке, и на белом фоне; обводка даёт
   небольшой объём. Размер ~ под высоту названия команды.
   Реальный диапазон: 1 (победа в прошлой игре) или 2 (страйк);
   3 — рекорд. count-many — защитный fallback. */
.team-streak {
    /* Корона по центру НАД названием команды. Абсолютное позиционирование
       не меняет высоту строки. --ogr-crown-offset-y — отступ верхней кромки
       короны от верха ячейки (px): 0 = вровень с верхом, отрицательное —
       выступает выше. Все параметры приходят из настроек через CSS-vars. */
    position: absolute;
    left: 50%;
    top: 0;
    transform: translate(-50%, var(--ogr-crown-offset-y, 0px));
    display: inline-flex;
    gap: 2px;
    color: var(--ogr-crown-color, #FFC700);
    line-height: 1;
    z-index: 3;
    pointer-events: none;
    text-shadow: var(--ogr-crown-text-shadow, none);
}
/* Размер = заданный в настройках для реального диапазона страйка (1-3);
   только при 4+ коронах (count-many) уменьшаем, иначе ряд слишком широкий. */
.team-streak.count-1,
.team-streak.count-2,
.team-streak.count-3 { font-size: var(--ogr-streak-size, 26px); }
.team-streak.count-many { font-size: calc(var(--ogr-streak-size, 26px) * 0.62); }

/* ==========================================================================
   TODO модалка — список идей с drag&drop приоритетом, архив,
   inline-редактирование, sync с GitHub (см. /api/todos в server.js).
   ========================================================================== */
.todo-modal-content { max-width: 640px !important; }
.todo-body { display: flex; flex-direction: column; gap: 12px; }

.todo-toolbar {
    display: flex;
    gap: 6px;
    align-items: center;
}
.todo-view-btn {
    flex: 1;
    padding: 8px 12px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
}
.todo-view-btn:hover { background: #e2e8f0; }
.todo-view-btn.active {
    background: #e20713;
    color: white;
    border-color: #e20713;
}
.todo-sync-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.todo-sync-btn:hover { background: #1a1a1a; color: white; border-color: #1a1a1a; }
.todo-sync-btn.synced { background: #16a34a; color: white; border-color: #16a34a; }

.todo-sync-save-btn {
    padding: 8px 12px;
    background: #2563eb;
    color: white;
    border: 1px solid #2563eb;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.todo-sync-save-btn:hover { background: #1d4ed8; }
.todo-sync-save-btn.dirty { background: #f59e0b; border-color: #f59e0b; animation: todoSavePulse 1.4s ease-in-out infinite; }
@keyframes todoSavePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
    50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

.todo-add-form {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.todo-add-form input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
}
.todo-add-form input[type="text"]:focus { outline: 2px solid #e20713; border-color: transparent; }
.todo-add-btn {
    flex-shrink: 0;
    padding: 0 16px;
    background: #e20713;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}
.todo-add-btn:hover { background: #b30510; }

.todo-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 55vh;
    overflow-y: auto;
}
.todo-empty {
    padding: 24px;
    text-align: center;
    color: #6b7280;
    font-weight: 500;
    background: #f8fafc;
    border-radius: 8px;
}
.todo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    /* touch-action:none на сам item даёт нашему drag pointerdown полный
       контроль (scroll не перехватывает gesture). */
}
.todo-item.dragging {
    opacity: 0.55;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    background: white;
}
.todo-item .todo-drag-handle {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    cursor: grab;
    touch-action: none;
    user-select: none;
    font-size: 14px;
}
.todo-item .todo-drag-handle:hover { color: #475569; }
.todo-item .todo-drag-handle:active { cursor: grabbing; }
.todo-item.archived .todo-drag-handle { visibility: hidden; }

.todo-item .todo-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    cursor: text;
    word-break: break-word;
    padding: 4px 0;
}
.todo-item .todo-title:hover { color: #e20713; }
.todo-item.archived .todo-title { color: #94a3b8; text-decoration: line-through; cursor: default; }
.todo-item .todo-title-input {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid #e20713;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
}
.todo-item .todo-action-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.todo-item .todo-archive { background: #16a34a; }
.todo-item .todo-archive:hover { background: #15803d; }
.todo-item .todo-restore { background: #2563eb; }
.todo-item .todo-restore:hover { background: #1d4ed8; }
.todo-item .todo-delete { background: #dc2626; }
.todo-item .todo-delete:hover { background: #b91c1c; }
.todo-item .todo-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.todo-hint {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex-wrap: wrap;
}
.todo-hint i { color: #9ca3af; flex-shrink: 0; }

/* Drop-placeholder — пустое место, куда упадёт перетаскиваемый элемент. */
.todo-placeholder {
    height: 44px;
    background: rgba(226, 7, 19, 0.06);
    border: 2px dashed #e20713;
    border-radius: 8px;
}

/* GitHub-sync sub-form */
.todo-sync-form {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
}
.todo-sync-form h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 6px;
}
.todo-sync-status {
    margin: 0 0 12px;
    font-size: 12px;
    color: #6b7280;
}
.todo-sync-status.ok { color: #16a34a; }
.todo-sync-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}
.todo-sync-fields label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}
.todo-sync-fields label small { font-weight: 400; color: #6b7280; }
.todo-sync-fields input {
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
}
.todo-sync-fields input:focus { outline: 2px solid #e20713; border-color: transparent; }
.todo-sync-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.todo-sync-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .todo-modal-content { max-width: 100vw !important; }
    .todo-sync-row { grid-template-columns: 1fr; }
}

/* Сбрасываем десктопную !important-ширину колонки «Счёт» на мобиле —
   должна управляться процентом .m-scores-side, а не --ogr-d-total-w. */
@media (max-width: 768px) {
    .table-container .total-cell,
    .table-container .score-header-reset {
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
    }
}

/* Маркеры лучшего раунда на мобиле — отдельный настраиваемый размер. */
@media (max-width: 768px) {
    .marker-gold-star,
    .marker-gold-circle {
        width: var(--ogr-m-marker-size, 36px) !important;
        height: var(--ogr-m-marker-size, 36px) !important;
    }
}
