:root {
            --bg: #f4f7fb;
            --panel: #ffffff;
            --panel-soft: #f8fafc;
            --border: #d9e2ec;
            --text: #243447;
            --muted: #6b7b8c;
            --primary: #2563eb;
            --primary-soft: #e8f0ff;
            --danger: #d32f2f;
            --warning: #f59e0b;
            --success: #2e7d32;
            --task-incomplete-bg: #f8fafc;
            --task-progress-bg: #fff7e6;
            --task-complete-bg: #edf9f0;
            --task-abandoned-bg: #e5e7eb;
            --task-hint-ring: #2563eb;
            --task-replaced-ring: #9333ea;
            --task-level-1: #15803d;
            --task-level-2: #0369a1;
            --task-level-3: #c2410c;
            --task-level-4: #7e22ce;
            --task-level-5: #dc2626;
            --task-level-6: #991b1b;
            --shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
        }

        body[data-theme="dark"] {
            --bg: #0f172a;
            --panel: #172033;
            --panel-soft: #111827;
            --border: #334155;
            --text: #e5edf8;
            --muted: #9fb0c6;
            --primary: #60a5fa;
            --primary-soft: #1e3a5f;
            --danger: #f87171;
            --warning: #fbbf24;
            --success: #4ade80;
            --task-incomplete-bg: #19263b;
            --task-progress-bg: #382b16;
            --task-complete-bg: #153322;
            --task-abandoned-bg: #272e3a;
            --task-hint-ring: #60a5fa;
            --task-replaced-ring: #c084fc;
            --task-level-1: #4ade80;
            --task-level-2: #60a5fa;
            --task-level-3: #fb923c;
            --task-level-4: #c084fc;
            --task-level-5: #fb7185;
            --task-level-6: #f43f5e;
            --shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
        }

        * {
            box-sizing: border-box;
        }

        body {
            font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
            margin: 0;
            padding: 24px;
            color: var(--text);
            background: linear-gradient(180deg, #eef4ff 0%, #f7f9fc 180px, #f4f7fb 100%);
        }

        body[data-theme="dark"] {
            background: linear-gradient(180deg, #0b1120 0%, #111827 220px, #0f172a 100%);
        }

        body[data-theme="dark"] .panel,
        body[data-theme="dark"] .toolbar-row,
        body[data-theme="dark"] #admin-controls,
        body[data-theme="dark"] .modal-content,
        body[data-theme="dark"] .match-options-panel,
        body[data-theme="dark"] .score-detail-table,
        body[data-theme="dark"] .postmatch-panel,
        body[data-theme="dark"] .task-grid,
        body[data-theme="dark"] .task-cell {
            background: var(--panel) !important;
            color: var(--text) !important;
            border-color: var(--border) !important;
        }

        body[data-theme="dark"] input,
        body[data-theme="dark"] select,
        body[data-theme="dark"] textarea {
            background: #0f172a;
            color: var(--text);
            border-color: #475569;
        }

        body[data-theme="dark"] .page-subtitle,
        body[data-theme="dark"] .score-rule-note,
        body[data-theme="dark"] .match-options-desc,
        body[data-theme="dark"] .match-options-status {
            color: var(--muted) !important;
        }

        body[data-theme="dark"] .task-grid {
            background: #10243a !important;
        }

        body[data-theme="dark"] .task-cell {
            background: #132f4f !important;
            border-color: #31577d !important;
            color: #eaf4ff !important;
        }

        body[data-theme="dark"] .task-cell:hover {
            background: #173a61 !important;
        }

        body[data-theme="dark"] .task-desc {
            color: #eaf4ff !important;
        }

        body[data-theme="dark"] .task-action-log {
            background: #0f2438 !important;
            border-color: #3b638b !important;
            color: #eaf4ff !important;
        }

        body[data-theme="dark"] .task-action-log h5,
        body[data-theme="dark"] .task-action-log p,
        body[data-theme="dark"] .task-action-log td,
        body[data-theme="dark"] .task-action-log th {
            color: #eaf4ff !important;
        }

        body[data-theme="dark"] .scoreboard-table th,
        body[data-theme="dark"] .scoreboard-table td {
            border-color: #3b526d !important;
        }

        .theme-toggle {
            position: fixed;
            right: 18px;
            top: 18px;
            z-index: 90;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            border: 1px solid var(--border);
            background: var(--panel);
            color: var(--text);
            box-shadow: var(--shadow);
            border-radius: 999px;
            padding: 8px 12px;
            font-weight: 800;
        }

        .login-steps {
            margin-top: 14px;
            padding: 14px 16px;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: var(--panel-soft);
        }

        .login-steps ol {
            margin: 8px 0 0 22px;
            padding: 0;
            font-size: 17px;
            line-height: 1.85;
        }

        .flow-undo-safety-bar {
            position: sticky;
            top: 8px;
            z-index: 20;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 18px;
            margin-bottom: 14px;
            padding: 12px 16px;
            border: 1px solid #f0c36a;
            border-radius: 8px;
            background: #fff9e8;
            box-shadow: 0 5px 18px rgba(120, 83, 18, 0.12);
        }

        .pregame-readiness-card {
            margin: 0 0 14px;
            padding: 11px 14px;
            border: 1px solid var(--border-strong);
            border-left: 4px solid var(--primary);
            border-radius: 12px;
            background: var(--panel);
            box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
        }
        .pregame-readiness-card[hidden] { display: none; }
        .pregame-readiness-heading { display:flex; align-items:center; justify-content:space-between; gap:16px; }
        .pregame-readiness-heading h3 { margin: 1px 0 0; font-size: 18px; }
        .pregame-readiness-heading strong { color: var(--primary); font-size: 16px; white-space: nowrap; }
        .pregame-readiness-detail { margin: 6px 0 8px; color: var(--text); font-size: 14px; }
        .pregame-readiness-blockers { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:5px 8px; }
        .pregame-readiness-blocker, .pregame-readiness-ok {
            display:flex; align-items:center; justify-content:space-between; gap:12px;
            padding:6px 8px; border-radius:7px; background: var(--panel-soft); color: var(--text); font-size: 14px;
        }
        .pregame-readiness-blocker span { color: var(--muted); font-size: 13px; }
        .pregame-readiness-ok { color: var(--success); font-weight: 700; }
        .pregame-readiness-actions { margin-top: 8px; }
        .pregame-readiness-actions button { padding: 7px 11px; }
        @media (max-width: 720px) {
            .pregame-readiness-heading { align-items:flex-start; flex-direction:column; gap:4px; }
            .pregame-readiness-blockers { grid-template-columns: 1fr; }
            .pregame-readiness-blocker, .pregame-readiness-ok { align-items:flex-start; flex-direction:column; gap:3px; }
        }

        .flow-undo-safety-bar[hidden] {
            display: none;
        }

        .flow-undo-summary {
            display: grid;
            gap: 4px;
            min-width: 0;
        }

        .flow-undo-summary > div {
            overflow-wrap: anywhere;
        }

        .flow-phase-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 6px 22px;
        }

        .flow-undo-meta {
            color: var(--muted);
            font-size: 13px;
        }

        .flow-undo-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            flex: 0 0 auto;
        }

        .flow-undo-actions button {
            min-width: 132px;
        }

        #advance-phase-btn {
            background-color: #facc15;
            border-color: #eab308;
            color: #1f2937;
            font-weight: 900;
        }

        body[data-theme="dark"] .flow-undo-safety-bar {
            background: #2b2415;
            border-color: #8a6826;
            color: var(--text);
        }

        @media (max-width: 720px) {
            .flow-undo-safety-bar {
                top: 4px;
                align-items: stretch;
                flex-direction: column;
            }

            .flow-undo-actions {
                display: grid;
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }

            .flow-undo-actions button {
                width: 100%;
                min-width: 0;
            }

            #flow-audio-cue-btn {
                grid-column: 1 / -1;
            }
        }

        .lobby-announcement {
            margin-top: 16px;
            padding: 16px 18px;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: var(--panel-soft);
        }

        .lobby-announcement-header {
            display: flex;
            align-items: center;
            gap: 12px;
            flex-wrap: wrap;
            margin-bottom: 10px;
        }

        .lobby-announcement-header h3 {
            margin: 0;
            font-size: 20px;
            line-height: 1.35;
        }

        .lobby-announcement-body {
            line-height: 1.8;
            overflow-wrap: anywhere;
        }

        .lobby-announcement-body :first-child {
            margin-top: 0;
        }

        .lobby-announcement-body :last-child {
            margin-bottom: 0;
        }

        .lobby-announcement-body blockquote {
            margin: 10px 0;
            padding: 8px 12px;
            border-left: 4px solid var(--primary);
            background: rgba(37, 99, 235, 0.08);
        }

        .lobby-announcement-body a {
            color: var(--primary);
            font-weight: 700;
        }

        .lobby-announcement-admin-panel {
            display: block;
        }

        .lobby-announcement-enabled-row {
            margin-top: 10px;
        }

        .lobby-announcement-title-field {
            display: grid;
            gap: 6px;
            margin: 12px 0;
            font-weight: 800;
        }

        .lobby-announcement-title-field input {
            width: min(520px, 100%);
        }

        .lobby-rich-toolbar {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 6px;
            margin: 10px 0;
        }

        .lobby-rich-toolbar button {
            min-width: 36px;
            margin: 0;
            padding: 6px 10px;
            border-color: var(--border);
            background: var(--panel);
            color: var(--text);
            font-weight: 800;
        }

        .lobby-announcement-editor {
            min-height: 180px;
            max-height: 420px;
            overflow: auto;
            padding: 12px 14px;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: var(--panel);
            color: var(--text);
            line-height: 1.75;
            outline: none;
        }

        .lobby-announcement-editor:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
        }

        .player-list {
            margin-top: 20px;
        }

        .player-item {
            padding: 5px;
            border-bottom: 1px solid #ccc;
        }

        button {
            margin: 5px;
            padding: 8px 12px;
            font-size: 14px;
            cursor: pointer;
            border-radius: 4px;
            border: 1px solid #ccc;
            background-color: #f0f0f0;
        }

            button:hover {
                background-color: #e0e0e0;
            }

            button:disabled {
                background-color: #cccccc;
                color: #666666;
                cursor: not-allowed;
                border: 1px solid #aaa;
            }

        input[type="text"], input[type="number"], select {
            padding: 8px;
            font-size: 14px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 100;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0,0,0,0.5);
        }

        .modal-content {
            background-color: #fefefe;
            margin: 3% auto;
            padding: 20px;
            border: 1px solid #888;
            width: 95%;
            max-width: 1100px;
            line-height: 1.5;
            position: relative;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        }

        .caoren-dialog {
            width: min(92vw, 520px);
            max-width: 520px;
            padding: 0;
            border: 0;
            border-radius: 18px;
            background: transparent;
            color: var(--text-default);
            overflow: visible;
        }

        .caoren-dialog::backdrop {
            background: rgba(3, 8, 18, .72);
            backdrop-filter: blur(7px);
        }

        .caoren-dialog-card {
            padding: 22px;
            border: 1px solid var(--border-subtle);
            border-radius: 18px;
            background: var(--surface);
            box-shadow: 0 24px 70px rgba(0, 0, 0, .36);
        }

        .caoren-dialog-header {
            display: flex;
            align-items: center;
            gap: 14px;
        }

        .caoren-dialog-header h2 {
            margin: 3px 0 0;
            color: var(--text-strong);
            font-size: 22px;
        }

        .caoren-dialog-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex: 0 0 42px;
            width: 42px;
            height: 42px;
            border-radius: 13px;
            background: var(--primary-soft);
            color: var(--primary);
            font-size: 22px;
            font-weight: 900;
        }

        .caoren-dialog-card.is-danger .caoren-dialog-icon {
            background: var(--danger-surface);
            color: var(--danger-text);
        }

        .caoren-dialog-message {
            margin: 18px 0 0;
            color: var(--text-default);
            line-height: 1.7;
            white-space: pre-line;
        }

        .caoren-dialog-input-wrap {
            display: grid;
            gap: 8px;
            margin-top: 18px;
            color: var(--text-strong);
            font-weight: 800;
        }

        .caoren-dialog-input-wrap[hidden] {
            display: none;
        }

        .caoren-dialog-input-wrap input {
            width: 100%;
            min-height: 44px;
            box-sizing: border-box;
            border-color: var(--border-subtle);
            background: var(--surface-muted);
            color: var(--text-default);
        }

        .caoren-dialog-input-wrap small {
            color: var(--danger-text);
            font-weight: 700;
        }

        .caoren-dialog-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 22px;
        }

        .caoren-dialog-actions button {
            min-width: 112px;
        }

        .caoren-dialog-confirm {
            background: #2563eb;
            border-color: #2563eb;
            color: #fff;
        }

        .caoren-dialog-confirm.is-danger {
            background: var(--danger);
            border-color: var(--danger);
            color: #fff;
        }

        @media (max-width: 520px) {
            .caoren-dialog-card {
                padding: 18px;
            }

            .caoren-dialog-actions {
                display: grid;
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }

            .caoren-dialog-actions button {
                width: 100%;
                min-width: 0;
            }
        }

        .close {
            color: #aaa;
            position: absolute;
            right: 15px;
            top: 10px;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }

            .close:hover {
                color: #333;
            }

        #timer-display {
            font-size: 20px;
            font-weight: bold;
            color: #cc0000;
            margin: 10px 0;
        }

        .live-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #eee;
            padding: 10px 15px;
            border-radius: 5px;
            margin-bottom: 15px;
            font-weight: bold;
        }

        /* 放大并优化九宫格尺寸 */
        .task-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 20px;
            margin: 15px 0;
            padding: 10px;
            width: 100%;
            box-sizing: border-box;
        }

        .task-cell {
            width: 100%;
            min-width: 0;
            height: 200px;
            border: 2px solid #ccc;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            text-align: center;
            background: #fdfdfd;
            font-size: 14px;
            cursor: pointer;
            border-radius: 6px;
            padding: 15px;
            box-sizing: border-box;
            overflow-y: auto;
            word-break: break-word;
            line-height: 1.4;
            transition: transform 0.1s, box-shadow 0.1s;
        }

            .task-cell:hover {
                background: #fff;
                transform: translateY(-2px);
                box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            }

            .task-cell::-webkit-scrollbar {
                width: 4px;
            }

            .task-cell::-webkit-scrollbar-thumb {
                background: #ccc;
                border-radius: 2px;
            }

            .task-cell.abandoned {
                background: #e0e0e0;
                cursor: not-allowed;
                color: #777;
            }

            .task-cell.selected {
                outline: 3px dashed #ff0000;
                outline-offset: 4px;
            }

        /* 任务描述内允许使用的富文本基础样式 */
        .task-desc b {
            font-weight: 900;
        }

        .task-desc u {
            text-decoration: underline;
            text-underline-offset: 3px;
        }

        .scoreboard-table {
            border-collapse: collapse;
            width: 100%;
            margin-top: 15px;
        }

            .scoreboard-table th, .scoreboard-table td {
                border: 1px solid #ddd;
                padding: 10px;
                text-align: left;
            }

            .scoreboard-table tr.undercover {
                background: #ffe0b2;
            }

            .scoreboard-table tr.detective {
                background: #b3e5fc;
            }

            .scoreboard-table tr.soldier {
                background: #c8e6c9;
            }

        /* 可视化模板编辑器布局 */
        .tpl-editor-layout {
            display: flex;
            gap: 20px;
            margin-top: 15px;
            align-items: flex-start;
        }

        .tpl-preview-area {
            flex: 0 0 600px;
            padding: 10px;
            background: #f5f5f5;
            border: 1px solid #ddd;
            border-radius: 8px;
        }

        .tpl-form-area {
            flex: 1;
            padding: 20px;
            background: #fff;
            border: 1px solid #ddd;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        }

        .tpl-form-group {
            margin-bottom: 15px;
        }

            .tpl-form-group label {
                display: block;
                font-size: 13px;
                font-weight: bold;
                color: #555;
                margin-bottom: 5px;
            }

            .tpl-form-group input, .tpl-form-group select, .tpl-form-group textarea {
                width: 100%;
                box-sizing: border-box;
            }

        /* 富文本工具栏 */
        .format-toolbar {
            display: flex;
            gap: 5px;
            margin-bottom: 5px;
            flex-wrap: wrap;
        }

        .format-btn {
            padding: 4px 8px;
            font-size: 12px;
            margin: 0;
            background: #fff;
            border: 1px solid #ccc;
            font-weight: bold;
        }


        h1 {
            margin: 0 0 18px;
            font-size: 30px;
            color: #102a43;
        }

        h2, h3, h4 {
            color: #1f2937;
        }

        .page-shell {
            max-width: 1480px;
            margin: 0 auto;
        }

        .page-subtitle {
            margin: 8px 0 24px;
            color: var(--muted);
            font-size: 14px;
        }

        .panel {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 16px;
            box-shadow: var(--shadow);
            padding: 18px;
        }

        .status-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            border-radius: 999px;
            font-size: 13px;
            font-weight: 700;
            background: var(--primary-soft);
            color: var(--primary);
        }

        .toolbar-row {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            align-items: center;
            justify-content: space-between;
        }

        .info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
            gap: 14px;
            margin: 16px 0;
        }

        .info-card {
            background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 14px 16px;
        }

            .info-card .label {
                font-size: 12px;
                color: var(--muted);
                margin-bottom: 6px;
                display: block;
            }

            .info-card .value {
                font-size: 20px;
                font-weight: 800;
                color: #102a43;
            }

        #login-area, #lobby-area {
            max-width: 1480px;
            margin: 0 auto;
        }

        #login-area {
            background: var(--panel);
            border: 1px solid var(--border);
            box-shadow: var(--shadow);
            border-radius: 18px;
            padding: 24px;
        }

        .player-list {
            margin-top: 16px;
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 16px;
            box-shadow: var(--shadow);
            padding: 18px;
        }

        .player-item {
            padding: 10px 12px;
            border-bottom: 1px solid #e9eef5;
            border-radius: 10px;
        }

            .player-item:last-child {
                border-bottom: 0;
            }

        button {
            margin: 5px;
            padding: 9px 14px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            border-radius: 10px;
            border: 1px solid #cfd8e3;
            background-color: #fff;
            color: #243447;
            transition: .16s ease;
        }

            button:hover {
                background-color: #f6f8fb;
                transform: translateY(-1px);
                box-shadow: 0 6px 16px rgba(37, 99, 235, 0.08);
            }

        input[type="text"], input[type="number"], select, textarea {
            padding: 9px 10px;
            font-size: 14px;
            border: 1px solid #cfd8e3;
            border-radius: 10px;
            background: #fff;
        }

        textarea {
            line-height: 1.6;
        }

        .modal-content {
            background-color: #fefefe;
            margin: 2.5% auto;
            padding: 24px;
            border: 1px solid var(--border);
            width: 95%;
            max-width: 1180px;
            line-height: 1.6;
            position: relative;
            border-radius: 16px;
            box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
        }

        #timer-display {
            font-size: 18px;
            font-weight: 700;
            color: #b45309;
            margin: 10px 0 0;
            background: #fff7ed;
            display: inline-block;
            padding: 8px 12px;
            border-radius: 999px;
            border: 1px solid #fed7aa;
        }

        .task-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 18px;
            margin: 15px 0;
            padding: 10px 0;
            width: 100%;
            box-sizing: border-box;
        }

        .task-cell {
            width: 100%;
            min-width: 0;
            min-height: 210px;
            height: auto;
            border: 1px solid #dbe5ef;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            text-align: center;
            background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
            font-size: 14px;
            cursor: pointer;
            border-radius: 14px;
            padding: 16px;
            overflow-y: auto;
            word-break: break-word;
            line-height: 1.5;
            transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
            box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
        }

            .task-cell:hover {
                background: #fff;
                transform: translateY(-2px);
                box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
                border-color: #b9c8db;
            }

            .task-cell.selected {
                outline: 3px solid #ef4444;
                outline-offset: 2px;
            }

        .scoreboard-table {
            border-collapse: separate;
            border-spacing: 0;
            width: 100%;
            margin-top: 15px;
            overflow: hidden;
            border: 1px solid var(--border);
            border-radius: 14px;
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
        }

            .scoreboard-table th, .scoreboard-table td {
                border-bottom: 1px solid #e5edf5;
                padding: 10px 12px;
                text-align: left;
            }

            .scoreboard-table th {
                background: #f8fafc;
                font-weight: 800;
                color: #334155;
                position: sticky;
                top: 0;
            }

            .scoreboard-table tr:last-child td {
                border-bottom: 0;
            }

        #extra-info > div,
        #extra-info > table,
        #extra-info > .scoreboard-table,
        #extra-info > h2,
        #extra-info > h3,
        #extra-info > h4,
        #extra-info > p,
        #extra-info > hr {
            max-width: 100%;
        }

        #phase-info, #extra-info {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: 16px;
            box-shadow: var(--shadow);
            padding: 18px;
        }

        .section-title {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 14px;
        }

        .soft-block {
            background: #f8fbff;
            border: 1px solid #dbe7f5;
            border-radius: 14px;
            padding: 14px;
        }

        .danger-text {
            color: var(--danger);
        }

        .muted {
            color: var(--muted);
        }

        .json-toolbar {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin: 12px 0 0;
        }

        .admin-tabs {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin: 4px 0 14px;
            padding-bottom: 10px;
            border-bottom: 1px solid var(--border);
        }

        .admin-tab-btn {
            margin: 0;
            padding: 9px 14px;
            border: 1px solid #cbd5e1;
            border-radius: 8px;
            background: #eef4ff;
            color: #334155;
            font-size: 15px;
            font-weight: 800;
        }

        .admin-tab-btn.active {
            background: #2563eb;
            border-color: #1d4ed8;
            color: #ffffff;
            box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
        }

        .admin-tab-panel {
            display: none;
        }

        .admin-tab-panel.active {
            display: block;
        }

        .admin-action-row {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            align-items: center;
            margin-top: 12px;
        }

        .admin-danger-zone {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 14px;
            margin-top: 14px;
            padding: 14px 16px;
            border: 1px solid #fecaca;
            border-radius: 10px;
            background: #fef2f2;
            color: #7f1d1d;
        }

        .admin-danger-zone p {
            margin: 6px 0 0;
            color: #991b1b;
            font-size: 13px;
            line-height: 1.5;
        }

        .admin-undercover-task-panel h4 {
            margin-bottom: 10px;
        }

        .admin-undercover-task-list {
            display: grid;
            gap: 14px;
        }

        .admin-undercover-task-item {
            padding: 12px;
            border: 1px solid #dbe5ef;
            border-radius: 10px;
            background: #ffffff;
        }

        .admin-undercover-task-item h5 {
            margin: 0 0 10px;
            color: #334155;
            font-size: 15px;
        }

        .admin-undercover-task-item h5 span {
            color: #64748b;
            font-weight: 700;
        }

        @media (max-width: 960px) {
            body {
                padding: 14px;
            }

            .tpl-editor-layout {
                flex-direction: column;
            }

            .tpl-preview-area {
                flex: 1 1 auto;
                width: 100%;
            }

            .task-grid {
                grid-template-columns: repeat(3, minmax(0, 1fr));
            }
        }

        @media (max-width: 640px) {
            .admin-tabs,
            .admin-action-row,
            .admin-danger-zone {
                flex-direction: column;
                align-items: stretch;
            }

            .admin-tab-btn,
            .admin-action-row button,
            .admin-danger-zone button {
                width: 100%;
            }

            .task-grid {
                grid-template-columns: repeat(3, minmax(0, 1fr));
            }

            .toolbar-row {
                flex-direction: column;
                align-items: stretch;
            }

            #timer-display {
                display: block;
            }
        }



        /* Stage 3.3：更接近旧版后台表格风格 */
        body {
            background: #edf3f8;
            padding: 18px 22px;
        }

        .page-shell {
            max-width: 1600px;
        }

        h1 {
            font-size: 28px;
            letter-spacing: .5px;
            margin-bottom: 10px;
        }

        .page-subtitle {
            margin-bottom: 16px;
        }

        .panel, #login-area, .player-list, #phase-info, #extra-info {
            border-radius: 8px;
            box-shadow: 0 3px 14px rgba(15, 23, 42, 0.06);
        }

        .toolbar-row.panel {
            padding: 12px 16px;
            min-height: 58px;
        }

        #my-identity {
            background: #ffffff;
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 10px 14px;
            margin: 12px 0;
        }

        .player-list {
            padding: 12px 16px;
        }

        .cc-table-wrap {
            overflow-x: auto;
            border: 1px solid #cfd8e3;
            border-radius: 6px;
            background: #fff;
        }

        .cc-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 14px;
            min-width: 760px;
        }

            .cc-table th,
            .cc-table td {
                border: 1px solid #d7dee8;
                padding: 8px 10px;
                text-align: left;
                white-space: nowrap;
            }

            .cc-table th {
                background: #eef2f7;
                color: #1f2937;
                font-weight: 800;
            }

            .cc-table tr:nth-child(even) td {
                background: #fafcff;
            }

            .cc-table tr.role-undercover td {
                background: #ffe8ae;
            }

            .cc-table tr.role-detective td {
                background: #d9efff;
            }

            .cc-table tr.role-soldier td {
                background: #e5f3dc;
            }

            .cc-table tr.role-admin td {
                background: #f2e8ff;
            }

            .cc-table tr.side-mismatch td {
                background: #fff7ed;
            }

        .tag {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 800;
            border: 1px solid transparent;
        }

        .tag-blue {
            color: #075985;
            background: #e0f2fe;
            border-color: #bae6fd;
        }

        .tag-orange {
            color: #9a3412;
            background: #ffedd5;
            border-color: #fed7aa;
        }

        .tag-green {
            color: #166534;
            background: #dcfce7;
            border-color: #bbf7d0;
        }

        .tag-gray {
            color: #475569;
            background: #f1f5f9;
            border-color: #cbd5e1;
        }

        .tag-red {
            color: #991b1b;
            background: #fee2e2;
            border-color: #fecaca;
        }

        .tag-purple {
            color: #6b21a8;
            background: #f3e8ff;
            border-color: #e9d5ff;
        }

        .live-header {
            border-radius: 8px;
            padding: 12px 14px;
        }

        .scoreboard-table {
            border-radius: 6px;
            font-size: 14px;
        }

            .scoreboard-table th,
            .scoreboard-table td {
                padding: 8px 9px;
            }

        .task-grid {
            grid-template-columns: repeat(3, minmax(0, 1fr));
            align-items: stretch;
        }

        .task-cell {
            min-height: 178px;
            border-radius: 6px;
            box-shadow: none;
            padding: 12px;
        }

        .tpl-preview-area,
        .tpl-form-area {
            border-radius: 8px;
            box-shadow: none;
        }


        /* Stage 3.7 地图 BP 卡片 */
        .map-bp-board {
            background: #fff;
            border: 1px solid #dbe5ef;
            border-radius: 16px;
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
            padding: 18px;
        }

        .map-bp-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 16px;
            flex-wrap: wrap;
            padding-bottom: 14px;
            border-bottom: 1px solid #e5edf5;
            margin-bottom: 16px;
        }

        .map-bp-title {
            margin: 0;
            font-size: 24px;
            font-weight: 900;
            color: #102a43;
        }

        .map-bp-subtitle {
            margin: 8px 0 0;
            color: #607086;
            font-size: 14px;
        }

        .map-bp-turn {
            min-width: 220px;
            padding: 12px 14px;
            border-radius: 14px;
            background: #f8fbff;
            border: 1px solid #dbe7f5;
            text-align: right;
        }

            .map-bp-turn b {
                font-size: 20px;
                color: #d32f2f;
            }

        .map-bp-summary {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 12px;
            margin-bottom: 16px;
        }

        .map-bp-summary-card {
            border: 1px solid #dbe5ef;
            background: #f8fbff;
            border-radius: 14px;
            padding: 12px 14px;
        }

            .map-bp-summary-card span {
                display: block;
                color: #6b7b8c;
                font-size: 12px;
                margin-bottom: 6px;
            }

            .map-bp-summary-card strong {
                color: #102a43;
                font-size: 16px;
            }

        .map-card-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
            gap: 16px;
            margin-top: 12px;
        }

        .map-card {
            position: relative;
            overflow: hidden;
            border: 2px solid #dbe5ef;
            background: #fff;
            border-radius: 18px;
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
            transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, opacity .15s ease;
        }

            .map-card.clickable {
                cursor: pointer;
            }

                .map-card.clickable:hover {
                    transform: translateY(-3px);
                    border-color: #ef4444;
                    box-shadow: 0 16px 30px rgba(239, 68, 68, 0.16);
                }

            .map-card.banned {
                opacity: 1;
            }

            .map-card.banned .map-card-body {
                opacity: .78;
            }

            .map-card.waiting {
                background: #eef2f7;
                opacity: .62;
                filter: grayscale(.72);
            }

            .map-card.selected-map {
                border-color: #2e7d32;
                box-shadow: 0 0 0 4px rgba(46, 125, 50, .12), 0 16px 30px rgba(46, 125, 50, .12);
            }

        .map-card-image {
            width: 100%;
            aspect-ratio: 16 / 9;
            background: linear-gradient(135deg, #334155 0%, #94a3b8 100%);
            background-size: cover;
            background-position: center;
            border-bottom: 1px solid #e5edf5;
        }

            .map-card-image.placeholder {
                display: flex;
                align-items: center;
                justify-content: center;
                color: rgba(255,255,255,.86);
                font-weight: 900;
                font-size: 28px;
                letter-spacing: .04em;
                text-shadow: 0 2px 8px rgba(0,0,0,.25);
            }

        .map-card-body {
            padding: 12px 14px 14px;
        }

        .map-card-name {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin-bottom: 10px;
        }

            .map-card-name strong {
                font-size: 18px;
                color: #102a43;
            }

        .map-card-slug {
            font-size: 12px;
            color: #6b7b8c;
            background: #f1f5f9;
            border-radius: 999px;
            padding: 4px 8px;
            white-space: nowrap;
        }

        .map-card-status {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-height: 28px;
            padding: 5px 10px;
            border-radius: 999px;
            font-size: 13px;
            font-weight: 800;
            border: 1px solid transparent;
        }

            .map-card-status.available {
                color: #b91c1c;
                background: #fff1f2;
                border-color: #fecdd3;
            }

            .map-card-status.waiting {
                color: #475569;
                background: #f8fafc;
                border-color: #e2e8f0;
            }

            .map-card-status.admin {
                color: #7c2d12;
                background: #ffedd5;
                border-color: #fdba74;
            }

        .bp-action-banner {
            display: flex;
            align-items: center;
            gap: 12px;
            margin: 0 0 16px;
            padding: 14px 16px;
            border-radius: 14px;
            border: 2px solid #cbd5e1;
            background: #f1f5f9;
        }

            .bp-action-banner strong {
                font-size: 18px;
                color: #334155;
                white-space: nowrap;
            }

            .bp-action-banner span {
                color: #64748b;
                font-size: 14px;
            }

            .bp-action-banner.active {
                border-color: #f97316;
                background: linear-gradient(90deg, #fff7ed, #fffbeb);
                box-shadow: 0 8px 20px rgba(249, 115, 22, .12);
            }

                .bp-action-banner.active strong { color: #c2410c; }

            .bp-action-banner.admin {
                border-color: #a855f7;
                background: #faf5ff;
            }

                .bp-action-banner.admin strong { color: #7e22ce; }

        @media (max-width: 720px) {
            .bp-action-banner {
                align-items: flex-start;
                flex-direction: column;
                gap: 4px;
            }

                .bp-action-banner strong { white-space: normal; }
        }

            .map-card-status.banned {
                color: #334155;
                background: #e2e8f0;
                border-color: #cbd5e1;
            }

            .map-card-status.selected {
                color: #166534;
                background: #dcfce7;
                border-color: #bbf7d0;
            }

        .map-card-visual {
            position: relative;
        }

        .map-card-overlay {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
            font-size: 34px;
            font-weight: 900;
            color: rgba(255,255,255,.92);
            background: rgba(15, 23, 42, .42);
            text-shadow: 0 3px 12px rgba(0,0,0,.35);
        }

            .map-card-overlay.banned-overlay {
                flex-direction: column;
                gap: 0;
                background: rgba(185, 28, 28, .58);
            }

            .map-card-ban-x {
                display: block;
                color: #fecaca;
                font-size: clamp(96px, 12vw, 156px);
                font-weight: 300;
                line-height: .72;
                text-shadow: 0 3px 10px rgba(69, 10, 10, .6);
            }


        .map-vote-list {
            margin: 10px 0 0;
            padding: 0;
            list-style: none;
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

            .map-vote-list li {
                padding: 6px 10px;
                background: #f8fafc;
                border: 1px solid #dbe5ef;
                border-radius: 999px;
                font-size: 13px;
            }

        .map-admin-ban-row {
            margin-top: 16px;
            padding-top: 14px;
            border-top: 1px dashed #cbd5e1;
        }

        .map-thumb-spec {
            margin-top: 16px;
            padding: 12px 14px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 14px;
            color: #475569;
            font-size: 13px;
            line-height: 1.6;
        }


        /* Stage 3.9：全局悬浮倒计时，滚动页面时仍可见 */
        #timer-display {
            position: fixed;
            top: 14px;
            right: 18px;
            z-index: 2000;
            margin: 0;
            padding: 10px 16px;
            border-radius: 999px;
            border: 1px solid #fed7aa;
            background: rgba(255, 247, 237, 0.96);
            color: #c2410c;
            font-size: 17px;
            font-weight: 900;
            box-shadow: 0 10px 28px rgba(194, 65, 12, 0.16);
            backdrop-filter: blur(6px);
        }

            #timer-display:empty {
                display: none;
            }

        .side-thumb-spec {
            margin-top: 14px;
            padding: 12px 14px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 14px;
            color: #475569;
            font-size: 13px;
            line-height: 1.6;
        }


        /* Stage 3.10：更醒目的官匹式 BP 倒计时 */
        #timer-display {
            position: fixed;
            top: 18px;
            right: 22px;
            z-index: 5000;
            min-width: 210px;
            margin: 0;
            padding: 12px 18px 13px;
            border-radius: 18px;
            border: 2px solid rgba(255,255,255,.75);
            background: linear-gradient(135deg, #ef4444 0%, #f97316 52%, #f59e0b 100%);
            color: #ffffff;
            font-size: 22px;
            font-weight: 900;
            text-align: center;
            letter-spacing: .02em;
            box-shadow: 0 18px 42px rgba(239, 68, 68, .34), 0 0 0 4px rgba(249, 115, 22, .12);
            backdrop-filter: blur(8px);
            animation: timerPulse 1.2s ease-in-out infinite;
        }

            #timer-display::before {
                content: "当前投票倒计时";
                display: block;
                font-size: 12px;
                line-height: 1;
                margin-bottom: 5px;
                font-weight: 800;
                opacity: .92;
                letter-spacing: .12em;
            }

            #timer-display:empty {
                display: none;
            }

        @keyframes timerPulse {
            0%, 100% {
                transform: translateY(0) scale(1);
                box-shadow: 0 18px 42px rgba(239, 68, 68, .34), 0 0 0 4px rgba(249, 115, 22, .12);
            }

            50% {
                transform: translateY(-1px) scale(1.025);
                box-shadow: 0 22px 54px rgba(239, 68, 68, .42), 0 0 0 7px rgba(249, 115, 22, .16);
            }
        }

        .map-bp-header {
            position: sticky;
            top: 10px;
            z-index: 80;
            background: rgba(255,255,255,.94);
            backdrop-filter: blur(10px);
            border: 1px solid #dbe5ef;
            border-radius: 16px;
            padding: 14px;
            box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
        }

        .map-bp-turn-wrap {
            display: flex;
            gap: 12px;
            align-items: stretch;
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        .map-bp-turn {
            min-width: 220px;
            padding: 12px 16px;
            border-radius: 16px;
            background: linear-gradient(180deg, #fff7ed 0%, #ffffff 100%);
            border: 2px solid #fed7aa;
            text-align: right;
            box-shadow: 0 10px 22px rgba(234, 88, 12, .10);
        }

            .map-bp-turn b {
                font-size: 22px;
                color: #dc2626;
            }

        .bp-inline-timer {
            min-width: 160px;
            padding: 12px 16px;
            border-radius: 16px;
            background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
            color: #fff;
            text-align: center;
            box-shadow: 0 14px 28px rgba(239, 68, 68, .24);
        }

            .bp-inline-timer span {
                display: block;
                font-size: 12px;
                font-weight: 800;
                opacity: .9;
                margin-bottom: 4px;
            }

            .bp-inline-timer strong {
                display: block;
                font-size: 24px;
                font-weight: 950;
                line-height: 1.1;
            }

        @media (max-width: 720px) {
            #timer-display {
                top: auto;
                right: 12px;
                bottom: 12px;
                min-width: 170px;
                font-size: 18px;
                border-radius: 16px;
            }

            .map-bp-header {
                top: 6px;
            }
        }


        /* Stage 3.11：选人倒计时面板 */
        .draft-board {
            background: #fff;
            border: 1px solid #dbe5ef;
            border-radius: 16px;
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
            padding: 18px;
        }

        .draft-header {
            display: flex;
            justify-content: space-between;
            align-items: stretch;
            gap: 14px;
            flex-wrap: wrap;
            background: rgba(255,255,255,.94);
            border: 1px solid #dbe5ef;
            border-radius: 16px;
            padding: 14px;
            box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
            margin-bottom: 16px;
        }

        .draft-title {
            margin: 0;
            font-size: 24px;
            font-weight: 900;
            color: #102a43;
        }

        .draft-subtitle {
            margin: 8px 0 0;
            color: #607086;
            font-size: 14px;
        }

        .draft-turn-card {
            min-width: 220px;
            padding: 12px 16px;
            border-radius: 16px;
            background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
            border: 2px solid #dbe7f5;
            text-align: right;
        }

            .draft-turn-card b {
                font-size: 22px;
                color: #2563eb;
            }

        .draft-pick-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
            gap: 12px;
            margin: 14px 0;
        }

        .draft-player-card {
            border: 1px solid #dbe5ef;
            background: #fff;
            border-radius: 14px;
            padding: 14px;
            min-height: 84px;
            box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
            transition: .15s ease;
        }

            .draft-player-card.pickable {
                cursor: pointer;
                border-color: #93c5fd;
                background: #eff6ff;
                box-shadow: 0 10px 24px rgba(37, 99, 235, .12);
            }

            .draft-player-card:not(.pickable) {
                background: #eef2f7;
                opacity: .68;
                filter: grayscale(.55);
            }

                .draft-player-card.pickable:hover {
                    transform: translateY(-2px);
                    border-color: #2563eb;
                    box-shadow: 0 14px 26px rgba(37, 99, 235, .14);
                }

            .draft-player-card strong {
                display: block;
                font-size: 18px;
                color: #102a43;
                margin-bottom: 8px;
            }

        .draft-team-panels {
            display: grid;
            grid-template-columns: 1fr;
            gap: 14px;
            margin-top: 14px;
        }

        .draft-team-panel {
            border: 1px solid #dbe5ef;
            border-radius: 14px;
            padding: 14px;
            background: #f8fbff;
        }

            .draft-team-panel.a {
                background: #fff7ed;
                border-color: #fed7aa;
            }

            .draft-team-panel.b {
                background: #eff6ff;
                border-color: #bfdbfe;
            }


        /* Stage 3.12：地图卡片内显示本队投票人 */
        .map-card-voters {
            margin-top: 10px;
            min-height: 32px;
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            align-items: center;
        }

        .map-card-voters-empty {
            color: #94a3b8;
            font-size: 12px;
            padding: 5px 0;
        }

        .map-voter-pill {
            display: inline-flex;
            align-items: center;
            max-width: 100%;
            gap: 4px;
            padding: 5px 8px;
            border-radius: 999px;
            background: #eff6ff;
            border: 1px solid #bfdbfe;
            color: #1d4ed8;
            font-size: 12px;
            font-weight: 800;
            line-height: 1.1;
        }

            .map-voter-pill.me {
                background: #fff7ed;
                border-color: #fdba74;
                color: #c2410c;
            }

            .map-voter-pill .dot {
                width: 7px;
                height: 7px;
                border-radius: 999px;
                background: currentColor;
                flex: 0 0 auto;
            }

        .map-card-vote-count {
            margin-left: auto;
            color: #64748b;
            font-size: 12px;
            font-weight: 800;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 999px;
            padding: 5px 8px;
        }

        .map-card.my-vote {
            border-color: #f97316;
            box-shadow: 0 0 0 4px rgba(249, 115, 22, .12), 0 16px 30px rgba(249, 115, 22, .12);
        }


        /* Stage 3.14：结算明细表 */
        .score-detail-table {
            border-collapse: separate;
            border-spacing: 0;
            width: 100%;
            margin-top: 18px;
            border: 1px solid #dbe5ef;
            border-radius: 14px;
            overflow: hidden;
            background: #fff;
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
            font-size: 13px;
        }

            .score-detail-table th,
            .score-detail-table td {
                border-right: 1px solid #e5edf5;
                border-bottom: 1px solid #e5edf5;
                padding: 10px 10px;
                vertical-align: top;
                text-align: left;
            }

                .score-detail-table th:last-child,
                .score-detail-table td:last-child {
                    border-right: 0;
                }

            .score-detail-table tr:last-child td {
                border-bottom: 0;
            }

            .score-detail-table th {
                background: #f8fafc;
                color: #334155;
                font-weight: 900;
                white-space: nowrap;
                position: sticky;
                top: 0;
                z-index: 2;
            }

            .score-detail-table tr.undercover td {
                background: #fff7ed;
            }

            .score-detail-table tr.detective td {
                background: #eff6ff;
            }

            .score-detail-table tr.soldier td {
                background: #f0fdf4;
            }

        .score-term {
            display: block;
            line-height: 1.55;
            white-space: nowrap;
        }

            .score-term.muted {
                color: #94a3b8;
            }

        .score-positive {
            color: #15803d;
            font-weight: 900;
        }

        .score-negative {
            color: #dc2626;
            font-weight: 900;
        }

        .score-neutral {
            color: #334155;
            font-weight: 700;
        }

        .score-count {
            color: #0f172a;
            font-weight: 700;
        }

        .score-final {
            font-size: 22px;
            font-weight: 950;
            white-space: nowrap;
        }

        .score-detail-wrap {
            overflow-x: auto;
            padding-bottom: 4px;
        }

        .score-rule-note {
            margin-top: 12px;
            padding: 12px 14px;
            background: #f8fafc;
            border: 1px solid #dbe5ef;
            border-radius: 12px;
            color: #64748b;
            font-size: 13px;
            line-height: 1.6;
        }

        .postmatch-panel {
            margin-top: 18px;
            padding: 16px;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: var(--panel);
            box-shadow: var(--shadow);
        }

        .postmatch-tabs {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin: 10px 0 14px;
        }

        .postmatch-tabs button {
            border: 1px solid var(--border);
            background: var(--panel-soft);
            color: var(--text);
            font-weight: 800;
        }

        .postmatch-tabs button.active {
            background: var(--primary);
            border-color: var(--primary);
            color: #fff;
        }

        .postmatch-fun-scroll {
            width: 100%;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }

        .postmatch-fun-scroll .hltv-style-table {
            min-width: 1320px;
        }

        .postmatch-fun-scroll .sticky-player-col {
            position: sticky;
            left: 0;
            z-index: 3;
            background: #f8fbff;
            box-shadow: 1px 0 0 #dbe5ef;
        }

        .postmatch-fun-scroll th.sticky-player-col {
            z-index: 4;
            background: #eef4fb;
        }

        .postmatch-subvalue {
            color: var(--muted);
            font-weight: 600;
        }

        .funfact-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 10px;
        }

        .funfact-card {
            min-height: 104px;
            padding: 14px;
            border: 1px solid #dbe5ef;
            border-left: 5px solid #64748b;
            border-radius: 8px;
            background: #ffffff;
        }

        .funfact-title {
            margin-bottom: 8px;
            color: #0f172a;
            font-size: 16px;
            font-weight: 900;
        }

        .funfact-text {
            color: #334155;
            font-size: 14px;
            line-height: 1.6;
            word-break: break-word;
        }

        .funfact-text strong {
            color: #0f172a;
            font-weight: 900;
        }

        .funfact-blue { border-left-color: #2563eb; }
        .funfact-red { border-left-color: #dc2626; }
        .funfact-amber { border-left-color: #d97706; }
        .funfact-purple { border-left-color: #7c3aed; }
        .funfact-green { border-left-color: #16a34a; }
        .funfact-cyan { border-left-color: #0891b2; }
        .funfact-orange { border-left-color: #ea580c; }

        .hl-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 13px;
        }

        .hl-table th,
        .hl-table td {
            padding: 10px 9px;
            border-bottom: 1px solid var(--border);
            text-align: right;
            white-space: nowrap;
        }

        .hl-table th:first-child,
        .hl-table td:first-child {
            text-align: left;
        }

        .hltv-style-wrap {
            display: flex;
            flex-direction: column;
            gap: 18px;
            overflow-x: auto;
        }

        .hltv-style-table {
            min-width: 960px;
            background: #ffffff !important;
            color: #334155 !important;
            border: 1px solid #dbe5ef !important;
            border-collapse: collapse;
        }

        .hltv-style-table th,
        .hltv-style-table td {
            background: #ffffff !important;
            border-right: 1px solid #dbe5ef;
            border-bottom: 1px solid #dbe5ef;
            color: #334155;
            padding: 10px 12px;
            text-align: center;
        }

        .hltv-style-table th:first-child,
        .hltv-style-table td:first-child {
            min-width: 170px;
            text-align: left;
        }

        .hltv-style-table thead th {
            background: #f8fafc !important;
            color: #334155 !important;
            font-weight: 800;
        }

        .hltv-style-table .team-heading {
            font-size: 16px;
            background: #eef4fb !important;
            color: #0f172a !important;
        }

        .hltv-style-table th span {
            display: block;
            font-size: 11px;
            line-height: 1;
            opacity: 0.75;
        }

        .hltv-style-table th.stat-tip {
            cursor: help;
            text-decoration: underline dotted rgba(100, 116, 139, 0.65);
            text-underline-offset: 3px;
        }

        .hltv-style-table td.positive {
            color: #18d918;
            font-weight: 800;
        }

        .hltv-style-table td.negative {
            color: #ff2d2d;
            font-weight: 800;
        }

        .hltv-style-table td.neutral {
            color: #475569;
            font-weight: 700;
        }

        .matrix-wrap {
            overflow-x: auto;
        }

        .matrix-direction {
            margin-top: 12px;
        }

        .matrix-direction h4 {
            margin: 0 0 8px;
            color: var(--text);
        }

        .matrix-table {
            border-collapse: separate;
            border-spacing: 0;
            min-width: 720px;
            width: 100%;
            font-size: 12px;
        }

        .matrix-table th,
        .matrix-table td {
            border-right: 1px solid var(--border);
            border-bottom: 1px solid var(--border);
            padding: 8px;
            text-align: center;
        }

        .matrix-table th {
            background: var(--panel-soft);
            position: sticky;
            top: 0;
            z-index: 1;
        }

        .matrix-table th:first-child {
            left: 0;
            z-index: 2;
        }

        .duel-matrix td {
            white-space: nowrap;
        }

        .matrix-score {
            display: inline-block;
            min-width: 28px;
            padding: 3px 7px;
            border-radius: 4px;
            color: #ffffff;
            font-weight: 900;
            line-height: 1.2;
        }

        .matrix-score-row {
            background: #d6a000;
        }

        .matrix-score-col {
            background: #2f75b5;
        }

        .matrix-separator {
            display: inline-block;
            padding: 0 5px;
            color: var(--muted);
            font-weight: 900;
        }

        .task-grid.compact-task-grid {
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 10px;
            padding: 10px;
        }

        .compact-task-grid .task-cell {
            width: auto;
            min-height: 150px;
            height: auto;
            margin: 0 !important;
            padding: 10px;
            font-size: 12px;
        }

        .task-round-note {
            margin-top: 6px;
            color: var(--muted);
            font-size: 12px;
            font-weight: 800;
        }


        /* 第一阶段：本局模式设置（固定在管理员控制区） */
        .match-options-panel {
            margin: 12px 0 16px;
            padding: 14px 16px;
            border: 1px solid #dbe5ef;
            border-radius: 12px;
            background: #f8fbff;
        }

        .match-options-panel h4 {
            margin: 0 0 10px;
            color: #102a43;
        }

        .match-options-status {
            margin: 8px 0 12px;
            padding: 8px 10px;
            border-radius: 10px;
            background: #eef4ff;
            color: #334155;
            font-size: 13px;
        }

        .match-options-row {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 10px;
            margin: 8px 0;
            border: 1px solid #dbe5ef;
            border-radius: 10px;
            background: #fff;
        }

        .match-options-row input[type="checkbox"] {
            margin-top: 5px;
            transform: scale(1.18);
        }

        .match-options-title {
            font-weight: 900;
            color: #243447;
        }

        .match-options-desc {
            margin-top: 4px;
            color: #6b7b8c;
            font-size: 13px;
            line-height: 1.5;
        }

        .match-options-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            margin-top: 10px;
        }

        .match-options-actions button {
            margin-left: 0;
            color: #fff;
            border: 0;
        }

        .match-options-actions .primary-btn {
            background: #2563eb;
        }

        .match-options-actions .secondary-btn {
            background: #64748b;
        }

        .match-options-warning {
            margin-top: 8px;
            color: #b45309;
            font-size: 13px;
        }
        /* 第二阶段：CaorenCup 修改可视化面板 */
        .caoren-mod-panel {
            margin: 12px 0 16px;
            padding: 14px 16px;
            border: 1px solid #fed7aa;
            border-radius: 12px;
            background: #fff7ed;
        }

        .caoren-mod-panel h4 {
            margin: 0 0 10px;
            color: #9a3412;
        }

        .caoren-mod-status {
            margin: 8px 0 12px;
            padding: 8px 10px;
            border-radius: 10px;
            background: #ffedd5;
            color: #7c2d12;
            font-size: 13px;
            line-height: 1.6;
        }

        body.caoren-modifiers-disabled .caoren-unified-mod-shell,
        body.caoren-modifiers-disabled .caoren-batch2-wrapper,
        body.caoren-modifiers-disabled #caoren-mod-panel .caoren-mod-grid {
            display: none !important;
        }


        .caoren-mod-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 10px;
        }

        .caoren-mod-card {
            padding: 12px;
            border: 1px solid #fdba74;
            border-radius: 12px;
            background: #fff;
        }

        .caoren-mod-card h5 {
            margin: 0 0 8px;
            color: #1f2937;
            font-size: 15px;
        }

        .caoren-mod-card p {
            margin: 0 0 8px;
            color: #64748b;
            font-size: 12px;
            line-height: 1.5;
        }

        .caoren-mod-field {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin: 6px 0;
            font-size: 13px;
        }

        .caoren-mod-field input,
        .caoren-mod-field select {
            max-width: 110px;
        }

        .caoren-mod-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 10px;
        }

        .caoren-mod-actions button {
            margin-left: 0;
            border: 0;
            color: #fff;
            background: #ea580c;
        }

        .caoren-mod-actions button.secondary {
            background: #64748b;
        }

        .caoren-mod-actions button.danger {
            background: #dc2626;
        }

    
/* CAOREN_V1_3_2_HIDE_DISABLED_MOD_PANEL_PATCH: 未启用 CaorenCup 修改时，强制隐藏所有模块配置内容，只保留状态提示 */
body.caoren-modifiers-disabled #caoren-mod-panel .caoren-mod-grid,
body.caoren-modifiers-disabled #caoren-mod-panel .caoren-unified-mod-shell,
body.caoren-modifiers-disabled #caoren-mod-panel .caoren-batch2-wrapper,
body.caoren-modifiers-disabled .caoren-unified-mod-shell,
body.caoren-modifiers-disabled .caoren-batch2-wrapper {
    display: none !important;
}

/* Dark theme consolidation: keep old inline light blocks from breaking the page tone. */
body[data-theme="dark"] {
    color-scheme: dark;
    background: radial-gradient(circle at 18% 0%, rgba(37, 99, 235, 0.14), transparent 32%),
        linear-gradient(180deg, #0b1220 0%, #101827 220px, #0d1524 100%);
}

body[data-theme="dark"] h1,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3,
body[data-theme="dark"] h4,
body[data-theme="dark"] h5,
body[data-theme="dark"] .match-options-title {
    color: var(--text) !important;
}

body[data-theme="dark"] .panel,
body[data-theme="dark"] #login-area,
body[data-theme="dark"] .player-list,
body[data-theme="dark"] #phase-info,
body[data-theme="dark"] #extra-info,
body[data-theme="dark"] #my-identity,
body[data-theme="dark"] .cc-table-wrap,
body[data-theme="dark"] .soft-block,
body[data-theme="dark"] .login-steps,
body[data-theme="dark"] .match-options-panel,
body[data-theme="dark"] .match-options-row,
body[data-theme="dark"] .caoren-mod-panel,
body[data-theme="dark"] .caoren-mod-card,
body[data-theme="dark"] .tpl-preview-area,
body[data-theme="dark"] .tpl-form-area {
    background: var(--panel) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

body[data-theme="dark"] .toolbar-row.panel,
body[data-theme="dark"] #admin-controls,
body[data-theme="dark"] .modal-content {
    background: rgba(23, 32, 51, 0.96) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

/* 卧底任务状态：底色表达当前结果，包边只保留提示/替换历史。 */
.task-cell {
    position: relative;
    overflow: visible;
    margin: 8px;
}

.task-cell .task-desc {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow-y: auto;
}

.task-cell.task-state-incomplete { background-color: var(--task-incomplete-bg) !important; }
.task-cell.task-state-progress { background-color: var(--task-progress-bg) !important; }
.task-cell.task-state-complete { background-color: var(--task-complete-bg) !important; }
.task-cell.task-state-abandoned {
    background-color: var(--task-abandoned-bg) !important;
    color: var(--text-muted) !important;
    filter: saturate(.5);
}

.task-special-blue { box-shadow: 0 0 0 4px var(--task-hint-ring) !important; }
.task-special-purple { box-shadow: 0 0 0 4px var(--task-replaced-ring) !important; }
.task-special-blue.task-special-purple {
    box-shadow: 0 0 0 4px var(--task-hint-ring), 0 0 0 8px var(--task-replaced-ring) !important;
}

.task-level-title {
    width: 100%;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
}

.task-level-title.task-level-strong { font-weight: 900; }

.task-n-progress {
    width: 100%;
    margin-top: 8px;
    padding: 4px;
    border-radius: 5px;
    background: color-mix(in srgb, var(--danger) 16%, transparent);
    color: var(--danger-text);
    font-weight: 800;
}

.task-status-wrap { margin-top: 7px; }
.task-status-badge {
    display: inline-block;
    min-width: 86px;
    padding: 3px 9px;
    border: 1px solid;
    border-radius: 999px;
    text-align: center;
    font-size: 12px;
    font-weight: 800;
}
.task-status-complete { background:#dcfce7; border-color:#86efac; color:#166534; }
.task-status-progress { background:#fef3c7; border-color:#fcd34d; color:#92400e; }
.task-status-incomplete { background:#ffe4e6; border-color:#fda4af; color:#9f1239; }
.task-status-abandoned { background:#e5e7eb; border-color:#9ca3af; color:#4b5563; }
body[data-theme="dark"] .task-status-complete { background:#12351f; border-color:#4ade80; color:#bbf7d0; }
body[data-theme="dark"] .task-status-progress { background:#3a2a10; border-color:#fbbf24; color:#fde68a; }
body[data-theme="dark"] .task-status-incomplete { background:#3b1820; border-color:#fb7185; color:#fecdd3; }
body[data-theme="dark"] .task-status-abandoned { background:#29313f; border-color:#64748b; color:#cbd5e1; }

.task-hint-availability {
    position: absolute;
    top: 7px;
    right: 38px;
    padding: 3px 7px;
    border: 1px solid color-mix(in srgb, var(--task-hint-ring) 55%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--task-hint-ring) 16%, var(--surface));
    color: var(--task-hint-ring);
    font-size: 11px;
    font-weight: 800;
}
.task-hint-availability.used { opacity: .78; }
.task-hint-text {
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    border-left: 3px solid var(--task-hint-ring);
    border-radius: 6px;
    background: color-mix(in srgb, var(--task-hint-ring) 12%, var(--surface));
    color: var(--text-default);
    font-size: 12px;
    line-height: 1.55;
    text-align: left;
}

.task-history-shell { position: absolute; top: 6px; right: 7px; z-index: 24; }
.task-history-trigger {
    width: 26px;
    min-width: 26px;
    height: 26px;
    min-height: 26px;
    padding: 0;
    border-color: var(--border-subtle);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 15px;
}
.task-history-popover {
    position: absolute;
    top: 32px;
    right: 0;
    display: none;
    width: min(300px, 78vw);
    padding: 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-default);
    box-shadow: var(--shadow);
    text-align: left;
}
.task-history-shell:hover .task-history-popover,
.task-history-shell:focus-within .task-history-popover,
.task-history-shell.open .task-history-popover { display: block; }
.task-history-popover > b { color: var(--text-strong); }
.task-history-popover ol { display:grid; gap:8px; margin:9px 0 0; padding-left:20px; }
.task-history-popover li { padding-bottom:7px; border-bottom:1px solid var(--border-subtle); }
.task-history-popover li:last-child { padding-bottom:0; border-bottom:0; }
.task-history-popover li strong,
.task-history-popover li span,
.task-history-popover li small { display:block; }
.task-history-popover li span,
.task-history-popover li small { margin-top:2px; color:var(--text-muted); font-size:11px; }

/* Public rules guide */
body.rules-page-body {
    min-height: 100vh;
    margin: 0;
    background: #eef3f8;
    color: var(--text-default);
}

body.rules-page-body[data-theme="dark"] {
    background: #0d1420;
}

.rules-page-shell {
    width: min(1280px, 100%);
    margin: 0 auto;
}

.rules-site-header {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) auto auto;
    align-items: center;
    gap: 22px;
    min-height: 68px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface);
}

.rules-brand {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    width: fit-content;
    color: var(--text-strong);
    text-decoration: none;
}

.rules-brand strong {
    font-size: 20px;
}

.rules-brand span {
    color: var(--primary);
    font-size: 14px;
    font-weight: 800;
}

.rules-site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rules-site-nav a {
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text-muted);
    font-weight: 700;
    text-decoration: none;
}

.rules-site-nav a:hover,
.rules-site-nav a.is-active {
    background: var(--surface-hover);
    color: var(--primary);
}

.rules-main {
    padding: 42px 24px 72px;
}

.rules-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 32px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-subtle);
}

.rules-eyebrow {
    display: block;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
}

.rules-hero h1 {
    max-width: 760px;
    margin: 6px 0 10px;
    color: var(--text-strong);
    font-size: clamp(28px, 4vw, 38px);
    line-height: 1.25;
}

.rules-hero p {
    max-width: 760px;
    margin: 0;
    color: var(--text-muted);
    font-size: 16px;
}

.rules-download-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    width: fit-content;
    padding: 9px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-strong);
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.rules-download-link:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.rules-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 36px;
    margin-top: 28px;
}

.rules-toc {
    position: sticky;
    top: 18px;
    align-self: start;
}

.rules-toc > span {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
}

.rules-toc a {
    display: block;
    padding: 8px 10px;
    border-left: 2px solid transparent;
    color: var(--text-muted);
    text-decoration: none;
}

.rules-toc a:hover,
.rules-toc a:focus-visible {
    border-left-color: var(--primary);
    color: var(--primary);
}

.rules-guide {
    min-width: 0;
}

.rules-section {
    scroll-margin-top: 24px;
    padding-bottom: 34px;
    margin-bottom: 34px;
    border-bottom: 1px solid var(--border-subtle);
}

.rules-section:last-child {
    border-bottom: 0;
}

.rules-section h2 {
    margin: 4px 0 8px;
    color: var(--text-strong);
    font-size: 23px;
}

.rules-section h3 {
    margin: 18px 0 8px;
    color: var(--text-strong);
    font-size: 16px;
}

.rules-section > p,
.rules-card p,
.rules-mode-card p,
.rules-warning-note p,
.rules-success-note p {
    color: var(--text-muted);
}

.rules-card-grid,
.rules-mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.rules-card,
.rules-mode-card {
    padding: 18px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--surface);
}

.rules-card h3,
.rules-mode-card h3 {
    margin-top: 0;
}

.rules-card p,
.rules-mode-card p {
    margin: 6px 0 0;
}

.rules-small-note {
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
    font-size: 13px;
}

.rules-steps {
    counter-reset: rules-step;
    display: grid;
    gap: 8px;
    margin: 14px 0;
    padding: 0;
    list-style: none;
}

.rules-steps li {
    position: relative;
    min-height: 44px;
    padding: 10px 12px 10px 48px;
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-default);
}

.rules-steps li::before {
    counter-increment: rules-step;
    content: counter(rules-step);
    position: absolute;
    top: 10px;
    left: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    line-height: 24px;
    text-align: center;
}

.rules-shared-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rules-warning-note,
.rules-success-note {
    padding: 14px 16px;
    margin-top: 16px;
    border-left: 3px solid var(--warning-text);
    border-radius: 0 6px 6px 0;
    background: var(--warning-surface);
    color: var(--warning-text);
}

.rules-success-note {
    border-left-color: var(--success-text);
    background: var(--success-surface);
    color: var(--success-text);
}

.rules-warning-note p,
.rules-success-note p {
    margin: 4px 0 0;
    color: inherit;
}

.rules-list {
    margin: 12px 0 0;
    padding-left: 22px;
    color: var(--text-default);
}

.rules-list li + li {
    margin-top: 6px;
}

.rules-page-body code {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface-muted);
    color: var(--text-strong);
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: .92em;
    overflow-wrap: anywhere;
}

.rules-command-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 16px 0 20px;
}

