:root {
    --bg: #0f1320;
    --panel: #1a1f2e;
    --panel-2: #212838;
    --text: #e8eaf0;
    --muted: #9aa3b5;
    --line: #2c3448;
    --gold: #d4a553;
    --gold-dark: #b4873d;
    --red: #c85a5a;
    --green: #5aae7c;
    --blue: #5a8dc8;
    --purple: #8e6fc1;
    --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ========== 顶栏 ========== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(15, 19, 32, 0.98);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.brand { font-size: 18px; font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.nav-links {
    display: flex;
    gap: 6px;
    background: #141926;
    padding: 4px;
    border-radius: 999px;
    border: 1px solid var(--line);
}
.nav-links a {
    color: var(--muted);
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 999px;
    transition: all 0.2s;
    white-space: nowrap;
}
.nav-links a:hover { background: #242c3f; color: var(--text); text-decoration: none; }
.nav-links a.active { background: var(--gold); color: #11141e; }
.user-box {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    flex-wrap: wrap;
}
.rank-badge {
    background: linear-gradient(135deg, #2b3145, #3a4258);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
}
.points-badge {
    background: #2b3145;
    border: 1px solid var(--line);
    color: var(--text);
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}
.board-config { color: var(--muted); font-size: 13px; margin-right: auto; }
.day-label { font-weight: 700; color: var(--gold); }

/* ========== 容器 ========== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}
.hero { margin-bottom: 26px; }
.hero h1 { font-size: 30px; margin-bottom: 6px; }
.hero p { color: var(--muted); }

/* ========== 面板 ========== */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 20px;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.panel-header h2 { font-size: 20px; }

/* ========== 板子列表（主页） ========== */
.board-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
.board-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
}
.board-card h3 { margin-bottom: 4px; }
.board-card p { color: var(--muted); font-size: 14px; }
.win-rate { font-size: 13px; margin-top: 6px; }

/* ========== 按钮 ========== */
.primary, .ghost {
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: 0.2s;
}
.primary { background: var(--gold); color: #11141e; }
.primary:hover { background: var(--gold-dark); }
.primary:disabled { background: #3c4254; color: #8a91a5; cursor: not-allowed; }
.ghost {
    background: #262c3d;
    color: var(--text);
    border: 1px solid var(--line);
}
.ghost:hover { background: #2f364b; }
.ghost:disabled { background: #1b202e; color: #5f667a; cursor: not-allowed; }
.link-btn { color: var(--gold); cursor: pointer; background: none; border: none; font-size: 15px; }
.link-btn:hover { text-decoration: underline; }

.empty { color: var(--muted); padding: 18px 0; }

/* ========== 表格（排行榜、后台） ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }

/* ========== 登录注册 ========== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px;
}
.auth-card h1 { margin-bottom: 20px; text-align: center; }
.auth-card form { display: flex; flex-direction: column; gap: 8px; }
.auth-card label { margin-top: 8px; color: var(--muted); font-size: 14px; }
.auth-card input {
    background: #0d101a;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text);
    font-size: 15px;
    outline: none;
}
.auth-card input:focus { border-color: var(--gold); }
.auth-card button { margin-top: 20px; }
.auth-link { text-align: center; margin-top: 18px; color: var(--muted); }
.error {
    background: #3a2028;
    border: 1px solid #6e3340;
    color: #f0b6c0;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
}

/* ========== 游戏主布局 ========== */
.game-layout {
    display: grid;
    grid-template-columns: 160px 1fr 160px;
    gap: 12px;
    padding: 16px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 60px);
}
.role-column {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    overflow-y: auto;
}
.role-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.role-button {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
    position: relative;
}
.role-button:hover { border-color: var(--gold); }
.role-button.dead { opacity: 0.6; background: #151a24; border-color: #5a3a3a; }
.role-button.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212,165,83,0.3); }
.role-button.no-interact { cursor: not-allowed; }
.role-button .role-number { font-weight: 700; font-size: 14px; }
.role-button .role-identity {
    font-size: 12px;
    margin: 2px 0;
    min-height: 18px;
}
.role-button .role-mark {
    font-size: 11px;
    color: var(--muted);
    min-height: 16px;
}
.role-button.dead::after {
    content: "出局";
    position: absolute;
    top: 4px;
    right: 4px;
    background: #b03a3a;
    color: #fff;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

/* 中央区域 */
.center-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.logs-panel, .action-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.panel-header h2 { font-size: 16px; }
.day-switcher { display: flex; gap: 4px; flex-wrap: wrap; }
.day-btn {
    background: #232a3b; border: 1px solid var(--line); color: var(--text);
    border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: pointer;
}
.day-btn.active { background: var(--gold); color: #11141e; border-color: var(--gold); }
.log-list {
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.log-item {
    background: #0e121c;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
}
.log-item.system { color: var(--gold); border-color: #4a3b1e; }
.previous-system-reminder {
    color: #999;
    background: #1a1d26;
    border-color: #3a3f4d;
    font-style: italic;
}

/* 操作面板 */
.action-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.exile-area { display: flex; flex-direction: column; gap: 6px; }
.exile-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.player-select {
    background: #0d101a;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text);
    font-size: 13px;
    min-width: 120px;
}
.god-panel {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    margin-top: 6px;
}
.god-panel h3 { font-size: 14px; margin-bottom: 6px; }
.god-status { font-size: 12px; margin-bottom: 6px; color: var(--muted); }
.god-area { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.god-area select { flex: 1; }

/* 标记 */
.mark-options { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.mark-option {
    background: #262c3d; color: var(--text); border: 1px solid var(--line);
    border-radius: 6px; padding: 8px; cursor: pointer; font-size: 14px;
}
.mark-option:hover { background: #353d55; border-color: var(--gold); }
.mark-badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.mark-good { background: #f0c94a; color: #111; }
.mark-civilian { background: #3a6ea5; color: #fff; }
.mark-wolf { background: #b03a3a; color: #fff; }
.mark-wolf-special { background: #6b1e1e; color: #fff; }
.mark-camp { background: #3a7a5a; color: #fff; }

/* ========== 模态框 ========== */
.modal {
    position: fixed; inset: 0; background: rgba(5,7,12,0.7);
    display: flex; align-items: center; justify-content: center; z-index: 200; padding: 18px;
}
.modal-box {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 24px; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; position: relative;
}
.small-modal { max-width: 420px; }
.wide-modal { max-width: 980px; }
.modal-close {
    position: absolute; top: 12px; right: 16px; background: none; border: none;
    color: var(--muted); font-size: 28px; cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal h2 { margin-bottom: 16px; }

/* ========== 个人主页 ========== */
.profile-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 24px;
}
.rank-card {
    background: linear-gradient(135deg, #1a2134, #232b42);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    padding: 24px;
    flex: 1 1 300px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
.rank-main { display: flex; align-items: center; gap: 16px; }
.rank-icon {
    width: 56px;
    height: 56px;
    background: var(--gold);
    color: #111;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    box-shadow: 0 0 12px rgba(212,165,83,0.4);
}
.rank-name { font-size: 24px; font-weight: 700; }
.rank-sub { color: var(--muted); font-size: 14px; }
.rank-points { display: flex; align-items: baseline; gap: 8px; }
.points-value { font-size: 36px; font-weight: 700; color: var(--gold); }
.points-label { color: var(--muted); }
.rank-progress-bar { height: 8px; background: #141926; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold-dark), var(--gold)); border-radius: 999px; transition: width 0.3s; }
.rank-progress { color: var(--muted); font-size: 14px; }
.stats-row { flex: 1 1 300px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gold); }
.stat-label { color: var(--muted); font-size: 14px; }
.setting-form { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.switch-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }

/* ========== 排行榜 ========== */
.page-title { font-size: 28px; margin-bottom: 20px; }
.leaderboard-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* ========== 管理后台 ========== */
.admin-container { max-width: 900px; margin: 30px auto; }
.admin-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
}
.admin-card h2 { margin-bottom: 16px; }
.admin-card label { display: block; margin-bottom: 6px; color: var(--muted); }
.admin-card input[type="password"],
.admin-card input[type="text"],
.admin-card input[type="number"],
.admin-card textarea {
    width: 100%;
    background: #0d101a;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text);
    font-size: 15px;
    outline: none;
    margin-bottom: 16px;
}
.admin-card input:focus, .admin-card textarea:focus { border-color: var(--gold); }
.admin-card button { width: 100%; }
.admin-message { margin-top: 12px; font-weight: 600; }
.admin-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.guides-form { display: flex; flex-direction: column; gap: 12px; }
.guide-edit-item { display: flex; flex-direction: column; gap: 4px; }
.guide-edit-item label { font-weight: 600; color: var(--gold); }
.guide-edit-item textarea {
    background: #0d101a;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    color: var(--text);
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
}
.board-edit-item { margin-bottom: 16px; padding: 12px; background: var(--panel-2); border-radius: 12px; }
.board-edit-item label { display: block; margin-bottom: 4px; color: var(--gold); font-weight: 600; }
.board-edit-item input, .board-edit-item textarea {
    width: 100%;
    background: #0d101a;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 8px;
}
.roles-json-input { font-family: monospace; min-height: 80px; }

/* ========== 响应式 ========== */
@media (max-width: 900px) {
    .game-layout { grid-template-columns: 70px 1fr 70px; }
    .role-column { padding: 4px; }
    .role-button { padding: 4px; }
    .role-button .role-number { font-size: 12px; }
    .role-button .role-identity { font-size: 10px; min-height: 14px; }
    .role-button .role-mark { font-size: 9px; }
    .role-button.dead::after {
        font-size: 8px;
        padding: 1px 3px;
        top: 2px;
        right: 2px;
    }
    .center-area { gap: 6px; }
    .logs-panel, .action-panel { padding: 6px; }
    .log-list { max-height: 200px; }
    .day-switcher .day-btn { padding: 2px 4px; font-size: 10px; }
    .player-select, .primary, .ghost { padding: 4px 8px; font-size: 12px; }
    .god-panel { padding: 6px; }
    .god-area { flex-wrap: wrap; }
}

/* 空发言框样式 */
.log-item.empty-speech {
    background: #0e121c;
    border: 1px dashed var(--line);
    color: var(--muted);
    font-style: italic;
    min-height: 32px;
    display: flex;
    align-items: center;
}