:root {
    --bg-color-nav: #121212;
    --game-bg: #1a1d23;
    --game-area-bg: #1e2130;
    --target-color: #ff4655;
    --target-hit: #00e5a0;
    --waiting-color: #ff6b35;
    --ready-color: #00e5a0;
    --warning-color: #ff3860;
    --accent-gold: #ffd700;
    --accent-blue: #4da6ff;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-subtle: #2a2d38;
    --card-bg: #21242e;
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-glow-green: 0 0 40px rgba(0, 229, 160, 0.4);
    --shadow-glow-red: 0 0 40px rgba(255, 70, 85, 0.5);
    --shadow-glow-gold: 0 0 30px rgba(255, 215, 0, 0.4);
}

* {
    box-sizing: border-box;
}

body {
    background: #13151a;
    background-image:
        radial-gradient(ellipse at 50% 0%, rgba(255, 70, 85, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(0, 229, 160, 0.04) 0%, transparent 50%);
    min-height: 100vh;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    overflow-x: hidden;
}

/* ========== 主容器 ========== */
.main-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ========== 头部 ========== */
.app-header {
    text-align: center;
    padding: 20px 0 10px;
    margin-bottom: 10px;
}

.app-header .logo-icon {
    font-size: 2.8rem;
    display: inline-block;
    animation: logoPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.5));
}

@keyframes logoPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.12);
    }
}

