:root {
    --bg: #08111f;
    --panel: rgba(14, 24, 44, 0.86);
    --panel-strong: rgba(19, 32, 58, 0.96);
    --line: rgba(158, 180, 207, 0.18);
    --text: #edf4ff;
    --muted: #9ab0cf;
    --orange: #ff8a3d;
    --cyan: #31d0c6;
    --green: #67d38f;
    --red: #ff6467;
    --gold: #ffcc6a;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(49, 208, 198, 0.12), transparent 28%),
        radial-gradient(circle at top right, rgba(255, 138, 61, 0.14), transparent 28%),
        linear-gradient(180deg, #07111d 0%, #0b1324 100%);
    color: var(--text);
    font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    opacity: 0.32;
}

.hidden {
    display: none !important;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
}

.login-card {
    width: min(460px, 100%);
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 32px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.kicker,
.panel-eyebrow {
    margin: 0 0 8px;
    color: var(--cyan);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.login-card h1,
.topbar h1,
.panel-header h2 {
    margin: 0;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.login-note,
.subtle-note {
    color: var(--muted);
    line-height: 1.6;
}

.field {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.field span,
.wall-setting-row label {
    font-size: 13px;
    color: var(--muted);
}

.field input {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(4, 11, 22, 0.75);
    color: var(--text);
    padding: 14px 16px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
    border-color: rgba(49, 208, 198, 0.52);
    box-shadow: 0 0 0 4px rgba(49, 208, 198, 0.16);
}

button,
a {
    border: none;
    border-radius: 16px;
    font: inherit;
    text-decoration: none;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.ghost-button:hover {
    transform: translateY(-1px);
}

.primary-button {
    padding: 14px 18px;
    background: linear-gradient(135deg, #ff9d58 0%, var(--orange) 100%);
    color: #231104;
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(255, 138, 61, 0.24);
}

.secondary-button {
    padding: 14px 18px;
    background: rgba(49, 208, 198, 0.14);
    color: var(--text);
    border: 1px solid rgba(49, 208, 198, 0.28);
}

.danger-button {
    padding: 14px 18px;
    background: rgba(255, 100, 103, 0.16);
    color: #ffd8d9;
    border: 1px solid rgba(255, 100, 103, 0.3);
}

.ghost-button {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-status {
    min-height: 24px;
    margin: 16px 0 0;
    color: var(--red);
}

.app-shell {
    min-height: 100vh;
    padding: 26px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 22px;
}

.topbar-actions {
    display: flex;
    gap: 12px;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
}

.panel {
    position: relative;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.panel::after {
    content: "";
    position: absolute;
    inset: auto -10% -45% auto;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(49, 208, 198, 0.12), transparent 70%);
    pointer-events: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.composer-panel { grid-column: span 3; }
.excel-import-panel {
    grid-column: span 12;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.excel-upload-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}
.excel-file-label {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    margin: 0;
}
.excel-file-label input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
}
.excel-filename {
    color: var(--muted);
    font-size: 13px;
    flex: 1;
    min-width: 120px;
}
.roster-import-status-line {
    min-height: 22px;
    margin-top: 8px;
}
.roster-table-wrap {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(4, 11, 22, 0.45);
    max-height: min(52vh, 520px);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.roster-table-scroll {
    overflow: auto;
    flex: 1;
    min-height: 0;
}
.roster-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.roster-table th,
.roster-table td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}
.roster-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(19, 32, 58, 0.98);
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.02em;
}
.roster-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}
.roster-table .cell-empty {
    color: var(--muted);
    opacity: 0.65;
}

.winner-row td {
    background: rgba(103, 211, 143, 0.12);
}

.winner-row:hover td {
    background: rgba(103, 211, 143, 0.2);
}
.live-panel { grid-column: span 9; }
.roster-panel {
    grid-column: span 4;
    display: flex;
    flex-direction: column;
    height: 440px;
}

.roster-panel .participant-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}
.moderation-panel { grid-column: span 4; }
.approved-panel { grid-column: span 4; }
.history-panel { grid-column: span 12; }

.session-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.metric-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    padding: 14px;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 20px;
}

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

.status-pill,
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.status-pill.is-idle {
    background: rgba(154, 176, 207, 0.16);
    color: var(--muted);
}

.status-pill.is-join {
    background: rgba(49, 208, 198, 0.16);
    color: var(--cyan);
}

.status-pill.is-ready {
    background: rgba(255, 204, 106, 0.16);
    color: var(--gold);
}

.status-pill.is-race {
    background: rgba(103, 211, 143, 0.16);
    color: var(--green);
}

.status-pill.is-finish {
    background: rgba(255, 138, 61, 0.18);
    color: var(--orange);
}

.count-badge {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.control-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.round-config-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.wall-setting-row {
    display: grid;
    grid-template-columns: 100px 1fr 56px;
    gap: 12px;
    align-items: center;
    margin-top: 18px;
}

.dev-tools {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    gap: 14px;
}

.panel-header.compact {
    margin-bottom: 0;
}

.inline-control-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
}

.compact-field {
    flex: 1;
    min-width: 120px;
    margin-top: 0;
}

.compact-field input {
    padding: 12px 14px;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.toggle-row input {
    width: 18px;
    height: 18px;
}

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

#wall-opacity-slider {
    width: 100%;
}

.participant-list,
.message-list,
.history-list {
    display: grid;
    gap: 12px;
}

.empty-state {
    min-height: 130px;
    align-content: center;
    justify-items: center;
    color: var(--muted);
}

.participant-card,
.message-card,
.history-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 14px;
}

.participant-card {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    gap: 12px;
    align-items: center;
    position: relative;
}

.online-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    justify-self: center;
}

.participant-card.online .online-indicator {
    background: #22c55e; /* 绿色在线 */
}

.participant-card.offline .online-indicator {
    background: #ef4444; /* 红色离线 */
}

.avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.08);
}

