/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

/* 头部按钮 */
.header-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.refresh-btn {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(23, 162, 184, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(23, 162, 184, 0.4);
}

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

/* 统计概览 */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.15);
}

.stat-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.stat-content {
    flex: 1;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
}

/* 游戏选择器 */
.game-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.game-tab {
    background: white;
    border: 2px solid #e1e5e9;
    color: #666;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.game-tab:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.game-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* 排行榜容器 */
.leaderboard-container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f1f3f4;
}

.leaderboard-header h2 {
    color: #333;
    font-size: 1.5rem;
    margin: 0;
}

.leaderboard-stats {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
}

/* 排行榜列表 */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.leaderboard-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.leaderboard-item.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border-left-color: #ffd700;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.3);
}

.leaderboard-item.rank-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
    border-left-color: #c0c0c0;
    box-shadow: 0 6px 20px rgba(192, 192, 192, 0.3);
}

.leaderboard-item.rank-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #daa520 100%);
    border-left-color: #cd7f32;
    box-shadow: 0 6px 20px rgba(205, 127, 50, 0.3);
}

.rank-number {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    margin-right: 20px;
    min-width: 60px;
    text-align: center;
}

.rank-1 .rank-number {
    color: #b8860b;
}

.rank-2 .rank-number {
    color: #696969;
}

.rank-3 .rank-number {
    color: #8b4513;
}

.player-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.player-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.player-id {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

.score-info {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.total-score {
    font-size: 1.8rem;
    font-weight: bold;
    color: #667eea;
    margin: 0;
}

.rank-1 .total-score {
    color: #b8860b;
}

.rank-2 .total-score {
    color: #696969;
}

.rank-3 .total-score {
    color: #8b4513;
}

.game-scores {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.game-score {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rank-1 .game-score {
    background: rgba(184, 134, 11, 0.1);
    color: #b8860b;
}

.rank-2 .game-score {
    background: rgba(105, 105, 105, 0.1);
    color: #696969;
}

.rank-3 .game-score {
    background: rgba(139, 69, 19, 0.1);
    color: #8b4513;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.empty-state p {
    font-size: 1rem;
    margin: 0;
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.3s;
}

.close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 30px;
}

/* 游戏详情弹窗 */
.game-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.game-stat-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    border-left: 4px solid #667eea;
}

.game-stat-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.game-stat-label {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

.recent-scores h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.recent-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 3px solid #667eea;
}

.recent-score-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recent-score-name {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.recent-score-time {
    font-size: 0.8rem;
    color: #666;
}

.recent-score-value {
    font-weight: bold;
    color: #667eea;
    font-size: 1.1rem;
}

/* 加载动画 */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 消息提示 */
.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    z-index: 2000;
    animation: messageSlideIn 0.3s ease;
}

.message.success {
    background: #28a745;
}

.message.error {
    background: #dc3545;
}

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

/* 工具类 */
.hidden {
    display: none !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .stats-overview {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .game-selector {
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 5px 0;
        -webkit-overflow-scrolling: touch;
        position: relative;
        justify-content: space-between;
    }
    
    .game-selector::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 20px;
        height: 100%;
        background: linear-gradient(to left, rgba(102, 126, 234, 0.1), transparent);
        pointer-events: none;
        z-index: 1;
    }
    
    .game-tab {
        padding: 8px 12px;
        font-size: 0.75rem;
        white-space: nowrap;
        flex: 1;
        min-width: 0;
        text-align: center;
    }
    
    .leaderboard-container {
        padding: 20px;
    }
    
    .leaderboard-item {
        padding: 15px;
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    
    .rank-number {
        font-size: 1.6rem;
        margin-right: 12px;
        margin-bottom: 0;
        min-width: 45px;
        text-align: center;
    }
    
    .player-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }
    
    .score-info {
        text-align: right;
        flex-direction: column;
        align-items: flex-end;
        gap: 6px;
        min-width: 70px;
    }
    
    .total-score {
        font-size: 1.5rem;
    }
    
    .game-scores {
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 3px;
    }
    
    .game-score {
        font-size: 0.65rem;
        padding: 2px 5px;
    }
    
    .header-buttons {
        flex-direction: row; /* 保持一行 */
        gap: 10px;
        align-items: stretch;
        justify-content: center;
        flex-wrap: nowrap; /* 不换行 */
    }
    
    .refresh-btn {
        flex: 1 1 0; /* 两个按钮平分一行宽度 */
        width: auto;
        max-width: none;
        justify-content: center;
        white-space: nowrap; /* 避免按钮文字换行 */
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .modal-body {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    .game-selector {
        gap: 6px;
        padding: 3px 0;
    }
    
    .game-tab {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
    
    .leaderboard-item {
        padding: 12px;
        gap: 10px;
    }
    
    .rank-number {
        font-size: 1.4rem;
        min-width: 35px;
    }
    
    .player-name {
        font-size: 0.95rem;
    }
    
    .total-score {
        font-size: 1.3rem;
    }
    
    .game-score {
        font-size: 0.6rem;
        padding: 2px 4px;
    }
    
    .score-info {
        min-width: 60px;
        gap: 4px;
    }
}

/* 超小屏幕优化 (360px以下) */
@media (max-width: 360px) {
    .game-selector {
        gap: 4px;
        padding: 2px 0;
    }
    
    .game-tab {
        padding: 5px 6px;
        font-size: 0.65rem;
    }
    
    .container {
        padding: 10px;
    }
}
