:root {
    --primary-grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-grad: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%);
    --accent-color: #ff4b1f;
    --text-main: #2d3436;
    --text-sub: #636e72;
    --glass-bg: rgba(255, 255, 255, 0.92);
    --glass-border: rgba(255, 255, 255, 0.6);
    --shadow-soft: 0 10px 40px -10px rgba(0,0,0,0.15);
    --shadow-strong: 0 15px 35px rgba(0,0,0,0.2);
    --font-main: 'KCCMurukmuruk', cursive;
}

@font-face {
    font-family: 'KCCMurukmuruk';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2302@1.0/KCCMurukmuruk.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
    -webkit-tap-highlight-color: transparent;
}

/* [수정 1] html 높이 100% 추가 (가장 확실한 풀스크린 방법) */
html {
    height: 100%;
}

body {
    background: #a18cd1;
    background-image: linear-gradient(120deg, #a18cd1 0%, #fbc2eb 100%);
    
    /* [수정 2] 100dvh 대신 100% 사용 */
    height: 100%;
    
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
    position: relative;
}

/* --- 배경 부유 오브젝트 --- */
.floating-shapes div {
    position: absolute;
    border-radius: 50%;
    opacity: 0.6;
    z-index: -1;
    animation: float 20s infinite linear;
}

.shape-1 {
    width: 300px; height: 300px;
    background: #ff9a9e;
    top: -50px; left: -50px;
    filter: blur(60px);
}
.shape-2 {
    width: 400px; height: 400px;
    background: #a18cd1;
    bottom: -100px; right: -100px;
    filter: blur(80px);
    animation-delay: -5s;
}
.shape-3 {
    width: 200px; height: 200px;
    background: #84fab0;
    top: 40%; left: 60%;
    filter: blur(50px);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -50px) rotate(10deg); }
    66% { transform: translate(-20px, 20px) rotate(-5deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* --- 메인 컨테이너 (앱 프레임) --- */
.container {
    width: 100%;
    max-width: 500px;
    
    /* [수정 3] 높이 100%로 변경하여 부모(html, body)를 가득 채움 */
    height: 100%;
    max-height: none;
    
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden; 
}

/* 데스크탑(PC) 환경일 경우 스타일 */
@media (min-width: 501px) {
    .container {
        height: 90vh;
        max-height: 900px;
        border-radius: 30px;
        border: 1px solid var(--glass-border);
        box-shadow: var(--shadow-strong);
    }
}

/* --- 광고 영역 (상단) --- */
.ad-banner-top {
    width: 100%;
    height: 110px;       
    min-height: 110px;   
    flex-shrink: 0;      
    
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255,255,255,0.3);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    overflow: hidden;   
    z-index: 5;
    margin-bottom: 0;
}

.ad-banner-top .adsbygoogle {
    width: 320px !important;
    height: 100px !important;
    min-height: 100px !important;
    max-height: 100px !important;
}

/* --- 메인 콘텐츠 영역 (스크롤 가능) --- */
main {
    flex: 1;             
    position: relative;
    width: 100%;
    
    /* 스크롤 설정 강화 */
    overflow-y: auto;    
    overflow-x: hidden;
    padding: 20px 1.5rem 40px 1.5rem; /* 하단 여백 충분히 확보 */
    
    /* iOS 부드러운 스크롤 */
    -webkit-overflow-scrolling: touch; 
    
    /* 스크롤바 숨김 (선택사항) */
    -ms-overflow-style: none;
    scrollbar-width: none;
}
main::-webkit-scrollbar { display: none; }

header {
    text-align: center;
    padding-top: 15px;
    padding-bottom: 5px;
    flex-shrink: 0;
}

.logo-title {
    font-size: 2rem;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 2px 2px 10px rgba(118, 75, 162, 0.2);
}

/* --- 섹션 공통 --- */
section {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: auto; /* 고정 높이 해제 */
    min-height: 100%; /* 최소 높이 확보 */
    opacity: 0;
    padding-bottom: 50px; /* 맨 아래 내용 잘림 방지 */
}

section.active {
    display: flex;
    opacity: 1;
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 메인 비주얼 --- */
.main-visual {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}
.visual-icon {
    font-size: 5rem;
    animation: bounce 3s infinite;
}
.visual-text {
    font-size: 1.2rem;
    color: var(--text-sub);
    margin-top: 10px;
}
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* --- 버튼 스타일 --- */
.hero-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    margin-bottom: 20px;
    align-items: center;
    flex-shrink: 0;
}

.btn-hero {
    width: 100%;
    padding: 18px;
    border-radius: 20px;
    background: var(--primary-grad);
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.btn-hero::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.3), transparent);
    transform: translateX(-100%);
    animation: shine 3s infinite;
}

@keyframes shine { 100% { transform: translateX(100%); } }

.pulse-anim { animation: pulse 2s infinite; }
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 15px rgba(102, 126, 234, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(102, 126, 234, 0); }
}

