/* =========================================
   1. 기본 설정 (Reset & Typography)
   ========================================= */
/* 폰트: 제목용(Jua), 본문용(Noto Sans KR) */
@import url('https://fonts.googleapis.com/css2?family=Jua&family=Noto+Sans+KR:wght@400;500;700&display=swap');

:root {
    /* 브랜드 컬러 */
    --primary: #6c5ce7;       /* 메인 보라색 */
    --primary-dark: #5f27cd;  /* 진한 보라색 */
    --secondary: #dfe6e9;     /* 회색 배경 */
    --accent: #ff7675;        /* 포인트 붉은색 */
    
    /* 텍스트 컬러 */
    --text-main: #2d3436;
    --text-sub: #636e72;
    --text-white: #ffffff;

    /* 배경 컬러 */
    --bg-body: #f0f2f5;
    --bg-white: #ffffff;

    /* 기타 */
    --radius: 15px;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 모바일 터치 하이라이트 제거 */
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
ul, ol { padding-left: 20px; }

/* =========================================
   2. 레이아웃 (App Container)
   ========================================= */
/* 모바일 앱처럼 보이는 중앙 컨테이너 */
.app-container {
    width: 100%;
    max-width: 600px; /* 데스크탑에서도 모바일 비율 유지 */
    background-color: var(--bg-white);
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    position: relative;
    margin: 0 auto;
}

/* 헤더 */
header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    background: rgba(255, 255, 255, 0.95);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.logo {
    font-family: 'Jua', sans-serif;
    font-size: 1.3rem;
    color: var(--text-main);
}

.lang-switch { display: flex; gap: 5px; }

.lang-btn {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    color: #b2bec3;
    background: transparent;
    border: 1px solid #eee;
    transition: 0.2s;
}

.lang-btn.active {
    background: var(--text-main);
    color: var(--text-white);
    border-color: var(--text-main);
}

/* 푸터 */
footer {
    padding: 40px 20px;
    text-align: center;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    margin-top: auto; /* 하단 고정 */
    font-size: 0.85rem;
    color: #999;
}
footer a { color: #666; margin: 0 5px; }

/* 광고 영역 */
.ad-banner {
    width: 100%;
    min-height: 100px; /* CLS 방지용 최소 높이 */
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    overflow: hidden;
    text-align: center;
}

/* =========================================
   3. 메인 페이지 (Index) 스타일
   ========================================= */
.hero-banner {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
    border-radius: 0 0 20px 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.hero-banner h1 { margin: 10px 0; font-family: 'Jua', sans-serif; font-size: 1.8rem; }
.hero-banner p { margin: 0 0 20px 0; font-size: 1rem; opacity: 0.9; }

.hero-btn {
    display: inline-block;
    background: white;
    color: var(--primary);
    padding: 12px 30px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}
.hero-btn:hover { transform: scale(1.05); }

/* 카테고리 네비게이션 */
.category-nav {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 10px 20px;
    -ms-overflow-style: none; /* IE, Edge 스크롤바 숨김 */
    scrollbar-width: none;    /* Firefox 스크롤바 숨김 */
}
.category-nav::-webkit-scrollbar { display: none; }

.cat-btn {
    white-space: nowrap;
    padding: 8px 16px;
    border: 1px solid #eee;
    border-radius: 20px;
    background: white;
    color: #666;
    font-size: 0.9rem;
    transition: 0.2s;
}
.cat-btn.active {
    background: var(--text-main);
    color: white;
    border-color: var(--text-main);
}

/* 그리드 카드 리스트 */
.grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 20px;
}

.card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border: 1px solid #f0f0f0;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }

.card-img {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
}

.card-body { padding: 15px; }
.card-tag { font-size: 0.7rem; color: #888; background: #f1f2f6; padding: 2px 6px; border-radius: 4px; }
.card h3 { font-family: 'Jua', sans-serif; font-size: 1.1rem; margin: 8px 0 4px 0; color: var(--text-main); }
.card p { font-size: 0.85rem; color: #666; margin: 0; line-height: 1.3; }

/* SEO용 하단 텍스트 섹션 */
.article-section {
    padding: 30px 20px;
    background: #fdfdfd;
    border-top: 1px solid #eee;
    color: #555;
    font-size: 0.95rem;
}
.article-section h3 {
    font-family: 'Jua', sans-serif;
    color: var(--primary);
    margin-bottom: 10px;
    margin-top: 25px;
}

/* =========================================
   4. 테스트/게임 진행 화면 (Common UI)
   ========================================= */
.screen {
    display: none;
    padding: 20px;
    flex: 1;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}
.screen.active { display: flex; }

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

/* 상단 뒤로가기 바 */
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.back-btn { background: none; border: none; font-size: 1rem; color: #b2bec3; padding: 0; font-family: 'Jua', sans-serif; transition: color 0.2s; }
.back-btn:hover { color: var(--text-main); }

/* 게임 시작 화면 */
.hero { text-align: center; padding: 40px 0; }
.icon-large { font-size: 5rem; margin-bottom: 20px; animation: bounce 2s infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.main-title { font-family: 'Jua', sans-serif; font-size: 2.2rem; color: var(--text-main); margin-bottom: 10px; }
.sub-desc { color: #666; font-size: 1rem; margin-bottom: 40px; }

/* 버튼 스타일 */
.btn-primary, .btn-secondary, .opt-btn {
    display: block;
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    font-size: 1.1rem;
    font-weight: bold;
    font-family: 'Jua', sans-serif;
    transition: 0.1s;
    text-align: center;
}

/* 주요 버튼 (시작, 다음 등) */
.btn-primary { 
    background-color: var(--primary); 
    color: white; 
    box-shadow: 0 4px 0 var(--primary-dark); 
    margin-bottom: 10px;
}
.btn-primary:active { transform: translateY(4px); box-shadow: none; }

/* 보조 버튼 (공유, 다시하기 등) */
.btn-secondary { 
    background-color: var(--secondary); 
    color: var(--text-main); 
    box-shadow: 0 4px 0 #b2bec3; 
}
.btn-secondary:active { transform: translateY(4px); box-shadow: none; }

/* =========================================
   5. 퀴즈 진행 및 결과 (Quiz & Result)
   ========================================= */
/* 진행바 */
.progress-container {
    width: 100%;
    height: 8px;
    background-color: #eee;
    border-radius: 4px;
    margin-bottom: 30px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

/* 질문 텍스트 */
.quiz-content h2#q-text {
    font-family: 'Jua', sans-serif;
    font-size: 1.6rem;
    margin-bottom: 40px;
    text-align: center;
    color: var(--text-main);
    word-break: keep-all;
}

/* 선택지 버튼 */
.opt-btn {
    background: white;
    border: 2px solid #eee;
    color: var(--text-main);
    margin-bottom: 15px;
    font-weight: normal;
    font-family: 'Noto Sans KR', sans-serif;
    text-align: left;
    padding: 20px;
    box-shadow: none;
}
.opt-btn:hover {
    border-color: var(--primary);
    background-color: #f4f3ff;
    color: var(--primary);
}
.opt-btn:active { transform: scale(0.98); }

/* 결과 카드 */
.result-card {
    background: #fdfdfd;
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid #eee;
    box-shadow: 0 5px 15px rgba(0,0,0,0.03);
}
.res-icon { font-size: 4rem; margin-bottom: 15px; }
#res-level { color: var(--primary); font-weight: bold; margin-bottom: 5px; display: block; font-family: 'Jua', sans-serif; font-size: 1.2rem; }
#res-title { font-family: 'Jua', sans-serif; font-size: 2rem; margin: 0 0 20px 0; color: var(--text-main); word-break: keep-all; }
#res-desc { color: #555; line-height: 1.7; word-break: keep-all; }

/* =========================================
   6. 게임별 특수 스타일
   ========================================= */
/* 절대색감 게임 */
#board {
    display: grid;
    gap: 8px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    margin: 0 auto;
    background: #e0e0e0;
    padding: 10px;
    border-radius: 15px;
}
.cell { border-radius: 8px; cursor: pointer; transition: transform 0.1s; }
.cell:active { transform: scale(0.95); }

/* 순발력 게임 */
#game-area {
    width: 100%;
    height: 350px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    user-select: none;
    text-align: center;
    transition: background-color 0.1s;
    touch-action: manipulation;
}
.state-wait { background-color: #0984e3 !important; }
.state-ready { background-color: #d63031 !important; }
.state-go { background-color: #00b894 !important; }

/* 로또/파워볼 공 */
.lotto-container { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 30px 0; min-height: 60px; }
.ball {
    width: 45px; height: 45px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-family: 'Jua', sans-serif; font-size: 1.2rem;
    color: white;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }

/* 한국 로또 색상 */
.bg-yellow { background: #fbc400; }
.bg-blue   { background: #69c8f2; }
.bg-red    { background: #ff7272; }
.bg-gray   { background: #b0b0b0; }
.bg-green  { background: #b0d840; }

/* 공유 완료 토스트 메시지 */
#toast {
    visibility: hidden;
    min-width: 250px;
    margin-left: -125px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 30px;
    padding: 16px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 30px;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.5s, bottom 0.5s;
}
#toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

/* 게임 연구소 이동 버튼 (둥둥 떠다니는 효과) */
.game-lab-btn {
    font-family: 'Jua', sans-serif;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-left: 10px;
    animation: floating 2s infinite ease-in-out;
    display: inline-block;
}
@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}


/* style.css (맨 아래 추가) */

/* 메인 페이지 그리드 */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 20px;
    padding: 20px 0;
}
.card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
}
.card:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }
.card-img { height: 120px; display: flex; align-items: center; justify-content: center; font-size: 3rem; color: white; }
.card-body { padding: 20px; text-align: left; }
.card-tag { font-size: 0.8rem; color: #666; background: #f1f2f6; padding: 4px 8px; border-radius: 4px; margin-bottom: 8px; display: inline-block; }
.card h3 { margin: 5px 0; font-size: 1.2rem; color: #2d3436; font-family: 'Jua', sans-serif; }
.card p { font-size: 0.9rem; color: #636e72; margin: 0; }

/* 광고 CLS(레이아웃 덜컹거림) 방지 */
.ad-banner {
    width: 100%;
    min-height: 280px; 
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 30px 0;
    text-align: center;
    border: 1px solid #eee;
}

/* 히어로 배너 */
.hero-banner {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    padding: 40px 20px;
    border-radius: 20px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 10px 20px rgba(108, 92, 231, 0.3);
}
.hero-btn {
    display: inline-block;
    background: white;
    color: #6c5ce7;
    padding: 10px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 15px;
    transition: 0.2s;
}
.hero-btn:hover { transform: scale(1.05); }

/* 카테고리 네비게이션 */
.category-nav { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 20px; -webkit-overflow-scrolling: touch; }
.cat-btn { white-space: nowrap; padding: 8px 16px; border: 1px solid #ddd; border-radius: 20px; background: white; cursor: pointer; color: #555; transition: 0.2s; }
.cat-btn.active { background: #2d3436; color: white; border-color: #2d3436; }