.horse-chip {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, 0.18);
}

.participant-name {
    font-weight: 700;
}

.participant-meta,
.message-meta,
.history-meta {
    color: var(--muted);
    font-size: 12px;
}

.message-card {
    display: grid;
    gap: 12px;
}

.message-card.is-top {
    box-shadow: 0 0 0 1px rgba(255, 204, 106, 0.42) inset;
}

.message-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
}

.message-content {
    line-height: 1.65;
    white-space: pre-wrap;
}

.message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mini-button {
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    cursor: pointer;
}

.mini-button.primary {
    background: rgba(49, 208, 198, 0.18);
    border: 1px solid rgba(49, 208, 198, 0.28);
}

.mini-button.warn {
    background: rgba(255, 204, 106, 0.16);
    border: 1px solid rgba(255, 204, 106, 0.28);
}

.mini-button.danger {
    background: rgba(255, 100, 103, 0.16);
    border: 1px solid rgba(255, 100, 103, 0.28);
}

.history-list {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.history-card {
    display: grid;
    gap: 12px;
}

.history-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.history-actions > button,
.history-actions > a {
    width: 100%;
}

.history-title {
    font-size: 18px;
    font-weight: 800;
}

.podium-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.podium-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 12px;
}

.podium-rank {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 138, 61, 0.18);
    color: var(--orange);
    font-size: 12px;
    font-weight: 800;
}

@media (max-width: 1400px) {
    .composer-panel,
    .live-panel,
    .roster-panel,
    .moderation-panel,
    .approved-panel {
        grid-column: span 6;
    }
}

@media (max-width: 980px) {
    .app-shell {
        padding: 18px;
    }

    .dashboard {
        grid-template-columns: 1fr;
    }

    .composer-panel,
    .live-panel,
    .roster-panel,
    .moderation-panel,
    .approved-panel,
    .history-panel {
        grid-column: span 1;
    }

    .control-actions,
    .session-meta-grid,
    .round-config-row {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions > * {
        flex: 1;
    }
}
