/* 폰트 및 변수 설정 */
@font-face {
    font-family: 'MyCustomFont';
    src: url('font.ttf') format('truetype');
    font-weight: normal; font-style: normal;
}

:root {
    --bg-color: #050505;
    --text-color: #fff;
    --accent-red: #8a0b0b;
    --accent-gold: #c5a059;
    --ui-bg: rgba(5, 5, 5, 0.95);
    --paper-bg: #d4c5a3; 
    --paper-text: #2b1d0e;
    --font-serif: 'MyCustomFont', 'Nanum Myeongjo', serif;
    --font-sans: 'Noto Sans KR', sans-serif;
    --card-bg: rgba(20, 20, 20, 0.85);
    --nav-bg: #111;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { background-color: var(--bg-color); color: var(--text-color); font-family: var(--font-sans); overflow: hidden; user-select: none; }

/* 유틸리티 */
.hidden { display: none !important; opacity: 0; pointer-events: none; }
.visible { display: flex !important; opacity: 1; pointer-events: auto; }
.fade-element { transition: opacity 1.5s ease-in-out; opacity: 0; }
.fade-in { opacity: 1 !important; }

/* 배경 고정 [수정] .webp */
#global-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: url('bg_intro.webp') no-repeat center center;
    background-size: cover; z-index: -1;
    transition: filter 1.5s ease-in-out, transform 1.5s ease-in-out;
}
#global-bg.blurred { filter: blur(8px) brightness(0.6); transform: scale(1.05); }
#global-bg.clear { filter: blur(0) brightness(1.1); transform: scale(1); }

/* 반전 효과 */
#global-bg.horror-invert { 
    animation: invert-shake 0.5s ease-in-out forwards; 
    transition: none !important; 
}

/* BGM 컨트롤 */
#bgm-controls {
    position: fixed; top: 20px; left: 20px; z-index: 3000;
    display: flex; align-items: center; gap: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 15px;
    border: 1px solid var(--accent-gold);
    border-radius: 5px;
    pointer-events: auto;
}
#bgm-toggle { background: transparent; border: none; color: var(--accent-gold); font-weight: bold; cursor: pointer; }
#bgm-volume { width: 80px; height: 4px; cursor: pointer; accent-color: var(--accent-red); }

