/* --- [Deep Green & Pastel Yellow Theme] --- */
:root {
    --green-deep: #0E2A1E;    
    --green-forest: #1A4332;  
    --yellow-pastel: #FCE68D; 
    --yellow-hover: #FDF0C0;  
    --bg-base: #F9F9F9;       
    --bg-white: #FFFFFF;
    --text-dark: #111111;
    --text-gray: #555555;
    --text-on-green-sub: #A3C6B4; 
    --max-width: 1200px;
    --radius-card: 24px;
    --radius-btn: 100px;
}

/* --- Reset & Base --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Pretendard', sans-serif;
    background: var(--bg-base);
    color: var(--text-dark); 
    line-height: 1.6; 
    overflow-x: hidden;
    word-break: keep-all;
    min-height: 100vh;
}

html {
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; }
img { display: block; max-width: 100%; }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.section-padding { padding: 140px 0; }

/* --- Typography --- */
.fancy-font { font-family: 'Playfair Display', serif; }
.serif-font { font-family: 'Nanum Myeongjo', serif; }

.section-header { text-align: center; margin-bottom: 70px; max-width: 800px; margin-left: auto; margin-right: auto; }
.section-header h2 { 
    font-size: 3rem; font-weight: 800; margin-bottom: 20px; 
    color: var(--green-deep); line-height: 1.2; letter-spacing: -0.02em;
}
.section-header p { font-size: 1.2rem; color: var(--text-gray); font-weight: 500; }

/* --- Main Container --- */
.main-container {
    min-height: 100vh;
    background: var(--bg-base);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Screen Visibility Control --- */
#subject-selection-screen,
#quiz-selection-screen,
#student-info-screen,
#quiz-screen,
#results-screen {
    width: 100%;
    min-height: 100vh;
    display: none;
}

/* PC에서 퀴즈 화면 중앙 정렬 */
@media (min-width: 769px) {
    #quiz-selection-screen,
    #student-info-screen,
    #quiz-screen,
    #results-screen {
        display: flex !important;
        justify-content: center;
        align-items: center;
        width: 100%;
        min-height: 100vh;
        padding: 100px 24px 40px;
    }
    
    #quiz-screen .container,
    #quiz-selection-screen .container,
    #student-info-screen .container,
    #results-screen .container {
        width: 100%;
        max-width: var(--max-width);
        margin: 0;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}

/* Subject selection section uses its own padding */
.subject-selection-section {
    display: block !important;
    padding: 0 !important;
    min-height: 100vh;
    background: var(--bg-white);
}

/* --- Card Styles --- */
.quiz-card {
    background: var(--bg-white);
    border-radius: var(--radius-card);
    padding: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
    border: 1px solid rgba(0,0,0,0.03);
    max-width: 800px;
    width: 100%;
    overflow: hidden;
}

.card-header-custom {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(241, 245, 249, 0.8));
    padding: 2rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    text-align: center;
}

.card-header-custom h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--green-deep);
    margin: 0;
}

.card-body-custom {
    padding: 2.5rem;
    background: var(--bg-white);
}

/* --- Subject Selection Section --- */
.subject-selection-section {
    background: var(--bg-white);
    padding: 140px 0;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    overflow-y: auto;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
}

.subject-btn {
    background: var(--bg-white);
    border: 1px solid rgba(0,0,0,0.03);
    border-radius: var(--radius-card);
    padding: 40px 30px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--green-deep);
    cursor: pointer;
    transition: all 0.4s ease;
    text-align: center;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
    position: relative;
    overflow: hidden;
}

.subject-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(252, 230, 141, 0.1), rgba(252, 230, 141, 0.05));
    opacity: 0;
    transition: opacity 0.4s ease;
}

.subject-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.06);
    border-color: rgba(14, 42, 30, 0.1);
}

.subject-btn:hover::before {
    opacity: 1;
}

.subject-btn:active {
    transform: translateY(-2px);
}

.subject-btn span {
    position: relative;
    z-index: 1;
}

/* --- Quiz Selection Buttons --- */
.quiz-list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

.quiz-select-btn {
    background: var(--bg-white);
    border: 2px solid rgba(14, 42, 30, 0.1);
    border-radius: 16px;
    padding: 20px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--green-deep);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.quiz-select-btn:hover {
    background: var(--yellow-pastel);
    border-color: var(--green-deep);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    color: var(--green-deep);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;
    font-weight: 700;
    font-size: 1rem;
    border-radius: var(--radius-btn);
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--green-deep);
    color: var(--yellow-pastel);
}