.rules-command-list > div {
    display: grid;
    grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--surface);
}

.rules-command-list dt,
.rules-command-list dd {
    margin: 0;
}

.rules-command-list dd {
    color: var(--text-muted);
}

@media (max-width: 900px) {
    .rules-site-header {
        grid-template-columns: 1fr auto;
    }

    .rules-site-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        padding-bottom: 10px;
    }

    .rules-main {
        padding-top: 30px;
    }

    .rules-command-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .rules-site-header {
        gap: 10px;
        padding: 10px 16px;
    }

    .rules-site-nav {
        width: 100%;
        overflow-x: auto;
    }

    .rules-site-nav a {
        flex: 0 0 auto;
    }

    .rules-main {
        padding: 26px 16px 56px;
    }

    .rules-hero {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 16px;
    }

    .rules-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .rules-toc {
        position: static;
        display: flex;
        gap: 2px;
        overflow-x: auto;
        border-bottom: 1px solid var(--border-subtle);
    }

    .rules-toc > span {
        display: none;
    }

    .rules-toc a {
        flex: 0 0 auto;
        border-left: 0;
        border-bottom: 2px solid transparent;
    }

    .rules-toc a:hover,
    .rules-toc a:focus-visible {
        border-left: 0;
        border-bottom-color: var(--primary);
    }

    .rules-card-grid,
    .rules-mode-grid,
    .rules-shared-steps {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .rules-brand {
        display: grid;
        gap: 0;
    }

    .rules-site-header .theme-toggle {
        min-width: 0;
        padding-inline: 10px;
    }

    .rules-command-list > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .rules-download-link {
        width: 100%;
    }
}

