/* 기본 스타일 */
@import url('https://fonts.googleapis.com/css2?family=Dongle:wght@300&family=Gamja+Flower&family=Gowun+Dodum&display=swap');

body {
    font-family: "Gowun Dodum", sans-serif;
    text-align: center;
    background-color: #f0f8ff;
    margin: 0;
    padding: 0;
}

h1 {
    margin: 20px 0;
    color: #333;
    font-size: 2em;
}

/* 공통 스타일 */
#controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px 0;
    padding: 0 10px;
}

#controls > * {
    margin: 5px 0;
    width: 100%;
    max-width: 300px;
}

select, button, input {
    padding: 10px;
    font-size: 1em;
    border: 1px solid #ccc;
    border-radius: 5px;
}

button {
    background-color: #ffa500;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #ff8c00;
}

#score {
    font-size: 1.2em;
    margin: 10px 0;
    transition: color 0.5s;
}

/* 퀴즈 게임 스타일 */
#quizContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* 수직 중앙 정렬 */
    width: 100%;
    max-width: 800px; /* PC 화면에서의 최대 너비 */
    height: auto; /* 콘텐츠에 따라 높이 조정 */
    min-height: 100vh; /* 최소 높이를 뷰포트 높이로 설정 */
    margin: 0 auto; /* 중앙 정렬 */
    padding: 20px; /* 패딩 추가 */
    box-sizing: border-box; /* 패딩을 포함한 크기 계산 */
    background-color: #fff; /* 배경색 추가 (선택 사항) */
    border: 2px solid #ccc; /* 테두리 추가 (선택 사항) */
    border-radius: 10px; /* 모서리 둥글게 */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* 그림자 추가 (선택 사항) */
    overflow: hidden; /* 과도한 내용 숨기기 */
}

#questionImage {
    flex: 1; /* 남은 공간을 모두 차지 */
    width: 100%;
    max-width: 600px; /* 이미지의 최대 너비 제한 */
    aspect-ratio: 1 / 1; /* 정사각형 비율 유지 */
    background-color: #fff;
    border: 2px solid #ccc;
    border-radius: 10px;
    background-size: contain; /* 이미지가 잘리지 않도록 설정 */
    background-repeat: no-repeat; /* 이미지 반복 방지 */
    background-position: center;
    position: relative;
    margin-bottom: 20px; /* 필요 시 조정 */
}

#feedback {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 2em;
    font-weight: bold;
}

/* 정답 표시 영역 */
#correctAnswer {
    position: absolute;
    bottom: 10px;
    left: 10px;
    font-size: 1em;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 5px;
    display: none; /* 기본적으로 숨김 */
}

#options {
    display: grid;
    grid-template-columns: repeat(2, 150px);
    gap: 10px;
}

.option-button {
    padding: 15px;
    font-size: 1em;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #87cefa;
    cursor: pointer;
    transition: background-color 0.3s;
}

.option-button:hover {
    background-color: #00bfff;
}

/* 성공 메시지 스타일 */
#successMessage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    z-index: 1000;
    display: none;
    padding: 20px;
    box-sizing: border-box;
}

#successMessage img {
    width: 80px;
    margin-bottom: 20px;
}

#successMessage button {
    margin-top: 20px;
}

/* 기록 섹션 스타일 (모달) */
#recordSection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* 반투명 배경 */
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#recordContent {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 80%; /* 높이 제한 추가 */
    overflow-y: auto; /* 스크롤 추가 */
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: fadeIn 0.3s ease-out;
}

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

#recordTable {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    max-height: 200px;
    overflow-y: auto;
}

#recordTable th, #recordTable td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: center;
}

/* 미디어 쿼리로 화면 크기에 맞게 조정 */
@media (max-width: 768px) {
    #quizContainer {
        width: 100%;
        height: auto; /* 높이를 자동으로 조정 */
        padding: 10px; /* 패딩 줄이기 */
        max-width: 100%; /* 최대 너비를 100%로 설정 */
        min-height: auto; /* 최소 높이 제거 */
    }

    #questionImage {
        width: 90%; /* 전체 너비의 90% 사용 */
        height: auto; /* 높이를 내용에 맞게 조정 */
        aspect-ratio: 1 / 1; /* 정사각형 유지 */
        margin-bottom: 15px; /* 마진 조정 */
        background-size: contain; /* 이미지가 잘리지 않도록 */
    }

    #options {
        grid-template-columns: repeat(1, 100%);
        gap: 10px;
        width: 100%;
    }

    .option-button {
        width: 100%; /* 버튼을 전체 너비로 확장 */
        max-width: none;
    }

    #controls > * {
        max-width: none; /* 모바일에서 최대 너비 제한 해제 */
        width: 100%;
    }

    #recordContent {
        width: 95%;
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
        margin: 15px 0;
    }

    #controls {
        padding: 0 5px;
    }

    #options {
        grid-template-columns: 1fr;
    }

    .option-button {
        padding: 10px;
        font-size: 0.9em;
    }

    #successMessage {
        font-size: 1.2em;
        padding: 15px;
    }

    #successMessage img {
        width: 60px;
        margin-bottom: 15px;
    }
}

.correct-answer {
    text-decoration: underline;
}

/* 정답 애니메이션: 확대되면서 서서히 나타나기 */
@keyframes correctAnimation {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

/* 오답 애니메이션: 흔들리면서 빨리 사라지기 */
@keyframes incorrectAnimation {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    25% {
        transform: translateX(-10px);
    }
    50% {
        transform: translateX(10px);
    }
    75% {
        transform: translateX(-10px);
    }
    100% {
        transform: translateX(0);
        opacity: 0;
    }
}

/* 정답 애니메이션 클래스 */
.animate-correct {
    animation: correctAnimation 1s ease-out forwards;
}

/* 오답 애니메이션 클래스 */
.animate-incorrect {
    animation: incorrectAnimation 1s ease-out forwards;
}

#viewRecordsButton {
    background-color: #ffa500;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#viewRecordsButton:hover {
    background-color: #ff8c00;
}
