* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #000;
}

#game-container {
    position: fixed;
    inset: 0;
    background: #0a0a0a;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
}

/* ---------- 加载画面 ---------- */
#loading-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    background: radial-gradient(circle at 50% 40%, #1a1a22, #050505);
    color: #aaa;
    z-index: 100;
}
.loader-title {
    font-size: 26px;
    letter-spacing: 8px;
    color: #c43a2a;
    text-shadow: 0 0 18px rgba(196, 58, 42, 0.6);
}
.loader-bar {
    width: 300px;
    height: 6px;
    background: #222;
    border-radius: 3px;
    overflow: hidden;
}
.loader-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #c43a2a, #e08a5a);
    transition: width 0.3s;
}
.loader-tip {
    font-size: 13px;
    color: #555;
}

/* ---------- 覆盖层 ---------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(4px);
    z-index: 60;
}
/* 覆盖层电影暗角 */
.overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.6) 100%),
        linear-gradient(180deg, rgba(0,0,0,0.5), transparent 20%, transparent 80%, rgba(0,0,0,0.5));
    pointer-events: none;
}
.hidden { display: none !important; }

.menu-box {
    width: 420px;
    max-width: 90vw;
    max-height: 90vh;
    padding: 36px 40px;
    background: rgba(18, 16, 14, 0.92);
    border: 1px solid #3a3028;
    border-radius: 6px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 60px rgba(0,0,0,0.5);
    text-align: center;
}
.menu-title {
    font-size: 44px;
    letter-spacing: 12px;
    color: #d8482a;
    text-shadow: 0 0 22px rgba(196, 58, 42, 0.8), 0 2px 0 rgba(0,0,0,0.5);
    margin-bottom: 6px;
    animation: titleGlow 3s ease-in-out infinite;
}
@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 18px rgba(196, 58, 42, 0.6), 0 2px 0 rgba(0,0,0,0.5); }
    50% { text-shadow: 0 0 34px rgba(232, 80, 40, 0.9), 0 2px 0 rgba(0,0,0,0.5); }
}
.menu-title.small { font-size: 24px; letter-spacing: 4px; }
.menu-title.death { color: #8a1f12; text-shadow: 0 0 22px rgba(138, 31, 18, 0.8); }
.menu-title.win { color: #d8a53a; text-shadow: 0 0 22px rgba(216, 165, 58, 0.7); }
.menu-subtitle {
    color: #777;
    letter-spacing: 3px;
    margin-bottom: 28px;
    font-size: 14px;
}
.menu-footer {
    margin-top: 22px;
    color: #555;
    font-size: 12px;
    letter-spacing: 1px;
}

.menu-btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin: 10px 0;
    background: #1d1a17;
    color: #d8d0c6;
    border: 1px solid #4a3f34;
    border-radius: 4px;
    font-size: 16px;
    letter-spacing: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.menu-btn:hover {
    background: #2a241f;
    border-color: #c43a2a;
    color: #fff;
    box-shadow: 0 0 16px rgba(196, 58, 42, 0.3);
}

/* ---------- 帮助 ---------- */
.help-box { text-align: left; }
.help-list {
    list-style: none;
    color: #bbb;
    font-size: 14px;
    line-height: 2.1;
    margin: 12px 0 20px;
}
.help-list b { color: #e8c45a; }
.key-icon, .zombie-icon { font-style: normal; }

/* ---------- HUD ---------- */
#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 20;
}
#hud * { pointer-events: none; }

#top-bar {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.hud-label {
    color: #8a837a;
    font-size: 12px;
    letter-spacing: 2px;
    margin-right: 8px;
}
#health-wrap {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #3a3028;
    border-radius: 4px;
    padding: 6px 12px;
}
#health-bar {
    width: 160px;
    height: 14px;
    background: #140f0d;
    border: 1px solid #3a2f28;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
/* 血条分段效果 */
#health-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent 0 18px, rgba(0,0,0,0.25) 18px 20px);
    pointer-events: none;
}
#health-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #e07a4a, #b83a2a);
    transition: width 0.25s ease-out;
    box-shadow: inset 0 0 8px rgba(255, 120, 60, 0.3);
}
#health-fill.low {
    background: linear-gradient(180deg, #ff5a3a, #b01818);
    animation: healthBlink 1s infinite;
}
@keyframes healthBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
#health-num {
    color: #e8d8c6;
    font-size: 13px;
    margin-left: 10px;
    width: 34px;
    text-align: right;
}

#objective {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #3a3028;
    border-radius: 4px;
    padding: 8px 16px;
    color: #d8cbb8;
    font-size: 14px;
    letter-spacing: 1px;
    text-align: center;
    max-width: 40vw;
}

#inventory-bar {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #3a3028;
    border-radius: 4px;
    padding: 6px 12px;
}
#inventory-items {
    display: flex;
    gap: 6px;
}
.inv-slot {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: #1d1a17;
    border: 1px solid #3a3028;
    border-radius: 4px;
}

/* 互动提示 */
#interact-prompt {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid #5a4a3a;
    border-radius: 4px;
    color: #e8d8c6;
    padding: 10px 20px;
    font-size: 14px;
    letter-spacing: 1px;
}

/* 底部 */
#bottom-center {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}
/* 状态条（弹药/手电筒） */
#status-bar {
    position: absolute;
    right: 14px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
    text-align: right;
}
#status-bar > div {
    background: rgba(15, 12, 10, 0.8);
    border: 1px solid #4a3f34;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    color: #e8d8c6;
    letter-spacing: 1px;
    display: inline-block;
}
#ammo-num {
    color: #ffd479;
    font-weight: bold;
    font-size: 15px;
    margin-left: 4px;
}
#torch-wrap.off { opacity: 0.6; }
#torch-wrap.on { border-color: #ffd479; color: #ffe9b0; }

