* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: 'Courier New', Courier, monospace, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.hidden {
    display: none !important;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 1;
}

#game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* 중앙 조준점 (Crosshair) */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    pointer-events: none;
    z-index: 10;
}

#crosshair::before,
#crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
}

#crosshair::before {
    top: 0;
    left: 8px;
    width: 2px;
    height: 18px;
}

#crosshair::after {
    top: 8px;
    left: 0;
    width: 18px;
    height: 2px;
}

/* 피격 / 데미지 붉은 플래시 오버레이 */
#damage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle, rgba(255, 0, 0, 0.2) 0%, rgba(220, 0, 0, 0.65) 100%);
    opacity: 0;
    pointer-events: none;
    z-index: 15;
    transition: opacity 0.08s ease-out;
}

/* 일시정지 메뉴 액션 바 (ESC / 일시멈춤 상태) */
#pause-menu-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 14px 0 10px 0;
    flex-wrap: wrap;
}

.menu-btn {
    background: #404040;
    color: #ffffff;
    border: 2px solid #888888;
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
    transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.2s;
    user-select: none;
}

.menu-btn:hover {
    background: #5a5a5a;
    border-color: #ffffff;
}

.menu-btn:active {
    transform: translateY(1px);
}

/* 밤 효과 ON 상태일 때의 보라/청록 야광 하이라이트 스타일 */
#btn-toggle-night.active {
    background: #1f2b48;
    border-color: #58a6ff;
    color: #79c0ff;
    box-shadow: 0 0 12px rgba(88, 166, 255, 0.45);
}

#btn-toggle-night.active:hover {
    background: #2b3b64;
    border-color: #a5d6ff;
}

#save-status {
    font-size: 13px;
    color: #55ff55;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
    min-height: 18px;
    margin-bottom: 8px;
    transition: opacity 0.3s;
}

/* 디버그 정보 HUD */
#debug-hud {
    position: absolute;
    top: 15px;
    left: 15px;
    color: #ffffff;
    text-shadow: 1px 1px 2px #000000;
    font-size: 13px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* 서바이벌 스탯 HUD (체력 하트 & 허기 고기) */
#survival-hud {
    position: absolute;
    bottom: 74px;
    left: 50%;
    transform: translateX(-50%);
    width: 480px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

#health-bar, #hunger-bar {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* 하트 / 고기 아이콘 */
.stat-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    background-size: contain;
    background-repeat: no-repeat;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.8));
}

/* 핫바 UI (1 ~ 9 슬롯) */
#hotbar {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    background: rgba(20, 20, 20, 0.7);
    padding: 5px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
    z-index: 10;
}

.hotbar-slot {
    position: relative;
    width: 48px;
    height: 48px;
    background: rgba(45, 45, 45, 0.85);
    border: 2px solid #555555;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.08s ease, border-color 0.08s ease;
}

.hotbar-slot:hover {
    background: rgba(65, 65, 65, 0.95);
}

.hotbar-slot.active {
    border: 3px solid #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), inset 0 0 6px rgba(255, 255, 255, 0.4);
    transform: scale(1.06);
}

.slot-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.slot-key {
    position: absolute;
    bottom: 2px;
    left: 4px;
    font-size: 10px;
    color: #aaaaaa;
    font-weight: bold;
    text-shadow: 1px 1px 1px #000;
}

.slot-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 12px;
    color: #ffffff;
    font-weight: 900;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    pointer-events: none;
}

/* ==========================================
   12단계: 인벤토리 & 2x2 조합 모달 (E키)
   ========================================== */
#inventory-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#inventory-window {
    background: #c6c6c6;
    border: 4px solid #ffffff;
    border-right-color: #555555;
    border-bottom-color: #555555;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    padding: 16px;
    color: #3f3f3f;
    font-family: inherit;
    border-radius: 4px;
    width: 440px;
}

.inv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: bold;
    font-size: 16px;
}

.inv-close {
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}
.inv-close:hover {
    color: #ff3333;
}

.crafting-section {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #8b8b8b;
    padding: 10px 14px;
    border: 2px solid #373737;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    margin-bottom: 14px;
    border-radius: 3px;
}

.crafting-label {
    font-size: 13px;
    font-weight: bold;
    color: #222222;
}

.crafting-grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 40px);
    grid-gap: 4px;
}

.craft-arrow {
    font-size: 22px;
    font-weight: bold;
    color: #333333;
}

.craft-result-slot {
    width: 46px !important;
    height: 46px !important;
    border: 2px solid #373737 !important;
    border-right-color: #ffffff !important;
    border-bottom-color: #ffffff !important;
    background: #8b8b8b !important;
}

.inv-section-title {
    font-size: 12px;
    font-weight: bold;
    color: #3f3f3f;
    margin: 6px 0 4px 2px;
}

.inv-grid-main {
    display: grid;
    grid-template-columns: repeat(9, 40px);
    grid-gap: 4px;
    margin-bottom: 8px;
}

.inv-grid-hotbar {
    display: grid;
    grid-template-columns: repeat(9, 40px);
    grid-gap: 4px;
}

.inv-slot {
    position: relative;
    width: 40px;
    height: 40px;
    background: #8b8b8b;
    border: 2px solid #373737;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.inv-slot:hover {
    background: #a0a0a0;
}

/* 마우스 커서 플로팅 아이템 */
#cursor-item {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cursor-item-canvas {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

#cursor-item-count {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 12px;
    color: #ffffff;
    font-weight: 900;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

/* ==========================================
   14단계: 사망 화면 (Game Over Overlay)
   ========================================== */
#death-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(120, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#death-content {
    text-align: center;
    color: #ffffff;
}

.death-title {
    font-size: 48px;
    color: #ff3333;
    text-shadow: 3px 3px 0 #000;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.death-reason {
    font-size: 18px;
    margin-bottom: 24px;
    text-shadow: 1px 1px 2px #000;
    color: #ffcccc;
}

.death-btn {
    font-size: 18px;
    font-weight: bold;
    padding: 12px 28px;
    background: #333333;
    color: #ffffff;
    border: 3px solid #aaaaaa;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.8);
    transition: background 0.15s, border-color 0.15s;
}

.death-btn:hover {
    background: #555555;
    border-color: #ffffff;
}

/* 게임 시작 / 일시정지 오버레이 */
#blocker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    cursor: pointer;
}

#instructions {
    text-align: center;
    color: #ffffff;
    max-width: 500px;
    padding: 30px 40px;
    background: rgba(30, 30, 30, 0.85);
    border: 3px solid #888888;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

#instructions h1 {
    font-size: 36px;
    margin-bottom: 16px;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0px #000;
    color: #55ff55;
}

#instructions .start-btn {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 24px;
    padding: 10px 20px;
    background: #333333;
    border: 2px solid #aaaaaa;
    border-radius: 4px;
    display: inline-block;
    transition: background 0.2s, border-color 0.2s;
}

#blocker:hover #instructions .start-btn {
    background: #555555;
    border-color: #ffffff;
}

.controls-guide {
    text-align: left;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 13px;
    line-height: 1.7;
    color: #cccccc;
}

.controls-guide strong {
    color: #ffaa00;
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
}
