/* =========================================
   6. 모달창 (학습 설정)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #0f172a; /* 더 진한 수트색 */
    border: 1px solid #1e293b;
    color: white;
    width: 90%;
    max-width: 450px;
    padding: 32px 24px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    word-break: break-all;
}

.modal-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 25px;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
}

.modal-back-buttons {
    display: flex;
    justify-content: flex-start;
}

.modal-content h3#modal-title {
    margin-bottom: 0;
    font-size: 17px;
    color: #ffffff;
    font-weight: 800;
}

.modal-back-btn, .modal-nav .home-btn {
    background: #1a1f2c;
    color: #d4af37;
    border: 1px solid #d4af37;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: normal; /* line-height 제거하여 flex 정렬 극대화 */
}

.modal-back-btn {
    padding: 0 12px;
    font-size: 13px;
    min-width: 70px;
    height: 32px; /* 고정 높이로 중앙 정렬 안정화 */
}

.modal-nav .home-btn {
    padding: 0 8px;
    font-size: 11px;
    height: 28px; /* 홈 버튼은 더 작게 */
    justify-self: end; /* 오른쪽 정렬 유지 */
}

.modal-back-btn:hover, .modal-nav .home-btn:hover {
    background: #d4af37;
    color: #0f1219;
}

/* 도승하 스타일의 모달 테두리 장식 */
.modal-content::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 18px;
    pointer-events: none;
}

/* 게임 오버 전용 모달 효과 */
.game-over-content {
    border: 2px solid #ef4444; /* 빨간색 포인트 */
}

/* 게임 클리어(성공) 전용 모달 효과 */
.success-content {
    border: 2px solid var(--accent-gold);
    background: linear-gradient(180deg, #1e293b 0%, #0f1219 100%);
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.2);
}

.success-header h2 {
    color: var(--accent-gold);
    font-size: 26px;
    margin-bottom: 8px;
    font-weight: 800;
}

.success-header p {
    color: #cbd5e1;
    line-height: 1.6;
    margin-bottom: 24px;
    font-size: 15px;
}

.success-icon {
    font-size: 54px;
    margin-bottom: 20px;
}

.game-over-header h2 {
    color: #ef4444;
    font-size: 24px;
    margin-bottom: 8px;
}

.game-over-header p {
    color: #94a3b8;
    line-height: 1.5;
    margin-bottom: 24px;
}

.game-over-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: bounce 1s infinite alternate;
}

.game-over-stats {
    background: #1e293b;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    color: #94a3b8;
    font-size: 14px;
}

.stat-value {
    color: #ffffff;
    font-weight: 700;
    font-size: 18px;
}

.modal-buttons.vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-over-motto {
    margin-top: 24px;
    font-style: italic;
    color: #fbbf24;
    font-size: 14px;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content h3 {
    color: #fbbf24;
    margin-bottom: 24px;
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: -0.5px;
}

.step-desc {
    color: #94a3b8;
    margin-bottom: 16px;
    font-size: 14px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.mode-btn {
    padding: 16px;
    border-radius: 12px;
    border: none;
    color: white;
    font-weight: 700;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    line-height: 1.4;
}

.mode-btn span {
    display: block;
    margin-top: 4px;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.mode-btn:active {
    opacity: 0.9;
    transform: translateY(0);
}

.mode-btn.primary { 
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}
.mode-btn.secondary { 
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}
.mode-btn.beginner { 
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.mode-btn.expert { 
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.text-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 8px 12px;
    transition: color 0.3s;
}

.text-btn:hover {
    color: #d4af37;
}

/* 강조 텍스트 스타일 */
.highlight-red {
    color: #ff4d4d;
    font-weight: 800;
    text-shadow: 0 0 5px rgba(255, 77, 77, 0.3);
    padding: 0 2px;
}

.home-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 8px 12px;
    transition: color 0.3s;
}

.home-btn:hover {
    color: #d4af37;
}

.close-btn {
    background: none;
    border: none;
    color: #64748b;
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
}

/* 애니메이션 */
.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.bounce {
    display: inline-block;
    animation: bounce 2s infinite ease-in-out;
}
/* =========================================
   7. 정답/오답 시각 효과 및 버튼 위치
   ========================================= */
#ox-area {
    position: relative; 
}

/* O/X 마크 스타일 */
.ox-mark {
    position: absolute;
    left: 50%;
    top: -20px; 
    transform: translate(-50%, -100%);
    
    width: 80px;
    height: 80px;
    z-index: 50;
    opacity: 0;
    animation: popMark 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

@keyframes popMark {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    100% { transform: translate(-50%, -100%) scale(1); opacity: 1; }
}

/* ★ 수정됨: 다음 문제 버튼 (푸터용) */
.next-btn-fixed {
    z-index: 60;
    /* '이전문제 확인' 버튼(.back-btn)과 동일한 사이즈로 조정 */
    width: 95px;
    height: 36px;
    padding: 0;
    
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    white-space: nowrap;
    transition: all 0.3s;
}

.next-btn-fixed:hover {
    background-color: #2563eb;
    transform: translateY(-2px);
}

/* ★ 수정됨: 다음 문제 버튼 (마크가 있던 자리에 위치) */
.next-btn-floating {
    position: absolute;
    /* 마크와 동일한 중앙 정렬 위치 */
    left: 50%;
    top: -20px;
    transform: translate(-50%, -100%);
    
    z-index: 60;
    background-color: #3b82f6;
    color: white;
    border: none;
    padding: 10px 20px; /* 크기 약간 키움 */
    border-radius: 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3); /* 그림자 강조 */
    animation: fadeIn 0.3s ease-out;
    white-space: nowrap; /* 줄바꿈 방지 */
}

.next-btn-floating:hover {
    background-color: #2563eb;
    transform: translate(-50%, -105%); /* 호버 시 살짝 위로 */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -80%); }
    to { opacity: 1; transform: translate(-50%, -100%); }
}