#btn-inventory {
    pointer-events: auto !important;
    padding: 10px 22px;
    background: rgba(20, 18, 15, 0.85);
    color: #d8d0c6;
    border: 1px solid #4a3f34;
    border-radius: 4px;
    font-size: 14px;
    letter-spacing: 2px;
    cursor: pointer;
}
#btn-inventory:hover {
    border-color: #c43a2a;
    color: #fff;
}

/* ---------- 小地图 ---------- */
#minimap {
    position: absolute;
    top: 70px;
    right: 14px;
    background: rgba(10, 8, 6, 0.78);
    border: 1px solid #4a3f34;
    border-radius: 6px;
    padding: 8px;
    width: 150px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
}
.minimap-title {
    font-size: 11px;
    letter-spacing: 3px;
    color: #8a7a6a;
    text-align: center;
    margin-bottom: 4px;
    border-bottom: 1px solid #3a332c;
    padding-bottom: 4px;
}
#minimap-svg {
    width: 100%;
    height: auto;
    display: block;
}
.minimap-room {
    fill: #1c1915;
    stroke: #4a423a;
    stroke-width: 1;
    transition: fill 0.4s ease;
}
/* 未探索房间（迷雾） */
.minimap-room.unexplored {
    fill: #0a0908;
    stroke: #23201c;
}
.minimap-room-label.unexplored {
    fill: #3a362e;
}
.minimap-room.current {
    fill: #2e2418;
    stroke: #c9a94a;
    stroke-width: 1.5;
}
.minimap-room-label {
    font-size: 6.5px;
    fill: #7a6f60;
    text-anchor: middle;
    font-family: 'Segoe UI', sans-serif;
}
.minimap-door {
    stroke: #5a6a8a;
    stroke-width: 2.5;
}
.minimap-door.locked {
    stroke: #a03322;
}
.minimap-door.used {
    stroke: #6a6a5a;
}
.minimap-player {
    fill: #e8e8f0;
    stroke: #000;
    stroke-width: 0.6;
}
.minimap-enemy {
    fill: #c43a2a;
}

/* 检视框 */
#inspect-box {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #6a5a3a;
    border-radius: 4px;
    padding: 14px 24px;
    color: #e8d0a8;
    font-size: 16px;
    letter-spacing: 2px;
    max-width: 60vw;
    text-align: center;
    box-shadow: 0 0 30px rgba(216, 165, 58, 0.15);
}

/* ---------- 背包界面 ---------- */
.inventory-box { text-align: center; }
#inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 64px);
    gap: 10px;
    justify-content: center;
    margin: 18px 0;
}
.inv-item {
    width: 64px;
    height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #1d1a17;
    border: 1px solid #3a3028;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.inv-item:hover {
    border-color: #c43a2a;
    background: #2a241f;
}
.inv-item.selected {
    border-color: #e8c45a;
    box-shadow: 0 0 14px rgba(232, 196, 90, 0.4);
}
.inv-item .icon { font-size: 28px; }
.inv-item .name { font-size: 11px; color: #bbb; }
.inv-desc {
    color: #999;
    font-size: 13px;
    min-height: 40px;
    padding: 8px;
    line-height: 1.6;
}

/* ---------- Toast ---------- */
#toast-container {
    position: absolute;
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 80;
}
.toast {
    background: rgba(20, 18, 15, 0.9);
    border: 1px solid #4a3f34;
    border-left: 3px solid #c43a2a;
    color: #e8d8c6;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    letter-spacing: 1px;
    animation: toastIn 0.3s ease;
    max-width: 70vw;
    text-align: center;
}
.toast.success { border-left-color: #6ab83a; }
.toast.warn { border-left-color: #e8c45a; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 机位切换黑场过渡 */
#room-transition {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
    pointer-events: none;
    z-index: 55;
    transition: opacity 0.22s ease;
}
#room-transition.active { opacity: 1; }

/* 瞄准准星 */
#crosshair {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    pointer-events: none;
    z-index: 46;
}
#crosshair .ch-line {
    position: absolute;
    background: rgba(120, 230, 120, 0.95);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}
#crosshair .ch-h { left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; }
#crosshair .ch-v { top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; }
#crosshair .ch-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 4px;
    margin: -2px 0 0 -2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

/* 低血量/受击红晕氛围 */
#danger-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 45;
    opacity: 0;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(150, 0, 0, 0.55) 100%);
    transition: opacity 0.3s ease;
}

/* 死亡画面渐暗 + 血色光晕 */
#death-screen {
    background: radial-gradient(ellipse at center, rgba(90, 10, 10, 0.35), rgba(0, 0, 0, 0.9));
    animation: deathPulse 2.5s ease-in-out infinite;
}
#win-screen {
    background: radial-gradient(ellipse at center, rgba(200, 150, 40, 0.18), rgba(0, 0, 0, 0.9));
}
@keyframes deathPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.25); }
}
#death-info, #win-info { color: #999; margin: 10px 0 20px; }
.menu-title.death { animation: bloodDrip 3s ease-in-out infinite; }
@keyframes bloodDrip {
    0%, 100% { text-shadow: 0 0 22px rgba(138, 31, 18, 0.8), 0 4px 0 rgba(0,0,0,0.3); }
    50% { text-shadow: 0 0 34px rgba(196, 40, 20, 1), 0 6px 4px rgba(0,0,0,0.4); }
}

/* 提示光标 */
#game-canvas.clickable { cursor: pointer; }
#game-canvas.inspect { cursor: crosshair; }