body[data-theme="dark"] .admin-tabs {
    border-color: var(--border);
}

body[data-theme="dark"] .admin-tab-btn {
    background: #1e293b;
    border-color: #475569;
    color: #dbeafe;
}

body[data-theme="dark"] .admin-tab-btn.active {
    background: #2563eb;
    border-color: #60a5fa;
    color: #ffffff;
}

body[data-theme="dark"] .admin-danger-zone {
    background: rgba(127, 29, 29, 0.22);
    border-color: rgba(248, 113, 113, 0.5);
    color: #fecaca;
}

body[data-theme="dark"] .admin-danger-zone p {
    color: #fecaca;
}

body[data-theme="dark"] .admin-undercover-task-item {
    background: var(--panel);
    border-color: var(--border);
    color: var(--text);
}

body[data-theme="dark"] .admin-undercover-task-item h5 {
    color: #dbeafe;
}

body[data-theme="dark"] .admin-undercover-task-item h5 span {
    color: #94a3b8;
}

body[data-theme="dark"] #my-identity {
    color: #93c5fd !important;
}

body[data-theme="dark"] .toolbar-row.panel [style*="background:#fff7ed"],
body[data-theme="dark"] .toolbar-row.panel [style*="background: #fff7ed"],
body[data-theme="dark"] [style*="background:#fff3e0"],
body[data-theme="dark"] [style*="background: #fff3e0"],
body[data-theme="dark"] [style*="background:#fff8e1"],
body[data-theme="dark"] [style*="background: #fff8e1"],
body[data-theme="dark"] [style*="background:#fff7ed"],
body[data-theme="dark"] [style*="background: #fff7ed"],
body[data-theme="dark"] [style*="background:#e3f2fd"],
body[data-theme="dark"] [style*="background: #e3f2fd"],
body[data-theme="dark"] [style*="background:#e8f5e9"],
body[data-theme="dark"] [style*="background: #e8f5e9"],
body[data-theme="dark"] [style*="background:#f3e5f5"],
body[data-theme="dark"] [style*="background: #f3e5f5"],
body[data-theme="dark"] [style*="background:#fafafa"],
body[data-theme="dark"] [style*="background: #fafafa"],
body[data-theme="dark"] [style*="background:#f8fbff"],
body[data-theme="dark"] [style*="background: #f8fbff"],
body[data-theme="dark"] [style*="background:#f8fafc"],
body[data-theme="dark"] [style*="background: #f8fafc"],
body[data-theme="dark"] [style*="background:#f5f5f5"],
body[data-theme="dark"] [style*="background: #f5f5f5"],
body[data-theme="dark"] [style*="background:#eceff1"],
body[data-theme="dark"] [style*="background: #eceff1"] {
    background: var(--panel-soft) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

body[data-theme="dark"] [style*="color:#334155"],
body[data-theme="dark"] [style*="color: #334155"],
body[data-theme="dark"] [style*="color:#64748b"],
body[data-theme="dark"] [style*="color: #64748b"],
body[data-theme="dark"] [style*="color:#555"],
body[data-theme="dark"] [style*="color: #555"],
body[data-theme="dark"] [style*="color:#666"],
body[data-theme="dark"] [style*="color: #666"],
body[data-theme="dark"] [style*="color:#333"],
body[data-theme="dark"] [style*="color: #333"],
body[data-theme="dark"] [style*="color:#2e7d32"],
body[data-theme="dark"] [style*="color: #2e7d32"],
body[data-theme="dark"] [style*="color:#1565c0"],
body[data-theme="dark"] [style*="color: #1565c0"],
body[data-theme="dark"] [style*="color:#1976d2"],
body[data-theme="dark"] [style*="color: #1976d2"],
body[data-theme="dark"] [style*="color:#e65100"],
body[data-theme="dark"] [style*="color: #e65100"],
body[data-theme="dark"] [style*="color:#b45309"],
body[data-theme="dark"] [style*="color: #b45309"],
body[data-theme="dark"] [style*="color:#92400e"],
body[data-theme="dark"] [style*="color: #92400e"],
body[data-theme="dark"] [style*="color:#78350f"],
body[data-theme="dark"] [style*="color: #78350f"] {
    color: var(--text) !important;
}

body[data-theme="dark"] a {
    color: #93c5fd;
}

body[data-theme="dark"] button {
    background-color: #223149;
    border-color: #40516b;
    color: var(--text);
}

body[data-theme="dark"] button:hover {
    background-color: #2b3a55;
}

body[data-theme="dark"] button:disabled {
    background-color: #1a2435;
    border-color: #334155;
    color: #7f8ea3;
}

body[data-theme="dark"] .theme-toggle {
    background: #1b2940;
    border-color: #40516b;
}

body[data-theme="dark"] #timer-display,
body[data-theme="dark"] .status-chip,
body[data-theme="dark"] .caoren-mod-status {
    background: rgba(96, 165, 250, 0.14) !important;
    border-color: rgba(96, 165, 250, 0.28) !important;
    color: #bfdbfe !important;
}

body[data-theme="dark"] .match-options-warning,
body[data-theme="dark"] .caoren-mod-panel h4 {
    color: #fbbf24 !important;
}

body[data-theme="dark"] .cc-table {
    color: var(--text);
}

body[data-theme="dark"] .cc-table th,
body[data-theme="dark"] .scoreboard-table th {
    background: #1f2b40 !important;
    border-color: var(--border) !important;
    color: #dbeafe !important;
}

body[data-theme="dark"] .cc-table td,
body[data-theme="dark"] .scoreboard-table td {
    background: #172033 !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

body[data-theme="dark"] .cc-table tr:nth-child(even) td,
body[data-theme="dark"] .scoreboard-table tr:nth-child(even) td {
    background: #1b263a !important;
}

body[data-theme="dark"] .cc-table tr.role-undercover td {
    background: rgba(245, 158, 11, 0.16) !important;
}

body[data-theme="dark"] .cc-table tr.role-detective td {
    background: rgba(14, 165, 233, 0.16) !important;
}

body[data-theme="dark"] .cc-table tr.role-soldier td {
    background: rgba(34, 197, 94, 0.14) !important;
}

body[data-theme="dark"] .cc-table tr.role-admin td {
    background: rgba(168, 85, 247, 0.16) !important;
}

body[data-theme="dark"] .cc-table tr.side-mismatch td {
    background: rgba(245, 158, 11, 0.18) !important;
}

body[data-theme="dark"] #extra-info table {
    background: #111827 !important;
    border-color: #334155 !important;
    color: var(--text) !important;
}

body[data-theme="dark"] #extra-info table th {
    background: #1f2b40 !important;
    border-color: #40516b !important;
    color: #dbeafe !important;
}