.btn-primary:hover {
    background: var(--green-forest);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.btn-success {
    background: var(--yellow-pastel);
    color: var(--green-deep);
}

.btn-success:hover {
    background: var(--yellow-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.btn-outline-secondary {
    background: transparent;
    border: 2px solid var(--text-gray);
    color: var(--text-gray);
}

.btn-outline-secondary:hover {
    background: var(--text-gray);
    color: white;
    transform: translateY(-2px);
}

/* --- Form Elements --- */
.form-control {
    border-radius: 12px;
    border: 2px solid rgba(14, 42, 30, 0.1);
    padding: 14px 18px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--bg-white);
    color: var(--text-dark);
    font-family: 'Pretendard', sans-serif;
}

.form-control:focus {
    outline: none;
    border-color: var(--green-deep);
    box-shadow: 0 0 0 3px rgba(14, 42, 30, 0.1);
}

.form-label {
    font-weight: 600;
    color: var(--green-deep);
    margin-bottom: 8px;
    font-size: 1rem;
}

/* --- Question Display --- */
.question-header {
    margin-bottom: 1.5rem;
}

.question-badge {
    background: var(--green-deep);
    color: var(--yellow-pastel);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.95rem;
    display: inline-block;
}

#question-text {
    font-size: 1.3rem;
    line-height: 1.8;
    color: var(--text-dark);
    font-weight: 600;
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.9));
    padding: 24px;
    border-radius: 16px;
    border-left: 4px solid var(--green-deep);
    margin: 20px 0;
}

/* --- Conditions Container --- */
.conditions-container {
    background: linear-gradient(135deg, rgba(252, 230, 141, 0.2), rgba(252, 230, 141, 0.1));
    border: 2px solid var(--yellow-pastel);
    border-radius: 16px;
    padding: 20px 24px;
    margin: 20px 0;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-dark);
    font-weight: 600;
}

.condition-line {
    margin: 8px 0;
    padding: 4px 0;
}

.condition-label {
    font-weight: 700;
    font-size: 1.2em;
    color: var(--green-deep);
    margin-right: 12px;
    display: inline-block;
    min-width: 24px;
}

/* --- Answer Options --- */
.answer-option {
    background: var(--bg-white);
    border: 2px solid rgba(14, 42, 30, 0.1);
    border-radius: 14px;
    padding: 20px 24px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 1.1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.answer-option:hover {
    border-color: var(--green-deep);
    background: var(--yellow-pastel);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.answer-option.selected {
    border-color: var(--green-deep);
    background: var(--yellow-pastel);
    color: var(--green-deep);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(14, 42, 30, 0.15);
}

/* --- Progress & Timer --- */
#quiz-progress, #quiz-timer {
    font-weight: 600;
    font-size: 1rem;
    color: var(--green-deep);
}

/* --- Results Screen --- */
#score-display {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--green-deep);
    font-family: 'Pretendard', sans-serif;
}

