/* =========================================
   WISH VALLEY STYLE.CSS (최종 수정본)
   ========================================= */

/* 1. 기본 설정 및 폰트 */
:root {
    --pastel-pink: #FFD1DC;
    --deep-pink: #FFB7C5;
    --border-pink: #E5989B;
    --pastel-green: #E2F0CB;
    --deep-green: #A5D6A7;
    --border-green: #81C784;
    --text-color: #5D4037;
    --pixel-size: 3px; /* 테두리 두께 */
}

@font-face {
    font-family: 'MyGameFont'; /* 기본 게임 폰트 이름 */
    src: url('../assets/fonts/main_font.ttf'); /* 파일명 정확히 맞출 것 */
}

@font-face {
    font-family: 'MyLetterFont'; /* 편지용 폰트 이름 */
    src: url('../assets/fonts/letter_font.ttf');
}

body {
    margin: 0; padding: 0;
    background-color: #fce4ec;
    font-family: 'MyGameFont', sans-serif;
    display: flex; justify-content: center; align-items: center;
    height: 100vh; overflow: hidden;
    cursor: url('../assets/images/ui/star_cursor.png'), auto;
}

/* 편지 본문에만 손글씨 폰트 적용 */
#letter-text {
    font-family: 'MyLetterFont', serif !important;
}

/* 2. 게임 메인 컨테이너 */
#game-container {
    width: 800px; height: 600px;
    background-color: #fff0f5;
    position: relative; /* 모든 절대 위치 요소의 기준점 */
    display: flex; flex-direction: column;
    /* 이중 테두리 효과 */
    box-shadow: 
        0 0 0 var(--pixel-size) var(--border-pink),
        0 0 0 calc(var(--pixel-size) * 2) white,
        0 0 20px rgba(0,0,0,0.1);
}

/* 3. 상단 상태바 */
#status-bar {
    background-color: var(--pastel-pink);
    padding: 10px 20px;
    display: flex; justify-content: space-between;
    font-size: 14px; color: var(--text-color);
    border-bottom: var(--pixel-size) solid var(--border-pink);
}
#energy-display span { color: #e91e63; letter-spacing: 2px; }

/* 4. 게임 뷰 (배경) */
#location-view {
    flex-grow: 1;
    background-size: cover; background-position: center;
    position: relative; image-rendering: pixelated;
}

/* 5. 하단 컨트롤 패널 */
#control-panel {
    height: 140px;
    background-color: #fff9fa;
    border-top: var(--pixel-size) solid var(--border-pink);
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 25px; gap: 15px;
}

#move-buttons {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 6px; width: 40%;
}

button {
    font-family: 'MyGameFont', sans-serif;
    font-size: 14px; color: var(--text-color);
    background-color: white;
    border: 3px solid var(--pastel-pink);
    padding: 8px 5px; cursor: pointer;
    box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
    transition: all 0.1s;
}
button:hover { background-color: #fff0f5; transform: translateY(-1px); }
button:active { transform: translateY(1px); box-shadow: none; }

/* 6. 하단 미니 인벤토리 */
#inventory-container {
    flex-grow: 1;
    display: flex; flex-direction: column; align-items: center;
    background-color: var(--pastel-green);
    padding: 8px;
    border: var(--pixel-size) solid var(--border-green);
    border-radius: 4px;
}
#inventory-container p { margin: 0 0 10px 0; font-size: 13px; font-weight: bold; color: #2E7D32; }
#inventory-slots { display: flex; gap: 7px; }

.slot {
    width: 38px; height: 38px;
    background-color: white;
    border: var(--pixel-size) solid var(--deep-green);
    display: flex; justify-content: center; align-items: center;
    image-rendering: pixelated; cursor: pointer;
}
.slot img { width: 30px; height: 30px; object-fit: contain; }
.slot:hover { background-color: #f1f8e9; }

/* 가방 아이콘 (우측 하단) */
#inventory-icon {
    position: absolute; bottom: 160px; right: 20px;
    width: 60px; height: 60px;
    cursor: pointer; z-index: 100;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.2));
    transition: transform 0.2s;
}
#inventory-icon:hover { transform: scale(1.1) rotate(10deg); }