body[data-theme="dark"] #extra-info table td {
    background: #172033 !important;
    border-color: #334155 !important;
    color: var(--text) !important;
}

body[data-theme="dark"] #extra-info table tr:nth-child(even) td {
    background: #1b263a !important;
}

body[data-theme="dark"] #extra-info [style*="color:#6b7280"],
body[data-theme="dark"] #extra-info [style*="color: #6b7280"] {
    color: var(--muted) !important;
}

body[data-theme="dark"] .tag-blue,
body[data-theme="dark"] .tag-orange,
body[data-theme="dark"] .tag-green,
body[data-theme="dark"] .tag-gray,
body[data-theme="dark"] .tag-red,
body[data-theme="dark"] .tag-purple {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(148, 163, 184, 0.34);
    color: #dbeafe;
}

body[data-theme="dark"] code {
    color: #bfdbfe;
}

body[data-theme="dark"] #advance-phase-btn,
body[data-theme="dark"] button[style*="background-color:#ffeb3b"],
body[data-theme="dark"] button[style*="background-color: #ffeb3b"] {
    background-color: #facc15 !important;
    border-color: #eab308 !important;
    color: #1f2937 !important;
}

body[data-theme="dark"] #template-config-btn {
    background-color: #2563eb !important;
    border-color: #60a5fa !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.38);
}

