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

/* Root variables for consistent theming */
:root {
    --primary-color: #667eea;
    --primary-dark: #5a6fd8;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-accent: #f3f4f6;
    --border-color: #e5e7eb;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Body and container styles */
body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header styles */
.quiz-header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
    position: relative;
}

.quiz-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.quiz-title i {
    margin-right: 15px;
    color: #fbbf24;
}

.timer-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin: 0 auto;
    max-width: 200px;
}

#timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fbbf24;
    min-width: 40px;
    text-align: center;
}

.timer-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Progress bar styles */
.progress-container {
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text {
    text-align: center;
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
}

/* Main content and screen management */
.quiz-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex: 1;
    animation: fadeIn 0.5s ease-in-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

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

/* Welcome screen styles */
.welcome-content {
    text-align: center;
    background: var(--bg-primary);
    padding: 50px 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    margin: auto;
    max-width: 600px;
}

.welcome-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-content h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.welcome-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
    line-height: 1.7;
}

.quiz-rules {
    text-align: left;
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: var(--border-radius);
    margin: 30px 0;
}

.quiz-rules h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-weight: 600;
}

.quiz-rules ul {
    list-style: none;
}

.quiz-rules li {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 500;
}

.quiz-rules li i {
    color: var(--success-color);
    margin-right: 12px;
    width: 20px;
}

/* Quiz screen styles */
.question-container {
    background: var(--bg-primary);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.question-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.question-category {
    background: var(--bg-accent);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.question-text {
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.6;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.question-image {
    margin-bottom: 30px;
    text-align: center;
}

.question-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

/* Answer options styles */
.answers-container {
    flex: 1;
    margin-bottom: 30px;
}

.answer-option {
    display: flex;
    align-items: center;
    padding: 18px 20px;
    margin-bottom: 15px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.answer-option:hover {
    background: #e0e7ff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.answer-option.selected {
    background: #ddd6fe;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.answer-option.correct {
    background: #d1fae5;
    border-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.answer-option.incorrect {
    background: #fee2e2;
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.answer-option input[type="radio"] {
    margin-right: 15px;
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.answer-option label {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-primary);
}

.answer-feedback {
    position: absolute;
    right: 15px;
    font-size: 1.2rem;
}

.answer-feedback.correct {
    color: var(--success-color);
}

.answer-feedback.incorrect {
    color: var(--error-color);
}

/* Question actions */
.question-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-top: auto;
}

.hint-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.hint-text {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    color: #92400e;
    max-width: 300px;
    text-align: right;
    box-shadow: var(--shadow-sm);
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

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

.btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.btn-primary:not(:disabled):hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary-color));
}

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

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

/* Results screen styles */
.results-content {
    background: var(--bg-primary);
    padding: 50px 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    flex: 1;
}

.results-header {
    margin-bottom: 40px;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 30px;
    color: white;
    box-shadow: var(--shadow-lg);
}

.score-percentage {
    font-size: 2.5rem;
    font-weight: 700;
}

.score-text {
    font-size: 1rem;
    opacity: 0.9;
}

.results-header h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.results-summary {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.score-details {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
}

.score-item i {
    font-size: 1.3rem;
}

.text-success { color: var(--success-color); }
.text-error { color: var(--error-color); }

/* Detailed results */
.detailed-results {
    text-align: left;
    margin-bottom: 40px;
}

.detailed-results h3 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.4rem;
    color: var(--text-primary);
}

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

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

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

.review-question {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.review-answer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 0.95rem;
}

.review-answer.your-answer {
    color: var(--text-secondary);
}

.review-answer.correct-answer {
    color: var(--success-color);
    font-weight: 600;
}

.review-explanation {
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 12px;
    border-radius: 8px;
    margin-top: 10px;
    font-style: italic;
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Footer styles */
.quiz-footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    margin-top: 30px;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .quiz-title {
        font-size: 2rem;
    }
    
    .welcome-content,
    .question-container,
    .results-content {
        padding: 30px 25px;
    }
    
    .question-text {
        font-size: 1.2rem;
    }
    
    .answer-option {
        padding: 15px;
    }
    
    .question-actions {
        flex-direction: column;
        gap: 15px;
    }
    
    .hint-container {
        align-items: stretch;
    }
    
    .hint-text {
        text-align: left;
        max-width: none;
    }
    
    .score-details {
        flex-direction: column;
        gap: 20px;
        align-items: center;
    }
    
    .results-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .quiz-title {
        font-size: 1.7rem;
    }
    
    .timer-container {
        font-size: 1rem;
        padding: 10px 20px;
    }
    
    #timer {
        font-size: 1.3rem;
    }
    
    .welcome-content,
    .question-container,
    .results-content {
        padding: 25px 20px;
    }
    
    .question-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .score-circle {
        width: 120px;
        height: 120px;
    }
    
    .score-percentage {
        font-size: 2rem;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.slide-up {
    animation: slideUp 0.5s ease-out;
}

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

/* Timer warning states */
.timer-warning {
    color: var(--warning-color) !important;
    animation: pulse 1s infinite;
}

.timer-danger {
    color: var(--error-color) !important;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