/* [수정 1] 편지 팝업 완벽한 중앙 정렬 */
#letter-modal {
    display: flex;           /* 플렉스 박스 사용 */
    justify-content: center; /* 가로 중앙 */
    align-items: center;     /* 세로 중앙 */
    /* 기존에 혹시 top, left 등이 있다면 무시되도록 설정 */
}
.letter-paper {
    /* 기존 margin이 있다면 제거해서 정중앙에 오게 함 */
    margin: 0 !important; 
    position: relative; /* 위치 잡기 */
}

/* 7. 인벤토리 팝업 (중앙 정렬 수정됨) */
#inventory-modal {
    position: absolute;
    top: 50%; left: 50%; /* 화면 정중앙 배치 */
    transform: translate(-50%, -50%);
    width: 450px;
    background-color: #fff9fa;
    padding: 20px;
    z-index: 2000;
    text-align: center;
    border: 3px solid var(--border-pink);
    box-shadow: 0 0 0 6px white, 0 20px 50px rgba(0,0,0,0.3);
    border-radius: 10px;
}

#inventory-modal h3 {
    margin-top: 0; color: var(--border-pink);
    border-bottom: 2px dashed var(--border-pink);
    padding-bottom: 10px;
}

.inventory-grid {
    display: grid; 
    grid-template-columns: repeat(4, 1fr); /* 가로 4칸 균등 분할 */
    gap: 10px; 
    padding: 15px;
    background-color: #fff0f5;
    border: 2px solid var(--pastel-pink);
    border-radius: 5px; 
    margin-bottom: 15px;
    min-height: 100px; 
    
    /* [수정] 이 두 줄을 추가하면 슬롯이 각 칸의 가운데로 옵니다! */
    justify-items: center; /* 가로 중앙 정렬 */
    align-items: center;   /* 세로 중앙 정렬 */
}

.item-slot {
    width: 60px; height: 60px;
    background-color: white;
    border: 2px solid var(--deep-pink);
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}
.item-slot:hover { transform: scale(1.05); }
.item-slot.selected { background-color: var(--pastel-pink); border-color: #e91e63; }
.item-slot img { width: 45px; height: 45px; }

/* --- 잠자기 알림바 (위치 수정됨: 상단 상태바 바로 밑) --- */
#sleep-alert {
    position: absolute;
    top: 50px; /* 상태바 높이만큼 띄워서 배치 */
    left: 0;
    width: 100%;
    background-color: rgba(44, 62, 80, 0.95); /* 가독성을 위해 조금 더 진하게 */
    color: white;
    padding: 10px 0; /* 높이 살짝 줄임 */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 1500;
    
    /* 테두리 위치 변경 (위->아래) */
    border-bottom: 3px solid var(--border-pink);
    border-top: none;
    
    /* 애니메이션 변경 (위에서 아래로) */
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

#sleep-alert span { font-size: 16px; }

#sleep-alert button {
    background-color: var(--pastel-pink);
    color: white;
    border: none;
    padding: 5px 15px;
    font-size: 14px;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--border-pink);
}
#sleep-alert button:hover {
    background-color: var(--deep-pink);
    transform: translateY(-2px);
}

/* 9. 대화창 UI */
#dialogue-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.1);
    display: flex; justify-content: center; align-items: flex-end;
    padding-bottom: 20px; z-index: 100;
}

/* [수정] 대화 박스: 높이 제한을 풀거나 flex 설정을 단순화 */
#dialogue-box {
    width: 720px; 
    background-color: white;
    border: 3px solid var(--border-pink);
    padding: 15px; 
    box-shadow: 4px 4px 0 rgba(0,0,0,0.1);
    /* flex-direction: column;  <-- 이 줄은 이제 굳이 없어도 되지만 둬도 상관없습니다. */
}

