/* Светлая и тёмная темы публичного фронта.
   Подключается после player.css / stat.css; админка тему не использует. */

:root {
    --line: #e4e7ea;
    --soft: #f5f7f8;
    --input: #ffffff;
    --warm: #fff7ed;
    --warm-line: #ffe0a3;
    --teal-soft: #e8f4f6;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1417;
    --card: #181f23;
    --text: #e7eef2;
    --muted: #9aa8b1;
    --primary: #ff8c2a;
    --primary-dark: #e07316;
    --teal: #6cc7d8;
    --danger: #fca5a5;
    --line: #2b353b;
    --soft: #11191d;
    --input: #12191d;
    --warm: #251b10;
    --warm-line: #4a351b;
    --teal-soft: #142f36;

    --sr-ink: #0b0f11;
    --sr-canvas: #070a0c;
    --sr-warm-white: #e7eef2;
    --sr-orange: #ff8c2a;
    --sr-line-1: #ffb435;
    --sr-line-2: #e07316;
    --sr-brown: #ff9d5c;
    --sr-brown-dark: #f08a3c;
    --sr-teal: #6cc7d8;
    --sr-steel: #9fb4bc;
    --sr-border: #2b353b;
    --sr-soft: #232d33;
    --sr-page: #0f1417;
    --sr-muted: #9aa8b1;
    --sr-red: #ff7b7b;
}

.sr-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 40px;
    height: 40px;
    margin: 0 0 0 4px;
    padding: 0;
    border: 1px solid #4a4a4a;
    border-radius: 9px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
}

