/* ============================================
   余城狼积分系统 - 查询页面样式
   暗色主题，月夜狼嚎风格
   ============================================ */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-card-hover: #1e2a42;
    --border-color: #2a3550;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --blood: #dc2626;
    --blood-light: #ef4444;
    --blood-dark: #991b1b;
    --moon: #fbbf24;
    --moon-dim: #92400e;
    --wolf-blue: #60a5fa;
    --good-green: #22c55e;
    --wolf-red: #f87171;
    --tier-bronze: #cd7f32;
    --tier-silver: #c0c0c0;
    --tier-gold: #ffd700;
    --tier-platinum: #40e0d0;
    --tier-diamond: #00bfff;
    --tier-master: #9333ea;
    --tier-king: #ff4500;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* 背景氛围 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(220, 38, 38, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 0%, rgba(251, 191, 36, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(96, 165, 250, 0.03) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* 顶部导航 */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.top-bar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.top-bar .logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--blood), var(--blood-dark));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 900;
    color: white;
}

.top-bar .logo-text {
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--blood-light), var(--moon));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.top-bar .logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 12px;
}

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

.nav-links a {
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-links a.active {
    color: var(--blood-light);
    background: rgba(220, 38, 38, 0.1);
}

.nav-links .btn-admin {
    margin-left: 8px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
}

.nav-links .btn-admin:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* 主内容 */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* 页面标题区 */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 筛选栏 */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.filter-bar select:focus,
.filter-bar input:focus {
    border-color: var(--blood);
}

.filter-bar select {
    cursor: pointer;
}

/* Tab切换 */
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 8px 18px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    color: var(--blood-light);
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.2);
}

/* 卡片 */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 0;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(220, 38, 38, 0.3);
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-card .stat-value.blood { color: var(--blood-light); }
.stat-card .stat-value.moon { color: var(--moon); }
.stat-card .stat-value.green { color: var(--good-green); }
.stat-card .stat-value.blue { color: var(--wolf-blue); }

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

thead th.center { text-align: center; }

tbody tr {
    border-bottom: 1px solid rgba(42, 53, 80, 0.4);
    transition: background 0.15s;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

tbody td {
    padding: 10px 16px;
    color: var(--text-primary);
    vertical-align: middle;
}

tbody td.center { text-align: center; }

/* 排名前三行 */
tbody tr.rank-1 { background: rgba(251, 191, 36, 0.04); }
tbody tr.rank-2 { background: rgba(192, 192, 192, 0.03); }
tbody tr.rank-3 { background: rgba(205, 127, 50, 0.03); }

/* 排名数字 */
.rank-num {
    font-weight: 800;
    font-size: 14px;
    width: 28px;
    text-align: center;
}
.rank-1 .rank-num { color: var(--tier-gold); }
.rank-2 .rank-num { color: var(--tier-silver); }
.rank-3 .rank-num { color: var(--tier-bronze); }

/* 玩家名（可点击） */
.player-name {
    font-weight: 600;
    color: var(--wolf-blue);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s;
}

.player-name:hover {
    color: var(--moon);
    text-decoration: underline;
}

/* 段位徽章 */
.tier-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

/* 胜率条 */
.win-rate-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}

.win-rate-bar .bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.win-rate-bar .bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.win-rate-bar .bar-text {
    font-size: 12px;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
    font-family: 'SF Mono', 'Menlo', monospace;
}

/* 阵营标签 */
.faction-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.faction-good { background: rgba(34, 197, 94, 0.15); color: var(--good-green); }
.faction-wolf { background: rgba(248, 113, 113, 0.15); color: var(--wolf-red); }
.faction-third { background: rgba(251, 191, 36, 0.15); color: var(--moon); }

/* MVP标签 */
.mvp-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}
.mvp-gold { background: rgba(251, 191, 36, 0.2); color: var(--moon); }
.mvp-purple { background: rgba(147, 51, 234, 0.2); color: var(--tier-master); }