/* [수정] 대화 컨텐츠 영역: 내부 요소 정렬 방식 변경 */
#dialogue-content { 
    display: flex; 
    align-items: flex-start; /* 위쪽 정렬 (초상화와 텍스트 높이 맞춤) */
    min-height: 120px; 
}

#dialogue-portrait {
    width: 110px; height: 110px;
    background-color: #fff0f5;
    border: var(--pixel-size) solid var(--border-pink);
    margin-right: 15px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
#dialogue-portrait img { width: 100%; height: 100%; object-fit: contain; }

/* [수정] 텍스트 래퍼: 내부 요소들을 세로로 배치 */
#text-wrapper { 
    flex-grow: 1; 
    position: relative; 
    /* display: flex;        <-- 삭제 또는 주석 처리 */
    /* flex-direction: column; <-- 삭제 또는 주석 처리 */
    /* justify-content: space-between; <-- 삭제 또는 주석 처리 */
}

/* [수정] 대화 텍스트: 인라인(Inline)으로 바꿔서 커서가 옆에 붙게 함 */
#dialogue-text { 
    display: inline;       /* 중요! block -> inline 변경 */
    font-size: 18px; 
    line-height: 1.6; 
    color: var(--text-color); 
    padding: 5px; 
    /* margin-bottom 제거 (inline에서는 위아래 마진이 안 먹힘) */
}

/* [수정] 커서: 절대 위치(absolute)를 풀고 글자 옆에 붙임 */
#next-cursor {
    position: static;      /* 고정 위치 해제 */
    display: inline-block; /* 글자처럼 취급 */
    margin-left: 5px;      /* 텍스트와의 간격 */
    vertical-align: baseline; /* 텍스트 줄 맞춤 */
    
    /* 기존 스타일 유지 */
    color: var(--deep-pink); 
    font-size: 14px;
    animation: blink 1s infinite;
}

/* [추가] 선택지와 입력창: 텍스트 바로 뒤가 아니라 '다음 줄'에 나오도록 */
#choice-area, #input-area {
    margin-top: 15px;      /* 텍스트와의 간격 */
    display: block;        /* 줄바꿈 강제 */
}

/* [수정] 입력창 영역: 상단 여백 제거 (text-wrapper 흐름에 맡김) */
#input-area { 
    margin-top: 5px; /* 필요하면 조절 */
    display: flex; 
    gap: 8px; 
    /* width: 100%; <-- 필요하면 추가 */
}

#keyword-input {
    flex: 1; padding: 8px;
    font-family: 'MyGameFont'; font-size: 16px;
    border: var(--pixel-size) solid var(--border-pink); outline: none;
}
.choice-btn {
    width: 100%; text-align: left;
    background-color: var(--pastel-green); border-color: var(--border-green);
    margin-bottom: 5px;
}

/* 10. 오프닝 화면 */
#intro-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('../assets/images/backgrounds/farm.png');
    background-size: cover; background-position: center;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.3); backdrop-filter: blur(2px);
}
.logo-area { margin-bottom: 30px; animation: floatUp 2s ease-out forwards; opacity: 0; transform: translateY(30px); }
@keyframes floatUp { to { opacity: 1; transform: translateY(0); } }
.game-logo-img { max-width: 500px; height: auto; }

#menu-area { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.menu-btn {
    width: 180px; padding: 12px; font-size: 18px;
    background-color: white; border: 3px solid var(--border-pink);
    border-radius: 10px; box-shadow: 0 4px 0 var(--pastel-pink);
}
.menu-btn:hover { background-color: var(--pastel-pink); color: white; transform: scale(1.05); }

