/* =========================================
   1. 기본 설정 (Reset & Typography)
   ========================================= */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

:root {
    --primary: #6c5ce7;       
    --primary-dark: #5b4cc4;  
    --secondary: #dfe6e9;     
    --accent: #ff7675;        
    --text: #2d3436;          
    --text-light: #636e72;    
    --bg: #f0f2f5;            
    --white: #ffffff;
    --radius: 16px;           
    --shadow: 0 4px 15px rgba(0,0,0,0.05);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    /* 모바일에서는 상단, 데스크탑에서는 중앙 정렬 느낌을 위해 flex 유지하되 min-height 처리 */
    display: flex;
    justify-content: center;
    min-height: 100vh;
    line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* =========================================
   2. 레이아웃 (Layout)
   ========================================= */
/* 컨테이너: 모바일 기본, 데스크탑 확장 */
.container, .app-container {
    background-color: var(--white);
    width: 100%;
    max-width: 100%; /* 기본은 꽉 차게 */
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    position: relative;
    margin: 0 auto;
}

/* ★ 반응형: 태블릿/데스크탑 (768px 이상) 설정 */
@media (min-width: 768px) {
    .container, .app-container {
        max-width: 1000px; /* 데스크탑에서는 더 넓게 */
        border-radius: 0; /* 화면이 넓어지면 꽉 찬 느낌 */
        min-height: 100vh;
    }
    
    /* 퀴즈 진행 화면은 너무 넓으면 읽기 힘들므로 중앙 정렬 및 폭 제한 */
    .screen {
        max-width: 600px; 
        margin: 0 auto; 
        width: 100%;
    }

    body {
        align-items: flex-start; /* 데스크탑에서는 위에서부터 시작 */
    }
}

/* 헤더 */
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;
}

.logo {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary);
}

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

.lang-btn {
    border: 1px solid #eee;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    background: #f8f9fa;
    cursor: pointer;
    transition: 0.2s;
}

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

/* 푸터 */
footer {
    padding: 30px 20px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    margin-top: auto; 
    font-size: 0.8rem;
    color: #888;
}
footer a { color: var(--text-light); text-decoration: underline; }

/* 광고 영역 */
.ad-banner, .ad-placeholder {
    width: 100%;
    min-height: 60px;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 0.8rem;
    margin: 10px 0;
    overflow: hidden;
}

/* =========================================
   3. 메인 인덱스 (Index Page)
   ========================================= */
/* 히어로 배너 */
.hero-banner {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
    margin-bottom: 20px;
    /* 데스크탑에서 모서리 둥글기 제거하여 자연스럽게 */
    border-radius: 0; 
}
@media (min-width: 768px) {
    .hero-banner { border-radius: 0 0 20px 20px; }
}

.hero-banner h1 { margin: 10px 0; font-size: 1.8rem; }
.hero-banner p { margin: 0 0 25px 0; font-size: 1rem; opacity: 0.95; }

.hero-btn {
    display: inline-block;
    background: var(--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: 0.2s;
}
.hero-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(0,0,0,0.15); }

/* 카테고리 네비게이션 */
.category-nav {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 10px 20px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }

/* 데스크탑에서는 카테고리 중앙 정렬 및 줄바꿈 허용 */
@media (min-width: 768px) {
    .category-nav {
        justify-content: center;
        flex-wrap: wrap;
        overflow-x: visible;
    }
}

.cat-btn {
    white-space: nowrap;
    padding: 8px 18px;
    border: none;
    border-radius: 20px;
    background: #f1f2f6;
    color: #666;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
}
.cat-btn.active, .cat-btn:hover {
    background: var(--text);
    color: white;
}

/* ★ 그리드 카드 리스트 (반응형 핵심) */
.grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 모바일: 2열 */
    gap: 15px;
    padding: 20px;
}

/* 태블릿: 3열 */
@media (min-width: 600px) {
    .grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
}
/* 데스크탑: 4열 */
@media (min-width: 900px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    border: 1px solid #f0f0f0;
    display: block;
    height: 100%; /* 카드 높이 맞춤 */
}
.card:hover { transform: translateY(-5px); 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: 3rem;
    background-color: #eee;
}