body[data-theme="dark"] #template-config-btn:hover {
    background-color: #1d4ed8 !important;
    border-color: #93c5fd !important;
}

body[data-theme="dark"] #match-options-status {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(96, 165, 250, 0.62);
    color: #dbeafe;
    font-weight: 800;
}

body[data-theme="dark"] .map-bp-board,
body[data-theme="dark"] .map-bp-header,
body[data-theme="dark"] .map-bp-summary-card,
body[data-theme="dark"] .map-card,
body[data-theme="dark"] .draft-board,
body[data-theme="dark"] .draft-header,
body[data-theme="dark"] .draft-player-card,
body[data-theme="dark"] .draft-team-panel,
body[data-theme="dark"] .sidepick-final-map-wrap,
body[data-theme="dark"] .sidepick-map-hero-body,
body[data-theme="dark"] .sidepick-final-map-empty {
    background: #172033 !important;
    border-color: #334155 !important;
    color: var(--text) !important;
}

body[data-theme="dark"] .map-bp-header {
    background: rgba(23, 32, 51, 0.96) !important;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.26);
}

body[data-theme="dark"] .map-bp-title,
body[data-theme="dark"] .map-card-name strong,
body[data-theme="dark"] .map-bp-summary-card strong,
body[data-theme="dark"] .draft-title,
body[data-theme="dark"] .draft-player-card strong,
body[data-theme="dark"] .sidepick-final-map-title {
    color: var(--text) !important;
}