/* 이름 입력창 */
#name-input-area {
    background-color: rgba(255, 255, 255, 0.95);
    padding: 25px; border: 2px solid var(--border-pink);
    border-radius: 15px; display: flex; flex-direction: column;
    align-items: center; gap: 15px; width: 300px;
}
#player-name-input {
    width: 200px; padding: 10px;
    font-family: 'MyGameFont'; font-size: 12px; text-align: center;
    border: 1px solid var(--border-pink); background-color: #fff0f5; outline: none;
}
.button-row { display: flex; gap: 10px; width: 100%; justify-content: center; }
.confirm-btn { width: 120px; padding: 10px; background-color: var(--pastel-pink); color: white; border: none; }
.cancel-btn { width: 80px; padding: 10px; background-color: #e0e0e0; border: none; }

/* 11. 밤 & 엔딩 화면 (중앙 정렬 수정됨) */
#night-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex; justify-content: center; align-items: center;
    z-index: 500;
}
.night-content {
    background-color: white; padding: 20px 30px;
    border: 3px solid var(--border-pink); border-radius: 15px;
    text-align: center; display: flex; flex-direction: column; align-items: center; gap: 15px;
    box-shadow: 0 0 20px rgba(0,0,0,0.2); min-width: 300px;
}
.night-content h2 { font-size: 18px; margin: 0; font-weight: normal; }
.night-content button {
    padding: 8px 20px; font-size: 16px;
    background-color: var(--pastel-pink); color: white;
    border: none; border-radius: 8px; box-shadow: 0 3px 0 var(--border-pink);
}

/* [수정 3] 엔딩 제목 폰트 크기 줄이기 */
#ending-title {
    font-size: 24px; /* 기존보다 작게 조절 (원하는 크기로 변경 가능) */
    margin-bottom: 15px;
}

#ending-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    background-color: rgba(0,0,0,0.8); z-index: 600;
}
.ending-content {
    background-color: #fff9fa; border: 4px solid var(--border-pink);
    padding: 30px; border-radius: 20px; text-align: center; max-width: 500px;
}
#ending-image-wrapper img {
    width: 150px; height: 150px; border-radius: 50%;
    border: 4px solid white; box-shadow: 0 0 15px var(--pastel-pink); margin: 15px 0;
}

/* 12. 기타 모달 및 유틸리티 */
.modal {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000;
}
.modal-content, .info-content {
    background: white; padding: 25px;
    border: 3px solid var(--border-pink); border-radius: 10px;
    width: 300px; text-align: center; box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
/* [수정 2] 아이템 정보 팝업 내부 요소 중앙 정렬 */
#item-info-modal .modal-content {
    display: flex;
    flex-direction: column; /* 세로로 배치 */
    align-items: center;    /* 가로축 기준 중앙 정렬 */
    text-align: center;     /* 텍스트 중앙 정렬 */
}
#info-image {
    margin: 10px auto;      /* 이미지 위아래 여백 + 좌우 자동 중앙 */
    display: block;
}

/* [수정 4] 커스텀 알림창(Alert) 스타일 (새로 추가) */
#alert-modal {
    z-index: 3000; /* 제일 위에 뜨도록 */
    display: flex;
    justify-content: center;
    align-items: center;
}
.alert-content {
    background: white;
    border: 4px double var(--deep-green);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    min-width: 250px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.alert-content p {
    margin-bottom: 15px;
    font-size: 16px;
    color: #333;
}

/* NPC 및 아이템 */
.npc-sprite {
    width: 64px; height: 64px;
    background-size: contain; background-repeat: no-repeat;
    position: absolute; 
    transform: translate(-50%, -50%);
    cursor: pointer; 
    z-index: 10;
}

/* 채집 아이템 */
.collectible-item {
    width: 40px; height: 40px;
    position: absolute; 
    z-index: 20; /* [수정] 5 -> 20으로 변경 (캐릭터보다 위에 오게) */
    animation: bounce 1.5s infinite; cursor: pointer;
}

@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes shake { 0% { transform: rotate(0deg); } 25% { transform: rotate(3deg); } 75% { transform: rotate(-3deg); } 100% { transform: rotate(0deg); } }
.inventory-grid.delete-mode .item-slot { border-color: red !important; animation: shake 0.3s infinite; }
#delete-toggle-btn { position: absolute; bottom: 15px; right: 15px; font-size: 20px; cursor: pointer; }

/* [필수 수정] 모든 팝업 숨김 처리 강제 적용 */
.hidden {
    display: none !important;
}

/* =========================================================
   [최종 수정 요청 반영] 팝업창 중앙 정렬 & 오버레이 설정
   (아이템 정보, 알림창, 편지함 적용 / 잠자기 알림 제외)
   ========================================================= */

/* 1. 팝업 컨테이너: 화면 전체를 덮고 내용을 정중앙에 배치 */
#alert-modal,
#letter-modal,
#item-info-modal {
    position: absolute;  /* 게임 화면 기준 절대 위치 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;        /* 화면 꽉 채우기 (배경 역할) */
    background-color: rgba(0, 0, 0, 0.5); /* 반투명 검은 배경 */
    display: flex;       
    justify-content: center; /* 가로 중앙 */
    align-items: center;     /* 세로 중앙 */
    z-index: 3000;       /* 다른 요소들보다 제일 위에 뜨도록 */
}