.sr-theme-toggle:hover {
    background: var(--sr-orange, #ff8c00);
    border-color: var(--sr-orange, #ff8c00);
}

.sr-theme-toggle:focus-visible {
    outline: 2px solid var(--sr-line-1, #ffb435);
    outline-offset: 2px;
}

html[data-theme="dark"] .sr-theme-toggle {
    border-color: #3c4a50;
}

/* --- общие поверхности тёмной темы --- */

html[data-theme="dark"] body {
    background: var(--bg);
    color: var(--text);
}

html[data-theme="dark"] .sr-body {
    color: var(--text);
    background-color: var(--sr-canvas);
    background-image:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 14px),
        linear-gradient(180deg, #0d1418, #080c0f);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .profile-card,
html[data-theme="dark"] .team-roster-item,
html[data-theme="dark"] .team-directory-card,
html[data-theme="dark"] .teams-search,
html[data-theme="dark"] .team-achievement,
html[data-theme="dark"] .team-empty,
html[data-theme="dark"] .help-toc,
html[data-theme="dark"] .help-section,
html[data-theme="dark"] .sr-block,
html[data-theme="dark"] .sr-card {
    border-color: var(--line);
    background: var(--card);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .22);
}

html[data-theme="dark"] .team-section--team,
html[data-theme="dark"] .team-section--game,
html[data-theme="dark"] .team-section--history {
    border-color: var(--line);
    background: #141c20;
}

html[data-theme="dark"] .game-info {
    border-color: var(--warm-line);
    background: linear-gradient(180deg, #241b12, #1a1510);
    color: #f4dcc2;
}

html[data-theme="dark"] .timer {
    border-color: #7a4b22;
    background: #2a1c10;
    color: #ffbd7d;
}

html[data-theme="dark"] .timer-warning {
    background: #3a230e;
}

html[data-theme="dark"] .progressbar {
    background: #29343a;
}

html[data-theme="dark"] .hint,
html[data-theme="dark"] .task-body {
    background: var(--card);
    color: var(--text);
}

html[data-theme="dark"] .team-roster-item {
    border-color: var(--line);
}

html[data-theme="dark"] .team-stat {
    border-color: var(--line);
    background: #131b20;
}

html[data-theme="dark"] .team-directory-stats span {
    background: #232d33;
    color: #b8c6cc;
}

html[data-theme="dark"] .team-directory-foot {
    border-top-color: var(--line);
    color: var(--muted);
}

html[data-theme="dark"] .team-mini-more {
    border-color: #0f1417;
    background: #26343a;
    color: #b8c6cc;
}

html[data-theme="dark"] .team-stat::after {
    opacity: .14;
}

html[data-theme="dark"] .team-directory-card:hover {
    border-color: #46616c;
    box-shadow: 0 5px 18px rgba(0, 0, 0, .28);
}

html[data-theme="dark"] .team-directory-title,
html[data-theme="dark"] .team-directory-meta b,
html[data-theme="dark"] .team-directory-stats b,
html[data-theme="dark"] .team-member-name,
html[data-theme="dark"] .team-history-rank,
html[data-theme="dark"] .team-history-points,
html[data-theme="dark"] .sr-card-team,
html[data-theme="dark"] .sr-task-name {
    color: var(--text);
}

html[data-theme="dark"] .team-history-row:hover {
    background: #1d282e;
}

html[data-theme="dark"] .team-jump a:hover {
    background: #1b292f;
    color: var(--teal);
}

html[data-theme="dark"] .team-section-body,
html[data-theme="dark"] .team-section {
    color: var(--text);
}

html[data-theme="dark"] .team-empty {
    background: #12191d;
}

html[data-theme="dark"] .form-row input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .code-input,
html[data-theme="dark"] .bonus-input,
html[data-theme="dark"] .answer-form input,
html[data-theme="dark"] .teams-search-form input[type="text"] {
    border-color: var(--line);
    background: var(--input);
    color: var(--text);
}

html[data-theme="dark"] .form-row input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #70828c;
}

html[data-theme="dark"] .flash-success {
    border-color: #2c7a4b;
    background: #10291c;
    color: #b8f4cf;
}

html[data-theme="dark"] .flash-error {
    border-color: #b63a3a;
    background: #2c1113;
    color: #ffc1c1;
}

html[data-theme="dark"] .flash-info {
    border-color: #2c5f8f;
    background: #0f1f30;
    color: #b9ddff;
}

html[data-theme="dark"] .banner-info {
    background: #0f1f30;
    color: #b9ddff;
}

html[data-theme="dark"] .banner-error {
    background: #2c1113;
    color: #ffc1c1;
}

html[data-theme="dark"] .notice {
    border-color: var(--line);
    background: #151d22;
    color: var(--text);
}

html[data-theme="dark"] .notice-warning {
    border-left-color: #b88720;
    background: #241c0e;
}

html[data-theme="dark"] .notice-urgent {
    border-left-color: #b63a3a;
    background: #2c1113;
}

html[data-theme="dark"] .sr-impersonate {
    background: #2c1113;
    color: #ffc1c1;
}

html[data-theme="dark"] .hint-closed,
html[data-theme="dark"] .codes-panel,
html[data-theme="dark"] .code-chip,
html[data-theme="dark"] .bonus-item,
html[data-theme="dark"] .team-avatar,
html[data-theme="dark"] .team-directory-stats,
html[data-theme="dark"] .team-journal,
html[data-theme="dark"] .team-history-status,
html[data-theme="dark"] .notice-modal,
html[data-theme="dark"] .sr-test-strip {
    border-color: var(--line);
    background: #1b252a;
    color: var(--text);
}

html[data-theme="dark"] .team-journal summary {
    color: #c9d8de;
}

html[data-theme="dark"] .team-journal-list {
    color: var(--text);
}

html[data-theme="dark"] .team-journal-list li {
    border-top-color: var(--line);
}

html[data-theme="dark"] .team-journal-time {
    color: #91a6b0;
}

html[data-theme="dark"] .task-summary {
    border-color: var(--line);
    background: var(--card);
}

html[data-theme="dark"] .task-step-badge,
html[data-theme="dark"] .hints-count {
    background: var(--teal-soft);
    color: var(--teal);
}

html[data-theme="dark"] .task-summary-timer {
    border-color: #4a351b;
    background: #2a1c10;
    color: #ffbd7d;
}

html[data-theme="dark"] .task-summary-timer.is-warning {
    border-color: #7a3030;
    background: #321416;
    color: #ff9d9d;
}

html[data-theme="dark"] .task-summary-body {
    border-top-color: var(--line);
}

html[data-theme="dark"] .task-goal-badge {
    border-color: var(--line);
    color: var(--muted);
}

html[data-theme="dark"] .task-timer {
    border-color: #4a351b;
    background: #2a1c10;
}

html[data-theme="dark"] .task-timer-label {
    color: #d5a06e;
}

html[data-theme="dark"] .task-timer b {
    color: #ffbd7d;
}

html[data-theme="dark"] .task-timer-game {
    border-color: var(--line);
    background: var(--soft);
}

html[data-theme="dark"] .task-timer-game .task-timer-label {
    color: var(--muted);
}

html[data-theme="dark"] .task-timer-game b {
    color: var(--teal);
}

html[data-theme="dark"] .task-summary .progressbar {
    background: #29343a;
}

html[data-theme="dark"] .task-body,
html[data-theme="dark"] .answer-card,
html[data-theme="dark"] .hints {
    border-color: var(--line);
    background: var(--card);
}

html[data-theme="dark"] .hints .hint {
    border-color: var(--line);
    background: #1b252a;
}

html[data-theme="dark"] .sr-team-badge {
    border-color: #76521d;
    background: #352610;
    color: #ffc06a;
}

html[data-theme="dark"] .sr-player-badge {
    border-color: var(--line);
    background: #1b252a;
    color: #b8c6cc;
}

html[data-theme="dark"] .codes-panel,
html[data-theme="dark"] .notice-modal,
html[data-theme="dark"] .sr-test-strip {
    background: #211a12;
    color: #f4dcc2;
}

html[data-theme="dark"] .team-captain-badge {
    background: #352610;
    color: #ffc06a;
}

html[data-theme="dark"] .team-avatar-empty {
    background: linear-gradient(145deg, #1d333a, #162329);
    color: #b8e7ee;
}

html[data-theme="dark"] .team-member-login,
html[data-theme="dark"] .team-member-meta,
html[data-theme="dark"] .team-jump,
html[data-theme="dark"] .profile-facts dt {
    color: var(--muted);
}

html[data-theme="dark"] .team-medal {
    background: linear-gradient(145deg, #3a2d13, #4a351b);
    color: #ffc06a;
}

html[data-theme="dark"] .btn-small {
    background: #29343a;
    color: var(--text);
}

html[data-theme="dark"] .btn-danger {
    background: #3a1719;
    color: #ffc1c1;
}

html[data-theme="dark"] .start-game {
    border-color: var(--warm-line);
    background:
        radial-gradient(circle at 90% 10%, rgba(255, 140, 0, .12), transparent 30%),
        linear-gradient(135deg, #241b12, #181f23);
}

html[data-theme="dark"] .start-links a,
html[data-theme="dark"] .help-cta a {
    border-color: var(--line);
    background: var(--card);
    color: var(--teal);
}

html[data-theme="dark"] .profile-avatar {
    background: #29343a;
}

html[data-theme="dark"] .status-ok {
    background: #12351f;
    color: #8ee8ac;
}

html[data-theme="dark"] .status-warn {
    background: #352610;
    color: #ffc06a;
}

html[data-theme="dark"] .status-muted {
    background: #222d33;
    color: #aebbc2;
}

html[data-theme="dark"] .help-toc a:hover {
    background: var(--teal-soft);
}

html[data-theme="dark"] .help-note {
    background: #251b10;
    color: #f4dcc2;
}

html[data-theme="dark"] .join-card {
    border-left-color: var(--primary);
}

html[data-theme="dark"] .join-badge {
    background: #352610;
    color: #ffc06a;
}

html[data-theme="dark"] .join-badge-ok {
    background: #12351f;
    color: #8ee8ac;
}

html[data-theme="dark"] .account-list li,
html[data-theme="dark"] .quick-link,
html[data-theme="dark"] .mini-game {
    border-color: var(--line);
}

/* --- архив --- */

html[data-theme="dark"] .sr-sheet {
    background: var(--sr-page);
    color: var(--text);
}

html[data-theme="dark"] .sr-block-title,
html[data-theme="dark"] .sr-table thead th {
    background: #0b1114;
    color: #dbe7ec;
}

html[data-theme="dark"] .sr-block-body,
html[data-theme="dark"] .sr-table,
html[data-theme="dark"] .sr-card {
    background: var(--card);
    color: var(--text);
}

html[data-theme="dark"] .sr-table td,
html[data-theme="dark"] .sr-table th {
    border-color: #2a353b;
}

html[data-theme="dark"] .sr-table tbody tr,
html[data-theme="dark"] .sr-table tbody tr:nth-child(even) {
    background: #181f23;
}

html[data-theme="dark"] .sr-table tbody tr:nth-child(even) {
    background: #1c252a;
}

html[data-theme="dark"] .sr-table tbody tr:hover {
    background: #243139;
}

html[data-theme="dark"] .sr-table tbody tr.sr-rank-1 {
    background: #3a2d13;
}

html[data-theme="dark"] .sr-table tbody tr.sr-rank-2 {
    background: #293239;
}

html[data-theme="dark"] .sr-table tbody tr.sr-rank-3 {
    background: #30251c;
}

html[data-theme="dark"] .sr-table tbody tr.sr-row-active {
    background: #13333a;
}

html[data-theme="dark"] .sr-table tbody tr.sr-season-row td,
html[data-theme="dark"] .sr-season-head {
    background: #1b252b;
    color: #8edbe7;
}

html[data-theme="dark"] .sr-sheet a:not(.sr-btn):not(.sr-btn-ghost) {
    color: #7fd0de;
}

html[data-theme="dark"] .sr-sheet a:not(.sr-btn):not(.sr-btn-ghost):hover {
    color: #ffb435;
}

html[data-theme="dark"] .sr-table tbody tr .sr-sticky-1,
html[data-theme="dark"] .sr-table tbody tr .sr-sticky-2,
html[data-theme="dark"] .sr-table tbody tr .sr-pin-total {
    background: #181f23;
}

html[data-theme="dark"] .sr-table tbody tr:nth-child(even) .sr-sticky-1,
html[data-theme="dark"] .sr-table tbody tr:nth-child(even) .sr-sticky-2,
html[data-theme="dark"] .sr-table tbody tr:nth-child(even) .sr-pin-total {
    background: #1c252a;
}

html[data-theme="dark"] .sr-table tbody tr.sr-rank-1 .sr-sticky-1,
html[data-theme="dark"] .sr-table tbody tr.sr-rank-1 .sr-sticky-2,
html[data-theme="dark"] .sr-table tbody tr.sr-rank-1 .sr-pin-total {
    background: #3a2d13;
}

html[data-theme="dark"] .sr-table tbody tr.sr-rank-2 .sr-sticky-1,
html[data-theme="dark"] .sr-table tbody tr.sr-rank-2 .sr-sticky-2,
html[data-theme="dark"] .sr-table tbody tr.sr-rank-2 .sr-pin-total {
    background: #293239;
}

html[data-theme="dark"] .sr-table tbody tr.sr-rank-3 .sr-sticky-1,
html[data-theme="dark"] .sr-table tbody tr.sr-rank-3 .sr-sticky-2,
html[data-theme="dark"] .sr-table tbody tr.sr-rank-3 .sr-pin-total {
    background: #30251c;
}

html[data-theme="dark"] .sr-table tbody tr:hover .sr-sticky-1,
html[data-theme="dark"] .sr-table tbody tr:hover .sr-sticky-2,
html[data-theme="dark"] .sr-table tbody tr:hover .sr-pin-total {
    background: #243139;
}

html[data-theme="dark"] .sr-table tbody tr.sr-row-active .sr-sticky-1,
html[data-theme="dark"] .sr-table tbody tr.sr-row-active .sr-sticky-2,
html[data-theme="dark"] .sr-table tbody tr.sr-row-active .sr-pin-total {
    background: #13333a;
}

html[data-theme="dark"] .sr-table .sr-best-points {
    background: #3a2d13;
}

html[data-theme="dark"] .sr-table .sr-best-time {
    background: #14333b;
}

html[data-theme="dark"] .sr-table .sr-best-points.sr-best-time {
    background: #2c3a1b;
}

html[data-theme="dark"] .sr-table .sr-sticky-2,
html[data-theme="dark"] .sr-table .sr-pin-total {
    box-shadow: 1px 0 0 #2b353b;
}

html[data-theme="dark"] .sr-pin-total {
    box-shadow: -1px 0 0 #2b353b;
}

html[data-theme="dark"] .sr-btn-ghost {
    border-color: var(--sr-steel);
    background: #182126;
    color: var(--teal);
}

html[data-theme="dark"] .sr-btn-ghost:hover {
    border-color: var(--sr-brown);
    background: #202c32;
    color: var(--sr-brown);
}

html[data-theme="dark"] .sr-btn-disabled,
html[data-theme="dark"] .sr-btn-disabled:hover {
    border-color: var(--line);
    background: #11191d;
    color: var(--muted);
}

html[data-theme="dark"] .sr-arch-team-row {
    border-bottom-color: #2b353b;
}

html[data-theme="dark"] .sr-arch-team-row[data-team]:hover,
html[data-theme="dark"] .sr-arch-skipped-name:hover {
    background: #2a2218;
}

html[data-theme="dark"] .sr-arch-team-selected {
    background: #14333b !important;
}

html[data-theme="dark"] .sr-help-hero {
    border-left-color: var(--sr-orange);
}

html[data-theme="dark"] .sr-help-hero .sr-block-body {
    background: linear-gradient(135deg, #211a12, #181f23 62%);
}

html[data-theme="dark"] .sr-arch-task {
    border-color: var(--sr-border);
}

html[data-theme="dark"] .sr-arch-task-active {
    border-left-color: var(--sr-brown);
    background: #332817;
    animation: none;
}

html[data-theme="dark"] .sr-arch-teams-details > summary:hover {
    background: #2a2218;
}

html[data-theme="dark"] .sr-arch-desc,
html[data-theme="dark"] .sr-arch-tip,
html[data-theme="dark"] .sr-arch-reward,
html[data-theme="dark"] .sr-arch-fact,
html[data-theme="dark"] .sr-arch-tiles > div,
html[data-theme="dark"] .sr-arch-bonus-item,
html[data-theme="dark"] .sr-code {
    border-color: var(--sr-border);
    background: #131b20;
    color: var(--text);
}

html[data-theme="dark"] .sr-arch-tip {
    border-left-color: var(--sr-orange);
    background: #251b10;
    color: #f4dcc2;
}

html[data-theme="dark"] .sr-code {
    color: #ffbd7d;
}

html[data-theme="dark"] .sr-badge {
    background: #3a2a1a;
    color: #ffc58a;
}

html[data-theme="dark"] .sr-badge-pending {
    border-color: #76521d;
    background: #2c2414;
    color: #ffc06a;
}

html[data-theme="dark"] .sr-badge-answers {
    background: #13333a;
    color: #8edbe7;
}

html[data-theme="dark"] .sr-badge-bonus {
    background: #2c2414;
    color: #ffc06a;
}

html[data-theme="dark"] .help-note {
    border-left-color: var(--sr-orange);
}

html[data-theme="dark"] .sr-footer {
    color: #7f919a;
}

html[data-theme="dark"] .sr-footer a {
    color: var(--teal);
}

html[data-theme="dark"] .sr-card-head {
    border-bottom-color: var(--line);
}

html[data-theme="dark"] .sr-task {
    border-top-color: var(--line);
}

html[data-theme="dark"] .sr-task-name,
html[data-theme="dark"] .sr-card-team {
    color: var(--text);
}

html[data-theme="dark"] .sr-card-meta {
    color: var(--sr-muted);
}

html[data-theme="dark"] .sr-tip::after {
    border-color: transparent;
    background: #0b1114;
    color: #dbe7ec;
}

@media (max-width: 1023.98px) {
    .sr-header-inner {
        position: relative;
    }

    .sr-theme-toggle {
        position: absolute;
        top: 7px;
        right: 52px;
        width: 36px;
        height: 36px;
        margin: 0;
        order: 0;
    }

    .sr-burger {
        order: 0;
        margin-left: auto;
    }
}

/* --- ожидание игры --- */

html[data-theme="dark"] .game-info,
html[data-theme="dark"] .wait-card {
    border-color: var(--line);
    background: var(--card);
    color: var(--text);
}

html[data-theme="dark"] .game-info-title,
html[data-theme="dark"] .wait-card-head h1 {
    color: var(--text);
}

html[data-theme="dark"] .game-info-status {
    border-color: #76521d;
    background: #352610;
    color: #ffc06a;
}

html[data-theme="dark"] .game-info-status-live {
    border-color: #2c7a4b;
    background: #10291c;
    color: #8ee8ac;
}

html[data-theme="dark"] .game-info-status-test {
    border-color: #2c5f8f;
    background: #0f1f30;
    color: #b9ddff;
}

html[data-theme="dark"] .game-info-status-finished,
html[data-theme="dark"] .game-info-status-archived {
    border-color: var(--line);
    background: var(--soft);
    color: var(--muted);
}

html[data-theme="dark"] .game-info-row {
    border-color: var(--line);
    background: #131b20;
}

html[data-theme="dark"] .game-info-row > span:first-child,
html[data-theme="dark"] .wait-countdown-label,
html[data-theme="dark"] .wait-countdown-date {
    color: var(--muted);
}

html[data-theme="dark"] .wait-countdown {
    border-color: #4a351b;
    background: #2a1c10;
}

html[data-theme="dark"] .wait-countdown b {
    color: #ffbd7d;
}

html[data-theme="dark"] .wait-note--info {
    border-left-color: var(--teal);
    background: var(--teal-soft);
}

html[data-theme="dark"] .wait-note--warning {
    border-left-color: #b88720;
    background: #241c0e;
}

html[data-theme="dark"] .wait-note--danger {
    border-left-color: #b63a3a;
    background: #2c1113;
}

html[data-theme="dark"] .wait-info {
    border-color: var(--line);
}

/* --- общий фактурный фон публичного фронта --- */

body.player-body {
    background-color: #3b3b3b;
    background-image:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, .02) 0 2px, transparent 2px 14px),
        linear-gradient(180deg, #484848, #3b3b3b);
}

html[data-theme="dark"] body.player-body {
    background-color: #070a0c;
    background-image:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, .018) 0 2px, transparent 2px 14px),
        linear-gradient(180deg, #0d1418, #080c0f);
}

.player-sheet {
    margin: 14px auto 0;
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 16px;
    background: var(--bg);
    box-shadow: 0 14px 40px rgba(0, 0, 0, .28);
}

.container-login {
    background: transparent;
}

body.page-account-auth-login .start-brand {
    color: #ffffff;
}

body.page-account-auth-login .start-brand small {
    color: #9cbcc4;
}

body.page-account-auth-login .start-tagline,
body.page-account-auth-login .start-footnote {
    color: #c9d8de;
}

body.page-account-auth-login .start-auth {
    border: 1px solid rgba(255, 255, 255, .14);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35), 0 5px 14px rgba(0, 0, 0, .18);
}

body.page-account-auth-login .start-game {
    box-shadow: 0 14px 35px rgba(0, 0, 0, .18);
}

.engine-footer {
    padding: 13px 16px 18px;
    color: #9cbcc4;
    font-size: 10px;
    line-height: 1.45;
    text-align: center;
}

.engine-footer a {
    color: #d6e4e8;
    text-decoration: none;
}

.engine-footer a:hover {
    color: #ffb435;
}

/* --- архив: тёмная панель команд по заданию --- */

html[data-theme="dark"] .sr-arch-teams-details {
    border-color: var(--sr-border);
    background: #181f23;
}

html[data-theme="dark"] .sr-arch-teams-details[open] > summary {
    border-bottom-color: var(--sr-border);
}

@media (max-width: 767.98px) {
    .player-sheet {
        margin: 8px 8px 0;
        border-radius: 12px;
    }
}
