/* 1. Root 변수 및 기본 설정 */
:root {
    --moa-red: #C8102E; 
    --moa-red-dark: #A50D26;
    --moa-gold: #FFCD00; 
    --moa-dark: #1A1A1B;
    --moa-light: #F8F9FA; 
    --moa-soft-yellow: #FFF9E6;
}

body { 
    background-color: var(--moa-light); 
    font-family: 'Pretendard', -apple-system, sans-serif; 
    color: var(--moa-dark); 
    line-height: 1.6;
}

/* 2. 네비바 & 메인 메뉴 (시원한 간격) */
.navbar-brand { color: var(--moa-red) !important; font-weight: 900; letter-spacing: -1px; }

.nav-link { 
    font-weight: 600; color: #444 !important; transition: 0.2s; 
    padding-left: 1.4rem !important; 
    padding-right: 1.4rem !important; 
    padding-top: 0.8rem !important;
    padding-bottom: 0.8rem !important;
}
.nav-link:hover { color: var(--moa-red) !important; }

/* 3. 드롭다운 서브 메뉴 */
.dropdown-menu { 
    border: none; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); 
    border-radius: 18px; 
    padding: 12px; 
}
.dropdown-item { 
    padding: 10px 18px; 
    margin-bottom: 4px; 
    border-radius: 10px; 
    font-weight: 500; 
    transition: 0.2s; 
}
.dropdown-item:last-child { margin-bottom: 0; }
.dropdown-item:hover { background-color: var(--moa-soft-yellow); color: var(--moa-red); }