/* 2. 팝업 내부 하얀 박스 디자인 (통일) */
#alert-modal .alert-content,
#letter-modal .modal-content,
#item-info-modal .info-content {
    background-color: white;
    padding: 25px 30px;
    border: 3px solid var(--border-pink);
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3); /* 그림자 효과 */
    
    /* 크기 및 정렬 */
    min-width: 280px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    margin: 0 !important; /* 기존 마진 강제 제거 */
}

/* 3. 내부 텍스트 스타일 */
#alert-msg, 
#letter-text, 
#info-desc {
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-color);
}

/* 4. 팝업 내 버튼 스타일 */
#alert-modal button,
#letter-modal button,
#item-info-modal button {
    background-color: var(--pastel-pink);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'MyGameFont';
    font-size: 16px;
    box-shadow: 0 4px 0 var(--border-pink); /* 버튼 입체감 */
    transition: transform 0.1s;
    margin-top: 5px;
}

/* 버튼 마우스 올렸을 때 효과 */
#alert-modal button:hover,
#letter-modal button:hover,
#item-info-modal button:hover {
    transform: translateY(-2px);
    background-color: var(--deep-pink);
}

/* =========================================
   [추가] 날씨 효과 오버레이
   ========================================= */

/* 공통 설정: 위치 잡기 및 클릭 통과시키기 */
#location-view.weather-rain::after,
#location-view.weather-blossom::after {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: cover;      /* 화면에 꽉 차게 */
    background-position: center;
    pointer-events: none;        /* 효과 위를 클릭해도 아래 아이템이 눌리도록 설정 */
    z-index: 5;                  /* 배경(0)보다 위, NPC(10)보다 아래 */
}

/* 1. 비 오는 날: 어두운 배경 + 비 GIF */
#location-view.weather-rain::after {
    background-color: rgba(0, 0, 0, 0.3); /* 검은색 30% 투명도 (화면 어둡게) */
    background-image: url('../assets/effects/rain.gif');
    opacity: 0.7; /* 너무 진하면 조절하세요 */
}

/* 2. 벚꽃 날리는 날: 분홍빛 배경 + 벚꽃 GIF */
#location-view.weather-blossom::after {
    background-color: rgba(255, 192, 203, 0.15); /* 연한 핑크색 틴트 */
    background-image: url('../assets/effects/blossom.gif');
}

/* js/style.css 파일 맨 아래에 추가 */

/* 페이드 아웃/인 효과를 위한 오버레이 */
#fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 9999;
    opacity: 0;
    pointer-events: none; /* 평소에는 클릭 방해 안 함 */
    transition: opacity 1s ease; /* 1초 동안 부드럽게 변함 */
}

/* 화면을 가릴 때 붙일 클래스 */
#fade-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

* {
    cursor: url('../assets/images/ui/star_cursor.png'), auto !important;
}