body[data-theme="dark"] .map-bp-subtitle,
body[data-theme="dark"] .map-bp-summary-card span,
body[data-theme="dark"] .map-card-slug,
body[data-theme="dark"] .map-card-voters-empty,
body[data-theme="dark"] .map-card-vote-count,
body[data-theme="dark"] .draft-subtitle,
body[data-theme="dark"] .sidepick-map-hero-body span,
body[data-theme="dark"] .map-thumb-spec,
body[data-theme="dark"] .side-thumb-spec {
    color: var(--muted) !important;
}

body[data-theme="dark"] .map-bp-turn {
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.14), rgba(23, 32, 51, 0.96)) !important;
    border-color: rgba(251, 191, 36, 0.42) !important;
    color: var(--text) !important;
}

body[data-theme="dark"] .map-bp-turn b {
    color: #f87171 !important;
}

body[data-theme="dark"] .map-bp-summary,
body[data-theme="dark"] .map-admin-ban-row {
    border-color: #334155 !important;
}

body[data-theme="dark"] .map-card {
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
}

body[data-theme="dark"] .map-card.waiting {
    background: #202b3d !important;
    opacity: .62;
}

body[data-theme="dark"] .bp-action-banner {
    background: #202b3d !important;
    border-color: #40516b !important;
}

