/* ========== 游戏系统 UI 样式 ========== */

/* ---------- 全局调整 ---------- */
html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

body {
    padding-top: 50px;
    background: #0a0a1a;
}

/* 游戏画布缩放适配手机 */
.game-container {
    transform-origin: top center;
}

/* ---------- 隐藏广告/引导层 ---------- */
._2iIk {
    display: none !important;
}

/* ---------- 顶部信息栏 ---------- */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 9000;
    color: #fff;
    font-size: 14px;
}

.top-bar .player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-bar .player-info .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #009688, #4caf50);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    overflow: hidden;
}

.top-bar .player-info .name {
    font-weight: 600;
    color: #4caf50;
}

.top-bar .game-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.top-bar .game-info .info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.top-bar .game-info .info-item .label {
    color: #999;
    font-size: 12px;
}

.top-bar .game-info .info-item .value {
    font-weight: 600;
    font-size: 16px;
    color: #fff;
    min-width: 50px;
}

.top-bar .actions {
    display: flex;
    gap: 10px;
}

.top-bar .actions button {
    padding: 6px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.top-bar .actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.top-bar .actions button.active {
    background: #009688;
    border-color: #009688;
}

/* ---------- 游戏状态覆盖层 ---------- */
#game-status-overlay {
    position: fixed;
    top: 55px;
    right: 10px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 12px;
    padding: 12px 18px;
    color: #fff;
    z-index: 8000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    backdrop-filter: blur(5px);
}

#game-status-overlay.visible {
    opacity: 1;
    visibility: visible;
}

#game-status-overlay .timer-label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#game-status-overlay .timer-value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: #4caf50;
}

#game-status-overlay .live-score {
    font-size: 12px;
    color: #ccc;
    margin-top: 4px;
}

#game-status-overlay .live-score span {
    color: #ffd700;
    font-weight: 600;
    font-size: 16px;
}

/* ---------- 游戏结果弹窗 ---------- */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.result-modal.visible {
    opacity: 1;
    visibility: visible;
}

.result-content {
    background: #fff;
    border-radius: 20px;
    padding: 35px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    transform: scale(0.8);
    transition: transform 0.3s;
}

.result-modal.visible .result-content {
    transform: scale(1);
}

.result-content h3 {
    font-size: 24px;
    color: #333;
    margin: 0 0 25px;
}

.result-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.result-stat {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 15px 10px;
}

.result-stat .stat-label {
    font-size: 12px;
    color: #999;
    margin-bottom: 5px;
}

.result-stat .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #333;
}

.result-stat.highlight {
    background: linear-gradient(135deg, #009688, #4caf50);
}

.result-stat.highlight .stat-label {
    color: rgba(255, 255, 255, 0.8);
}

.result-stat.highlight .stat-value {
    color: #fff;
}

.result-close {
    padding: 12px 40px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #009688, #00796b);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.result-close:hover {
    transform: translateY(-2px);
}

/* ---------- 结果弹窗按钮（覆盖在 game-ui.css 基础样式上） ---------- */
.result-content {
    background: #1e1e3a;
    color: #fff;
}

.result-content h3 {
    color: #fff;
}

.result-stat {
    background: rgba(255, 255, 255, 0.06);
}

.result-stat .stat-value {
    color: #fff;
}

.result-stat .stat-label {
    color: rgba(255, 255, 255, 0.5);
}

.result-close {
    display: none; /* 隐藏旧的关闭按钮，新版使用 result-actions */
}

/* ---------- 排行榜面板 ---------- */
.leaderboard-panel {
    position: fixed;
    top: 50px;
    right: -420px;
    width: 400px;
    height: calc(100% - 50px);
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(15px);
    z-index: 9500;
    transition: right 0.3s ease;
    overflow-y: auto;
    color: #fff;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
}

.leaderboard-panel.open {
    right: 0;
}

.leaderboard-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-header h3 {
    font-size: 20px;
    margin: 0 0 15px;
    font-weight: 700;
}

.leaderboard-tabs {
    display: flex;
    gap: 8px;
}

.leaderboard-tabs button {
    flex: 1;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: transparent;
    color: #ccc;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.leaderboard-tabs button.active {
    background: #009688;
    border-color: #009688;
    color: #fff;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th {
    padding: 12px 10px;
    text-align: left;
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    background: rgba(20, 20, 30, 0.98);
}

.leaderboard-table td {
    padding: 10px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-table .rank {
    font-weight: 700;
    width: 40px;
    text-align: center;
}

.leaderboard-table .rank.gold {
    color: #ffd700;
}

.leaderboard-table .rank.silver {
    color: #c0c0c0;
}

.leaderboard-table .rank.bronze {
    color: #cd7f32;
}

.leaderboard-table .name {
    font-weight: 600;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-table .score {
    color: #4caf50;
    font-weight: 600;
}

.leaderboard-table .speed {
    color: #ffd700;
    font-weight: 600;
}

.leaderboard-table .duration {
    color: #aaa;
}

.leaderboard-table .lines {
    color: #aaa;
}

.leaderboard-table .empty {
    text-align: center;
    color: #666;
    padding: 40px;
}

/* ---------- 玩家统计面板 ---------- */
.player-stats-panel {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.player-stats-panel h4 {
    font-size: 14px;
    color: #999;
    margin: 0 0 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.stat-item .stat-label {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.stat-item .stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #4caf50;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    body {
        padding-top: 44px;
    }

    .top-bar {
        height: 44px;
        padding: 0 8px;
        font-size: 11px;
    }

    .top-bar .player-info .avatar {
        width: 24px;
        height: 24px;
    }

    .top-bar .player-info .name {
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .top-bar .game-info {
        gap: 8px;
    }

    .top-bar .game-info .info-item .label {
        font-size: 10px;
    }

    .top-bar .game-info .info-item .value {
        font-size: 13px;
        min-width: 36px;
    }

    .top-bar .actions button {
        padding: 4px 10px;
        font-size: 11px;
    }

    .leaderboard-panel {
        width: 100%;
        right: -100%;
        top: 44px;
        height: calc(100% - 44px);
    }

    .leaderboard-panel.open {
        right: 0;
    }

    .leaderboard-header {
        padding: 12px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 6px;
        font-size: 12px;
    }

    .result-content {
        padding: 20px 16px;
        border-radius: 16px;
    }

    .result-content h3 {
        font-size: 18px;
        margin-bottom: 16px;
    }

    .result-stat {
        padding: 10px 6px;
    }

    .result-stat .stat-value {
        font-size: 18px;
    }

    .result-stat .stat-label {
        font-size: 10px;
    }

    .result-actions .btn-leaderboard {
        padding: 10px;
        font-size: 14px;
    }

    .overwrite-box {
        padding: 20px 16px;
    }

    .overwrite-box .old-score,
    .overwrite-box .new-score {
        font-size: 22px;
    }

    #game-status-overlay {
        top: 48px;
        right: 6px;
        padding: 8px 12px;
    }

    #game-status-overlay .timer-value {
        font-size: 22px;
    }

    .player-stats-panel {
        padding: 10px 12px;
    }

    .stats-grid {
        gap: 6px;
    }

    .stat-item {
        padding: 8px 6px;
    }

    .stat-item .stat-value {
        font-size: 15px;
    }
}

/* 小屏幕手机 */
@media (max-width: 375px) {
    .top-bar .player-info .name {
        max-width: 50px;
    }

    .top-bar .game-info .info-item .value {
        font-size: 12px;
    }

    .leaderboard-table .name {
        max-width: 60px;
    }
}
