/* ===== 现代变量系统 ===== */
:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;

    --gold: #f59e0b;
    --silver: #94a3b8;
    --bronze: #b45309;

    --win: #10b981;
    --lose: #ef4444;
}

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

body {
    background: var(--bg);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

/* ===== 头部样式 ===== */
.rank-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
}

h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: #0f172a;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

.tournament-filter select {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.tournament-filter select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== 表格容器 ===== */
.table-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border);
}

.rank-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* 锁定布局，控制列宽 */
}

/* ===== 列宽控制 (Web端) ===== */
.col-rank { width: 50px; text-align: center; }
.col-player { width: 120px; text-align: left; min-width: 70px;}
.col-stat { width: 75px; text-align: center; }
.col-stat.col-medal { width: 120px; }

/* 表头样式 */
.rank-table thead th {
    background: #f8fafc;
    padding: 16px 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.rank-table tbody td {
    padding: 16px 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.rank-table tbody tr:last-child td {
    border-bottom: none;
}

.rank-table tbody tr {
    transition: background 0.2s;
}

.rank-table tbody tr:hover {
    background: #f1f5f9;
}

/* 选手名字加粗 */
.player-name {
    font-weight: 600;
    color: #0f172a;
}

/* 排名勋章 */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    background: var(--primary-light);
    color: var(--primary);
}

/* 前三名特殊效果 */
tr:nth-child(1) .rank-badge { background: #fef3c7; color: var(--gold); }
tr:nth-child(2) .rank-badge { background: #f1f5f9; color: var(--silver); }
tr:nth-child(3) .rank-badge { background: #ffedd5; color: var(--bronze); }

/* 胜负着色 */
.win { color: var(--win); font-weight: 600; }
.lose { color: var(--lose); font-weight: 500; }
.win-rate { color: var(--primary); font-weight: 700; }


/* ===== 奖金池卡片样式 ===== */
.prize-pool-card {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
    padding: 12px 20px;
    border-radius: 14px;
    border: 1px solid #e0f2fe;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.05);
    margin: 0 20px; /* 在标题和筛选框中间保持间距 */
    min-width: 180px;
}

.prize-icon {
    width: 40px;
    height: 40px;
    background: #dbeafe;
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.prize-icon svg {
    width: 20px;
    height: 20px;
}

.prize-info {
    display: flex;
    flex-direction: column;
}

.prize-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.prize-amount {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Inter', system-ui, sans-serif;
}

/* 只有可点击行才显示手型 */
.clickable-row {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
}

/* 鼠标悬停时的效果：背景微变 + 稍微明亮的阴影 */
.clickable-row:hover {
    background-color: var(--primary-light) !important; /* 使用之前定义的淡蓝色 */
    transform: translateY(-1px); /* 轻微上浮，增加高级感 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    z-index: 1; /* 确保阴影不被遮挡 */
}

/* 点击时的反馈（按下效果） */
.clickable-row:active {
    transform: translateY(0);
    background-color: #e2e8f0 !important;
}

/* ===== 导航头容器 ===== */
.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.nav-left {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    padding: 6px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* ===== 通用导航按钮样式 ===== */
.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 4px;
    transition: all 0.2s ease;
}

.nav-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5px; /* 稍微加粗图标线条 */
}

/* 悬停反馈 */
.nav-btn:hover {
    color: var(--primary);
}

/* 中间的分隔线 */
.nav-divider {
    width: 1px;
    height: 14px;
    background: var(--border);
    margin: 0 16px;
}

/* 特殊样式：如果是返回排行，可以稍微加重一点点颜色 */
.rank-link:hover {
    color: var(--primary);
}

#back-to-top {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background-color: #f8d28a;
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: none;               /* 默认隐藏 */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 9999;
}

#back-to-top:hover {
    background-color: #ffc555;
}

/* ===== 选手头像单元格样式 ===== */
.player-profile-cell {
    display: flex;
    align-items: center;
    gap: 12px; /* 头像和名字的间距 */
}

.player-avatar-mini {
    width: 36px;
    height: 36px;
    border-radius: 10px; /* 稍微圆角，比纯圆看起来更现代 */
    object-fit: cover;
    background-color: var(--primary-light);
    border: 1px solid var(--border);
    flex-shrink: 0; /* 防止头像被挤压 */
}

.player-name-group {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-weight: 600;
    color: var(--text-main);
    font-size: 14px;
}


/* ===== 响应式设计 (移动端重写) ===== */
@media (max-width: 768px) {
    .container {
        margin: 20px auto;
    }

    .rank-header {
        display: grid;
        grid-template-columns: 1fr 1fr; /* 移动端分两列 */
        gap: 16px;
        align-items: start;
    }

    .rank-table, .rank-table thead, .rank-table tbody, .rank-table th, .rank-table td, .rank-table tr {
        display: block;
    }

    /* 隐藏表头 */
    .rank-table thead {
        display: none;
    }

    .rank-table tbody tr {
        margin-bottom: 12px;
        padding: 16px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--card-bg);
        display: grid;
        grid-template-columns: repeat(3, 1fr); /* 4列网格布局 */
        gap: 8px;
    }

    .rank-table td .stat-value {
        display: flex;
        flex-direction: row;
        gap: 2px;
    }

    /* 排名和选手占满首行 */
    .rank-table td[data-label="排名"] {
        grid-column: span 1;
        padding: 0;
        border: none;
        text-align: left;
    }

    .rank-table td[data-label="选手"] {
        grid-column: span 3;
        padding: 0;
        border: none;
        text-align: left;
        font-size: 18px;
    }

    /* 其他数据展示为小卡片 */
    .rank-table td:not([data-label="排名"]):not([data-label="选手"]) {
        grid-column: span 1;
        padding: 8px 0 0 0;
        border: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        font-size: 13px;
    }

    /* 使用 data-label 生成小标题 */
    .rank-table td:not([data-label="排名"]):not([data-label="选手"])::before {
        content: attr(data-label);
        font-size: 10px;
        color: var(--text-muted);
        text-transform: uppercase;
        margin-bottom: 4px;
        font-weight: 600;
    }

    .table-card {
        background: transparent;
        box-shadow: none;
        border: none;
    }

    .header-content {
        grid-column: span 2; /* 标题占满一行 */
    }

    .prize-pool-card {
        margin: 0;
        grid-column: span 1; /* 奖金卡片占一半 */
        padding: 10px;
        min-width: 0;
    }

    .tournament-filter {
        grid-column: span 1; /* 筛选框占一半 */
    }

    .prize-amount {
        font-size: 16px;
    }

    .prize-icon {
        width: 32px;
        height: 32px;
        margin-right: 8px;
    }

    .rank-table tbody tr.clickable-row {
        margin-bottom: 16px; /* 增加卡片间距 */
        border: 1px solid var(--border);
    }

    .rank-table tbody tr.clickable-row:active {
        background-color: var(--primary-light) !important;
        border-color: var(--primary);
    }

    .nav-left {
        padding: 4px 12px;
        width: 100%;
        justify-content: space-around;
    }

    .nav-divider {
        margin: 0 8px;
    }

    .nav-btn {
        font-size: 12px;
    }

    .player-profile-cell {
        justify-content: flex-start; /* 移动端卡片内左对齐 */
    }

    .player-avatar-mini {
        width: 40px; /* 移动端手指操作空间大，头像可以稍微大一点 */
        height: 40px;
    }

    .player-name {
        font-size: 16px; /* 移动端名字加大，方便阅读 */
    }
}