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

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --gradient: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
header {
    text-align: center;
    padding: 30px 0;
    background: var(--gradient);
    color: white;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    animation: fadeInDown 0.5s ease;
}

.tagline {
    font-size: 1.1em;
    opacity: 0.95;
}

/* Progress Section */
.progress-section {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.level-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.level-indicator span {
    font-weight: 600;
    color: var(--text-primary);
}

.current-level {
    color: var(--primary-color);
}

.score, .streak {
    padding: 5px 15px;
    background: var(--bg-color);
    border-radius: 20px;
}

.progress-bar {
    height: 30px;
    background: var(--bg-color);
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--gradient);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.level-badges {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.badge {
    flex: 1;
    padding: 8px 15px;
    background: var(--bg-color);
    border-radius: 20px;
    text-align: center;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    cursor: pointer;
    min-width: 100px;
}

.badge.active {
    background: var(--gradient);
    color: white;
    transform: scale(1.05);
}

.badge.completed {
    background: var(--success-color);
    color: white;
}

/* Screens */
.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); }
}

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

/* Welcome Screen */
#welcomeScreen {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

#welcomeScreen h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 2em;
}

.level-selection {
    margin: 40px 0;
}

.level-selection h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.level-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.level-card {
    background: var(--bg-color);
    padding: 25px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    text-align: center;
}

.level-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.level-card h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.3em;
}

.level-card p {
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-bottom: 10px;
}

.question-count {
    display: inline-block;
    padding: 5px 10px;
    background: var(--primary-color);
    color: white;
    border-radius: 15px;
    font-size: 0.85em;
    margin-top: 10px;
}

.start-btn {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1em;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

/* Question Screen */
#questionScreen {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

.question-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.question-number {
    font-weight: 600;
    color: var(--primary-color);
}

.question-topic {
    background: var(--bg-color);
    padding: 5px 15px;
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.question-content h3 {
    color: var(--text-primary);
    margin-bottom: 25px;
    font-size: 1.4em;
    line-height: 1.5;
}

.visual-aid {
    margin: 20px 0;
    padding: 20px;
    background: var(--bg-color);
    border-radius: 10px;
    text-align: center;
    min-height: 100px;
    display: none;
}

.visual-aid.active {
    display: block;
}

.visual-aid img {
    max-width: 100%;
    height: auto;
}

.options {
    display: grid;
    gap: 15px;
    margin: 30px 0;
}

.option {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.05em;
}

.option:hover:not(.disabled) {
    background: white;
    border-color: var(--primary-color);
    transform: translateX(5px);
}

.option.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.option.correct {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
    animation: correctPulse 0.5s ease;
}

.option.incorrect {
    border-color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
    animation: shake 0.5s ease;
}

.option.disabled {
    cursor: not-allowed;
    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); }
}

.option-letter {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.option.correct .option-letter {
    background: var(--success-color);
}

.option.incorrect .option-letter {
    background: var(--error-color);
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.hint-btn, .skip-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    font-weight: 600;
}

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

.hint-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 158, 11, 0.3);
}

.hint-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.skip-btn {
    background: var(--text-secondary);
    color: white;
}

.skip-btn:hover {
    background: var(--text-primary);
    transform: translateY(-2px);
}

.hint-box, .feedback-box {
    margin: 20px 0;
    padding: 20px;
    border-radius: 10px;
    display: none;
    animation: slideDown 0.3s ease;
}

.hint-box.active, .feedback-box.active {
    display: block;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 500px; }
}

.hint-box {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid var(--warning-color);
    color: var(--text-primary);
}

.feedback-box {
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--primary-color);
    color: var(--text-primary);
}

.feedback-box.correct {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--success-color);
}

.feedback-box.incorrect {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: var(--error-color);
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.navigation-buttons button {
    padding: 12px 30px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    font-weight: 600;
}

.navigation-buttons button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.navigation-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Results Screen */
#resultsScreen {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
}

#resultsScreen h2 {
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 2.5em;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.result-card {
    background: var(--bg-color);
    padding: 25px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.result-card h3 {
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 1em;
}

.big-number {
    font-size: 2.5em;
    font-weight: bold;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.achievement-section {
    margin: 30px 0;
    padding: 20px;
    background: var(--bg-color);
    border-radius: 12px;
}

.achievement {
    display: inline-block;
    margin: 10px;
    padding: 10px 20px;
    background: var(--gradient);
    color: white;
    border-radius: 20px;
    font-weight: 600;
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.next-steps {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

.next-steps button {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    font-weight: 600;
}

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

.next-level-btn {
    background: var(--gradient);
    color: white;
}

.retry-btn {
    background: var(--text-secondary);
    color: white;
}

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

.next-steps button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Review Screen */
#reviewScreen {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

#reviewScreen h2 {
    color: var(--primary-color);
    margin-bottom: 30px;
    text-align: center;
}

.review-item {
    background: var(--bg-color);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 10px;
    border-left: 4px solid var(--border-color);
}

.review-item.correct {
    border-left-color: var(--success-color);
}

.review-item.incorrect {
    border-left-color: var(--error-color);
}

.review-item h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
}

.review-item .your-answer {
    margin: 10px 0;
    padding: 10px;
    background: white;
    border-radius: 5px;
}

.review-item .correct-answer {
    margin: 10px 0;
    padding: 10px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 5px;
    color: var(--success-color);
    font-weight: 600;
}

.review-item .explanation {
    margin-top: 15px;
    padding: 15px;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 5px;
    color: var(--text-secondary);
}

.back-btn {
    margin-top: 30px;
    padding: 12px 30px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    font-weight: 600;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-secondary);
    margin-top: 50px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8em;
    }

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

    .results-summary {
        grid-template-columns: 1fr;
    }

    .navigation-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .navigation-buttons button {
        width: 100%;
    }

    #questionScreen, #welcomeScreen, #resultsScreen, #reviewScreen {
        padding: 20px;
    }

    .question-content h3 {
        font-size: 1.2em;
    }

    .option {
        padding: 15px;
        font-size: 1em;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: var(--text-primary);
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.9em;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Special Effects */
.sparkle {
    animation: sparkle 1s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

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