.app-header h1 {
    font-weight: 800;
    font-size: 1.9rem;
    letter-spacing: -0.5px;
    margin: 6px 0 2px;
    background: linear-gradient(135deg, #ffffff 0%, #c0c0c0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ========== 模式选择标签 ========== */
.mode-tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.mode-tab {
    padding: 10px 22px;
    border-radius: 50px;
    border: 2px solid var(--border-subtle);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.mode-tab:hover {
    border-color: #555;
    color: #fff;
    background: #282c38;
    transform: translateY(-1px);
}

.mode-tab.active {
    background: var(--target-color);
    border-color: var(--target-color);
    color: #fff;
    box-shadow: var(--shadow-glow-red);
    transform: translateY(-1px);
}

.mode-tab .tab-icon {
    margin-right: 6px;
}

/* ========== 游戏区域 ========== */
.game-area-wrapper {
    position: relative;
    background: var(--game-area-bg);
    border-radius: 20px;
    border: 2px solid var(--border-subtle);
    min-height: 420px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-direction: column;
}

.game-area-wrapper.classic-mode {
    min-height: 380px;
}

.game-area-wrapper.target-mode,
.game-area-wrapper.combo-mode {
    min-height: 440px;
    cursor: crosshair;
}

@media (min-width: 768px) {
    .game-area-wrapper {
        min-height: 460px;
    }

    .game-area-wrapper.classic-mode {
        min-height: 420px;
    }

    .game-area-wrapper.target-mode,
    .game-area-wrapper.combo-mode {
        min-height: 480px;
    }
}

/* 游戏区域状态覆盖 */
.game-area-wrapper.state-waiting {
    background: #2a1a1a !important;
    border-color: #ff6b35 !important;
    box-shadow: 0 0 50px rgba(255, 107, 53, 0.25), var(--shadow-lg);
    animation: pulseWaiting 1.5s ease-in-out infinite;
}

@keyframes pulseWaiting {

    0%,
    100% {
        box-shadow: 0 0 30px rgba(255, 107, 53, 0.2), var(--shadow-lg);
    }

    50% {
        box-shadow: 0 0 60px rgba(255, 107, 53, 0.45), var(--shadow-lg);
    }
}

.game-area-wrapper.state-ready {
    background: #0a2a1a !important;
    border-color: #00e5a0 !important;
    box-shadow: var(--shadow-glow-green), var(--shadow-lg);
    animation: flashReady 0.15s ease-out;
}

@keyframes flashReady {
    from {
        box-shadow: 0 0 100px rgba(0, 229, 160, 0.9), var(--shadow-lg);
        background: #0f4a2a !important;
    }

    to {
        box-shadow: var(--shadow-glow-green), var(--shadow-lg);
        background: #0a2a1a !important;
    }
}

.game-area-wrapper.state-warning {
    background: #2a0a0a !important;
    border-color: #ff3860 !important;
    animation: shake 0.5s ease-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    15% {
        transform: translateX(-8px);
    }

    30% {
        transform: translateX(8px);
    }

    45% {
        transform: translateX(-5px);
    }

    60% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-2px);
    }

    90% {
        transform: translateX(2px);
    }
}

/* 游戏区域内的文字 */
.game-prompt {
    text-align: center;
    z-index: 2;
    pointer-events: none;
    transition: all 0.2s ease;
}

.game-prompt .prompt-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.game-prompt .prompt-text {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ccc;
    transition: all 0.2s ease;
}

.state-waiting .game-prompt .prompt-text {
    color: #ff6b35;
}

.state-ready .game-prompt .prompt-text {
    color: #00e5a0;
    font-size: 1.6rem;
    animation: textPop 0.2s ease-out;
}

@keyframes textPop {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========== 目标（Target模式 & Combo模式） ========== */
.click-target {
    position: absolute;
    border-radius: 50%;
    background: var(--target-color);
    cursor: pointer;
    z-index: 5;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    box-shadow: 0 0 25px rgba(255, 70, 85, 0.6), 0 6px 20px rgba(0, 0, 0, 0.4);
    animation: targetAppear 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.click-target:hover {
    transform: scale(1.08);
    box-shadow: 0 0 40px rgba(255, 70, 85, 0.85), 0 8px 25px rgba(0, 0, 0, 0.5);
}

.click-target:active {
    transform: scale(0.85);
    box-shadow: 0 0 15px rgba(255, 70, 85, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.05s ease;
}

@keyframes targetAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 命中涟漪 */
.ripple {
    position: absolute;
    border-radius: 50%;
    border: 3px solid var(--target-hit);
    pointer-events: none;
    z-index: 6;
    animation: rippleOut 0.6s ease-out forwards;
}

@keyframes rippleOut {
    0% {
        width: 20px;
        height: 20px;
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.3);
    }

    100% {
        width: 160px;
        height: 160px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* miss 闪烁 */
.miss-flash {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 56, 96, 0.5);
    pointer-events: none;
    z-index: 4;
    animation: missFlash 0.35s ease-out forwards;
}

@keyframes missFlash {
    0% {
        width: 30px;
        height: 30px;
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(0.3);
    }

    100% {
        width: 80px;
        height: 80px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ========== 统计面板 ========== */
.stats-panel {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.stats-panel .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-panel .stat-row:last-child {
    border-bottom: none;
}

.stats-panel .stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.stats-panel .stat-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
}

.stat-value.grade-legend {
    color: var(--accent-gold) !important;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.stat-value.grade-great {
    color: #00e5a0 !important;
    text-shadow: 0 0 8px rgba(0, 229, 160, 0.4);
}

.stat-value.grade-good {
    color: #4da6ff !important;
}

.stat-value.grade-avg {
    color: #ffa940 !important;
}

.stat-value.grade-slow {
    color: #ff5c5c !important;
}

/* 分布条 */
.dist-bar-container {
    margin-top: 12px;
}

.dist-bar-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
    font-size: 0.78rem;
}

.dist-bar-label {
    width: 55px;
    text-align: right;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.dist-bar-track {
    flex: 1;
    height: 18px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 9px;
    overflow: hidden;
    position: relative;
}

.dist-bar-fill {
    height: 100%;
    border-radius: 9px;
    transition: width 0.5s cubic-bezier(0.25, 0.8, 0.25, 1.2);
    min-width: 2px;
}

.dist-bar-count {
    width: 28px;
    text-align: left;
    color: #aaa;
    flex-shrink: 0;
    font-weight: 600;
}

.fill-legend {
    background: linear-gradient(90deg, #ffd700, #ffaa00);
}

.fill-great {
    background: linear-gradient(90deg, #00e5a0, #00c080);
}

.fill-good {
    background: linear-gradient(90deg, #4da6ff, #3d8ed9);
}

.fill-avg {
    background: linear-gradient(90deg, #ffa940, #e89030);
}

.fill-slow {
    background: linear-gradient(90deg, #ff5c5c, #d94040);
}

/* 最近成绩列表 */
.recent-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 8px;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    margin-bottom: 3px;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s;
}

.recent-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.recent-item .recent-time {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
}

.recent-item .recent-mode {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ========== 按钮样式 ========== */
.btn-start {
    padding: 14px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 50px;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    border: none;
    background: var(--target-color);
    color: #fff;
    box-shadow: 0 8px 25px rgba(255, 70, 85, 0.35);
    z-index: 10;
    position: relative;
}

.btn-start:hover {
    background: #ff5566;
    box-shadow: 0 12px 35px rgba(255, 70, 85, 0.5);
    transform: translateY(-2px);
}

.btn-start:active {
    transform: scale(0.95);
    box-shadow: 0 4px 15px rgba(255, 70, 85, 0.3);
    transition: all 0.1s ease;
}

.btn-reset {
    padding: 10px 24px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 50px;
    letter-spacing: 0.3px;
    transition: all 0.25s ease;
    border: 2px solid var(--border-subtle);
    background: transparent;
    color: #ccc;
    cursor: pointer;
}

.btn-reset:hover {
    border-color: #666;
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
}

.btn-share {
    padding: 10px 24px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 50px;
    letter-spacing: 0.3px;
    transition: all 0.25s ease;
    border: 2px solid var(--accent-gold);
    background: transparent;
    color: var(--accent-gold);
    cursor: pointer;
}

.btn-share:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: #fff;
    color: #fff;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* ========== Toast提示 ========== */
.custom-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 12px 28px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.4px;
    pointer-events: none;
    animation: toastIn 0.4s ease-out, toastOut 0.4s 1.6s ease-in forwards;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.toast-warning {
    background: #ff3860;
    color: #fff;
}

.toast-success {
    background: #00c080;
    color: #fff;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* ========== 分享卡片样式 ========== */
#shareCard {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 600px;
    height: 800px;
    background: linear-gradient(135deg, #1a1d2e 0%, #151821 100%);
    border-radius: 24px;
    padding: 40px 30px;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
    color: #fff;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8);
    border: 3px solid #333;
}

#shareCard .card-header {
    margin-bottom: 30px;
}

#shareCard .card-title {
    font-size: 2.4rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffd700, #ff6b35);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

#shareCard .card-subtitle {
    font-size: 1rem;
    color: #aaa;
    letter-spacing: 2px;
    text-transform: uppercase;
}

#shareCard .divider {
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #ff4655, #ffd700);
    margin: 15px auto;
    border-radius: 3px;
}

#shareCard .player-name {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    margin: 20px 0 5px;
    word-break: break-word;
}

#shareCard .best-score {
    font-size: 3.5rem;
    font-weight: 900;
    color: #00e5a0;
    text-shadow: 0 0 25px rgba(0, 229, 160, 0.6);
    margin: 10px 0;
}

#shareCard .best-score span {
    font-size: 1.4rem;
    color: #ccc;
}

#shareCard .grade-badge {
    display: inline-block;
    padding: 6px 20px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 1rem;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

#shareCard .rank-text {
    font-size: 1.2rem;
    margin: 20px 0 10px;
    color: #ccc;
}

#shareCard .rank-number {
    font-weight: 900;
    font-size: 2rem;
    color: var(--accent-gold);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

#shareCard .qrcode-wrapper {
    margin: 25px auto 15px;
    display: inline-block;
    background: #fff;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#shareCard .qrcode-wrapper canvas {
    display: block;
}

#shareCard .card-footer-text {
    font-size: 0.85rem;
    color: #777;
    margin-top: 10px;
}

#shareCard .sparkle-icon {
    font-size: 1.8rem;
    vertical-align: middle;
    margin: 0 5px;
}

@media (max-width: 600px) {
    #shareCard {
        width: 320px;
        height: 480px;
        padding: 20px 15px;
    }

    #shareCard .card-title {
        font-size: 1.4rem;
    }

    #shareCard .best-score {
        font-size: 2.2rem;
    }

    #shareCard .player-name {
        font-size: 1.3rem;
    }
}