/* 구구단 퀴즈 메인 스타일시트 */

:root {
    --primary-color: #4A90E2;
    --secondary-color: #7ED321;
    --accent-color: #F5A623;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --background-color: #F8F9FA;
    --text-color: #333333;
    --light-gray: #6c757d;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --card-shadow-hover: 0 8px 15px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 헤더 스타일 개선 */
header {
    background: var(--primary-color) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    color: white !important;
}

header h1 {
    color: white !important;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

header small {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* 기본 카드 스타일 개선 */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow-hover);
}

.card-title {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 1.5rem;
}

/* 버튼 스타일 개선 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary-color), #357ABD);
    color: white;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.btn-success {
    background: linear-gradient(45deg, var(--secondary-color), #5cb85c);
    color: white;
    box-shadow: 0 4px 15px rgba(126, 211, 33, 0.3);
}

.btn-warning {
    background: linear-gradient(45deg, var(--accent-color), #e0a800);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 166, 35, 0.3);
}

.btn-outline-primary {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* 답안 버튼 특별 스타일 - 2포커스 */
.answer-btn {
    font-size: 1.8rem;
    font-weight: 700;
    min-height: 70px;
    border-radius: 12px;
    transition: var(--transition);
    border-width: 2px;
}

.answer-btn:hover {
    transform: scale(1.05);
}

.answer-btn.correct {
    background: linear-gradient(45deg, var(--success-color), #20c997) !important;
    color: white !important;
    border-color: var(--success-color) !important;
    animation: correctPulse 0.6s ease-in-out;
}

.answer-btn.incorrect {
    background: linear-gradient(45deg, var(--danger-color), #e74c3c) !important;
    color: white !important;
    border-color: var(--danger-color) !important;
    animation: incorrectShake 0.6s ease-in-out;
}

/* 기본 상태로 돌아가는 스타일 */
.answer-btn:not(.correct):not(.incorrect) {
    background: transparent !important;
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

/* 폼 요소 스타일 */
.form-select, .form-control {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: var(--transition);
    font-size: 16px;
}

.form-select:focus, .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(74, 144, 226, 0.25);
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* 진행률 바 스타일 */
.progress {
    height: 8px;
    border-radius: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.6s ease;
    border-radius: 10px;
}

/* 타이머 스타일 */
#timer-display {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--warning-color);
    animation: timerPulse 1s infinite;
}

/* 문제 텍스트 스타일 - 1포커스 */
#question-text {
    font-size: 3.5rem !important;
    font-weight: 900;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.15);
    margin: 2.5rem 0;
    color: var(--primary-color);
    letter-spacing: 0.05em;
}

/* 피드백 메시지 스타일 */
.alert {
    border-radius: 10px;
    border: none;
    font-weight: 600;
    animation: fadeInUp 0.5s ease-out;
}

.alert-success {
    background: linear-gradient(45deg, var(--success-color), #20c997);
    color: white;
}

.alert-danger {
    background: linear-gradient(45deg, var(--danger-color), #e74c3c);
    color: white;
}

/* 뱃지 스타일 */
.badge {
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 20px;
}

/* 결과 카드 스타일 */
#result-card .card-body {
    text-align: center;
}

#result-card .card {
    margin-bottom: 1rem;
    border-radius: 10px;
    transition: var(--transition);
}

#result-card .card:hover {
    transform: scale(1.05);
}

/* 푸터 스타일 */
footer {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(10px);
    margin-top: 3rem;
}

/* 애니메이션 */
@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .card {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    #question-text {
        font-size: 2.5rem !important;
        margin: 2rem 0 !important;
    }
    
    .answer-btn {
        min-height: 60px;
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    /* 모바일 헤더 스타일 개선 */
    header {
        padding: 1.25rem 0 !important;
        background: var(--primary-color) !important;
    }
    
    header h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
        color: white !important;
        font-weight: 800;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    }
    
    header small {
        font-size: 0.9rem !important;
        line-height: 1.3;
        color: rgba(255, 255, 255, 0.95) !important;
        display: block;
        margin-top: 0.25rem;
    }
}