body[data-theme="dark"] .bp-action-banner strong,
body[data-theme="dark"] .bp-action-banner span {
    color: var(--text) !important;
}

body[data-theme="dark"] .bp-action-banner.active {
    background: rgba(249, 115, 22, .16) !important;
    border-color: rgba(251, 146, 60, .72) !important;
}

body[data-theme="dark"] .bp-action-banner.active strong { color: #fed7aa !important; }

body[data-theme="dark"] .bp-action-banner.admin {
    background: rgba(168, 85, 247, .16) !important;
    border-color: rgba(192, 132, 252, .72) !important;
}

body[data-theme="dark"] .bp-action-banner.admin strong { color: #e9d5ff !important; }

body[data-theme="dark"] .map-card-image {
    border-color: #334155 !important;
}

body[data-theme="dark"] .map-card-slug,
body[data-theme="dark"] .map-vote-list li,
body[data-theme="dark"] .map-voter-pill,
body[data-theme="dark"] .map-card-vote-count {
    background: #223149 !important;
    border-color: #40516b !important;
    color: #cbd5e1 !important;
}

body[data-theme="dark"] .map-voter-pill.me {
    background: rgba(245, 158, 11, 0.16) !important;
    border-color: rgba(251, 191, 36, 0.42) !important;
    color: #fde68a !important;
}

body[data-theme="dark"] .map-card-status.available {
    background: rgba(248, 113, 113, 0.14) !important;
    border-color: rgba(248, 113, 113, 0.34) !important;
    color: #fecaca !important;
}

body[data-theme="dark"] .map-card-status.waiting,
body[data-theme="dark"] .map-card-status.banned {
    background: #26344b !important;
    border-color: #40516b !important;
    color: #cbd5e1 !important;
}

body[data-theme="dark"] .map-card-status.selected {
    background: rgba(34, 197, 94, 0.16) !important;
    border-color: rgba(74, 222, 128, 0.34) !important;
    color: #bbf7d0 !important;
}

body[data-theme="dark"] .map-thumb-spec,
body[data-theme="dark"] .side-thumb-spec {
    background: #111827 !important;
    border-color: #334155 !important;
}

body[data-theme="dark"] .sidepick-final-map-wrap {
    background: radial-gradient(circle at top, rgba(96, 165, 250, 0.12), transparent 46%),
        linear-gradient(180deg, #172033, #111827) !important;
}


        .postmatch-empty {
            margin: 16px 0 8px;
            padding: 16px 18px;
            border: 1px dashed #cbd5e1;
            border-radius: 8px;
            background: #f8fafc;
            color: #64748b;
            font-weight: 800;
        }

        .postmatch-note {
            margin-top: 10px;
            color: #64748b;
            font-weight: 700;
            line-height: 1.6;
        }

body[data-theme="dark"] .hltv-style-table td.positive,
body[data-theme="dark"] #extra-info .hltv-style-table td.positive,
body[data-theme="dark"] .score-positive,
body[data-theme="dark"] #extra-info .score-positive {
    color: #22c55e !important;
    font-weight: 900 !important;
}

body[data-theme="dark"] .hltv-style-table td.negative,
body[data-theme="dark"] #extra-info .hltv-style-table td.negative,
body[data-theme="dark"] .score-negative,
body[data-theme="dark"] #extra-info .score-negative {
    color: #ef4444 !important;
    font-weight: 900 !important;
}

body[data-theme="dark"] .hltv-style-table td.neutral,
body[data-theme="dark"] #extra-info .hltv-style-table td.neutral,
body[data-theme="dark"] .score-neutral,
body[data-theme="dark"] #extra-info .score-neutral {
    color: #cbd5e1 !important;
    font-weight: 800 !important;
}

body[data-theme="dark"] .score-rule-note,
body[data-theme="dark"] #extra-info .score-rule-note,
body[data-theme="dark"] .postmatch-empty,
body[data-theme="dark"] #extra-info .postmatch-empty,
body[data-theme="dark"] .postmatch-note,
body[data-theme="dark"] #extra-info .postmatch-note {
    background: rgba(15, 23, 42, 0.78) !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

body[data-theme="dark"] .hltv-style-table {
    background: #2f3d4b !important;
    color: #aeb8c3 !important;
    border-color: #455668 !important;
}

body[data-theme="dark"] .hltv-style-table th,
body[data-theme="dark"] .hltv-style-table td {
    background: #2f3d4b !important;
    color: #aeb8c3 !important;
    border-color: #455668 !important;
}

body[data-theme="dark"] .hltv-style-table thead th {
    background: #354657 !important;
    color: #aeb8c3 !important;
}

body[data-theme="dark"] .hltv-style-table .team-heading {
    color: #d5dde6 !important;
}

body[data-theme="dark"] .map-card-status.admin {
    background: rgba(249, 115, 22, .18) !important;
    border-color: rgba(251, 146, 60, .5) !important;
    color: #fed7aa !important;
}

body[data-theme="dark"] .funfact-card {
    background: #172033 !important;
    border-color: #334155 !important;
    color: var(--text) !important;
}

body[data-theme="dark"] .funfact-title {
    color: #dbeafe !important;
}

body[data-theme="dark"] .funfact-text {
    color: #cbd5e1 !important;
}

body[data-theme="dark"] .funfact-text strong {
    color: #ffffff !important;
}
/* Identity administration */
.identity-admin-panel {
    border: 1px solid #d8dee9;
    border-radius: 6px;
    background: #f8fafc;
}

.muted-line { color: #64748b; font-size: 13px; line-height: 1.6; }
.identity-toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.identity-admin-panel { margin-bottom: 14px; padding: 12px; }
.identity-admin-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.identity-admin-header > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; }
.identity-admin-table { width: 100%; margin-top: 10px; border-collapse: collapse; }
.identity-admin-table th, .identity-admin-table td { padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; font-size: 13px; }
.identity-admin-table-wrap { width: 100%; overflow-x: auto; }

@media (max-width: 760px) {
    .identity-admin-header { align-items: stretch; flex-direction: column; }
    .identity-toolbar-actions { justify-content: flex-start; }
}

/* Control center workspace */
:root {
    --surface: #ffffff;
    --surface-muted: #f6f8fb;
    --surface-raised: #ffffff;
    --surface-hover: #eef3f8;
    --text-strong: #142033;
    --text-default: #334155;
    --text-muted: #64748b;
    --border-subtle: #dbe3ec;
    --border-strong: #b8c5d4;
    --focus-ring: rgba(37, 99, 235, 0.24);
    --success-surface: #edf9f1;
    --success-text: #166534;
    --warning-surface: #fff8e7;
    --warning-text: #92400e;
    --danger-surface: #fff1f2;
    --danger-text: #9f1239;
    --control-height: 44px;
    --workspace-radius: 8px;
}

body[data-theme="dark"] {
    --surface: #151d2b;
    --surface-muted: #101722;
    --surface-raised: #1a2434;
    --surface-hover: #222f42;
    --text-strong: #f1f5f9;
    --text-default: #d7e0ec;
    --text-muted: #9baabd;
    --border-subtle: #334155;
    --border-strong: #526177;
    --focus-ring: rgba(96, 165, 250, 0.28);
    --success-surface: #10291e;
    --success-text: #86efac;
    --warning-surface: #30230d;
    --warning-text: #fcd34d;
    --danger-surface: #33151c;
    --danger-text: #fda4af;
}

body {
    color: var(--text-default);
    background: #eef3f8;
    letter-spacing: 0;
}

body[data-theme="dark"] {
    background: #0d1420;
}

.page-shell {
    width: min(1600px, 100%);
    margin: 0 auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 auto 20px;
    max-width: 1480px;
}

.site-brand h1 {
    margin: 0;
    color: var(--text-strong);
    font-size: clamp(26px, 3vw, 36px);
}

.site-brand .page-subtitle {
    margin: 6px 0 0;
    color: var(--text-muted);
}

.site-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex: 0 0 auto;
}

.header-text-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--workspace-radius);
    background: var(--surface);
    color: var(--text-default);
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.header-text-link:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.header-text-link:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.theme-toggle {
    position: static;
    flex: 0 0 auto;
    min-height: 40px;
    margin: 0;
    border-radius: var(--workspace-radius);
    box-shadow: none;
}

button,
input,
select,
textarea,
summary {
    font: inherit;
    letter-spacing: 0;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-width: 0;
    min-height: var(--control-height);
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    outline: 0;
    background: var(--surface);
    color: var(--text-default);
    box-sizing: border-box;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.82;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
summary:focus-visible,
[contenteditable="true"]:focus-visible {
    border-color: var(--primary);
    outline: 3px solid var(--focus-ring);
    outline-offset: 1px;
}

button {
    min-height: 40px;
    margin: 0;
    border-radius: 6px;
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text-default);
    box-shadow: none;
}

button:hover {
    background: var(--surface-hover);
    box-shadow: none;
    transform: none;
}