.card-body { padding: 15px; }
.card-tag { font-size: 0.75rem; color: #888; font-weight: bold; display: block; margin-bottom: 5px; }
.card h3 { font-size: 1.1rem; margin: 0 0 5px 0; color: var(--text); }
.card p { font-size: 0.85rem; color: #666; margin: 0; line-height: 1.4; }

.article-section { padding: 30px 20px; background: #fdfdfd; text-align: center; }

/* =========================================
   4. 테스트/게임 화면 (Screens)
   ========================================= */
.screen {
    display: none;
    padding: 20px;
    animation: fadeIn 0.4s ease-out;
    flex: 1;
}
.screen.active { display: block; }
@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;
    font-size: 0.9rem;
    color: #888;
}
.back-btn { background: none; border: none; font-size: 1rem; cursor: pointer; color: #666; padding: 0; }

/* 히어로 (테스트 시작 전) */
.hero { text-align: center; padding: 40px 0; }
.icon-large { font-size: 5rem; margin-bottom: 20px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-10px); } 100% { transform: translateY(0px); } }
.main-title { font-size: 2rem; margin: 10px 0; line-height: 1.2; font-weight: 800; }
.sub-desc { color: #666; font-size: 1.1rem; margin-bottom: 40px; }

/* 버튼 공통 */
.btn-primary, .btn-secondary, .opt-btn {
    display: block;
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    text-align: center;
}
.btn-primary { background-color: var(--primary); color: white; box-shadow: 0 4px 10px rgba(108, 92, 231, 0.3); }
.btn-primary:hover { background-color: var(--primary-dark); transform: scale(0.98); }

.btn-secondary { background-color: var(--secondary); color: var(--text); }
.btn-secondary:hover { background-color: #d1d8dd; }

/* =========================================
   5. 퀴즈 UI
   ========================================= */
.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-size: 1.5rem;
    margin-bottom: 40px;
    min-height: 60px;
    text-align: center;
    word-break: keep-all; /* 한글 줄바꿈 최적화 */
}

/* 선택지 버튼 */
.opt-btn {
    background: white;
    border: 1px solid #ddd;
    color: var(--text);
    margin-bottom: 12px;
    text-align: left;
    font-weight: normal;
    padding: 20px;
    border-radius: 16px;
}
.opt-btn:hover {
    border-color: var(--primary);
    background-color: #f4f3ff;
    color: var(--primary);
    font-weight: bold;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* 결과 카드 */
.result-card {
    background: #f8f9fa;
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid #eee;
}
.res-icon { font-size: 4rem; margin-bottom: 15px; }
#res-level { color: var(--primary); font-weight: 800; font-size: 1.2rem; margin-bottom: 10px; display: block; }
#res-title { font-size: 1.8rem; margin: 5px 0 20px 0; font-weight: 800; }
#res-desc { color: #555; line-height: 1.7; font-size: 1rem; }

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap; 
}
.action-buttons button { flex: 1 1 40%; } /* 버튼 균등 분할 */

/* =========================================
   6. 게임별 스타일 (절대색감, 순발력 등)
   ========================================= */
/* 절대색감 */
.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-weight: bold;
    font-size: 1.2rem;
}
#board {
    display: grid;
    gap: 8px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    margin: 0 auto;
    background: #e0e0e0;
    padding: 10px;
    border-radius: 16px;
}
.cell { border-radius: 8px; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05); }
.timer-danger { color: #e74c3c; animation: pulse 1s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* 순발력 */
#game-area {
    width: 100%;
    height: 400px;
    border-radius: 24px;
    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;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.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: 10px;
    margin: 40px 0;
    min-height: 60px;
}
.ball {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    box-shadow: 2px 4px 10px rgba(0,0,0,0.2);
    font-size: 1.2rem;
    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; }

/* 파워볼 색상 */
.bg-white { background: #fff; color: #333; border: 1px solid #ddd; }
.bg-power { background: #d63031; color: white; border: none; }

.history-box {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.95rem;
}
.history-item {
    border-bottom: 1px solid #f0f0f0;
    padding: 10px 0;
    display: flex;
    justify-content: space-between;
}

/* 게임 연구소 이동 버튼 스타일 */
.game-lab-btn {
    display: inline-block;
    background-color: #6c5ce7; /* 보라색 포인트 */
    color: white;
    text-decoration: none;
    font-weight: bold;
    padding: 12px 25px;
    border-radius: 30px;
    box-shadow: 0 4px 0 #5f27cd;
    transition: all 0.2s;
    margin: 15px 0;
    font-family: 'Jua', sans-serif; /* 폰트가 없다면 기본 폰트 적용됨 */
    font-size: 1.1rem;
    animation: floating 2s infinite ease-in-out; /* 둥둥 떠다니는 효과 */
}

.game-lab-btn:hover {
    background-color: #5f27cd;
    transform: translateY(-2px);
}

.game-lab-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* 둥둥 떠다니는 애니메이션 */
@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
