:root {
    --bg-color: #0c0c16;
    --pixel-green: #00ff88;
    --pixel-blue: #00e5ff;
    --pixel-red: #ff3e3e;
    --text-color: #e0e0e0;
    --border-color: #4a4a6a;
    --highlight-color: #ffcc00;
}

body.pixel-theme {
    margin: 0;
    padding: 0;
    background-color: #05050a; /* 컨테이너 외부 배경색 */
    color: var(--text-color);
    font-family: 'Noto Sans KR', sans-serif;
    overflow: hidden;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
}

#game-container {
    width: 450px; /* 스마트폰 가로 크기 고정 */
    height: 90vh; /* 화면 높이의 90% 사용 */
    max-height: 920px;
    display: grid;
    grid-template-rows: 80px 1fr 340px;
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden;
    border: 4px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 0 20px var(--pixel-blue);
}

/* CRT 스캔라인 효과 레이어 */
#game-container::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%),
                linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 4px, 3px 100%;
    z-index: 50;
    pointer-events: none;
    pointer-events: none;
}

/* 픽셀아트 배경 레이어 */
#scene-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    image-rendering: pixelated;
    transition: opacity 0.5s ease-in-out;
}

.pixel-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 20%, rgba(0,0,0,0.5) 100%),
                linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
                linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 100%, 100% 4px, 3px 100%;
    pointer-events: none;
}

/* HUD 스타일 고도화 (Glassmorphism) */
#hud {
    z-index: 40;
    display: flex;
    justify-content: space-between;
    padding: 15px 25px;
    background: rgba(12, 12, 22, 0.85);
    backdrop-filter: blur(5px);
    border-bottom: 2px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.hud-item {
    font-family: 'DotGothic16', sans-serif;
    text-transform: uppercase;
}

.neon-text {
    color: var(--pixel-blue);
    text-shadow: 0 0 10px var(--pixel-blue);
    font-size: 0.9rem; /* 이전 크기로 복구 */
}

.neon-btn {
    background: transparent;
    border: 1px solid var(--pixel-red);
    color: var(--pixel-red);
    padding: 5px 15px;
    font-size: 0.7rem;
    cursor: pointer;
    font-family: 'DotGothic16', sans-serif;
    transition: all 0.3s;
    border-radius: 4px;
}

.neon-btn:hover {
    background: var(--pixel-red);
    color: #fff;
    box-shadow: 0 0 15px var(--pixel-red);
}

/* 캐릭터 스프라이트 영역 (중앙 고정 및 겹침 방지) */
#character-layer {
    grid-row: 2;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 10;
    pointer-events: none;
    overflow: hidden; /* 캐릭터가 영역을 벗어나지 않게 제어 */
}

#character-sprite {
    width: auto;
    height: 100%; /* 부모(중앙 영역) 높이에 맞춤 */
    max-height: 450px; /* 너무 커지는 것 방지 */
    aspect-ratio: 3 / 4;
    background-size: contain;
    background-position: bottom center;
    background-repeat: no-repeat;
    image-rendering: pixelated;
}

#character-sprite.silhouette,
#character-sprite[style*="silhouette.png"] {
    filter: brightness(0) invert(1) opacity(0.3);
}

/* 대화창 디자인 고도화 (영역 고정 및 겹침 수정) */
#dialogue-container {
    grid-row: 3;
    width: 90%;
    margin-bottom: 20px; /* 이전 간격으로 복구 */
    position: relative;
    z-index: 100;
    padding: 0 20px 20px 20px; /* 여백 최적화 */
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
}

.pixel-box {
    border: 2px solid var(--border-color);
    background: rgba(0, 0, 0, 0.85);
    padding: 20px;
    padding-top: 25px;
    min-height: 150px;
}

.pixel-box-title {
    font-family: 'DotGothic16', sans-serif;
    background: var(--border-color);
    color: #fff;
    padding: 5px 15px;
    display: inline-block;
    position: absolute;
    top: -38px; /* 위로 이동 */
    left: 20px;
    font-size: 1.2rem;
}

#dialogue-text {
    font-size: 1.15rem;
    line-height: 1.7;
    margin-bottom: 25px;
    color: #ffffff;
    min-height: 4.5em; /* 텍스트 길이에 따른 울렁임 방지 */
}

/* 선택지 버튼 */
#choices-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

/* 모바일 상속 처리 (작은 화면 대응) */
@media (max-width: 500px) {
    #game-container {
        width: 100vw;
        height: 100vh;
        max-height: none;
        border: none;
        border-radius: 0;
    }
    
    #game-container {
        grid-template-rows: 110px 1fr 300px;
    }
}

.choice-btn {
    background: transparent;
    border: 2px solid var(--pixel-green);
    color: var(--pixel-green);
    padding: 12px;
    font-family: 'Noto Sans KR', sans-serif;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
}

.choice-btn:hover {
    background: var(--pixel-green);
    color: var(--bg-color);
    box-shadow: 0 0 15px var(--pixel-green);
}

.choice-btn::before {
    content: "> ";
    opacity: 0;
    transition: opacity 0.2s;
}

.choice-btn:hover::before {
    opacity: 1;
}

/* 엔딩 리포트 및 Game Over 스타일 */
.game-over-text {
    font-family: 'DotGothic16', sans-serif;
    color: var(--pixel-red);
    font-size: 2.5rem;
    text-align: center;
    margin: 20px 0;
    letter-spacing: 5px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.report-summary {
    color: var(--pixel-blue);
    text-align: center;
    font-weight: bold;
    margin-bottom: 20px;
}

.decision-log {
    list-style: none;
    padding: 0;
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 30px;
}

.decision-log li {
    margin-bottom: 10px;
    border-left: 2px solid var(--border-color);
    padding-left: 10px;
}

.final-restart {
    border-color: var(--pixel-blue) !important;
    color: var(--pixel-blue) !important;
}

.final-restart:hover {
    background: var(--pixel-blue) !important;
    color: #000 !important;
}

/* Splash Screen (로딩 화면) */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000 url('assets/thumbnail.png') no-repeat center center;
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 1.5s ease-out;
}

.splash-content {
    background: rgba(0, 0, 0, 0.7);
    padding: 40px;
    border: 2px solid var(--pixel-blue);
    text-align: center;
    box-shadow: 0 0 30px var(--pixel-blue);
}

.neon-text-main {
    font-family: 'DotGothic16', sans-serif;
    color: #fff;
    font-size: 3rem;
    text-shadow: 0 0 15px var(--pixel-blue), 0 0 30px var(--pixel-blue);
    margin: 0;
    letter-spacing: 10px;
}

.loading-text {
    font-family: 'DotGothic16', sans-serif;
    color: var(--pixel-blue);
    margin-top: 20px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.splash-fade-out {
    opacity: 0;
    pointer-events: none;
}

/* 유틸리티 */
.hidden { display: none; }