.primary-btn,
body[data-theme="dark"] .primary-btn {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.primary-btn:hover,
body[data-theme="dark"] .primary-btn:hover {
    background: #1d4ed8;
}

.danger-btn,
body[data-theme="dark"] .danger-btn {
    background: #be123c;
    border-color: #be123c;
    color: #ffffff;
}

#login-area {
    max-width: 1120px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.player-center-entry,
.player-center-home {
    max-width: 980px;
    margin: 0 auto 20px;
}

.player-center-auth-panel {
    display: grid;
    gap: 14px;
    max-width: 560px;
    margin-top: 18px;
}

.player-center-auth-panel[hidden],
.player-center-home[hidden],
.player-center-entry[hidden] {
    display: none;
}

.player-center-credential-card {
    max-width: 680px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-muted);
}

.player-center-credential-card > div {
    display: grid;
    grid-template-columns: minmax(90px, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.player-center-credential-card strong {
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.player-center-profile-grid,
.player-center-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.player-center-profile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.player-center-profile-grid > div,
.player-center-settings-grid > form {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-muted);
}

.player-center-profile-grid span {
    color: var(--text-muted);
    font-size: .88rem;
}

.player-center-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.player-center-match-action {
    flex: 1 1 100%;
    min-height: 48px;
    font-size: 1.02rem;
    font-weight: 700;
}

.player-center-match-action.joined {
    border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
    background: transparent;
    color: var(--danger);
}

.player-center-security {
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-muted);
}

.player-center-security > summary {
    cursor: pointer;
    font-weight: 700;
}

.player-center-security .player-center-settings-grid {
    margin-top: 16px;
}

@media (max-width: 720px) {
    .player-center-profile-grid,
    .player-center-settings-grid {
        grid-template-columns: 1fr;
    }

    .player-center-credential-card > div {
        grid-template-columns: 1fr;
    }
}

.login-panel {
    margin: 0;
    padding: 28px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--workspace-radius);
    background: var(--surface);
    box-shadow: 0 18px 46px rgba(15, 23, 42, 0.08);
}

body[data-theme="dark"] .login-panel {
    background: var(--surface);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

.login-panel-header,
.login-utility-row,
.admin-view-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.login-panel-header h2,
.admin-view-heading h2,
.identity-admin-header h2 {
    margin: 4px 0 0;
    color: var(--text-strong);
    font-size: 22px;
}

.section-eyebrow {
    display: block;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.server-status-line {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-default);
    font-size: 14px;
}

.server-status-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

.login-utility-row {
    justify-content: flex-start;
    margin: 20px 0;
}

.download-menu {
    position: relative;
}

.download-menu summary {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

.download-menu-content {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    padding: 6px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--surface-raised);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

.download-menu-content a {
    display: block;
    padding: 10px;
    border-radius: 4px;
    color: var(--text-default);
    text-decoration: none;
    font-weight: 700;
}

.download-menu-content a:hover {
    background: var(--surface-hover);
}

.login-workspace {
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    padding: 22px 0;
}

.admin-view-panel[hidden] {
    display: none !important;
}

.identity-admin-panel {
    border-color: var(--border-subtle);
    background: var(--surface-muted);
    color: var(--text-default);
}

.muted-line {
    color: var(--text-muted);
}

.identity-toolbar {
    position: sticky;
    top: 12px;
    z-index: 30;
    margin-bottom: 16px;
    padding: 16px 18px;
    border-radius: var(--workspace-radius);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px);
}

.identity-welcome {
    margin: 8px 0 6px;
    color: var(--text-strong);
    font-size: 17px;
}

.admin-role-label {
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.lobby-phase-summary {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.my-identity-line {
    margin: 0 0 12px;
    color: var(--text-default);
    font-size: 14px;
    font-weight: 700;
}

#admin-controls {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.admin-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.admin-sidebar {
    position: sticky;
    top: 116px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: var(--workspace-radius);
    background: var(--surface);
}

.admin-sidebar-heading {
    display: grid;
    gap: 4px;
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-strong);
}

.admin-sidebar-heading span {
    color: var(--text-muted);
    font-size: 12px;
}

.admin-nav {
    display: grid;
    gap: 2px;
    padding: 8px;
}

.admin-nav-btn {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
}

.admin-nav-btn.active,
body[data-theme="dark"] .admin-nav-btn.active {
    background: var(--primary-soft);
    border-color: transparent;
    color: var(--primary);
}

.admin-workspace {
    min-width: 0;
}

.admin-view-panel {
    min-width: 0;
}

.admin-view-panel.active {
    display: block;
}

.admin-view-heading,
.identity-admin-header {
    margin-bottom: 16px;
}

#admin-overview,
.stage-content,
.identity-admin-panel,
.player-list,
.admin-view-panel > .match-options-panel,
.admin-view-panel > .caoren-mod-panel {
    padding: 20px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--workspace-radius);
    background: var(--surface);
    box-shadow: none;
}

.stage-content {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.stage-content #phase-info,
.stage-content #extra-info {
    margin: 0 !important;
    padding: 16px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--workspace-radius);
}

.stage-content #extra-info:empty {
    display: none;
}

.player-list {
    margin: 0 0 16px;
}

.overview-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--border-subtle);
    border-radius: var(--workspace-radius);
    overflow: hidden;
}

.overview-metric {
    display: grid;
    gap: 7px;
    min-width: 0;
    padding: 16px;
    border-right: 1px solid var(--border-subtle);
    background: var(--surface-muted);
}

.overview-metric:last-child {
    border-right: 0;
}

.overview-metric span {
    color: var(--text-muted);
    font-size: 12px;
}

.overview-metric strong {
    overflow-wrap: anywhere;
    color: var(--text-strong);
    font-size: 20px;
}

.overview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.admin-mobile-nav {
    display: none;
    margin-bottom: 12px;
}

.identity-admin-table th,
.identity-admin-table td,
.cc-table th,
.cc-table td,
.scoreboard-table th,
.scoreboard-table td {
    border-color: var(--border-subtle);
    color: var(--text-default);
}

.identity-admin-table th,
.cc-table th,
.scoreboard-table th {
    background: var(--surface-muted);
    color: var(--text-muted);
}

.identity-admin-table-wrap,
.cc-table-wrap,
.scoreboard-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-gutter: stable;
}

.identity-admin-table {
    min-width: 720px;
}

.match-options-panel,
.match-options-row,
.modal-content,
.caoren-mod-panel,
.caoren-mod-card,
.task-grid,
.task-cell,
#phase-info,
#extra-info,
.soft-block,
.tpl-preview-area,
.tpl-form-area {
    border-color: var(--border-subtle) !important;
    background-color: var(--surface) !important;
    color: var(--text-default) !important;
}

.match-options-row,
.caoren-mod-card,
.task-cell {
    background-color: var(--surface-muted) !important;
}

.match-options-title,
.caoren-mod-card h5,
.task-cell strong,
.modal-content h2,
.modal-content h3,
.modal-content h4 {
    color: var(--text-strong) !important;
}

.match-options-desc,
.match-options-status,
.caoren-mod-card p,
.task-desc {
    color: var(--text-muted) !important;
}

.match-options-status,
.caoren-mod-status {
    background: var(--surface-muted) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-muted) !important;
}

.admin-danger-zone {
    margin-top: 20px;
    background: var(--danger-surface);
    border-color: color-mix(in srgb, var(--danger-text) 38%, transparent);
    color: var(--danger-text);
}

.admin-danger-zone p {
    color: var(--danger-text);
}

#admin-tab-setup .admin-danger-zone {
    align-items: stretch;
    flex-direction: column;
}

#terminate-game-btn {
    width: 100%;
}

/* 任务模板编辑器统一使用当前主题，避免旧的浅色内联样式污染深色模式。 */
.template-modal-content {
    color: var(--text-default);
}

.task-preset-panel {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 12px 0;
    padding: 10px;
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--text-default);
}

.task-preset-panel button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

body[data-theme="dark"] .task-preset-panel {
    background: var(--panel) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
}

.template-modal-title,
.template-edit-title,
.template-preview-title {
    color: var(--text-strong) !important;
}

.template-tab-row,
.template-modal-actions {
    border-color: var(--border-subtle) !important;
}

.template-tab-btn,
.template-modal-content .format-btn,
.template-modal-content .json-toolbar button {
    border-color: var(--border-subtle) !important;
    background: var(--surface-muted) !important;
    color: var(--text-default) !important;
}

.template-tab-btn.active {
    background: var(--primary-soft) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    font-weight: 800;
}

.template-modal-content .tpl-form-group label {
    color: var(--text-strong);
}

.template-modal-content input,
.template-modal-content select,
.template-modal-content textarea {
    border-color: var(--border-subtle) !important;
    background: var(--surface-muted) !important;
    color: var(--text-default) !important;
}

.template-modal-content textarea::placeholder,
.template-modal-content input::placeholder {
    color: var(--text-muted);
}

.template-replacement-preview {
    margin-top: 20px;
    padding: 10px;
    border: 2px dashed var(--border-subtle);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    background: var(--surface-muted);
    color: var(--text-default);
}

.template-replacement-preview.selected {
    border-color: var(--danger) !important;
    background: var(--danger-surface) !important;
}

.template-n-panel {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.template-n-panel-simple {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface)) !important;
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border-subtle)) !important;
}

.template-n-panel-streak {
    background: color-mix(in srgb, var(--warning) 10%, var(--surface)) !important;
    border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border-subtle)) !important;
}

.template-n-panel p {
    color: var(--text-muted) !important;
}

#admin-controls:not(.is-admin-session) .admin-sidebar,
#admin-controls:not(.is-admin-session) .admin-mobile-nav,
#admin-controls:not(.is-admin-session) [data-admin-view-panel]:not(.public-roster-panel):not(.public-stage-panel) {
    display: none !important;
}

#admin-controls:not(.is-admin-session) .admin-shell {
    display: block;
}

#admin-controls:not(.is-admin-session) .public-roster-panel {
    display: block !important;
}

#admin-controls:not(.is-admin-session) .public-stage-panel {
    display: grid !important;
}

@media (max-width: 1100px) {
    .admin-shell {
        grid-template-columns: 190px minmax(0, 1fr);
    }

    .overview-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .overview-metric:nth-child(2) {
        border-right: 0;
    }

    .overview-metric:nth-child(-n + 2) {
        border-bottom: 1px solid var(--border-subtle);
    }
}

@media (max-width: 820px) {
    body {
        padding: 14px;
    }

    .site-header,
    .login-panel-header,
    .identity-admin-header {
        align-items: stretch;
        flex-direction: column;
    }

    .login-panel {
        padding: 20px;
    }

    .admin-sidebar {
        display: none;
    }

    .admin-mobile-nav {
        display: grid;
        gap: 6px;
    }

    .admin-shell {
        display: block;
    }

    .identity-toolbar {
        position: static;
    }
}

@media (max-width: 600px) {
    .site-header {
        flex-direction: row;
        align-items: flex-start;
    }

    .site-brand h1 {
        font-size: 24px;
    }

    .site-brand .page-subtitle {
        display: none;
    }

    .site-header-actions {
        gap: 6px;
    }

    .header-text-link,
    .site-header-actions .theme-toggle {
        min-height: 38px;
        padding-inline: 10px;
        white-space: nowrap;
    }

    .login-panel {
        padding: 16px;
    }

    .login-utility-row,
    .identity-toolbar-actions,
    .admin-view-heading,
    .admin-danger-zone {
        align-items: stretch;
        flex-direction: column;
    }

    .login-utility-row > button,
    .download-menu,
    .download-menu summary {
        width: 100%;
    }

    .download-menu-content {
        position: static;
        margin-top: 6px;
    }

    .overview-metrics {
        grid-template-columns: 1fr;
    }

    .overview-metric,
    .overview-metric:nth-child(2) {
        border-right: 0;
        border-bottom: 1px solid var(--border-subtle);
    }

    .overview-metric:last-child {
        border-bottom: 0;
    }

}
