:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #f59e0b;
    --success: #10b981;
    --error: #ef4444;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Header */
header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    border-radius: 0 0 30px 30px;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Cards */
.card {
    background: var(--card);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
}

/* Progress Bar */
.progress-container {
    margin-bottom: 30px;
}

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Quiz Questions */
.question-container {
    display: none;
}

.question-container.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

.question-number {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-text {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 25px;
    line-height: 1.6;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option {
    padding: 16px 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.option:hover {
    border-color: var(--primary);
    background: #f0f0ff;
}

.option.selected {
    border-color: var(--primary);
    background: #e0e7ff;
}

.option.correct {
    border-color: var(--success);
    background: #d1fae5;
}

.option.incorrect {
    border-color: var(--error);
    background: #fee2e2;
}

.option-letter {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-light);
    transition: all 0.3s ease;
}

.option.selected .option-letter {
    background: var(--primary);
    color: white;
}

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

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

/* Buttons */
.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    width: 100%;
    margin-top: 20px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Results */
.result-container {
    display: none;
    text-align: center;
    padding: 40px;
}

.result-container.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

.result-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 3rem;
}

.result-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--primary);
}

.result-level {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding: 10px 30px;
    background: linear-gradient(135deg, var(--secondary), #f97316);
    color: white;
    border-radius: 30px;
    display: inline-block;
}

.result-score {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 30px;
}

.result-details {
    background: var(--bg);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.result-details h3 {
    margin-bottom: 15px;
    color: var(--text);
}

.result-details p {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.result-details p:last-child {
    border-bottom: none;
}

/* Level Selection */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

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

.level-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
}

.level-card.selected {
    border-color: var(--primary);
    background: #e0e7ff;
}

.level-card h3 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.level-card p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.level-a1 { border-left: 4px solid #10b981; }
.level-a2 { border-left: 4px solid #3b82f6; }
.level-b1 { border-left: 4px solid #f59e0b; }
.level-b2 { border-left: 4px solid #f97316; }
.level-c1 { border-left: 4px solid #ef4444; }

/* Quiz Options Menu */
.quiz-menu {
    display: none;
}

.quiz-menu.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

.quiz-category h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-light);
}

.quiz-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.quiz-btn {
    padding: 20px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.quiz-btn:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.quiz-btn-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.quiz-btn-title {
    font-weight: 600;
    margin-bottom: 5px;
}

.quiz-btn-desc {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Stats */
.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Confetti */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: var(--secondary);
    animation: confetti 3s ease-in-out infinite;
}

@keyframes confetti {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Responsive */
@media (max-width: 768px) {
    header {
        padding: 30px 15px;
        border-radius: 0 0 20px 20px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    header p {
        font-size: 0.9rem;
    }

    .container {
        padding: 15px;
    }

    .card {
        padding: 20px;
        border-radius: 15px;
    }

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

    .option {
        padding: 14px 16px;
        font-size: 0.95rem;
    }

    .option-letter {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .btn {
        padding: 12px 24px;
        font-size: 0.95rem;
    }

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

    .level-card {
        padding: 20px;
    }

    .level-card h3 {
        font-size: 1.3rem;
    }

    .quiz-buttons {
        grid-template-columns: 1fr;
    }

    .stats {
        gap: 20px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .result-container {
        padding: 20px;
    }

    .result-icon {
        width: 80px;
        height: 80px;
        font-size: 2.5rem;
    }

    .result-title {
        font-size: 1.5rem;
    }

    .result-level {
        font-size: 1.2rem;
        padding: 8px 20px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 25px 12px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    header p {
        font-size: 0.85rem;
    }

    .container {
        padding: 10px;
    }

    .card {
        padding: 15px;
        border-radius: 12px;
    }

    .question-number {
        font-size: 0.8rem;
    }

    .question-text {
        font-size: 1rem;
        margin-bottom: 20px;
    }

    .options {
        gap: 10px;
    }

    .option {
        padding: 12px 14px;
        font-size: 0.9rem;
        gap: 10px;
    }

    .option-letter {
        width: 26px;
        height: 26px;
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .progress-bar {
        height: 8px;
    }

    .progress-text {
        font-size: 0.8rem;
    }

    .result-icon {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }

    .result-title {
        font-size: 1.3rem;
    }

    .result-level {
        font-size: 1.1rem;
        padding: 6px 16px;
    }

    .result-score {
        font-size: 1rem;
    }

    .result-details {
        padding: 15px;
    }

    .result-details h3 {
        font-size: 1rem;
    }

    .result-details p {
        font-size: 0.9rem;
    }

    .quiz-category h3 {
        font-size: 1rem;
    }

    .quiz-btn {
        padding: 15px;
    }

    .quiz-btn-icon {
        font-size: 1.5rem;
    }

    .quiz-btn-title {
        font-size: 0.95rem;
    }

    .quiz-btn-desc {
        font-size: 0.75rem;
    }

    .stats {
        gap: 15px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }
}

/* Very small devices */
@media (max-width: 360px) {
    header h1 {
        font-size: 1.2rem;
    }

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

    .option {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .option-letter {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
}

/* Touch devices optimization */
@media (hover: none) and (pointer: coarse) {
    .option {
        padding: 16px 18px;
    }

    .option:hover {
        background: var(--card);
        border-color: var(--border);
    }

    .option:active {
        border-color: var(--primary);
        background: #e0e7ff;
    }

    .btn:active {
        transform: scale(0.98);
    }

    .level-card:active {
        transform: scale(0.98);
    }

    .quiz-btn:active {
        transform: scale(0.98);
    }
}

/* Landscape mode for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    header {
        padding: 15px 20px;
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 1.2rem;
        margin-bottom: 5px;
    }

    header p {
        font-size: 0.8rem;
    }

    .card {
        padding: 15px;
    }

    .question-text {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .options {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .option {
        flex: 1 1 calc(50% - 6px);
        min-width: 140px;
        padding: 10px 12px;
        font-size: 0.85rem;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    header {
        background: white;
        color: var(--text);
        border-bottom: 2px solid var(--primary);
    }

    .btn, .progress-container {
        display: none;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Hidden class */
.hidden {
    display: none !important;
}