:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #ffffff;
    --text-color: #333333;
    --text-secondary: #666666;
    --border-color: #e5e7eb;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    --animation-speed: 0.3s;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    padding: 20px;
    padding-top: 80px;
    transition: background 0.3s ease;
}

/* Dark Mode */
body.dark-mode {
    --bg-color: #1f2937;
    --text-color: #f3f4f6;
    --text-secondary: #9ca3af;
    --border-color: #374151;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Navigation Bar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: all 0.3s ease;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--text-color);
}

.nav-menu {
    display: flex;
    gap: 10px;
}

.nav-btn {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-color);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 600px;
    transition: all 0.3s ease;
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: block;
}

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

/* 시작 화면 */
.start-content {
    padding: 60px 40px;
    text-align: center;
}

.title {
    font-size: 3em;
    color: #333;
    margin-bottom: 10px;
    animation: bounce 1s ease-in-out;
}

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

.subtitle {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 40px;
}

.categories-preview {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.category-chip {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 25px;
    font-size: 0.95em;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* 버튼 스타일 */
.btn {
    padding: 15px 40px;
    font-size: 1.1em;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
    background: #4CAF50;
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.btn-secondary:hover {
    background: #45a049;
    transform: translateY(-2px);
}

/* 퀴즈 화면 */
.quiz-header {
    padding: 25px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-info {
    font-size: 1.1em;
    font-weight: 500;
}

.score-info {
    font-size: 1.1em;
    font-weight: 500;
}

.progress-bar {
    height: 6px;
    background: #e0e0e0;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.5s ease;
    width: 0%;
}

.quiz-content {
    padding: 40px 30px;
}

.category-badge {
    display: inline-block;
    padding: 8px 16px;
    background: #f5f5f5;
    color: #666;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
    margin-bottom: 20px;
}

.question {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 30px;
    line-height: 1.4;
}

.options-container {
    display: grid;
    gap: 15px;
}

.option-btn {
    padding: 18px 25px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    text-align: left;
    font-size: 1.05em;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.option-btn:hover:not(.disabled) {
    background: #f8f9fa;
    border-color: #667eea;
    transform: translateX(5px);
}

.option-btn.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.option-btn.correct {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
    animation: correctPulse 0.5s ease;
}

.option-btn.incorrect {
    background: #f44336;
    color: white;
    border-color: #f44336;
    animation: shake 0.5s ease;
}

.option-btn.disabled {
    pointer-events: none;
    opacity: 0.7;
}

@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); }
}

/* 피드백 모달 */
.feedback-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: modalSlideIn 0.3s ease;
}

.feedback-modal.show {
    display: block;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.feedback-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.feedback-icon.correct::before {
    content: "✅";
}

.feedback-icon.incorrect::before {
    content: "❌";
}

#feedbackTitle {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 10px;
}

#feedbackExplanation {
    color: #666;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* 결과 화면 */
.result-content {
    padding: 50px 30px;
    text-align: center;
}

.result-title {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 30px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    padding: 20px;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    border-radius: 15px;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    color: #666;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.category-results {
    margin-bottom: 30px;
}

.category-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 10px;
}

.category-name {
    font-weight: 500;
    color: #333;
}

.category-score {
    color: #667eea;
    font-weight: bold;
}

/* 점수 브레이크다운 */
.score-breakdown {
    margin: 15px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.score-item {
    padding: 5px 0;
    color: #28a745;
    font-weight: 500;
}

/* 타이머 스타일 */
.timer {
    font-size: 1.2rem;
    font-weight: bold;
    color: #007bff;
    padding: 5px 10px;
    background: #e3f2fd;
    border-radius: 5px;
}

.timer.warning {
    color: #ff0000;
    background: #ffebee;
    animation: pulse 1s infinite;
}

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

/* 연속 정답 표시 */
.streak {
    font-size: 1.1rem;
    color: #ff6b35;
    font-weight: bold;
}

/* 힌트 버튼 */
.hint-btn {
    margin-top: 20px;
    padding: 10px 20px;
    background: #ffc107;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.hint-btn:hover:not(:disabled) {
    background: #ffb300;
    transform: translateY(-2px);
}

.hint-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 힌트로 숨겨진 옵션 */
.option-btn.hint-hidden {
    opacity: 0.3;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* 모드 선택 화면 */
.mode-selection {
    text-align: center;
    padding: 40px;
}

.mode-selection h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    color: #333;
}

.mode-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 20px 30px;
    background: white;
    border: 2px solid #007bff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 200px;
}

.mode-btn:hover {
    background: #007bff;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
}

.mode-btn h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.mode-btn p {
    font-size: 0.9rem;
    color: #666;
}

.mode-btn:hover p {
    color: white;
}

/* 카테고리 선택 화면 */
.category-selection {
    text-align: center;
    padding: 40px;
}

.category-selection h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    color: #333;
}

