/* --- 全局与字体定义 --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #FFD700; /* 帝王金 */
    --color-secondary: #8A2BE2; /* 紫罗兰 */
    --color-danger: #c0392b; /* 深红 */
    --color-background: #0a0814; /* 深空紫 */
    --font-main: 'Noto Sans SC', sans-serif;
}

body {
    font-family: var(--font-main);
    background: var(--color-background);
    color: #f0f0f0;
    min-height: 100vh;
    overflow: hidden;
}

/* --- 主要容器与画布 --- */
.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: var(--color-background);
    overflow: hidden;
}

#gameCanvas {
    display: block;
    background: radial-gradient(circle, #1a1824, var(--color-background));
    cursor: crosshair;
}

.vignette {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    box-shadow: inset 0 0 250px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    z-index: 50;
}

/* --- 加载界面 --- */
.loading {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 60px; height: 60px;
    border: 4px solid rgba(255, 215, 0, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- 开始与结束界面 --- */
.start-screen, .game-over {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 8, 20, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 2rem;
    text-align: center;
}

.game-title {
    font-size: clamp(3rem, 10vw, 5.5rem);
    font-weight: 700;
    color: var(--color-primary);
    text-shadow: 0 0 10px var(--color-primary), 0 0 20px var(--color-secondary), 0 0 40px var(--color-secondary);
    margin-bottom: 0.5rem;
    animation: divine-glow 3s ease-in-out infinite alternate;
}

@keyframes divine-glow {
    from { text-shadow: 0 0 10px var(--color-primary), 0 0 20px var(--color-secondary), 0 0 40px var(--color-secondary); }
    to   { text-shadow: 0 0 15px var(--color-primary), 0 0 35px #fff, 0 0 60px var(--color-secondary); }
}

.game-subtitle {
    font-size: clamp(1rem, 4vw, 1.5rem);
    color: #c0c0d0;
    margin-bottom: 3rem;
    font-weight: 400;
}

.player-input input {
    width: 320px;
    max-width: 90%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 50px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    text-align: center;
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
}

.player-input input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.instructions {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    margin-bottom: 3rem;
    line-height: 2.2; /* 增加行高，让两行指令更舒展 */
}

.instructions kbd {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-family: monospace;
    font-size: 1em;
    color: #fff;
    margin: 0 3px;
    box-shadow: 0 2px 2px rgba(0,0,0,0.2);
}

.start-btn, .restart-btn {
    padding: 1rem 3.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.start-btn { background: linear-gradient(45deg, var(--color-danger), var(--color-secondary)); }
.start-btn:hover { transform: translateY(-4px) scale(1.05); box-shadow: 0 12px 30px rgba(138, 43, 226, 0.4); }

.restart-btn { background: linear-gradient(45deg, #2980b9, #2c3e50); }
.restart-btn:hover { transform: translateY(-4px) scale(1.05); box-shadow: 0 12px 30px rgba(41, 128, 185, 0.4); }

.game-over h2 { font-size: clamp(2.5rem, 8vw, 4rem); margin-bottom: 2rem; color: var(--color-danger); }
.final-stats { text-align: center; font-size: 1.5rem; margin-bottom: 2.5rem; }
.final-stats p { margin: 0.5rem 0; color: #d0d0d0;}
.final-stats span { font-weight: 700; color: var(--color-primary); margin-left: 10px; }

/* --- 游戏内UI --- */
.game-ui { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

.info-panel {
    background: rgba(10, 8, 20, 0.75);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    pointer-events: auto;
}

.score-display { position: absolute; top: 20px; left: 20px; line-height: 1.7; font-size: 1rem; }
.score-display div { color: rgba(255,255,255,0.8); }
.score-display span { font-weight: 700; color: var(--color-primary); }

.timer-display { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); font-size: clamp(2rem, 6vw, 2.8rem); font-weight: 700; color: var(--color-primary); text-shadow: 0 0 15px var(--color-primary); }

.leaderboard { position: absolute; top: 20px; right: 20px; min-width: 260px; }
.leaderboard h3 { margin: 0 0 1rem; text-align: center; color: var(--color-primary); font-size: 1.2rem; }
.leaderboard-item { display: flex; justify-content: space-between; padding: 0.6rem; border-radius: 6px; transition: background 0.2s ease; font-size: 0.95rem; }
.leaderboard-item.current-player { background: rgba(255, 215, 0, 0.15); font-weight: 700; }
.leaderboard-item:not(:last-child) { margin-bottom: 0.5rem; }

/* --- 控制按钮 --- */
.controls-panel { position: absolute; pointer-events: auto; }
.audio-controls { top: 120px; right: 20px; } /* 调整位置避免和排行榜重叠 */
.skill-bar { bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 1.5rem; }

.skill-btn, .audio-btn {
    width: 60px; height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(255, 215, 0, 0.3);
    background: rgba(10, 8, 20, 0.8);
    backdrop-filter: blur(12px);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    position: relative;
    overflow: hidden;
}

.skill-btn:hover:not(.cooldown), .audio-btn:hover {
    border-color: var(--color-primary);
    transform: scale(1.1);
}

.audio-btn.active { border-color: var(--color-primary); }

.skill-btn.cooldown { opacity: 0.5; cursor: not-allowed; transform: scale(1); }
.skill-btn .cooldown-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: conic-gradient(rgba(192, 57, 43, 0.7) 0deg, transparent 0deg);
}

/* --- 无障碍: 隐藏对视觉用户无用的标签 --- */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
}