:root {
    --bg: #1a1a2e;
    --panel-bg: rgba(20, 20, 40, 0.9);
    --text: #e0e0e0;
    --accent: #f0c060;
    --danger: #e57373;
    --health: #4caf84;
    --border: rgba(255, 255, 255, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    cursor: crosshair;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    height: 100vh;
    width: 100vw;
}

#gameCanvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 10;
    padding: 16px 24px;
}

#hud-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    flex-wrap: nowrap; /* 一行放下，不换行 */
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.hud-panel {
    /* 透明无背景 */
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    color: var(--text);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    flex: 1 1 auto; /* 按内容有基础宽度 + 均分伸展铺满，整体更宽且血条不溢出 */
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* 信息在容器内左对齐 */
    gap: 8px;
    font-weight: 700;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.hud-label {
    font-size: 20px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: #ffffff;
    margin-bottom: 0;
    opacity: 0.85;
}
.hud-value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--accent); /* 变动的数值统一为橙色（与得分/关卡一致） */
}

/* 生命值红心 */
#health-hearts {
    display: flex;
    align-items: center;
    gap: 4px;
}
.heart {
    font-size: 22px;
    line-height: 1;
    transition: all 0.3s;
}
.heart.lost {
    filter: grayscale(1) opacity(0.3);
    transform: scale(0.85);
}
/* ==================== 暂停遮罩 / 游戏继续按钮 / 倒计时 ==================== */
#pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
#pause-overlay.active {
    display: flex;
}
#pause-text {
    font-size: 64px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.1em;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}
#pause-sub {
    margin-top: 12px;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
}

#resume-btn {
    margin-top: 24px;
    padding: 12px 40px;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    background: rgba(240, 192, 96, 0.25);
    border: 2px solid #f0c060;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    pointer-events: auto; /* 遮罩 pointer-events:none，按钮需可点击 */
    transition: background 0.2s;
    user-select: none;
}
#resume-btn:hover {
    background: rgba(240, 192, 96, 0.45);
}

#countdown-overlay {
    position: fixed;
    inset: 0;
    z-index: 16;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    pointer-events: none;
}
#countdown-overlay.active {
    display: flex;
}
#countdown-display {
    font-size: 120px;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 6px 30px rgba(0, 0, 0, 0.7);
}

/* 关卡开始提示（类似暂停覆盖层，2 秒后自动隐藏） */
#level-overlay {
    position: fixed;
    inset: 0;
    z-index: 17;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
#level-overlay.active {
    display: flex;
}
#level-text {
    font-size: 72px;
    font-weight: 900;
    color: #ffd700;
    letter-spacing: 0.08em;
    text-shadow: 0 6px 30px rgba(0, 0, 0, 0.7);
}

/* 开始页面（初次载入显示，风格与暂停/关卡提示一致） */
#start-overlay {
    position: fixed;
    inset: 0;
    z-index: 18;
    display: none;
    align-items: center;
    justify-content: flex-start;
    flex-direction: column;
    padding-top: 14vh; /* 标题整体偏上 */
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
#start-overlay.active {
    display: flex;
}
#start-title {
    font-size: 90px; /* 标题字号 */
    font-weight: 900;
    color: #ffd700;
    letter-spacing: 0.12em;
    text-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
}
#start-btn {
    margin: 90px 0 60px 0;
    padding: 12px 56px;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    background: rgba(240, 192, 96, 0.25);
    border: 2px solid #f0c060;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    pointer-events: all; /* 遮罩 pointer-events:none，按钮需可点击 */
    transition: background 0.2s;
    user-select: none;
}
#start-btn:hover {
    background: rgba(240, 192, 96, 0.45);
}
/* 开始页操作提示（纯文字，不用图标） */
#start-hint {
    margin-top: 30px;
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.05em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    user-select: none;
    pointer-events: none;
}
.health-dot.lost {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.7);
}

/* 击杀提示 */
#kill-feed {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(40px);
    pointer-events: none;
    z-index: 20;
    text-align: center;
}
.kill-msg {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 180, 50, 0.8);
    animation: killPop 1.2s ease-out forwards;
    white-space: nowrap;
}
@keyframes killPop {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.6);
    }
    25% {
        opacity: 1;
        transform: translateY(0) scale(1.2);
    }
    50% {
        transform: translateY(-10px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.8);
    }
}

/* 游戏结束（风格与暂停一致） */
#game-over-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* 非激活时不拦截点击 */
    opacity: 0;
    visibility: hidden; /* 彻底隐藏（连同子元素按钮），避免“再来一局”按钮仍可点击 */
    transition: opacity 0.5s, visibility 0s 0.5s; /* 淡出后再隐藏 */
}
#game-over-overlay.active {
    opacity: 1;
    pointer-events: all;
    visibility: visible;
    transition: opacity 0.5s;
}
#game-over-title {
    font-size: 64px;
    font-weight: 800;
    color: #ff5a5a;
    letter-spacing: 0.1em;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}
.game-over-stats {
    margin-top: 28px;
    display: flex;
    gap: 56px;
}
.stat-line {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.stat-label {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.2em;
}
.stat-value {
    font-size: 40px;
    font-weight: 800;
    color: #ffd700;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
#restart-btn {
    margin-top: 32px;
    padding: 12px 48px;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    background: rgba(240, 192, 96, 0.25);
    border: 2px solid #f0c060;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    pointer-events: all; /* 遮罩 pointer-events:none，按钮需可点击 */
    transition: background 0.2s;
    user-select: none;
}
#restart-btn:hover {
    background: rgba(240, 192, 96, 0.45);
}
/* 游戏通关（风格与游戏结束一致，标题用金色） */
#victory-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* 非激活时不拦截点击 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s, visibility 0s 0.5s;
}
#victory-overlay.active {
    opacity: 1;
    pointer-events: all;
    visibility: visible;
    transition: opacity 0.5s;
}
#victory-title {
    font-size: 64px;
    font-weight: 800;
    color: #ffd700;
    letter-spacing: 0.1em;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}
#victory-btn {
    margin-top: 32px;
    padding: 12px 48px;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    background: rgba(240, 192, 96, 0.25);
    border: 2px solid #f0c060;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    pointer-events: all; /* 遮罩 pointer-events:none，按钮需可点击 */
    transition: background 0.2s;
    user-select: none;
}
#victory-btn:hover {
    background: rgba(240, 192, 96, 0.45);
}

/* 方向指示器 */
#enemy-indicators {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 8;
}
.enemy-indicator {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(229, 115, 115, 0.7);
    border: 2px solid rgba(255, 150, 150, 0.9);
    transform: translate(-50%, -50%);
    animation: indicatorPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(229, 115, 115, 0.5);
}
@keyframes indicatorPulse {
    0%,
    100% {
        box-shadow: 0 0 8px rgba(229, 115, 115, 0.4);
    }
    50% {
        box-shadow: 0 0 22px rgba(229, 115, 115, 0.8);
    }
}

/* 提示 */
#tooltip {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 10;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    letter-spacing: 0.06em;
    text-align: center;
    transition: opacity 0.8s;
}
