/* 기본 리셋 및 폰트 설정 */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Malgun Gothic', sans-serif; }
body { background-color: #333; display: flex; justify-content: center; height: 100vh; overflow: hidden; }

/* 모바일 화면 컨테이너 */
#game-container {
    width: 100%;
    max-width: 450px; /* PC에서 봐도 모바일 크기 유지 */
    height: 100%;
    background-color: #b2c7d9; /* 카카오톡 배경색 */
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 상단 헤더 */
header {
    background-color: #fff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 10;
}
#ui-title { font-size: 1.2rem; font-weight: bold; }

/* 호감도 게이지 바 */
#affinity-bar-container {
    height: 5px; background-color: #ddd; width: 100%;
}
#affinity-bar {
    height: 100%; background-color: #ff6b81; transition: width 0.5s ease-out;
}

/* 채팅 영역 */
#chat-box {
    flex: 1; /* 남는 공간 꽉 채우기 */
    padding: 20px 15px;
    overflow-y: auto; /* 내용이 넘치면 스크롤 */
    display: flex;
    flex-direction: column;
    gap: 15px; /* 말풍선 사이 간격 */
}

/* --- 말풍선 공통 및 개별 스타일 --- */
.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: fadeIn 0.3s ease-in-out; /* 등장 애니메이션 */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 히로인(상대방) 말풍선 (왼쪽 정렬, 흰색) */
.message.heroine { align-self: flex-start; }
.message.heroine .bubble { background-color: #ffffff; border-radius: 15px 15px 15px 0; }
.speaker-name { font-size: 0.8rem; margin-bottom: 5px; color: #555; }

/* 주인공(나) 말풍선 (오른쪽 정렬, 노란색) */
.message.player { align-self: flex-end; }
.message.player .bubble { background-color: #fef01b; border-radius: 15px 15px 0 15px; }

/* 시스템 메시지 (중앙 정렬, 반투명 회색) */
.message.system { align-self: center; max-width: 90%; }
.message.system .bubble { background-color: rgba(0,0,0,0.2); color: white; border-radius: 20px; font-size: 0.9rem; text-align: center; }

/* 말풍선 안쪽 텍스트 여백 */
.bubble { padding: 10px 15px; font-size: 1rem; line-height: 1.4; word-break: keep-all; }

/* 하단 버튼 영역 */
footer { padding: 15px; background-color: #f9f9f9; text-align: center; }
#next-btn {
    width: 100%; padding: 15px; border: none; border-radius: 10px;
    background-color: #fef01b; font-size: 1.1rem; font-weight: bold; cursor: pointer;
} /* ✅ 빠져있던 중괄호 추가 완료 */

#next-btn:active { background-color: #e5d818; }

/* 화면 공통 */
.screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* 시작 화면 디자인 */
#title-screen {
    background: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)), url('../assets/images/title_bg.jpg');
    background-size: cover;
    justify-content: center;
    align-items: center;
}
.title-content h1 { color: white; font-size: 2.5rem; margin-bottom: 50px; text-shadow: 2px 2px 10px rgba(0,0,0,0.5); }
.menu-buttons { display: flex; flex-direction: column; gap: 15px; width: 200px; }
.main-btn { padding: 15px; border-radius: 30px; border: none; background: white; font-weight: bold; cursor: pointer; transition: 0.3s; }
.main-btn:hover { transform: scale(1.05); background: #ffb6c1; }

/* 캐릭터 선택창 캐릭터 카드 */
#character-list { padding: 20px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.char-card {
    display: flex; align-items: center; background: white; padding: 15px;
    border-radius: 15px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); cursor: pointer;
}
.char-img { width: 70px; height: 70px; border-radius: 50%; background: #eee; margin-right: 15px; }
.char-info h3 { margin-bottom: 5px; }
.char-info p { font-size: 0.8rem; color: #888; }

/* 모달 스타일 */
.modal { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: flex; justify-content: center; align-items: center; z-index: 100; }
.modal-content { background: white; padding: 30px; border-radius: 20px; width: 80%; }

/* 컷씬 뷰어 스타일 */
#cutscene-viewer { position: absolute; top:0; left:0; z-index: 200; }
#illustration-container { width: 100%; height: 100%; position: relative; }
#cutscene-image { width: 100%; height: 100%; object-fit: cover; }
#cutscene-script-box {
    position: absolute; bottom: 50px; width: 90%; left: 5%;
    background: rgba(0,0,0,0.7); color: white; padding: 20px; border-radius: 15px;
    text-align: center;
}
#cutscene-close-btn { margin-top: 15px; padding: 5px 20px; border-radius: 10px; border: none; cursor: pointer; }

/* 해금 팝업 버튼들 */
.modal-btns { display: flex; gap: 10px; margin-top: 20px; }
.modal-btns button { flex: 1; padding: 10px; border-radius: 10px; border: none; cursor: pointer; font-weight: bold; }
#ad-unlock-btn { background: #fef01b; }

/* --- 컷씬 미리보기 (채팅창 내부) --- */
.cg-thumbnail {
    width: 200px; max-width: 100%; border-radius: 10px; cursor: pointer;
    position: relative; overflow: hidden; margin-top: 10px; border: 2px solid #ddd;
}
.cg-thumbnail img {
    width: 100%; display: block; transition: filter 0.3s;
}
/* 잠긴 상태일 때 블러 처리 */
.cg-locked img {
    filter: blur(8px) brightness(0.6);
}
/* 자물쇠 아이콘 */
.lock-icon {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 2rem; color: rgba(255,255,255,0.8); display: none; text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.cg-locked .lock-icon { display: block; }

/* --- 클리어 도장 (캐릭터 선택창) --- */
.char-card { position: relative; } /* 기존 카드에 기준점 추가 */
.clear-stamp {
    position: absolute; right: 15px; top: 15px;
    color: #ff4757; border: 3px solid #ff4757; border-radius: 8px;
    padding: 3px 8px; font-weight: 900; font-size: 0.9rem;
    transform: rotate(-15deg); letter-spacing: 1px;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.8);
    box-shadow: 0 0 5px rgba(255,71,87,0.3);
}
/* --- 캐릭터 카드 슬라이더 (Carousel) --- */
#character-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory; /* 카드에 자석처럼 스크롤이 붙게 함 */
    gap: 15px;
    padding: 30px 20px;
    height: 100%;
    align-items: center;
    /* 스크롤바 숨기기 */
    -ms-overflow-style: none; scrollbar-width: none;
}
#character-carousel::-webkit-scrollbar { display: none; }

