/* 기본 스타일 */
:root {
    --primary-color: #4F46E5;
    --primary-dark: #4338CA;
    --secondary-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --card-shadow-hover: 0 15px 50px rgba(0, 0, 0, 0.15);
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* 화면 전환 */
.screen {
    display: none;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: block;
}

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

/* 메인 화면 */
.game-header {
    text-align: center;
    margin-bottom: 3rem;
    color: white;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    animation: bounceIn 1s ease;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.game-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
}

.section-title {
    text-align: center;
    color: white;
    font-size: 1.8rem;
    margin-bottom: 2rem;
    font-weight: 700;
}

/* 모드 카드 */
.mode-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.mode-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--bg-gradient);
    transform: scaleX(0);
    transition: var(--transition);
}

.mode-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-shadow-hover);
}

.mode-card:hover::before {
    transform: scaleX(1);
}

.mode-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.mode-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 700;
}

.mode-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.difficulty-badge {
    display: inline-block;
    padding: 0.4rem 1rem;
    background: var(--secondary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.difficulty-badge.expert {
    background: var(--danger-color);
}

/* 필터 버튼 */
.lesson-filter,
.type-filter {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--card-shadow);
}

.lesson-filter h3,
.type-filter h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.lesson-buttons,
.type-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.lesson-btn,
.type-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid #E5E7EB;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 1rem;
    color: var(--text-secondary);
}

.lesson-btn:hover,
.type-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.lesson-btn.active,
.type-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* 통계 미리보기 */
.stats-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.stat-item {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.stat-item i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-item span:first-of-type {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.5rem 0;
}

.stat-item span:last-of-type {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 게임 화면 */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.btn-back {
    padding: 0.75rem 1.5rem;
    background: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Noto Sans KR', sans-serif;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    box-shadow: var(--card-shadow);
}

.btn-back:hover {
    transform: translateX(-5px);
}

.game-stats {
    display: flex;
    gap: 1.5rem;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.stat i {
    color: var(--primary-color);
}

.streak-indicator i {
    color: var(--warning-color);
}

/* 진행바 */
.progress-bar {
    background: rgba(255, 255, 255, 0.3);
    height: 8px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.progress-fill {
    height: 100%;
    background: white;
    transition: width 0.5s ease;
    border-radius: 10px;
}

/* 질문 카드 */
.question-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 3rem;
    text-align: center;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-type {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: var(--bg-gradient);
    color: white;
    border-radius: 20px;
    font-weight: 600;
    margin-bottom: 2rem;
}

.hanja-display {
    font-family: 'Noto Serif KR', serif;
    font-size: 6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 2rem 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.question-hint {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-top: 1rem;
}

/* 선택지 */
.options-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.option-btn {
    padding: 1.5rem;
    background: white;
    border: 3px solid #E5E7EB;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 600;
    font-family: 'Noto Sans KR', sans-serif;
    transition: var(--transition);
    box-shadow: var(--card-shadow);
    color: var(--text-primary);
}

.option-btn:hover:not(.correct):not(.wrong) {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: var(--card-shadow-hover);
}

.option-btn.correct {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
    animation: correctPulse 0.5s ease;
}

.option-btn.wrong {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
    animation: shake 0.5s ease;
}

@keyframes correctPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* 피드백 */
.feedback {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    opacity: 0;
    transform: translateY(20px);
    transition: var(--transition);
}

.feedback.show {
    opacity: 1;
    transform: translateY(0);
}

.feedback-content {
    font-size: 1.1rem;
    font-weight: 500;
}

/* 결과 화면 */
.result-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 3rem;
    box-shadow: var(--card-shadow);
    text-align: center;
    animation: zoomIn 0.5s ease;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.result-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.result-title {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.final-score {
    margin-bottom: 3rem;
}

.score-label {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.score-value {
    font-size: 4rem;
    font-weight: 900;
    background: var(--bg-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.score-grade {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--warning-color);
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 2rem;
    background: #F9FAFB;
    border-radius: var(--border-radius);
}

.result-stat {
    text-align: center;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.btn-primary,
.btn-secondary {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
}

.btn-secondary {
    background: #F3F4F6;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #E5E7EB;
}

/* 복습 섹션 */
.review-section {
    margin-top: 2rem;
    text-align: left;
}

.review-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.review-item {
    background: #FEF2F2;
    border-left: 4px solid var(--danger-color);
    padding: 1rem;
    border-radius: 8px;
}

.review-item .hanja {
    font-family: 'Noto Serif KR', serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.review-item .info {
    color: var(--text-secondary);
}

.review-item .your-answer {
    color: var(--danger-color);
    font-weight: 600;
}

.review-item .correct-answer {
    color: var(--secondary-color);
    font-weight: 600;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .game-title {
        font-size: 2.5rem;
    }

    .mode-cards {
        grid-template-columns: 1fr;
    }

    .game-info {
        flex-direction: column;
    }

    .game-stats {
        width: 100%;
        justify-content: space-around;
        flex-wrap: wrap;
    }

    .hanja-display {
        font-size: 4rem;
    }

    .options-container {
        grid-template-columns: 1fr;
    }

    .result-actions {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

/* 로딩 애니메이션 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 정답 보상 오버레이 */
.reward-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.reward-overlay.show {
    display: flex;
}

.reward-content {
    text-align: center;
    animation: rewardPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes rewardPop {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-10deg);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.reward-image {
    width: 300px;
    height: 300px;
    object-fit: cover;
    border-radius: 50%;
    border: 8px solid white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    margin-bottom: 2rem;
}

.reward-text {
    font-size: 3rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: textGlow 1s ease-in-out infinite alternate;
}

@keyframes textGlow {
    from {
        text-shadow: 0 4px 20px rgba(255, 255, 255, 0.5),
                     0 0 30px rgba(255, 215, 0, 0.8);
    }
    to {
        text-shadow: 0 4px 20px rgba(255, 255, 255, 0.8),
                     0 0 50px rgba(255, 215, 0, 1);
    }
}

/* 오답 오버레이 스타일 */
.wrong-overlay {
    background: rgba(255, 0, 0, 0.15);
}

.wrong-text {
    color: #FF6B6B;
    animation: wrongShake 0.5s ease, textGlowRed 1s ease-in-out infinite alternate;
}

@keyframes wrongShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-15px);
    }
    75% {
        transform: translateX(15px);
    }
}

@keyframes textGlowRed {
    from {
        text-shadow: 0 4px 20px rgba(255, 255, 255, 0.5),
                     0 0 30px rgba(255, 107, 107, 0.8);
    }
    to {
        text-shadow: 0 4px 20px rgba(255, 255, 255, 0.8),
                     0 0 50px rgba(255, 107, 107, 1);
    }
}

@media (max-width: 768px) {
    .reward-image {
        width: 200px;
        height: 200px;
    }

    .reward-text {
        font-size: 2rem;
    }
}