/* 다음 문제 버튼 (X 버튼 오른쪽 위 배치용) */
.next-btn-floating {
    position: absolute;
    right: 0; /* 오른쪽 끝 (X버튼 쪽) */
    top: -50px; /* 버튼 위쪽 */
    z-index: 60;
    background-color: #3b82f6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    animation: fadeIn 0.3s ease-out;
}

.next-btn-floating:hover {
    background-color: #2563eb;
    transform: translateY(-2px);
}


/* 오답: 엑스 그려지는 효과 (총 1초) */
.svg-x {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: #f87171; /* 빨간색 */
    stroke-width: 15;
    stroke-linecap: round;
    stroke-dasharray: 150; /* 대각선 길이 */
    stroke-dashoffset: 150;
}

/* 첫 번째 선 */
.x-line1 {
    animation: drawX 0.5s ease-out forwards;
}

/* 두 번째 선 (0.5초 딜레이) */
.x-line2 {
    animation: drawX 0.5s ease-out 0.5s forwards;
}

@keyframes drawX {
    to { stroke-dashoffset: 0; }
}

/* =========================================
   난이도 선택 카드 스타일
   ========================================= */
.level-cards {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 10px 0;
}

.level-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 24px !important;
    border-radius: 14px;
    min-height: 150px;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    cursor: pointer;
}

/* 상단 은은한 빛 효과 상시 노출 */
.level-card::before {
    content: '';
    position: absolute;
    top: -30%;
    left: -30%;
    width: 160%;
    height: 160%;
    background: radial-gradient(circle, rgba(255,255,255,0.04) 0%, transparent 60%);
    pointer-events: none;
    z-index: 1;
}

/* 스치는 빛 효과 제거됨 */

.level-card > * {
    position: relative;
    z-index: 3;
}

/* 초보자 카드: 기본 상태를 호버 상태처럼 화려하게 */
.level-card.beginner {
    background: #141721;
    border: 1px solid rgba(99, 102, 241, 0.6);
    border-bottom: 3px solid #6366f1;
    box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.5), 0 0 15px rgba(99, 102, 241, 0.1);
}

.level-card.beginner:hover {
    background: #1c2130;
    transform: translateY(-6px);
    border-color: #818cf8;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7), 0 0 25px rgba(99, 102, 241, 0.2);
}

/* 숙련자 카드: 기본 상태를 골드 테마로 화려하게 */
.level-card.expert {
    background: #161a24;
    border: 1px solid rgba(212, 175, 55, 0.6);
    border-bottom: 3px solid #d4af37;
    box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.5), 0 0 15px rgba(212, 175, 55, 0.1);
}

