/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.app {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Screen management */
.screen {
    display: none;
    width: 100%;
    max-width: 650px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    position: relative;
}

.screen.active {
    display: block;
}

/* Welcome screen */
.welcome-content {
    padding: 60px 40px;
    text-align: center;
}

.title {
    font-size: 3rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.2rem;
    color: #718096;
    margin-bottom: 40px;
    font-weight: 400;
}

.stats {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: #f7fafc;
    border-radius: 16px;
    min-width: 100px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #4a5568;
}

.stat-label {
    font-size: 0.9rem;
    color: #718096;
    margin-top: 4px;
}

/* Saved progress info */
.saved-progress {
    margin-bottom: 24px;
}

.saved-progress-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.saved-progress-badge svg {
    flex-shrink: 0;
}

/* Start buttons */
.start-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    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:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.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 {
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
}

.btn-success:hover {
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.6);
}

.btn-text {
    background: transparent;
    color: #718096;
    padding: 10px 16px;
    font-size: 0.9rem;
}

.btn-text:hover {
    background: #f7fafc;
    color: #e53e3e;
    transform: none;
    box-shadow: none;
}

.btn-text::before {
    display: none;
}

.btn-nav {
    background: #f7fafc;
    color: #4a5568;
    border: 2px solid #e2e8f0;
    padding: 12px 20px;
}

.btn-nav:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

/* Quiz screen */
.header {
    padding: 20px 30px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.round-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(237, 137, 54, 0.3);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.score {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #4a5568;
}

.separator {
    margin: 0 8px;
    color: #cbd5e0;
}

/* Question card */
.question-card {
    padding: 30px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.category-badge {
    display: inline-block;
    padding: 6px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 20px;
    align-self: flex-start;
    letter-spacing: 0.3px;
}

.question-text {
    font-size: 1.35rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 30px;
    line-height: 1.5;
}

/* Options */
.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
}

.option {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.option:hover {
    border-color: #667eea;
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.option.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.option.correct {
    border-color: #48bb78;
    background: linear-gradient(135deg, rgba(72, 187, 120, 0.1) 0%, rgba(56, 161, 105, 0.1) 100%);
}

.option.incorrect {
    border-color: #f56565;
    background: linear-gradient(135deg, rgba(245, 101, 101, 0.1) 0%, rgba(229, 62, 62, 0.1) 100%);
}

.option.missed {
    border-color: #ed8936;
    background: linear-gradient(135deg, rgba(237, 137, 54, 0.1) 0%, rgba(221, 107, 32, 0.1) 100%);
}

.option.missed .option-letter {
    background: #ed8936;
    color: white;
    border-color: #ed8936;
}

.option-letter {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #4a5568;
    margin-right: 16px;
    flex-shrink: 0;
    transition: all 0.2s ease;
    position: relative;
}

.option-letter::after {
    content: attr(data-key);
    position: absolute;
    top: -6px;
    right: -6px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

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

.option.correct .option-letter {
    background: #48bb78;
    color: white;
    border-color: #48bb78;
}

.option.incorrect .option-letter {
    background: #f56565;
    color: white;
    border-color: #f56565;
}

.option-text {
    flex: 1;
    font-size: 1rem;
    color: #2d3748;
    line-height: 1.5;
}

/* Answer section */
.answer-section {
    margin-top: auto;
    padding-top: 30px;
    border-top: 1px solid #e2e8f0;
}

.correct-answer h3,
.explanation h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
}

.answer-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.answer-option {
    padding: 10px 16px;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}

.explanation p {
    color: #4a5568;
    line-height: 1.7;
    font-size: 0.95rem;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 30px;
}

.action-buttons .btn {
    flex: 1;
    justify-content: center;
}

/* Decision active state (for revisited questions) */
.btn.decision-active {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
    transform: scale(1.02);
}

.btn-success.decision-active {
    box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.4), 0 4px 15px rgba(72, 187, 120, 0.4);
}

.btn-secondary.decision-active {
    box-shadow: 0 0 0 3px rgba(160, 174, 192, 0.4);
    background: #edf2f7;
}

/* Navigation */
.navigation {
    padding: 20px 30px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.navigation .btn-primary {
    flex-shrink: 0;
}

.navigation .btn-nav {
    min-width: 130px;
}

/* Keyboard hints */
.keyboard-hints {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 16px 30px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #718096;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: #4a5568;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Completion screen */
.completion-content {
    padding: 60px 40px;
    text-align: center;
}

.completion-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.completion-content .title {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.completion-content .subtitle {
    font-size: 1.1rem;
    color: #718096;
    margin-bottom: 40px;
}

.final-stats {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.final-stats .stat {
    padding: 30px;
}

/* Responsive design */
@media (max-width: 640px) {
    .app {
        padding: 10px;
    }

    .welcome-content,
    .completion-content {
        padding: 40px 20px;
    }

    .title {
        font-size: 2.2rem;
    }

    .question-card {
        padding: 20px;
    }

    .question-text {
        font-size: 1.15rem;
    }

    .header {
        padding: 16px 20px;
    }

    .header-top {
        flex-direction: column;
        gap: 12px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .navigation {
        padding: 0 20px 16px;
        flex-wrap: wrap;
    }

    .navigation .btn-nav {
        flex: 1;
        min-width: 100px;
    }

    .navigation .btn-primary {
        order: -1;
        width: 100%;
        margin-bottom: 8px;
    }

    .keyboard-hints {
        display: none;
    }

    .option {
        padding: 14px 16px;
    }

    .option-letter {
        width: 32px;
        height: 32px;
        margin-right: 12px;
    }

    .option-letter::after {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }

    .start-buttons {
        width: 100%;
    }

    .start-buttons .btn {
        width: 100%;
    }
}

/* Wrong answer styling */
.question-card.wrong-answer {
    box-shadow: inset 0 0 0 2px rgba(245, 101, 101, 0.3);
}

.action-buttons.wrong-answer .btn-secondary {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(229, 62, 62, 0.4);
}

.action-buttons.wrong-answer .btn-secondary:hover {
    background: linear-gradient(135deg, #c53030 0%, #9b2c2c 100%);
    box-shadow: 0 8px 25px rgba(229, 62, 62, 0.6);
}

.next-question-btn {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(229, 62, 62, 0.4);
}

.next-question-btn:hover {
    background: linear-gradient(135deg, #c53030 0%, #9b2c2c 100%);
    box-shadow: 0 8px 25px rgba(229, 62, 62, 0.6);
}

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

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

.screen.active {
    animation: fadeIn 0.4s ease-out;
}

.question-card {
    animation: slideIn 0.3s ease-out;
}

/* Loading and disabled states */
.btn:disabled,
.btn.btn-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
    pointer-events: none;
}

.btn:disabled:hover,
.btn.btn-disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

.btn:disabled::before,
.btn.btn-disabled::before {
    display: none;
}

/* Focus styles for accessibility */
.btn:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.option:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* Smooth transitions */
.option,
.btn,
.progress-fill {
    transition: all 0.2s ease;
}

/* Tooltip for keyboard shortcuts */
.option-letter[data-key]::after {
    transition: opacity 0.2s ease;
}

.option:hover .option-letter::after {
    opacity: 1;
}