.btn-sub {
    background: white;
    color: var(--text-sub);
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 10px 25px;
    font-size: 0.95rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* --- 가로 스크롤 카드 --- */
.other-games-wrapper {
    width: 100%;
    flex-shrink: 0;
    margin-top: 10px;
    background: rgba(255,255,255,0.5);
    border-radius: 20px;
    padding: 15px;
}
.section-label {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--text-main);
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.section-label small {
    font-size: 0.75rem;
    color: var(--text-sub);
    font-weight: normal;
}
.scroll-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 5px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.scroll-container::-webkit-scrollbar { display: none; }

.game-card {
    flex: 0 0 auto;
    width: 110px;
    height: 110px;
    background: white;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: transform 0.2s;
    scroll-snap-align: start;
    border: 1px solid rgba(255,255,255,0.8);
}
.game-card:hover { transform: translateY(-3px); }
.game-card .emoji { font-size: 2.2rem; margin-bottom: 8px; }
.game-card .name { 
    font-size: 0.85rem; 
    color: var(--text-main); 
    text-align: center; 
    line-height: 1.3; 
    font-weight: 500;
}

/* --- 메뉴 & 숫자 선택 --- */
.grid-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    margin-bottom: 20px;
    margin-top: 20px;
}
.btn-menu {
    background: white;
    padding: 25px 15px;
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    color: var(--text-main);
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.btn-menu i { font-size: 1.8rem; color: #764ba2; }

.num-select-group { display: flex; gap: 10px; margin: 30px 0; justify-content: center; flex-wrap: wrap;}
.btn-num {
    width: 70px; height: 70px;
    border-radius: 50%;
    background: white;
    border: 2px solid #764ba2;
    color: #764ba2;
    font-size: 1.1rem;
    box-shadow: var(--shadow-soft);
}
.btn-text {
    background: none;
    color: var(--text-sub);
    font-size: 1rem;
    text-decoration: underline;
    margin-top: 10px;
    border: none;
    cursor: pointer;
}

/* --- 게임 플레이 화면 --- */
.progress-container { width: 100%; margin: 10px 0 20px 0; }
#progress_bar {
    width: 100%; height: 12px;
    background: #e0e0e0; border-radius: 6px; overflow: hidden;
    margin-bottom: 5px;
}
#progress_fill { height: 100%; width: 0%; background: var(--primary-grad); transition: width 0.3s; }
#progress_text { display:block; text-align: center; font-size: 0.9rem; color: var(--text-sub); }

.question-box {
    background: white;
    padding: 30px 20px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 40px; 
    width: 100%;
    min-height: 140px;
    display: flex; align-items: center; justify-content: center; text-align: center;
}
#question_text { font-size: 1.6rem; line-height: 1.4; color: var(--text-main); }

.answer-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 50px; 
    padding-bottom: 20px;
    position: relative;
}