.result-card {
    background: var(--bg-white);
    border: 2px solid rgba(14, 42, 30, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.result-card h5 {
    color: var(--text-gray);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.result-card .h3 {
    color: var(--green-deep);
    font-weight: 700;
}

.text-success {
    color: var(--green-deep) !important;
}

.text-danger {
    color: #ef4444 !important;
}

/* --- Incorrect Questions Badge --- */
.incorrect-question-badge {
    display: inline-block;
    padding: 8px 16px;
    background: var(--green-deep);
    color: var(--yellow-pastel);
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    margin: 4px;
}

/* --- Scrollbar --- */
.quiz-list-container::-webkit-scrollbar {
    width: 8px;
}

.quiz-list-container::-webkit-scrollbar-track {
    background: rgba(248, 250, 252, 0.8);
    border-radius: 4px;
}

.quiz-list-container::-webkit-scrollbar-thumb {
    background: var(--green-deep);
    border-radius: 4px;
}

.quiz-list-container::-webkit-scrollbar-thumb:hover {
    background: var(--green-forest);
}

/* --- Math Formula Styles --- */
.math-formula {
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-size: 1.2em;
    line-height: 1.8;
    text-align: center;
    margin: 15px 0;
    padding: 10px;
    background: linear-gradient(135deg, rgba(252, 230, 141, 0.2), rgba(252, 230, 141, 0.1));
    border-radius: 8px;
    border-left: 4px solid var(--green-deep);
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    /* 모바일에서 화면 전환 시 완전히 숨기기 */
    #subject-selection-screen,
    #quiz-selection-screen,
    #student-info-screen,
    #quiz-screen,
    #results-screen {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 100;
        background: var(--bg-base);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 모바일에서 교과목 선택 화면 스크롤 가능하도록 */
    #subject-selection-screen {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        height: 100vh !important;
        max-height: 100vh !important;
    }
    
    #subject-selection-screen .subject-selection-section {
        display: block !important;
        align-items: flex-start !important;
        min-height: auto !important;
        height: auto !important;
        position: relative;
        overflow: visible !important;
        padding-bottom: 40px !important;
    }
    
    #subject-selection-screen .container {
        overflow: visible !important;
        position: relative;
        height: auto;
        padding-bottom: 40px;
    }
    
    /* main-container가 스크롤을 방해하지 않도록 */
    .main-container {
        overflow: visible !important;
        height: auto !important;
        position: relative !important;
    }
    
    /* body 스크롤 방지 (모바일에서 fixed 화면 사용 시) */
    body {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    html {
        overflow: hidden !important;
        height: 100%;
    }
    
    /* 숨겨진 화면은 완전히 제거 */
    #subject-selection-screen[style*="none"],
    #quiz-selection-screen[style*="none"],
    #student-info-screen[style*="none"],
    #quiz-screen[style*="none"],
    #results-screen[style*="none"] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
    
    /* 활성화된 화면만 표시 */
    #subject-selection-screen[style*="block"],
    #quiz-selection-screen[style*="block"],
    #student-info-screen[style*="block"],
    #quiz-screen[style*="block"],
    #results-screen[style*="block"] {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    
    .subject-selection-section {
        padding: 100px 0 80px;
        display: block !important;
        align-items: flex-start !important;
    }
    
    /* 모바일에서 퀴즈 화면 컨테이너 조정 */
    #quiz-screen .container,
    #quiz-selection-screen .container,
    #student-info-screen .container,
    #results-screen .container {
        min-height: auto;
        padding: 80px 16px 30px;
        align-items: flex-start;
    }
    
    .section-header h2 {
        font-size: 2rem;
    }
    
    .section-header p {
        font-size: 1rem;
    }
    
    .main-container {
        padding: 80px 16px 30px;
    }
    
    .card-header-custom {
        padding: 1.5rem;
    }
    
    .card-header-custom h2 {
        font-size: 1.5rem;
    }
    
    .card-body-custom {
        padding: 1.5rem;
    }
    
    .subject-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .subject-btn {
        padding: 30px 20px;
        font-size: 1.1rem;
        min-height: 100px;
    }
    
    #question-text {
        font-size: 1.1rem;
        padding: 18px;
    }
    
    .answer-option {
        padding: 16px 20px;
        font-size: 1rem;
    }
    
    #score-display {
        font-size: 2.5rem;
    }
    
    .quiz-list-container {
        max-height: 50vh;
    }
}

@media (max-width: 576px) {
    .subject-selection-section {
        padding: 80px 0 60px;
    }
    
    .section-header {
        margin-bottom: 50px;
    }
    
    .section-header h2 {
        font-size: 1.75rem;
    }
    
    .subject-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .subject-btn {
        padding: 28px 18px;
        font-size: 1rem;
        min-height: 90px;
    }
    
    .card-body-custom {
        padding: 1rem;
    }
    
    #question-text {
        font-size: 1rem;
        padding: 16px;
    }
    
    .answer-option {
        padding: 14px 18px;
        font-size: 0.95rem;
    }
    
    #score-display {
        font-size: 2rem;
    }
}

/* --- Animation --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quiz-card {
    animation: fadeIn 0.5s ease-out;
}

/* --- Lead Text --- */
.lead {
    color: var(--text-gray) !important;
    font-weight: 500;
    font-size: 1.1rem;
}

/* --- Utility Classes (Bootstrap replacements) --- */
.w-100 { width: 100%; }
.d-grid { display: grid; }
.d-flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.text-center { text-align: center; }
.text-start { text-align: left; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.justify-content-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.btn-lg { padding: 16px 40px; font-size: 1.2rem; }
.display-4 { font-size: 2.5rem; font-weight: 300; line-height: 1.2; }
.h3 { font-size: 1.75rem; font-weight: 500; line-height: 1.2; }
.row { display: flex; flex-wrap: wrap; margin-left: -0.75rem; margin-right: -0.75rem; }
.col-12 { flex: 0 0 100%; max-width: 100%; padding-left: 0.75rem; padding-right: 0.75rem; }
.col-6 { flex: 0 0 50%; max-width: 50%; padding-left: 0.75rem; padding-right: 0.75rem; }
@media (min-width: 768px) {
    .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
}
.img-fluid { max-width: 100%; height: auto; }
.rounded { border-radius: 0.375rem; }