.category-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.category-btn {
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    transition: all 0.3s;
}

.category-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Quick Stats */
.quick-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.95em;
}

.stat-icon {
    font-size: 1.2em;
}

/* Result Actions */
.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    background: var(--bg-color);
    margin: 50px auto;
    padding: 30px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 15px;
    box-shadow: var(--shadow);
    animation: slideUp 0.3s ease;
}

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

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--danger-color);
}

/* Leaderboard Styles */
.leaderboard-filters {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    justify-content: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    color: var(--text-color);
    font-weight: 500;
}

.filter-group select {
    padding: 8px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
}

.leaderboard-table {
    margin: 20px 0;
    overflow-x: auto;
}

.leaderboard-table table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th {
    background: var(--primary-color);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.leaderboard-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.leaderboard-table tr:hover {
    background: rgba(102, 126, 234, 0.1);
}

.rank {
    font-weight: bold;
    font-size: 1.1em;
}

.player {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    font-size: 1.5em;
}

.personal-best {
    margin-top: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
}

.best-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.stat-value {
    color: var(--text-color);
    font-size: 1.3em;
    font-weight: bold;
}

/* Statistics Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.stat-card {
    background: rgba(102, 126, 234, 0.05);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.stat-card h3 {
    color: var(--text-color);
    margin-bottom: 15px;
    font-size: 1.1em;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-bar {
    margin: 15px 0;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    color: var(--text-color);
    font-size: 0.9em;
}

.bar-track {
    height: 20px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.5s ease;
}

.bar-fill.easy {
    background: var(--success-color);
}

.bar-fill.medium {
    background: var(--warning-color);
}

.bar-fill.hard {
    background: var(--danger-color);
}

.bar-info {
    text-align: right;
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-top: 3px;
}

/* Trend Chart */
.trend-chart {
    display: flex;
    align-items: flex-end;
    height: 150px;
    gap: 5px;
    padding: 10px;
}

.trend-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.bar-value {
    width: 100%;
    background: var(--primary-color);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
    position: relative;
}

.bar-value:hover .tooltip {
    display: block;
}

.tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8em;
    white-space: nowrap;
    margin-bottom: 5px;
}

.bar-index {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.8em;
}

/* Achievements */
.achievements-section {
    margin-top: 30px;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
    margin: 10px 0;
    transition: transform 0.3s ease;
}

.achievement-item:hover {
    transform: translateX(5px);
}

.achievement-icon {
    font-size: 2em;
}

.achievement-details h4 {
    color: var(--text-color);
    margin-bottom: 5px;
}

.achievement-details p {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Achievement Notification */
.achievement-notification {
    position: fixed;
    top: 100px;
    right: -400px;
    background: var(--bg-color);
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
    transition: right 0.5s ease;
    z-index: 3000;
}

.achievement-notification.show {
    right: 20px;
}

.achievement-info h4 {
    color: var(--text-color);
    margin-bottom: 5px;
}

.achievement-info p {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Profile Modal */
.profile-header {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    padding: 20px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
}

.profile-avatar {
    font-size: 4em;
    display: flex;
    align-items: center;
}

.profile-info {
    flex: 1;
}

.username-input {
    padding: 10px;
    font-size: 1.2em;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    margin-bottom: 10px;
}

.profile-level {
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 5px;
}

.profile-joined {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.avatar-selection {
    margin: 20px 0;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.avatar-option {
    padding: 15px;
    font-size: 2em;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.avatar-option:hover {
    transform: scale(1.1);
    border-color: var(--primary-color);
}

.avatar-option.selected {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
}

.profile-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

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

.btn-danger:hover {
    background: #dc2626;
}

/* Notifications */
.notification {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-color);
    border-radius: 10px;
    padding: 15px 25px;
    box-shadow: var(--shadow);
    transition: bottom 0.3s ease;
    z-index: 3000;
}

.notification.show {
    bottom: 30px;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-icon {
    font-size: 1.5em;
}

.notification-success {
    border: 2px solid var(--success-color);
}

.notification-error {
    border: 2px solid var(--danger-color);
}

.notification-info {
    border: 2px solid var(--primary-color);
}

/* Confetti Animation */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: red;
    animation: confetti-fall 5s linear forwards;
    z-index: 4000;
}

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* No Data Message */
.no-data {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .avatar-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .leaderboard-table {
        font-size: 0.9em;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .container {
        border-radius: 0;
        min-height: 100vh;
    }
    
    .title {
        font-size: 2em;
    }
    
    .question {
        font-size: 1.2em;
    }
    
    .option-btn {
        padding: 15px 20px;
        font-size: 1em;
    }
    
    .categories-preview {
        gap: 10px;
    }
    
    .category-chip {
        padding: 8px 15px;
        font-size: 0.85em;
    }
    
    .modal-content {
        margin: 20px;
        padding: 20px;
    }
    
    .quick-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .result-actions .btn {
        width: 100%;
    }
}