.answer-btn {
    width: 100%; padding: 25px; border-radius: 18px;
    border: 2px solid transparent; background: white;
    box-shadow: var(--shadow-soft);
    font-size: 1.4rem; color: var(--text-main);
    cursor: pointer;
}
.card-left { border-left: 6px solid #667eea; }
.card-right { border-left: 6px solid #ff9a9e; }
.answer-btn:active { transform: scale(0.98); background: #f0f0f0; }

.versus-badge {
    background: var(--accent-color); color: white;
    width: 50px; height: 50px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(255, 75, 31, 0.4);
    border: 3px solid white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
}

/* --- 결과 및 입력창 --- */
.result-icon { font-size: 4rem; margin: 20px 0 10px; }
.result-inputs { width: 100%; margin: 20px 0; }
.input-group { margin-bottom: 15px; width: 100%; text-align: left; }
.input-group label { display: block; margin-bottom: 5px; color: var(--text-sub); }
input[type="text"] {
    width: 100%; padding: 12px;
    border: 1px solid #ccc; border-radius: 10px;
    font-size: 1rem;
}
.btn-kakao {
    background: #FEE500; color: #3c1e1e;
    width: 100%; padding: 15px; border-radius: 12px;
    font-size: 1.1rem; margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(254, 229, 0, 0.4);
}
.btn-primary-small { background: var(--primary-grad); color: white; padding: 10px 20px; border-radius: 10px; }
.btn-secondary { background: #ddd; color: #333; padding: 10px 20px; border-radius: 10px; margin-right: 10px;}

/* [수정 4] 하단 광고 영역 수정 */
.ad-banner-bottom {
    width: 100%;
    /* height: 60px; -> 삭제 */
    min-height: 60px; /* 최소 높이 보장 */
    height: auto;     /* 내용물 및 패딩에 따라 늘어남 */
    flex-shrink: 0;   
    
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #eee;
    z-index: 100;
    
    /* 아이폰 노치 영역까지 흰색 배경 확보 */
    padding-bottom: env(safe-area-inset-bottom);
}

/* 유틸 */
#toast {
    position: fixed; bottom: 80px; 
    left: 50%; transform: translateX(-50%) translateY(50px);
    background: rgba(45, 52, 54, 0.95); color: white;
    padding: 12px 24px; border-radius: 30px;
    opacity: 0; transition: all 0.3s; pointer-events: none; z-index: 1000;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

button {
    border: none;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}

button:active {
    animation: jelly 0.5s;
}

@keyframes jelly {
    0%, 100% { transform: scale(1, 1); }
    25% { transform: scale(0.9, 1.1); }
    50% { transform: scale(1.1, 0.9); }
    75% { transform: scale(0.95, 1.05); }
}

.hidden { display: none !important; }

/* --- [추가] 결과 테이블 및 리스트 스타일 개선 --- */

/* 테이블 컨테이너 */
.table-wrapper {
    width: 100%;
    overflow-x: auto; /* 가로 스크롤 */
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    background: white;
    margin-bottom: 30px;
    border: 1px solid #eee;
    padding-bottom: 5px; /* 스크롤바 공간 */
}

/* 기본 테이블 스타일 */
.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    white-space: nowrap; /* 가로 스크롤 유도 */
}

/* 테이블 헤더 */
.result-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.result-table th, 
.result-table td {
    white-space: nowrap; 
    padding: 12px 15px;
}

/* 첫 번째 열(ID) 고정 효과 (선택사항) */
.result-table th:first-child,
.result-table td:first-child {
    position: sticky;
    left: 0;
    background: inherit; /* 부모 배경색 상속 */
    z-index: 1;
    border-right: 2px solid #f1f3f5;
    font-weight: bold;
    color: #495057;
}
.result-table thead th:first-child {
    background: #f8f9fa; /* 헤더 고정 시 배경 */
}

/* 테이블 본문 */
.result-table tbody tr {
    background: white;
    border-bottom: 1px solid #f1f3f5;
    transition: background 0.2s;
}

/* 줄무늬 효과 (짝수행 배경) */
.result-table tbody tr:nth-child(even) {
    background: #fdfdfd;
}

.result-table tbody tr:hover {
    background: #f1f3f5;
}

.result-table td {
    padding: 12px 10px;
    text-align: center;
    vertical-align: middle;
}

/* 선택지 배지 (A/B) */
.badge-choice {
    display: inline-block;
    width: 28px;
    height: 28px;
    line-height: 28px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.85rem;
    color: white;
}
.badge-a { background-color: #667eea; box-shadow: 0 2px 5px rgba(102, 126, 234, 0.3); }
.badge-b { background-color: #ff9a9e; box-shadow: 0 2px 5px rgba(255, 154, 158, 0.3); }
.badge-none { background-color: #dee2e6; color: #adb5bd; }


/* 질문 상세 리스트 (카드 형태) */
.q-list-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px 5px;
}

.q-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.q-card-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 10px;
    margin-bottom: 5px;
}

.q-num {
    background: var(--text-main);
    color: white;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
}

.q-title {
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--text-main);
    font-weight: 600;
}

.q-choices {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9rem;
}

.choice-box {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    font-weight: 500;
}

.choice-a { background: #f0f4ff; color: #5a67d8; border: 1px solid #c3dafe; }
.choice-b { background: #fff5f5; color: #e53e3e; border: 1px solid #fed7d7; }

/* 제목 스타일 */
.detail-title {
    font-size: 1.3rem;
    margin: 30px 0 15px;
    text-align: center;
    color: var(--text-main);
    position: relative;
    display: inline-block;
    width: 100%;
}

/* --- [추가] 궁합 점수 및 결과 카드 스타일 --- */
.score-container {
    background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
    border-radius: 20px;
    padding: 25px 15px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.8);
    position: relative;
    overflow: hidden;
}

/* 배경 장식 */
.score-container::before {
    content: '💖';
    position: absolute;
    top: -10px; right: -10px;
    font-size: 5rem;
    opacity: 0.1;
    transform: rotate(20deg);
}

.score-title {
    font-size: 1.1rem;
    color: var(--text-sub);
    margin-bottom: 10px;
    font-weight: bold;
}

.score-value {
    font-size: 3.5rem;
    font-weight: 900;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 5px 0;
    line-height: 1.1;
    text-shadow: 2px 2px 10px rgba(102, 126, 234, 0.2);
}

.score-text-box {
    background: white;
    border-radius: 15px;
    padding: 15px;
    margin-top: 15px;
    border: 1px dashed #ccc;
}

.result-emoji {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 5px;
    animation: bounce 2s infinite;
}

.result-main-text {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 5px;
}

.result-sub-text {
    font-size: 0.95rem;
    color: var(--text-sub);
    word-break: keep-all;
    line-height: 1.4;
}

/* 매치 뱃지 */
.match-tag {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    background: #ff4b1f;
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 10px;
    box-shadow: 0 3px 6px rgba(255, 75, 31, 0.3);
}