/* 胜负标记 */
.result-win { color: var(--good-green); font-weight: 600; }
.result-lose { color: var(--wolf-red); font-weight: 600; }

/* 积分变动 */
.rating-change {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 13px;
    font-weight: 600;
}
.rating-up { color: var(--good-green); }
.rating-down { color: var(--wolf-red); }

/* 个人页面 */
.player-header {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.player-avatar {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-card-hover));
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 900;
    color: var(--text-muted);
}

.player-info h1 {
    font-size: 28px;
    font-weight: 800;
}

.player-info .player-meta {
    display: flex;
    gap: 16px;
    margin-top: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

.player-rating-big {
    font-size: 48px;
    font-weight: 900;
    font-family: 'SF Mono', 'Menlo', monospace;
    line-height: 1;
}

/* 积分曲线图容器 */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    position: relative;
    height: 250px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* 对局记录卡片 */
.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.game-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(220, 38, 38, 0.2);
    transform: translateX(4px);
}

.game-card .game-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.game-card .game-code {
    font-weight: 700;
    font-size: 15px;
    font-family: 'SF Mono', 'Menlo', monospace;
}

.game-card .game-mode {
    font-size: 13px;
    color: var(--text-secondary);
}

.game-card .game-winner {
    font-size: 13px;
    font-weight: 600;
}

.game-card .game-players {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.game-card .game-player-tag {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.game-card .game-player-tag.is-win {
    background: rgba(34, 197, 94, 0.1);
    color: var(--good-green);
}

.game-card .game-player-tag.is-lose {
    background: rgba(248, 113, 113, 0.08);
    color: var(--wolf-red);
    opacity: 0.7;
}

/* 登录弹窗 */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    width: 400px;
    max-width: 90vw;
}

.modal h2 {
    font-size: 20px;
    margin-bottom: 20px;
}

.modal input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    margin-bottom: 16px;
}

.modal input:focus {
    border-color: var(--blood);
}

.modal .btn-row {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* 按钮 */
.btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--blood);
    color: white;
    border-color: var(--blood);
}

.btn-primary:hover {
    background: var(--blood-light);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.btn-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--good-green);
    border-color: rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
    background: rgba(34, 197, 94, 0.25);
}

/* Toast通知 */
.toast {
    position: fixed;
    top: 70px;
    right: 24px;
    z-index: 300;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    max-width: 360px;
}

.toast-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--good-green);
}

.toast-error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--wolf-red);
}

@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--blood);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
    font-size: 15px;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.pagination button {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.pagination button:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.pagination button.active { background: rgba(220, 38, 38, 0.15); color: var(--blood-light); border-color: rgba(220, 38, 38, 0.3); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* 两栏布局 */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group select,
.form-group input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.form-group select:focus,
.form-group input:focus {
    border-color: var(--blood);
}

/* 玩家添加行（录入页面用） */
.player-row {
    display: grid;
    grid-template-columns: 50px 1fr 1fr 60px 70px 60px 60px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(42, 53, 80, 0.3);
}

.player-row input,
.player-row select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

/* 隐藏 */
.hidden { display: none !important; }

/* 响应式 */
@media (max-width: 768px) {
    .main-content { padding: 16px; }
    .top-bar { padding: 0 16px; }
    .nav-links a { padding: 6px 10px; font-size: 13px; }
    .top-bar .logo-sub { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .player-row { grid-template-columns: 40px 1fr 80px 50px 50px; }
    .player-row > :nth-child(n+6) { display: none; }
}

/* 加载更多按钮 */
.load-more-container {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
}

.load-more-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.load-more-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 主页按钮样式 */
.btn-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white !important;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    margin-right: 8px;
}

.btn-home:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.btn-home:active {
    transform: translateY(0);
}

/* 赛季选择器样式 */
.season-select {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid #2a3550;
    border-radius: 8px;
    padding: 6px 12px;
    color: #94a3b8;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.season-select:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.season-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.season-select option {
    background: #1e293b;
    color: #e2e8f0;
    padding: 8px;
}