.char-card-new {
    flex: 0 0 82%; /* 카드가 화면의 82%만 차지해서 다음 카드가 살짝 보이게 함 */
    scroll-snap-align: center; /* 스크롤 시 화면 중앙에 맞춤 */
    background: white;
    border-radius: 20px;
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    position: relative;
}

/* --- 캐릭터 카드 프로필 사진 (동그라미 -> 큰 3:4 직사각형으로 변경) --- */
.char-profile-img {
    width: 100%; /* 카드 가로폭에 꽉 차게 */
    aspect-ratio: 4 / 3; /* 3:4 세로형 비율 (옷차림이 잘 보이도록) */
    /* ※ 가로형 4:3을 원하시면 aspect-ratio: 4 / 3; 으로 변경하세요! */
    border-radius: 15px; /* 부드러운 둥근 사각형 */
    object-fit: cover;
    border: 2px solid #ffb6c1;
    margin-bottom: 15px;
    background-color: #eee;
}

/* --- PC용 좌우 이동 화살표 버튼 --- */
.nav-arrow {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px; height: 40px;
    font-size: 1.2rem;
    color: #555;
    cursor: pointer;
    position: absolute;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: transform 0.2s;
    display: flex; justify-content: center; align-items: center;
}
.nav-arrow:hover { transform: scale(1.1); color: #ff6b81; }
#prev-char-btn { left: 10px; }
#next-char-btn { right: 10px; }

/* 카드 내 정보 텍스트 */
.char-info-box { width: 100%; text-align: left; margin-bottom: 20px; }
.char-info-box h3 { font-size: 1.5rem; text-align: center; margin-bottom: 5px; }
.char-info-box .tags { color: #ff6b81; font-weight: bold; text-align: center; font-size: 0.9rem; margin-bottom: 15px; }
.info-row { display: flex; justify-content: space-between; border-bottom: 1px solid #f0f0f0; padding: 8px 0; font-size: 0.95rem; color: #555; }
.info-row span:first-child { font-weight: bold; color: #333; }

/* 카드 내 버튼들 */
.char-action-btns { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.btn-chat { background: #fef01b; padding: 15px; border-radius: 12px; border: none; font-weight: bold; font-size: 1.1rem; cursor: pointer; }
.btn-gallery { background: #e0e0e0; padding: 12px; border-radius: 12px; border: none; font-weight: bold; cursor: pointer; }

/* --- 도감 (Gallery) 화면 --- */
#gallery-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
    padding: 20px; overflow-y: auto; align-content: start; height: 100%;
}
.gallery-item {
    width: 100%; aspect-ratio: 1; border-radius: 10px; object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); cursor: pointer;
}
.locked-gallery {
    width: 100%; aspect-ratio: 1; border-radius: 10px; background: #ddd;
    display: flex; justify-content: center; align-items: center; color: #999; font-size: 2rem;
}