.level-card.expert:hover {
    background: #1f2330;
    transform: translateY(-6px);
    border-color: #f9e29d;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7), 0 0 30px rgba(212, 175, 55, 0.25);
}

.card-icon-wrapper {
    margin-bottom: 20px;
}

.diamond-icon {
    width: 44px;
    height: 44px;
    border: 2px solid #6366f1;
    background: rgba(99, 102, 241, 0.15);
    transform: rotate(45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6366f1;
    font-size: 22px;
    font-weight: 900;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
    margin: 0 auto;
}

.diamond-icon.expert {
    border-color: #d4af37;
    background: rgba(212, 175, 55, 0.15);
    color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.2);
}

/* 다이아몬드 내부의 텍스트가 회전되지 않게 보정 */
.diamond-icon {
    line-height: 0;
}

.diamond-icon > * {
    /* 만약 텍스트가 바로 자식으로 있으면 */
}

/* 텍스트를 감싸는 속성이 없으므로, line-height와 flex로 처리하거나 컨텐츠를 회전 */
.diamond-icon span {
    transform: rotate(-45deg);
    display: block;
    line-height: 1;
}

.level-card:hover .diamond-icon span {
    transform: rotate(-225deg);
}

.level-card:hover .diamond-icon {
    transform: rotate(225deg);
    background: #6366f1;
    color: #ffffff;
}

.level-card:hover .diamond-icon.expert {
    background: #d4af37;
    color: #0f1219;
}

.card-icon {
    font-size: 44px;
    margin-bottom: 18px;
    transition: transform 0.4s ease;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.1));
}

.level-card:hover .card-icon {
    transform: scale(1.1) rotate(5deg);
}

.card-title {
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 10px;
    letter-spacing: -0.3px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.level-card.expert .card-title {
    background: linear-gradient(135deg, #f9e29d 0%, #d4af37 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-desc {
    font-size: 13.5px;
    color: #8fa0b9;
    line-height: 1.6;
    text-align: center;
    font-weight: 400;
    word-break: keep-all;
}

.level-card:hover .card-desc {
    color: #cbd5e1;
}

/* 주제 선택 영역 스타일 */
.topic-select-area {
    padding: 20px 0;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.topic-select-area .step-desc {
    font-size: 16px;
    color: #cbd5e1;
    margin-bottom: 24px;
    font-weight: 500;
}

.card-title {
    font-size: 20px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.card-desc {
    font-size: 13px;
    color: #cbd5e1;
    text-align: center;
    line-height: 1.5;
}

/* =========================================
   7. 오답통 관련 스타일
   ========================================= */
.wrong-toggle-btn {
    background: transparent;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #94a3b8;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.wrong-toggle-btn.active {
    background: rgba(251, 191, 36, 0.1);
    border-color: #fbbf24;
    color: #fbbf24;
}

.screen-title {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    margin: 20px 0 30px;
}

.wrong-note-header-box {
    background: #1e293b;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    text-align: center;
    border: 1px solid #334155;
}

.wrong-note-header-box h2 {
    font-size: 18px;
    color: #fbbf24;
    margin-bottom: 16px;
}

.practice-btn {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transition: all 0.2s;
}

.practice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.wrong-note-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wrong-item-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    padding: 20px;
    position: relative;
    transition: transform 0.2s;
}

.wrong-item-card:hover {
    border-color: #475569;
}

.wrong-item-q {
    font-size: 15px;
    color: #e2e8f0;
    line-height: 1.6;
    margin-bottom: 12px;
}

.wrong-item-a {
    font-size: 14px;
    color: #fbbf24;
    font-weight: 700;
    background: rgba(251, 191, 36, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-block;
}

.wrong-item-badge {
    position: absolute;
    top: -10px;
    right: 15px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 800;
}

/* 추가: 오답통 토글 버튼 스타일 */
.wrong-toggle-btn {
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 20px;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.wrong-toggle-btn .icon {
    font-size: 18px;
    color: #94a3b8;
}

.wrong-toggle-btn .text {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 600;
}

.wrong-toggle-btn.active {
    background: rgba(251, 191, 36, 0.15);
    border-color: #fbbf24;
}

.wrong-toggle-btn.active .icon {
    color: #fbbf24;
}

.wrong-toggle-btn.active .text {
    color: #fbbf24;
}