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

body {
    font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background: radial-gradient(circle at top right, rgba(102, 126, 234, 0.05) 0%, transparent 15%),
                radial-gradient(circle at bottom left, rgba(118, 75, 162, 0.05) 0%, transparent 15%),
                linear-gradient(to bottom, #f8fafc 0%, #e2e8f0 100%);
    min-height: 100vh;
    color: #1e293b;
    overflow-x: hidden;
    position: relative;
}

/* Floating background elements */
body::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 8%;
    width: 120px;
    height: 120px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-radius: 50%;
    opacity: 0.08;
    filter: blur(40px);
    z-index: -1;
}

body::after {
    content: '';
    position: absolute;
    bottom: 15%;
    right: 8%;
    width: 180px;
    height: 180px;
    background: linear-gradient(45deg, #f093fb, #f5576c);
    border-radius: 50%;
    opacity: 0.08;
    filter: blur(50px);
    z-index: -1;
}

.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 30px 15px;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 35px;
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    letter-spacing: -0.3px;
    position: relative;
}

header p {
    font-size: 1rem;
    color: #64748b;
    font-weight: 300;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.5;
}

.quiz-setup, .quiz-container, .results-container {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(15px);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 15px 30px -8px rgba(0, 0, 0, 0.1),
                inset 0 0 0 1px rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.quiz-setup::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.form-group {
    margin-bottom: 22px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
    transform: translateY(-1px);
}

.form-group input::placeholder,
.form-group select {
    color: #94a3b8;
}

.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
    margin-top: 12px;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.25);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transition: left 0.4s;
    z-index: -1;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.35);
}

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

.btn-secondary {
    background: transparent;
    color: #64748b;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

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

.loading {
    text-align: center;
    margin-top: 20px;
    padding: 20px;
}

.spinner {
    width: 35px;
    height: 35px;
    border: 2px solid rgba(102, 126, 234, 0.1);
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
    box-shadow: 0 0 12px rgba(102, 126, 234, 0.15);
}

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

.hidden {
    display: none !important;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
}

.quiz-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.quiz-header h2 {
    color: #1e293b;
    font-size: 1.3rem;
    font-weight: 600;
}

.quiz-progress {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.85rem;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.25);
}

.question-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: hidden;
}

.question-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #667eea, #764ba2);
}

.question-card h3 {
    font-size: 1.15rem;
    margin-bottom: 18px;
    color: #1e293b;
    line-height: 1.45;
    font-weight: 600;
    position: relative;
}

.answers-container {
    margin-bottom: 22px;
}

.answer-option {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.02);
}

.answer-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03), rgba(118, 75, 162, 0.03));
    opacity: 0;
    transition: opacity 0.25s;
    z-index: -1;
}

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

.answer-option:hover::before {
    opacity: 1;
}

.answer-option.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.01);
}

.answer-option.correct {
    border-color: #10b981;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.answer-option.incorrect {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #7f1d1d;
}

.answer-label {
    font-weight: 600;
    margin-right: 14px;
    min-width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.25s;
}

.answer-option.selected .answer-label {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.answer-option.correct .answer-label {
    background: #10b981;
    color: white;
}

.answer-option.incorrect .answer-label {
    background: #ef4444;
    color: white;
}

.question-controls {
    display: flex;
    gap: 12px;
    margin-top: 15px;
}

.question-controls .btn-secondary,
.question-controls .btn-primary {
    flex: 1;
    margin-top: 0;
}

.results-container {
    text-align: center;
}

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

.results-header h2 {
    font-size: 2.2rem;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.score-display {
    margin-bottom: 30px;
}

.score-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.25);
    position: relative;
    overflow: hidden;
}

.score-circle::before {
    content: '';
    position: absolute;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    top: -10%;
    left: -10%;
}

.score-circle span {
    font-size: 2.2rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.results-breakdown {
    text-align: left;
    margin-top: 30px;
}

.results-breakdown h3 {
    margin-bottom: 20px;
    color: #1e293b;
    font-size: 1.25rem;
    font-weight: 600;
    position: relative;
    display: inline-block;
}

.results-breakdown h3::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 35px;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
}

.review-item {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 14px;
    border-left: 3px solid #e2e8f0;
    transition: transform 0.2s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.02);
}

.review-item:hover {
    transform: translateX(3px);
}

.review-item.correct {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #f0fdfa 0%, #dcfce7 100%);
}

.review-item.incorrect {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.review-question {
    font-weight: 500;
    margin-bottom: 10px;
    color: #1e293b;
    font-size: 1rem;
    line-height: 1.45;
}

.review-answer {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.5;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
}

.review-answer.correct {
    color: #065f46;
}

.review-answer.incorrect {
    color: #7f1d1d;
}

/* Animation enhancements */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quiz-container *, .results-container * {
    animation: fadeInUp 0.4s ease-out;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 20px 12px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .quiz-setup, .quiz-container, .results-container {
        padding: 24px 18px;
    }
    
    .quiz-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .question-controls {
        flex-direction: column;
    }
    
    .score-circle {
        width: 140px;
        height: 140px;
    }
    
    .score-circle span {
        font-size: 2rem;
    }
    
    .results-header h2 {
        font-size: 1.8rem;
    }
}

/* API Key Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    margin: 5% auto;
    padding: 0;
    border-radius: 18px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    position: relative;
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

.modal-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.close:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 24px;
}

.api-key-form label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
    color: #374151;
    font-size: 0.95rem;
}

.input-with-button {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#api-key-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
}

#api-key-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

#saveApiKeyBtn {
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
}

.api-key-help {
    background: #f8fafc;
    padding: 18px;
    border-radius: 12px;
    border-left: 3px solid #667eea;
}

.api-key-help h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #1e293b;
    font-size: 1.1rem;
}

.api-key-help ol {
    padding-left: 20px;
    margin-bottom: 15px;
}

.api-key-help li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.api-key-help a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.api-key-help a:hover {
    text-decoration: underline;
}

.api-key-section {
    margin-top: 15px;
}

.small-btn {
    padding: 8px 16px !important;
    font-size: 14px !important;
    width: auto !important;
    margin: 0 !important;
}

@media (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
    
    .input-with-button {
        flex-direction: column;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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