/* --- 기존 CSS 유지 (webp 수정) --- */
#intro-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; z-index: 100; transition: opacity 1s ease; }
/* [수정] .webp */
.hero-section::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: url('bg_intro.webp') no-repeat center center; background-size: cover; filter: blur(8px) brightness(0.7); transform: scale(1.1); z-index: -1; }
.logo-area { z-index: 1000; filter: drop-shadow(0 0 10px rgba(0,0,0,0.8)); display: flex; flex-direction: column; align-items: center; } /* z-index 증가 */
.main-title { font-family: var(--font-serif); font-size: 5rem; color: #ff4444; margin-bottom: 20px; text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, 0 0 30px rgba(255, 0, 0, 0.6); }
.sub-title { color: var(--accent-gold); letter-spacing: 5px; display: block; margin-bottom: 10px; font-weight: 800; text-shadow: 1px 1px 2px #000; }
.catchphrase { font-style: italic; font-size: 1.4rem; font-weight: bold; color: #fff; margin-bottom: 30px; text-shadow: 1px 1px 2px #000; }
.input-area { margin-bottom: 20px; width: 100%; max-width: 400px; }
#user-name-input { width: 100%; padding: 12px 20px; background: rgba(0,0,0,0.7); border: 2px solid var(--accent-gold); color: #fff; font-family: var(--font-serif); font-size: 1.2rem; text-align: center; outline: none; transition: 0.3s; }
#user-name-input:focus { border-color: var(--accent-red); box-shadow: 0 0 10px var(--accent-red); }
#start-btn { padding: 15px 50px; background: rgba(0, 0, 0, 0.7); border: 2px solid var(--accent-gold); color: var(--accent-gold); font-family: var(--font-serif); font-size: 1.5rem; font-weight: bold; cursor: pointer; transition: 0.3s; text-shadow: 0 0 5px #000; }
#start-btn:hover { background: var(--accent-red); border-color: var(--accent-red); color: #fff; box-shadow: 0 0 20px var(--accent-red); }

#loading-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 2000; display: flex; justify-content: center; align-items: center; transition: opacity 1s ease; }
.loading-content { text-align: center; width: 60%; max-width: 600px; }
.loading-bar-container { width: 100%; height: 4px; background: #333; margin-bottom: 15px; position: relative; border: 1px solid #555; }
#loading-bar { width: 0%; height: 100%; background: var(--accent-red); box-shadow: 0 0 10px var(--accent-red); transition: width 0.1s linear; }
#loading-text { color: var(--accent-gold); font-family: var(--font-serif); font-size: 1.2rem; letter-spacing: 2px; }

#game-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 200; }
#skip-btn { position: absolute; top: 30px; right: 30px; z-index: 300; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--accent-gold); color: var(--accent-gold); padding: 8px 15px; cursor: pointer; transition: 0.3s; font-weight: bold; }
#skip-btn:hover { background: var(--accent-gold); color: #000; }

#vn-intro-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 80%; text-align: center; font-family: var(--font-serif); font-size: 2.2rem; color: #fff; font-weight: bold; z-index: 250; line-height: 1.6; text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, 0 0 20px rgba(0,0,0,0.8); }
#vn-black-layer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 245; display: flex; justify-content: center; align-items: center; text-align: center; }
#vn-black-text { color: #fff; font-family: var(--font-serif); font-size: 2.5rem; text-shadow: 0 0 10px #fff; line-height: 1.8; }

#vn-content-wrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 240; pointer-events: none; }
.vn-image-frame { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); width: 60%; max-width: 800px; aspect-ratio: 16/9; border: 3px solid var(--accent-gold); box-shadow: 0 0 50px rgba(0,0,0,1); background: #000; overflow: hidden; transition: opacity 0.5s ease; }
#vn-center-image { width: 100%; height: 100%; object-fit: cover; }
#vn-character { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); height: 90vh; object-fit: contain; filter: drop-shadow(0 0 30px rgba(0,0,0,0.8)); transition: opacity 0.5s ease; }

.vn-ui-container { position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 1000px; z-index: 250; pointer-events: none; }
.vn-menu-bar { position: absolute; top: -42px; right: 0; display: flex; gap: 10px; pointer-events: auto; }
.vn-menu-btn { background: rgba(0, 0, 0, 0.8); border: 1px solid var(--accent-gold); color: var(--accent-gold); padding: 8px 20px; font-family: var(--font-sans); font-weight: bold; cursor: pointer; transition: 0.3s; font-size: 0.9rem; border-bottom: none; border-radius: 5px 5px 0 0; padding-bottom: 10px; }
.vn-menu-btn:hover { background: var(--accent-gold); color: #000; }
.vn-menu-btn.active { background: var(--accent-red); color: #fff; border-color: #ff5555; box-shadow: 0 0 10px var(--accent-red); }
.vn-name-tag { position: absolute; top: -42px; left: 0; min-width: 160px; height: 45px; background: #1a0b0b; border: 2px solid var(--accent-gold); display: flex; align-items: center; justify-content: center; box-shadow: 3px 3px 10px rgba(0,0,0,0.7); border-radius: 5px 5px 0 0; z-index: 252; }
.vn-name-tag span { color: var(--accent-gold); font-family: var(--font-serif); font-size: 1.4rem; font-weight: 800; letter-spacing: 1px; text-shadow: 1px 1px 2px #000; }
.vn-dialogue-box { background: var(--ui-bg); border: 3px double var(--accent-gold); border-radius: 0 10px 10px 10px; padding: 30px 40px; min-height: 160px; position: relative; pointer-events: auto; box-shadow: 0 10px 40px rgba(0,0,0,1); backdrop-filter: blur(3px); }
#vn-text { font-size: 1.35rem; line-height: 1.7; color: #e0e0e0; font-family: var(--font-sans); text-shadow: 1px 1px 2px #000; }
.blinking-cursor { position: absolute; bottom: 15px; right: 20px; color: var(--accent-gold); font-size: 1.2rem; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

#decree-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.9); z-index: 1000; display: flex; justify-content: center; align-items: center; }
.decree-paper { width: 90%; max-width: 600px; height: 80vh; background: var(--paper-bg); border: 10px double #5a3e23; padding: 30px; display: flex; flex-direction: column; box-shadow: 0 0 50px rgba(0,0,0,1); position: relative; }
.decree-title { font-family: var(--font-serif); font-size: 2rem; color: #3e2b14; text-align: center; margin-bottom: 20px; text-decoration: underline; }
.decree-content { flex-grow: 1; overflow-y: auto; font-family: var(--font-serif); color: var(--paper-text); line-height: 1.6; padding: 15px; background: rgba(255,255,255,0.2); border: 1px solid rgba(62, 43, 20, 0.2); }
.decree-content::-webkit-scrollbar { width: 8px; }
.decree-content::-webkit-scrollbar-thumb { background: #5a3e23; border-radius: 4px; }
.seal-container { text-align: center; margin-top: 20px; margin-bottom: 5px; }
.decree-seal { width: 120px; height: 120px; object-fit: contain; mix-blend-mode: multiply; transform: rotate(-10deg); }
.decree-section { font-weight: bold; font-size: 1.2rem; color: #8a0b0b; margin-top: 15px; }
.decree-footer { text-align: center; font-style: italic; margin-top: 10px; font-weight: bold; font-size: 1.5rem; color: #8a0b0b; }
.decree-action { margin-top: 20px; text-align: center; }
#decree-btn { width: 100%; padding: 15px; font-family: var(--font-sans); font-weight: bold; font-size: 1.2rem; background: #555; color: #ccc; border: none; cursor: not-allowed; transition: 0.3s; }
#decree-btn.active { background: var(--accent-red); color: #fff; cursor: pointer; box-shadow: 0 0 15px var(--accent-red); }

#log-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 3000; display: flex; justify-content: center; align-items: center; }
.log-window { width: 80%; max-width: 800px; height: 70vh; background: rgba(10, 5, 2, 0.95); border: 2px solid var(--accent-gold); display: flex; flex-direction: column; box-shadow: 0 0 50px rgba(0,0,0,1); }
.log-header { padding: 15px 20px; background: #1a0b0b; border-bottom: 1px solid var(--accent-gold); display: flex; justify-content: space-between; align-items: center; color: var(--accent-gold); font-family: var(--font-serif); font-weight: bold; font-size: 1.2rem; }
#close-log-btn { background: transparent; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }
.log-content { flex-grow: 1; overflow-y: auto; padding: 20px; font-family: var(--font-sans); color: #ccc; }
.log-content::-webkit-scrollbar { width: 8px; }
.log-content::-webkit-scrollbar-thumb { background: var(--accent-gold); }
.log-entry { margin-bottom: 15px; border-bottom: 1px solid #333; padding-bottom: 10px; }
.log-name { color: var(--accent-gold); font-weight: bold; margin-bottom: 5px; font-family: var(--font-serif); }
.log-text { line-height: 1.5; }

/* === 메인 화면 스타일 === */
#main-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2000;
    display: flex; flex-direction: column;
    opacity: 0; transition: opacity 3s ease;
    overflow-y: auto;
}
#main-screen.fade-in { opacity: 1; }

.main-header {
    position: relative; 
    display: flex; justify-content: center; align-items: center;
    padding: 10px 40px; background: rgba(0,0,0,0.8);
    border-bottom: 2px solid var(--accent-gold);
    flex-shrink: 0; min-height: 100px; 
}

.header-center { z-index: 2; }
.main-title-text {
    font-family: 'UnifrakturMaguntia', cursive; 
    font-size: 4rem; 
    color: var(--accent-red);
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 0 0 20px rgba(255, 0, 0, 0.5);
    margin: 0;
}

.header-right-absolute {
    position: absolute; right: 40px; top: 50%; transform: translateY(-50%);
}
.header-btn {
    background: transparent; border: 1px solid var(--accent-gold);
    color: var(--accent-gold); padding: 8px 15px;
    font-family: var(--font-sans); font-weight: bold; cursor: pointer;
    transition: 0.3s;
}
.header-btn:hover { background: var(--accent-gold); color: #000; }

.tab-nav { display: flex; justify-content: center; background: rgba(0,0,0,0.9); border-bottom: 1px solid #333; }
.tab-btn { background: transparent; border: none; color: #888; padding: 15px 30px; font-size: 1.1rem; font-family: var(--font-serif); cursor: pointer; transition: 0.3s; border-bottom: 3px solid transparent; }
.tab-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }
.tab-btn.active { color: var(--accent-gold); border-bottom-color: var(--accent-gold); background: rgba(212, 175, 55, 0.1); }
.tab-btn:disabled { color: #333; cursor: not-allowed; }

.main-content-area { flex-grow: 1; padding: 30px; overflow-y: auto; }
.tab-content { display: none; animation: fadeIn 0.5s; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.character-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 25px; width: 100%; max-width: 1400px; margin: 0 auto; }
.char-card { background: var(--card-bg); border: 1px solid #444; border-radius: 8px; overflow: hidden; position: relative; transition: 0.3s; cursor: pointer; }
.char-card:hover { transform: translateY(-5px); border-color: var(--accent-gold); box-shadow: 0 10px 30px rgba(0,0,0,0.8); }
.char-card.special { border-color: #555; } 
.char-img-box { width: 100%; height: 400px; overflow: hidden; position: relative; }
.char-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.char-card:hover .char-img { transform: scale(1.05); }
.char-overlay { position: absolute; bottom: 0; left: 0; width: 100%; background: linear-gradient(to top, #000 10%, transparent); padding: 20px; }
.char-role { display: block; font-size: 0.8rem; color: #aaa; margin-bottom: 2px; }
.char-name { font-family: var(--font-serif); font-size: 1.8rem; color: #fff; margin: 0; text-shadow: 0 0 10px #000; }
.char-status-tag { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.8); color: #ccc; padding: 5px 10px; font-size: 0.8rem; border-radius: 4px; border: 1px solid #333; z-index: 2; }
.char-status-tag.ruler { border-color: var(--accent-red); color: var(--accent-red); }
.char-desc { padding: 15px; color: #ccc; font-size: 0.9rem; line-height: 1.5; border-top: 1px solid #333; background: #111; height: 100px; overflow: hidden; }
.world-text-container { max-width: 800px; margin: 0 auto; background: rgba(0,0,0,0.8); padding: 40px; border: 1px solid #444; color: #ddd; line-height: 1.8; }
.world-text-container h3 { color: var(--accent-gold); margin-bottom: 15px; margin-top: 30px; font-family: var(--font-serif); border-bottom: 1px solid #333; padding-bottom: 5px; }
.world-text-container p { margin-bottom: 10px; }
.rank-list li { margin-bottom: 8px; }
.rank-list strong { color: var(--accent-red); }
.coming-soon-box { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 400px; color: #555; }
.coming-soon-box i { font-size: 3rem; margin-bottom: 20px; }

/* 상세 정보 모달 */
#char-detail-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9); z-index: 4000;
    display: flex; justify-content: center; align-items: center;
}
.char-detail-window {
    width: 90%; max-width: 900px; height: 80vh;
    background: #111; border: 2px solid var(--accent-gold);
    position: relative; display: flex; box-shadow: 0 0 50px #000;
}
#close-detail-btn {
    position: absolute; top: 10px; right: 20px;
    background: transparent; border: none; color: #fff; font-size: 2rem; cursor: pointer; z-index: 10;
}
.char-detail-content { display: flex; width: 100%; height: 100%; }
.detail-left { width: 40%; position: relative; overflow: hidden; border-right: 1px solid #333; }
#detail-img { width: 100%; height: 100%; object-fit: cover; }
.detail-right { width: 60%; padding: 40px; overflow-y: auto; color: #ddd; display: flex; flex-direction: column; }
.detail-right h2 { font-family: var(--font-serif); font-size: 3rem; color: var(--accent-gold); margin-bottom: 5px; }
.detail-role { color: #888; font-size: 1rem; margin-bottom: 20px; }
.detail-right hr { margin-bottom: 30px; border-color: #333; }

.detail-info-list { list-style: none; margin-bottom: 30px; }
.detail-info-list li { margin-bottom: 10px; font-size: 1.2rem; }
.detail-info-list strong { color: var(--accent-red); margin-right: 10px; font-weight: bold; }
.detail-desc-box { background: rgba(255,255,255,0.05); padding: 20px; border-radius: 5px; line-height: 1.6; margin-bottom: 30px; font-style: italic; }

/* 대사 박스 스타일 */
.detail-quote-box {
    margin-top: auto; /* 하단 배치 */
    color: #aaa; 
    font-size: 1.3rem; 
    font-style: italic; 
    text-align: center; 
    border-top: 1px solid #333; 
    padding-top: 20px; 
    font-family: var(--font-serif);
    color: var(--accent-gold);
}

/* [수정] 모바일 최적화 (768px 이하) - 50% 수준 축소 */
@media (max-width: 768px) {
    /* 16px -> 8px (50%) */
    html { font-size: 8px; } 

    .vn-image-frame { top: 35%; width: 90%; height: auto; aspect-ratio: 16/9; }
    .vn-ui-container { bottom: 10px; width: 95%; }
    .vn-dialogue-box { padding: 15px; min-height: 130px; }
    #vn-text { font-size: 1.4rem; line-height: 1.4; }
    
    #skip-btn { top: 15px; right: 15px; padding: 5px 10px; font-size: 1.2rem; }
    #bgm-controls { top: 15px; left: 15px; padding: 5px 10px; }
    
    .main-title-text { font-size: 4rem; }
    .character-grid { grid-template-columns: 1fr; width: 90%; }
    .char-img-box { height: 300px; }

    /* [수정] 모바일 모달 레이아웃: 위(이미지) - 아래(텍스트) */
    .char-detail-window { height: 90vh; overflow-y: auto; display: block; } 
    .char-detail-content { display: block; height: auto; }
    
    .detail-left { 
        width: 100%; 
        height: 300px; 
        border-right: none; 
        border-bottom: 1px solid var(--accent-gold); 
    }
    .detail-right { 
        width: 100%; 
        height: auto; 
        padding: 20px; 
    }
}
/* 애니메이션 */
@keyframes flash-effect { 0% { filter: brightness(1); } 10% { filter: brightness(3) contrast(1.5); } 100% { filter: brightness(1); } }
.anim-flash { animation: flash-effect 1.5s ease-out forwards; }
@keyframes reveal-effect { 0% { opacity: 0; filter: brightness(0.5); } 100% { opacity: 1; filter: brightness(1); } }
.anim-reveal { animation: reveal-effect 3s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
@keyframes invert-shake { 0% { filter: invert(0); transform: translate(0, 0); } 10% { filter: invert(1); transform: translate(-5px, 5px); } 100% { filter: invert(1); transform: scale(1.1); } }
.horror-bg { animation: invert-shake 0.5s ease-in-out forwards; }