/* 4. 뉴스 리스트 & 유틸리티 */
.nav-pills .nav-link.active { background-color: var(--moa-red) !important; color: var(--moa-gold) !important; }
.nav-pills .nav-link { color: #666; transition: 0.3s; }

.hover-card { transition: all 0.3s ease; border-bottom: 3px solid transparent !important; }
.hover-card:hover { 
    transform: translateY(-8px); 
    box-shadow: 0 10px 20px rgba(0,0,0,0.1) !important; 
    border-bottom: 3px solid var(--moa-red) !important; 
}

/* 5. 뉴스 상세 본문 가독성 */
.news-content { font-size: 1.1rem; line-height: 1.8; color: #333; word-break: break-word; }
.news-content img { 
    max-width: 100%; height: auto; border-radius: 12px; 
    margin: 20px 0; box-shadow: 0 5px 15px rgba(0,0,0,0.05); 
}
.line-height-base { line-height: 1.4; }

/* 6. 공통 버튼 및 투표 기능 */
.btn-vn { background-color: var(--moa-red); color: white !important; font-weight: bold; border-radius: 50px; }
.btn-vn:hover { background-color: var(--moa-red-dark); }
.vote-btn { transition: all 0.2s ease; cursor: pointer; border: 1px solid #eee; background: #fff; }
.vote-btn:hover { transform: scale(1.05); background-color: var(--moa-soft-yellow); }
.vote-btn:active { transform: scale(0.95); }

/* 7. 지도 및 카드 유틸리티 */
.rounded-4 { border-radius: 1.2rem !important; }
.transition { transition: 0.3s; }
.hover-info { transition: 0.3s; cursor: pointer; }
.hover-info:hover { background-color: #fff !important; box-shadow: 0 5px 15px rgba(0,0,0,0.08); transform: translateY(-3px); }

/* 말줄임 처리 */
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.text-truncate-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* 애니메이션 */
.pulse { animation: pulse-animation 2s infinite; }
@keyframes pulse-animation {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* 8. 페이지네이션 */
.page-item.active .page-link { background-color: var(--moa-red); border-color: var(--moa-red); color: #fff; }
.page-link { color: var(--moa-red); }

/* 9. 푸터 (Footer) */
.footer { background-color: #ffffff; color: #6c757d; padding: 50px 0; border-top: 1px solid #eee; margin-top: 60px; font-size: 0.85rem; }
.footer-logo { color: #dee2e6; font-weight: 900; font-size: 1.5rem; margin-bottom: 20px; display: block; }
.footer-links a { color: #495057; text-decoration: none; margin-right: 20px; font-weight: 600; }
.footer-links a:hover { color: var(--moa-red); }
.footer-info { line-height: 2; margin-top: 20px; }
.copyright { margin-top: 30px; color: #adb5bd; border-top: 1px solid #f8f9fa; padding-top: 20px; }

/* 10. 반응형 및 데스크탑 전용 */
@media (max-width: 768px) {
    .news-content { font-size: 1rem; }
    .nav-link { padding-left: 0.8rem !important; padding-right: 0.8rem !important; }
}

@media (min-width: 992px) {
    .nav-item.dropdown:hover > .dropdown-menu { display: block; margin-top: -5px; animation: fadeInDown 0.3s ease-out; }
    /* 호버 시 브릿지 역할 */
    .nav-item.dropdown::after { content: ""; position: absolute; bottom: -15px; left: 0; width: 100%; height: 20px; }
}

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

/* --------------------------------------------------
   병원 리스트 전용 스타일
-------------------------------------------------- */
.bg-success-subtle { background-color: #e8f5e9 !important; }
.text-success { color: #2e7d32 !important; }
.border-primary-subtle { border-color: #cfe2ff !important; }
.bg-primary-subtle { background-color: #e7f1ff !important; }

/* 공통 카드 효과 (이미 추가됨) */
.hover-shadow:hover { 
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.1) !important; 
    transform: translateY(-3px); 
}
.rounded-4 { border-radius: 1.2rem !important; }
.transition { transition: 0.3s ease-in-out; }

/* --------------------------------------------------
   지도 인포윈도우 디자인 커스텀
-------------------------------------------------- */
.moa-iw-content { padding:15px; width:220px; font-family: 'Pretendard', sans-serif; }
.moa-iw-title { font-size:15px; font-weight:bold; color:var(--moa-red); margin-bottom:10px; }
.moa-iw-btns { display: flex; flex-direction: column; gap: 6px; }
.moa-iw-btn { display:block; text-align:center; padding:8px; color:#fff; text-decoration:none; border-radius:6px; font-size:12px; font-weight:bold; }

/* --------------------------------------------------
   맛집 & 핫플 전용 (Orange Theme)
-------------------------------------------------- */
.text-orange { color: #e67e22 !important; }
.btn-orange { background-color: #e67e22 !important; border-color: #e67e22 !important; color: #fff !important; }
.btn-orange:hover { background-color: #d35400 !important; color: #fff !important; }
.bg-orange-subtle { background-color: rgba(230, 126, 34, 0.1) !important; }
.border-orange-subtle { border-color: rgba(230, 126, 34, 0.3) !important; }

/* 공통 호버 섀도우 (오렌지 버전) */
.hover-shadow-orange:hover { 
    box-shadow: 0 0.7rem 1.5rem rgba(230, 126, 34, 0.15) !important; 
    transform: translateY(-5px); 
}

/* --------------------------------------------------
   회원가입/로그인 전용 스타일 (Form)
-------------------------------------------------- */
.form-control-lg { border-radius: 12px; font-size: 1rem; }
.form-control:focus { 
    border-color: var(--moa-gold); 
    box-shadow: 0 0 0 0.25rem rgba(255, 205, 0, 0.25); 
}

/* 주황색 버튼 (이미 사용 중인 경우 중복 확인) */
.btn-orange { 
    background-color: #ff9800 !important; 
    border-color: #ff9800 !important; 
    color: white !important; 
    border-radius: 12px;
}
.btn-orange:hover { background-color: #f57c00 !important; }
.btn-orange:disabled { background-color: #ffcc80 !important; border-color: #ffcc80 !important; }

/* 유효성 메시지 간격 */
.form-label.small { font-size: 0.8rem; margin-bottom: 0.4rem; }

/* --------------------------------------------------
   게시판 리스트 (Board List)
-------------------------------------------------- */
.board-list-item { 
    transition: background-color 0.2s ease; 
    border-bottom: 1px solid rgba(0,0,0,0.05) !important; 
}
.board-list-item:hover { background-color: var(--moa-soft-yellow); }
.board-list-item:last-child { border-bottom: 0 !important; }

/* 베트남어 서브 타이틀 스타일 */
.board-title-vn { 
    font-size: 0.85rem; 
    color: var(--moa-red); 
    font-weight: 500; 
    margin-bottom: 2px;
}

/* 추천 배지 커스텀 */
.badge-good {
    background-color: #e7f1ff;
    color: #0d6efd;
    border-radius: 50px;
    padding: 0.5rem 0.8rem;
    font-size: 0.75rem;
}

/* 페이지네이션 (moaviet 테마) */
.pagination-moa .page-link { color: var(--moa-dark); border: none; margin: 0 2px; border-radius: 8px; }
.pagination-moa .page-item.active .page-link { 
    background-color: var(--moa-red); 
    color: white; 
}

/* --------------------------------------------------
   게시판 본문 (Post View)
-------------------------------------------------- */
.post-view-title { font-size: 1.75rem; line-height: 1.4; word-break: keep-all; }
.post-meta { font-size: 0.85rem; color: #888; }
.post-content { 
    font-size: 1.05rem; 
    line-height: 1.9; 
    color: #333; 
    min-height: 250px;
}
.post-content img { 
    max-width: 100%; 
    height: auto; 
    border-radius: 15px; 
    margin: 25px 0; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

/* 언어 전환 탭 커스텀 */
.moa-lang-tabs { background-color: #f1f3f5 !important; padding: 5px !important; }
.moa-lang-tabs .nav-link { color: #666; border: none !important; transition: 0.3s; }
.moa-lang-tabs .nav-link.active { 
    background-color: white !important; 
    color: var(--moa-red) !important; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* 댓글 섹션 */
.comment-item { border-bottom: 1px solid #f1f3f5; transition: 0.2s; }
.comment-item:last-child { border-bottom: none; }
.comment-avatar { 
    width: 40px; height: 40px; 
    background-color: #e9ecef; 
    color: #adb5bd;
    border-radius: 50%; 
    display: flex; align-items: center; justify-content: center;
}
.comment-form { background-color: #f8f9fa; border-radius: 15px; border: 1px solid #eee; }

/* --------------------------------------------------
   글쓰기 페이지 (Board Write)
-------------------------------------------------- */
/* CKEditor 커스텀 */
.ck-editor__editable { 
    min-height: 400px; 
    border-radius: 0 0 15px 15px !important; 
    border-color: #eee !important;
}
.ck-toolbar { 
    border-radius: 15px 15px 0 0 !important; 
    background-color: #f8f9fa !important; 
    border-color: #eee !important;
}

/* 입력창 포커스 효과 (Moa 테마) */
.form-control-moa {
    border: 1px solid #eee;
    background-color: #f8f9fa;
    transition: 0.3s;
}
.form-control-moa:focus {
    background-color: #fff;
    border-color: var(--moa-gold);
    box-shadow: 0 0 0 0.25rem rgba(255, 205, 0, 0.15);
}

/* 유튜브/첨부파일 영역 */
.write-addon-box {
    background-color: #fff;
    border: 1px dashed #ddd;
    border-radius: 15px;
    padding: 20px;
    transition: 0.3s;
}
.write-addon-box:focus-within {
    border-color: var(--moa-red);
    background-color: #fff5f5;
}

/* --------------------------------------------------
   실생활 회화 (Education / Conversation)
-------------------------------------------------- */
.conv-page { background-color: #f1f3f5; min-height: 100vh; }

/* 스티키 필터 섹션 */
.filter-section { 
    background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(10px); 
    border-bottom: 1px solid #eee; 
    padding: 15px 0; 
    position: sticky; 
    top: 56px; /* 네비바 높이에 맞게 조절 */
    z-index: 100; 
}

/* 대화 카드 스타일 */
.conv-item { 
    border-radius: 20px; 
    border: 1px solid rgba(0,0,0,0.05); 
    transition: 0.2s; 
    background: #fff; 
    margin-bottom: 15px; 
}
.conv-item:hover { transform: translateY(-3px); box-shadow: 0 8px 15px rgba(0,0,0,0.05) !important; }

/* 재생 버튼 */
.btn-play-sm { 
    width: 42px; height: 42px; 
    border-radius: 50%; 
    border: none; 
    display: flex; align-items: center; justify-content: center; 
    transition: 0.2s; 
}
.btn-ko-sm { background: #e7f1ff; color: #0d6efd; }
.btn-ko-sm:active { background: #0d6efd; color: #fff; }
.btn-vi-sm { background: #fff0f0; color: var(--moa-red); }
.btn-vi-sm:active { background: var(--moa-red); color: #fff; }

/* 상황 태그 및 난이도 */
.situation-tag { 
    font-size: 0.75rem; 
    color: var(--moa-red); 
    font-weight: bold; 
    background: var(--moa-soft-yellow); 
    padding: 3px 12px; 
    border-radius: 50px; 
}
.level-badge { font-size: 0.7rem; padding: 3px 8px; border-radius: 6px; font-weight: 500; }

/* --------------------------------------------------
   낱말 찾기 게임 (Word Search Game)
-------------------------------------------------- */
.game-container { max-width: 500px; margin: 0 auto; user-select: none; -webkit-user-select: none; }

.grid-container {
    display: grid;
    grid-template-columns: repeat(10, 1fr); 
    gap: 4px;
    background: #fff;
    padding: 10px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    touch-action: none; /* 드래그 시 화면 밀림 방지 */
}

.grid-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--moa-dark);
    transition: 0.1s;
    cursor: pointer;
}

/* 선택 중인 칸 */
.grid-cell.selected { 
    background: var(--moa-gold) !important; 
    color: #000; 
    transform: scale(1.1);
    z-index: 2;
}

/* 이미 찾은 단어 */
.grid-cell.found { 
    background: #e7f1ff !important; 
    color: #0d6efd; 
    border: 2px solid #0d6efd;
}

/* 힌트 단어 목록 */
.hint-badge { 
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.hint-badge.done { 
    background: #f1f3f5;
    color: #adb5bd;
    text-decoration: line-through;
    box-shadow: none;
}

/* --------------------------------------------------
   단어 낚시 게임 (Fishing Game)
-------------------------------------------------- */
.sea-container { 
    max-width: 600px; 
    margin: 0 auto; 
    position: relative; 
    background-color: #e0f7fa;
    border-radius: 30px;
    padding: 15px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
}

.sea-area {
    width: 100%; 
    height: 60vh; 
    background: linear-gradient(to bottom, #4fc3f7 0%, #0288d1 100%);
    border-radius: 25px; 
    position: relative; 
    overflow: hidden; 
    border: 6px solid #fff;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.2);
}

/* 목표 단어 보드 (목패 느낌) */
.target-board {
    background: #fff; 
    padding: 12px; 
    border-radius: 20px; 
    text-align: center;
    border-bottom: 5px solid var(--moa-red);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
#targetMeaning { font-size: 1.8rem; font-weight: 900; color: var(--moa-red); }

/* 물고기(단어) 스타일 */
.fish {
    position: absolute; 
    padding: 6px 15px; 
    background: rgba(255, 255, 255, 0.95); 
    border-radius: 50px;
    font-weight: 800; 
    cursor: pointer; 
    white-space: nowrap; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    display: flex; 
    align-items: center; 
    gap: 8px; 
    z-index: 10;
    border: 2px solid #fff;
    transition: transform 0.2s;
}
.fish:hover { transform: scale(1.1); }
.fish img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: #eee; }

/* 애니메이션 정의 */
@keyframes swimRight { from { left: -150px; } to { left: 110%; } }
@keyframes swimLeft { from { left: 110%; } to { left: -150px; } }

/* --------------------------------------------------
   그림 퀴즈 게임 (Flashcard Quiz)
-------------------------------------------------- */
.quiz-container { max-width: 480px; margin: 0 auto; position: relative; }

/* 퀴즈 이미지 카드 */
.quiz-card {
    position: relative; /* 자식 요소인 베트남어 텍스트의 기준이 됩니다 */
    width: 100%;
    height: 350px;
    background: #f8f9fa;
    border-radius: 20px;
    overflow: hidden; /* 이미지가 밖으로 삐져나오지 않게 합니다 */
    display: flex;
    align-items: center;
    justify-content: center;
    border: 5px solid white;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

/* 4. 실제 이미지 스타일 */
.quiz-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 1; /* 텍스트 오버레이(10)보다 낮게 설정 */
    transition: opacity 0.3s;
}

/* [추가] 이미지 뒤에 보조 배경 (블러 효과) - 선택사항 */
#imageWrapper::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    /* 💡 이미지가 세로로 길어 옆이 비면 배경에 블러를 살짝 줍니다 */
    background-image: var(--bg-img);
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.8);
    opacity: 0.3;
    z-index: 0;
}

#quizImg {
    position: relative;
    z-index: 1;
}
/* 2. 베트남어 텍스트 오버레이 (이미지 위로 올리기) */
.vi-text-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.6); /* 반투명 검정 배경으로 글씨 선명하게 */
    color: white;
    text-align: center;
    padding: 12px 5px;
    font-size: 1.2rem;
    font-weight: 800;
    z-index: 10; /* 💡 이미지보다 높은 숫자를 주어 위로 올립니다 */
    backdrop-filter: blur(5px); /* 배경을 살짝 흐리게 해서 고급스럽게 */
}

/* 3. 오답 메시지 팝업 (화면 정중앙 고정) */
#wrongMsg {
    position: fixed; /* 💡 스크롤과 상관없이 화면에 고정 */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* 💡 정확히 정중앙으로 이동 */
    background: rgba(220, 53, 69, 0.95); /* Moa Red 계열 */
    color: white;
    padding: 20px 40px;
    border-radius: 50px;
    font-size: 1.5rem;
    font-weight: 900;
    z-index: 9999; /* 💡 최상단에 뜨도록 아주 높은 숫자 부여 */
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    pointer-events: none; /* 메시지가 떠 있을 때 클릭 방해 금지 */
}

/* 4열 선택지 그리드 */
.options-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    gap: 8px;
}

.option-btn {
    padding: 15px 2px;
    border: 2px solid #eee;
    border-radius: 12px;
    background: white;
    font-size: 0.9rem;
    font-weight: 800;
    transition: 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    color: var(--moa-dark);
}
/* 정답/오답 피드백 */
.option-btn.correct { background-color: #28a745 !important; color: white !important; border-color: #28a745 !important; }
.option-btn.wrong { background-color: var(--moa-red) !important; color: white !important; border-color: var(--moa-red) !important; opacity: 0.5; }

/* --------------------------------------------------
   듣기 퀴즈 게임 (Listening Quiz)
-------------------------------------------------- */
/* 중앙 오디오 카드 */
.audio-card {
    background: white; 
    border-radius: 25px; 
    padding: 50px 20px;
    text-align: center; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    margin: 20px 0; 
    border: 5px solid white; 
    transition: all 0.3s;
    cursor: pointer;
}

/* 재생 중일 때 금색 테두리 효과 */
.audio-card.playing {
    border-color: var(--moa-gold);
    transform: scale(1.02);
}

.speaker-icon { 
    font-size: 5rem; 
    color: var(--moa-red); 
}

/* 소리가 나갈 때 파동 애니메이션 */
.audio-card.playing .speaker-icon {
    animation: speaker-pulse 1s infinite;
}

@keyframes speaker-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

/* 상단 스탯 배지 (공통 스타일 활용) */
.badge-item { 
    font-weight: 700; 
    font-size: 0.85rem; 
    padding: 5px 15px; 
    border-radius: 50px; 
}
.badge-best { background: var(--moa-gold); color: #000; }
.badge-now { background: #fff; color: var(--moa-red); border: 1px solid #eee; }

/* --------------------------------------------------
   짝 맞추기 게임 (Matching Game)
-------------------------------------------------- */
.match-page { background-color: #fffafb; min-height: 100vh; }

/* 기록판 보드 */
.record-board {
    background: #fff;
    border-radius: 20px;
    padding: 15px;
    border: 2px solid var(--moa-soft-yellow);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.timer-badge {
    background: var(--moa-red);
    color: #fff;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 900;
    box-shadow: 0 4px 10px rgba(200, 16, 46, 0.2);
}

/* 매칭 카드 스타일 */
.match-card {
    background: white; 
    border: 2px solid #eee; 
    border-radius: 15px;
    padding: 18px 10px; 
    text-align: center; 
    font-weight: 700; 
    cursor: pointer;
    min-height: 70px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.03); 
    font-size: 1rem;
    transition: 0.2s;
    user-select: none;
}

/* 카드 상태별 스타일 */
.match-card.selected { 
    background: var(--moa-gold) !important; 
    border-color: var(--moa-gold) !important; 
    color: #000; 
    transform: scale(1.05);
    z-index: 5;
}
.match-card.matched { 
    background: #f8f9fa !important; 
    color: #dee2e6 !important; 
    border-color: #f1f3f5 !important; 
    pointer-events: none; 
}
.match-card.error { 
    background: #fff5f5 !important;
    border-color: var(--moa-red) !important;
    animation: shake 0.4s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* --------------------------------------------------
   카드 뒤집기 게임 (Memory Game)
-------------------------------------------------- */
.memory-page { background-color: #fcfcfc; min-height: 100vh; }

/* 카드 그리드 레이아웃 */
.memory-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 10px; 
    perspective: 1000px; 
}

/* 카드 본체 */
.memory-card { 
    aspect-ratio: 3 / 4; 
    position: relative; 
    transform-style: preserve-3d; 
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    cursor: pointer; 
}
.memory-card.flipped { transform: rotateY(180deg); }

/* 카드 앞/뒷면 공통 */
.card-face { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    backface-visibility: hidden; 
    border-radius: 15px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); 
    border: 2px solid #fff; 
}

/* 카드 앞면 (숨겨진 상태 - Moa Red) */
.card-front { 
    background: linear-gradient(135deg, var(--moa-red), var(--moa-red-dark)); 
    color: var(--moa-gold); 
}
.card-front i { font-size: 2.5rem; filter: drop-shadow(0 0 8px rgba(255,205,0,0.5)); }

/* 카드 뒷면 (공개된 상태 - White) */
.card-back { 
    background: #fff; 
    transform: rotateY(180deg); 
    border: 3px solid var(--moa-red); 
    overflow: hidden; 
}
.card-back img { width: 100%; height: 100%; object-fit: cover; }
.card-back.text-only { 
    padding: 5px; 
    text-align: center; 
    font-weight: 800; 
    font-size: 1rem; 
    color: var(--moa-dark); 
    word-break: keep-all; 
}

/* 매칭 성공 효과 */
.memory-card.matched .card-face { 
    border-color: #28a745 !important; 
    animation: matched-bounce 0.6s; 
}

@keyframes matched-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* --------------------------------------------------
   귀화 시험 준비 (Naturalization Study)
-------------------------------------------------- */
.quiz-page { background-color: #fcfcfc; min-height: 100vh; }

/* 진행 상태 바 */
.moa-progress-container { width: 100%; background: #eee; height: 6px; border-radius: 10px; overflow: hidden; }
.moa-progress-bar { 
    height: 100%; background: linear-gradient(to right, var(--moa-red), var(--moa-gold)); 
    transition: width 0.4s ease; 
}

/* 퀴즈 카드 스타일 */
.card-quiz { 
    border: none; border-radius: 30px; 
    box-shadow: 0 15px 35px rgba(0,0,0,0.06); 
    min-height: 500px; background: #fff; 
    position: relative; overflow: hidden;
}

/* 배경 질문 번호 */
.q-number-bg { 
    color: rgba(200, 16, 46, 0.05); 
    font-size: 6rem; font-weight: 900; 
    position: absolute; top: -10px; right: 20px; 
}

/* 오디오 버튼 유틸리티 */
.btn-audio-moa {
    width: 60px; height: 60px; border-radius: 50%; border: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 6px 15px rgba(0,0,0,0.1); transition: 0.2s;
}
.btn-audio-moa:active { transform: scale(0.9); }
.btn-audio-moa i { font-size: 1.5rem; }
.btn-audio-moa span { font-size: 0.65rem; font-weight: bold; margin-top: -2px; }

/* 정답 영역 애니메이션 */
.answer-box {
    background: #fffcf0; border-radius: 20px; 
    padding: 25px; border: 2px dashed var(--moa-gold);
    animation: slideUp 0.4s ease-out;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* --------------------------------------------------
   조사 끼워넣기 게임 (Particle Quiz)
-------------------------------------------------- */
.particle-page { background-color: #fcfcfc; min-height: 100vh; }

/* 문장 카드박스 */
.particle-card {
    background: #fff; 
    border-radius: 25px; 
    padding: 30px 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05); 
    border: 1px solid #eee;
    margin-bottom: 25px;
    text-align: center;
}

/* 베트남어 뜻 강조 */
.meaning-box {
    background-color: var(--moa-soft-yellow);
    color: var(--moa-red);
    padding: 10px 15px;
    border-radius: 15px;
    font-weight: 700;
    display: inline-block;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* 한국어 문장 내 빈칸 */
.particle-sentence {
    font-size: 1.5rem; 
    font-weight: 800; 
    line-height: 1.8;
    color: var(--moa-dark);
}
.particle-blank { 
    color: var(--moa-red); 
    border-bottom: 3px solid var(--moa-red); 
    padding: 0 12px; 
    min-width: 70px; 
    display: inline-block; 
    transition: 0.3s;
}

/* 선택 버튼 그리드 */
.particle-options { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
}
.btn-particle-opt {
    padding: 18px; 
    background: #fff; 
    border: 2px solid #eee;
    border-radius: 15px; 
    font-size: 1.2rem; 
    font-weight: 800;
    box-shadow: 0 4px 6px rgba(0,0,0,0.03);
    transition: 0.2s;
}
/* 정답/오답 상태 */
.btn-particle-opt.correct { background: #28a745 !important; color: #fff !important; border-color: #28a745 !important; }
.btn-particle-opt.wrong { background: #fff5f5 !important; color: var(--moa-red) !important; border-color: var(--moa-red) !important; opacity: 0.6; }

/* --------------------------------------------------
   단어 소나기 게임 (Word Rain Game)
-------------------------------------------------- */
.rain-page { background: linear-gradient(to bottom, #e3f2fd, #bbdefb); overflow: hidden; touch-action: none; }

/* 상단 정보바 커스텀 */
.game-top-bar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 3px solid var(--moa-red);
    padding: 10px;
    z-index: 50;
}

/* 목표 단어 박스 (황금색 강조) */
.target-display-box {
    background: var(--moa-soft-yellow);
    border: 2px solid var(--moa-gold);
    border-radius: 15px;
    padding: 8px 15px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
#targetWordKo { font-size: 1.6rem; font-weight: 900; color: var(--moa-red); line-height: 1.2; }
#targetWordVi { font-size: 0.9rem; color: #666; font-weight: 600; }

/* 떨어지는 단어 물방울 */
.word-drop {
    position: absolute;
    background: #fff;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--moa-dark);
    white-space: nowrap;
    border: 2px solid #fff;
    cursor: pointer;
    z-index: 10;
    user-select: none;
}

/* 라이프 하트 애니메이션 */
.life-hearts i { transition: 0.3s; margin-left: 2px; }
.heart-lost { color: #dee2e6 !important; transform: scale(0.8); }

/* --------------------------------------------------
   스피드 퀴즈 (Speed Quiz)
-------------------------------------------------- */
.speed-page { background-color: #f8f9fa; min-height: 100vh; }

/* 타이머 바 컨테이너 */
.speed-timer-container {
    width: 100%; height: 14px; 
    background: #e9ecef; 
    border-radius: 50px; 
    overflow: hidden; 
    border: 3px solid #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* 타이머 진행바 (황금색 -> 빨간색 그라데이션) */
.speed-timer-bar { 
    width: 100%; height: 100%; 
    background: linear-gradient(90deg, var(--moa-gold), var(--moa-red)); 
    transition: width 0.1s linear; 
}

/* 문제 카드 박스 */
.speed-q-card {
    position: relative; /* 💡 오버레이의 기준점 */
    background: #fff;
    border-radius: 25px;
    min-height: 250px; /* 💡 높이를 충분히 확보 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
}
/* 시작 오버레이 - 확실하게 위를 덮도록 */
    #startOverlay {
        position: absolute;
        top: 0; left: 0; width: 100%; height: 100%;
        background: white;
        z-index: 100; /* 💡 가장 위에 표시 */
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        transition: opacity 0.3s;
    }

    /* 문제 텍스트 - 오버레이가 사라진 후 보여야 함 */
    .speed-q-vi {
        font-size: 2rem;
        font-weight: 900;
        color: var(--moa-red);
        z-index: 10;
        text-align: center;
    }
/* 정답 버튼 그리드 - 위치 확보 */
    #optionsWrapper {
        min-height: 120px; /* 💡 버튼이 생길 공간 미리 확보 */
        margin-top: 20px;
    }
    

/* 선택 버튼 */
.btn-speed-opt {
    padding: 18px 10px; 
    border: none; 
    border-radius: 15px; 
    background: #fff;
    font-size: 1.15rem; 
    font-weight: 800; 
    box-shadow: 0 6px 12px rgba(0,0,0,0.05);
    transition: 0.1s; 
    color: var(--moa-dark);
    border: 2px solid transparent;
}
.btn-speed-opt:active { transform: scale(0.96); }
.btn-speed-opt.correct { background: #28a745 !important; color: #fff !important; }
.btn-speed-opt.wrong { background: var(--moa-red) !important; color: #fff !important; }
/* 게임 시작/종료 오버레이 (화면 정중앙 고정) */
/* 1. 게임 전체 감싸는 영역에 기준점 설정 */
.game-main-wrapper {
    position: relative; /* 💡 이게 있어야 오버레이가 이 박스 안에서만 움직입니다 */
    height: calc(100vh - 80px); /* 하단바 높이 제외 */
    overflow: hidden;
}

/* 2. 시작/종료 오버레이 수정 */
.game-overlay {
    position: absolute; /* 💡 fixed에서 absolute로 변경! */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100; /* 💡 메뉴바(보통 z-index 1000 이상)보다 낮게 설정 */
    
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    
    color: white;
    padding: 20px;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

/* 시작 버튼 디자인 보강 */
.btn-warning.btn-lg {
    padding: 18px 50px;
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 1px;
    border: 4px solid rgba(255,255,255,0.3);
    transition: all 0.2s;
}

.btn-warning.btn-lg:hover {
    transform: scale(1.1); /* 마우스 올리면 살짝 커짐 */
    background-color: #ffc107;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
}
🛠️ HTML 구조 체
/* --------------------------------------------------
   문장 기차 게임 (Sentence Train Game)
-------------------------------------------------- */
.train-page { background-color: #fcfcfc; min-height: 100vh; }

/* 기차 선로 (User Selection) */
.train-track {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 30px 15px;
    background: #fff;
    border: 3px dashed #dee2e6;
    border-radius: 20px;
    min-height: 130px;
    position: relative;
    transition: 0.3s;
}
.train-track::before { 
    content: "🚂"; position: absolute; left: 10px; top: -20px; font-size: 2rem; 
}

/* 단어 보관함 (Word Pool) */
.word-pool {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    background: #f1f3f5;
    border-radius: 20px;
    min-height: 100px;
}

/* 단어 조각 (기차 칸) */
.word-chunk {
    padding: 12px 20px;
    background: #fff;
    border: 2px solid #eee;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: 0.2s;
    color: var(--moa-dark);
}

/* 선로 위에 올라간 기차 칸 (Moa Red) */
.train-track .word-chunk {
    background: var(--moa-red);
    color: #fff;
    border-color: var(--moa-red);
    animation: train-attach 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes train-attach {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* 결과 상태 색상 */
.track-success { border-color: #28a745 !important; background-color: #f0fff4 !important; }
.track-error { border-color: var(--moa-red) !important; background-color: #fff5f5 !important; }

/* --------------------------------------------------
   숨은 단어 찾기 게임 (Word Search Puzzle)
-------------------------------------------------- */
.search-page { background-color: #fcfcfc; min-height: 100vh; }

/* 퍼즐 격자판 */
.puzzle-grid {
    display: grid; 
    grid-template-columns: repeat(10, 1fr); 
    gap: 3px;
    background: #e9ecef; 
    border: 5px solid var(--moa-red); 
    border-radius: 15px;
    overflow: hidden; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.puzzle-cell {
    aspect-ratio: 1; 
    background: #fff; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: 800; 
    font-size: 1.1rem; 
    cursor: pointer; 
    transition: 0.15s; 
    color: var(--moa-dark);
}

/* 셀 상태: 선택됨 (Gold) */
.puzzle-cell.selected { 
    background-color: var(--moa-gold) !important; 
    color: var(--moa-red); 
    transform: scale(0.9);
    border-radius: 6px;
}

/* 셀 상태: 정답 찾음 (Green) */
.puzzle-cell.found { 
    background-color: #28a745 !important; 
    color: #fff !important; 
    pointer-events: none; 
    z-index: 1;
}

/* 단어 목록 컨테이너: 3열로 강제 설정 */
.word-list { 
    display: grid !important; 
    grid-template-columns: repeat(3, 1fr) !important; /* 💡 한 줄에 3개씩 */
    gap: 8px; 
    margin-top: 15px; 
    padding: 0 5px; 
}

/* 개별 단어 박스: 크기를 줄이고 정렬 */
.search-word-item {
    background: white; 
    padding: 10px 4px !important; /* 💡 위아래 패딩만 주고 좌우는 최소화 */
    border-radius: 12px; 
    text-align: center; 
    font-weight: 800;
    border: 2px solid #eee; 
    font-size: 0.85rem; /* 💡 한국어 글자 크기 조정 */
    transition: 0.3s; 
    box-shadow: 0 3px 6px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 55px; /* 💡 모든 박스 높이를 똑같이 맞춰서 정갈하게 */
}

/* 카테고리 선택창 스타일 */
.category-selector { 
    border: 2px solid var(--moa-red); 
    border-radius: 10px; 
    font-weight: bold; 
    font-size: 0.85rem; 
    
    /* 💡 폭을 유연하게 조절 */
    width: auto; 
    min-width: 120px; 
    max-width: 160px; 
    flex: 1; /* 남는 공간을 채우되 버튼을 밀지 않게 함 */
}

/* 다시 버튼이 찌그러지지 않게 고정 */
.btn-danger.btn-sm {
    flex-shrink: 0 !important; /* 💡 핵심: 어떤 상황에서도 크기가 줄어들지 않음 */
    white-space: nowrap !important; /* 💡 글자가 줄바꿈되지 않게 고정 */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 베트남어 뜻: 아주 작게 표시 */
.word-vi { 
    font-size: 0.65rem !important; 
    color: #888; 
    display: block; 
    font-weight: normal; 
    margin-top: 2px;
    line-height: 1;
    word-break: keep-all; 
}

/* 찾은 단어 처리 */
.search-word-item.done { 
    background: #f1f3f5 !important; 
    color: #adb5bd !important; 
    text-decoration: line-through; 
    border-color: #ddd !important;
    box-shadow: none;
    opacity: 0.6; 
}

/* --------------------------------------------------
   단어 학습 (Vocabulary Study)
-------------------------------------------------- */
.word-page { background-color: #fcfcfc; min-height: 100vh; }

/* 메인 단어 카드 */
.card-word-main {
    border: none; 
    border-radius: 30px; 
    box-shadow: 0 20px 40px rgba(0,0,0,0.06); 
    min-height: 520px; 
    background: #fff; 
    position: relative; 
    overflow: hidden;
    border: 1px solid #f1f1f1;
}

/* 이미지 박스 (정사각형 유지) */
.word-img-wrapper {
    width: 100%; 
    height: 280px; 
    background-color: #f8f9fa;
    display: flex; 
    align-items: center; 
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #eee;
}
.word-img-wrapper img { 
    width: 100%; height: 100%; object-fit: cover; 
    transition: transform 0.5s ease;
}
.card-word-main:hover .word-img-wrapper img { transform: scale(1.05); }

/* 하단 버튼 바 */
.word-nav-bar {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 20px;
}
.btn-word-nav {
    flex: 1;
    background: #fff;
    border: 1px solid #eee;
    padding: 15px;
    border-radius: 20px;
    font-weight: 700;
    color: #555;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    transition: 0.2s;
}
.btn-word-nav:active { background: #f8f9fa; transform: translateY(2px); }
