@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    color: #333;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    line-height: 1.6;
    font-size: 16px;
}

.container {
    background-color: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 700px;
    text-align: center;
    position: relative; 
    animation: fadeIn 0.8s ease-out;
    font-size: 16px;
    border-top: 5px solid #007bff;
    margin: 20px;
    overflow: hidden; 
}

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

h1 {
    color: #1a2a40;
    margin-bottom: 20px;
    font-size: clamp(1.8em, 5vw, 2.5em);
    font-weight: 700;
}

p {
    font-size: clamp(1em, 2vw, 1.1em);
}

.screen {
    display: none;
    animation: fadeScreenIn 0.6s ease-out;
}

.screen.active {
    display: block;
}

@keyframes fadeScreenIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.quiz-section {
    text-align: left;
}

.question-box {
    background-color: #f7f9fc;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    border-left: 5px solid #007bff;
}

.question-box p {
    font-size: clamp(1em, 2.5vw, 1.2em);
    line-height: 1.6;
    font-weight: 500;
}

.options {
    list-style: none;
    padding: 0;
    margin: 0;
}

.options li {
    background-color: white;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    padding: 12px 15px;
    margin: 8px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    font-size: 1em;
    line-height: 1.4;
    word-break: keep-all;
}

.options li:hover {
    background-color: #dee2e6;
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.options li.correct {
    background-color: #d4edda;
    color: #155724;
    border-color: #28a745;
    font-weight: bold;
}

.options li.incorrect {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #dc3545;
}

.options li.selected {
    border-color: #007bff;
}

.feedback {
    margin-top: 15px;
    padding: 15px;
    border-radius: 10px;
    font-weight: bold;
    font-size: clamp(1em, 3vw, 1.1em);
    transition: all 0.3s ease;
}

.feedback.correct {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback.incorrect {
    display: none;
}

.explanation {
    display: none; 
}

button {
    background-color: #4a90e2;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1em;
    margin: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: auto;
    max-width: 100%;
}

button:hover {
    background: linear-gradient(45deg, #0056b3, #004494);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.3);
}

button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#score-display {
    font-size: clamp(1.1em, 3vw, 1.3em);
    font-weight: bold;
    color: #007bff;
    margin: 20px 0;
    padding: 10px;
    background-color: #e6f3ff;
    border-radius: 8px;
}

#progress-info {
    font-size: clamp(1em, 2.5vw, 1.1em);
    color: #6c757d;
    margin-bottom: 15px;
}

#end-quiz-btn {
    position: absolute;
    top: 15px; /* [수정] 20px에서 15px로 변경 */
    right: 20px;
    z-index: 5; /* [추가] 모달 오버레이보다 아래에 있지만 다른 요소보다는 위에 있도록 설정 */
}

#end-quiz-btn button {
    background: linear-gradient(45deg, #dc3545, #c82333);
    padding: 10px 20px;
    font-size: clamp(0.8em, 2vw, 0.9em);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

#end-quiz-btn button:hover {
    background: linear-gradient(45deg, #c82333, #bd2130);
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.4);
}

.home-screen p {
    font-size: clamp(1em, 2.5vw, 1.1em);
    margin-bottom: 30px;
    color: #666;
}

.home-screen button {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 15px auto;
    font-size: clamp(1em, 3vw, 1.1em);
    padding: 18px;
}

.end-screen h1 {
    color: #28a745;
}

#final-score {
    font-size: clamp(1.1em, 3vw, 1.2em);
    margin: 25px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 10px;
    color: #333;
    line-height: 1.6;
}

.navigation-buttons {
    text-align: center;
    margin-top: 25px;
}

/* 모달(팝업) 스타일 */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 15px;
    animation: fadeScreenIn 0.3s ease-out;
    border-radius: 20px; 
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 20px; 
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 550px;
    text-align: left;
    animation: modalPopIn 0.3s ease-out;
}

@keyframes modalPopIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content h3 {
    font-size: clamp(1.5em, 4vw, 1.8em);
    font-weight: 700;
    color: #dc3545;
    margin-bottom: 15px;
    text-align: center;
}

.modal-explanation {
    font-size: clamp(0.9em, 2.5vw, 1em);
    line-height: 1.7;
    margin-bottom: 25px;
    max-height: 50vh;
    overflow-y: auto;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.modal-explanation strong {
    color: #0056b3;
}

.modal-confirm-btn {
    background: linear-gradient(45deg, #28a745, #218838);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: clamp(1em, 3vw, 1.1em);
    margin: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.modal-confirm-btn:hover {
    background: linear-gradient(45deg, #218838, #1e7e34);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}
/* --- 모달 스타일 끝 --- */


@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
        margin: 10px;
    }

    .question-box {
        padding: 20px;
    }
    
    #end-quiz-btn {
        /* [수정] 모바일에서도 동일하게 15px 적용 */
        top: 15px; 
        right: 15px; /* [수정] 모바일에서는 오른쪽 여백도 15px로 조정 */
    }

    .modal-content {
        padding: 20px;
    }
}