@media (max-width: 576px) {
    /* 모바일 헤더 추가 최적화 */
    header {
        padding: 1rem 0 !important;
        background: var(--primary-color) !important;
    }
    
    header h1 {
        font-size: 1.3rem !important;
        color: white !important;
        font-weight: 800;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    header small {
        font-size: 0.85rem !important;
        color: rgba(255, 255, 255, 0.95) !important;
        margin-top: 0.25rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    #question-text {
        font-size: 2rem !important;
        margin: 1.5rem 0 !important;
    }
    
    .answer-btn {
        min-height: 55px;
        font-size: 1.3rem;
    }
    
    /* 모바일에서 구구단 선택 최적화 */
    .multiplication-range-simple .form-check-inline {
        margin-right: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .multiplication-range-simple .form-check-label {
        font-size: 0.9rem;
    }
    
    .btn-link-small {
        font-size: 0.8rem;
    }
}

/* 숨김 클래스 */
.hidden {
    display: none !important;
}

/* 로딩 애니메이션 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 구구단 범위 선택 심플 스타일 */
.multiplication-range-simple {
    margin-top: 10px;
}

/* 데스크톱에서는 인라인으로 표시 */
@media (min-width: 577px) {
    .multiplication-range-simple .form-check-inline {
        margin-right: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .range-row {
        display: inline;
    }
}

/* 모바일에서는 3줄로 표시 */
@media (max-width: 576px) {
    .range-row {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        margin-bottom: 0.75rem;
        gap: 1rem;
    }
    
    .range-row:last-child {
        margin-bottom: 0;
    }
    
    .multiplication-range-simple .form-check-inline {
        margin-right: 0;
        margin-bottom: 0;
        flex: 0 0 auto;
    }
    
    .select-all-inline {
        margin-left: auto;
    }
}

.multiplication-range-simple .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.multiplication-range-simple .form-check-label {
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

/* 작은 링크 버튼 스타일 */
.btn-link-small {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 4px 8px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-link-small:hover {
    color: var(--primary-color);
    text-decoration: underline;
    background: rgba(74, 144, 226, 0.1);
    border-radius: 4px;
}

/* 사용법 및 구구단표 스타일 */
.help-content {
    padding: 0;
}

.help-step {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(74, 144, 226, 0.05);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.step-text {
    flex: 1;
    line-height: 1.4;
    font-size: 0.95rem;
}

.step-text strong {
    color: var(--primary-color);
}

/* 구구단표 스타일 */
.multiplication-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.multiplication-table table {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.multiplication-table th {
    background-color: var(--primary-color) !important;
    color: white !important;
    font-weight: 600;
    text-align: center;
    padding: 0.5rem 0.25rem;
    font-size: 0.85rem;
}

.multiplication-table td {
    text-align: center;
    padding: 0.4rem 0.25rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.multiplication-table td:hover {
    background-color: rgba(74, 144, 226, 0.1);
}

/* 5단 세로열 강조 스타일 */
.multiplication-table .five-column {
    background-color: rgba(126, 211, 33, 0.15) !important;
    font-weight: 600;
    color: #2d5016;
}

.multiplication-table thead .five-column {
    background-color: var(--secondary-color) !important;
    color: white !important;
}

.multiplication-table .five-column:hover {
    background-color: rgba(126, 211, 33, 0.25) !important;
}

/* 도움말 카드 반응형 */
@media (max-width: 768px) {
    .help-step {
        margin-bottom: 0.75rem;
        padding: 0.6rem;
    }
    
    .step-number {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
        margin-right: 0.6rem;
    }
    
    .step-text {
        font-size: 0.9rem;
    }
    
    .multiplication-table {
        margin-top: 1rem;
    }
    
    .multiplication-table table {
        font-size: 0.8rem;
    }
    
    .multiplication-table th,
    .multiplication-table td {
        padding: 0.3rem 0.2rem;
    }
}

@media (max-width: 576px) {
    .help-step {
        flex-direction: column;
        text-align: center;
        padding: 0.75rem;
    }
    
    .step-number {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    .multiplication-table table {
        font-size: 0.75rem;
    }
    
    .multiplication-table th,
    .multiplication-table td {
        padding: 0.25rem 0.15rem;
    }
}

/* 특별 효과 */
.celebration {
    animation: celebration 1s ease-in-out;
}

@keyframes celebration {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}

/* 폭죽 효과 애니메이션 */
@keyframes fireworkExplode {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.5) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(3) rotate(360deg);
        opacity: 0;
    }
}

/* 별 떨어지는 효과 */
@keyframes starFall {
    0% {
        transform: translateY(-50px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* 하트 떠오르는 효과 */
@keyframes heartFloat {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 1;
    }
    50% {
        transform: translateY(-50vh) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-100vh) scale(0.5);
        opacity: 0;
    }
}

/* 화면 진동 효과 */
@keyframes screenShake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-5px); }
    20% { transform: translateX(5px); }
    30% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    50% { transform: translateX(-3px); }
    60% { transform: translateX(3px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    90% { transform: translateX(-1px); }
}

/* 무지개 효과 */
@keyframes rainbowPulse {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
    100% {
        opacity: 0;
        transform: scale(1);
    }
}