/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

header h1 {
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-size: 2.5rem;
    font-weight: 600;
}

header p {
    color: #718096;
    font-size: 1.1rem;
}

/* Sections */
.form-section,
.story-section,
.questions-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.form-section h2,
.story-section h2,
.questions-section h2 {
    color: #4a5568;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    font-weight: 600;
}

#storyTitle {
    color: #667eea;
    font-style: italic;
    font-weight: 500;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #4a5568;
}

.form-group select,
.form-group input[type="range"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: background 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #5a67d8;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #718096;
}

/* Buttons */
button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

#generateBtn {
    width: 100%;
    font-size: 1.1rem;
    padding: 1rem;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.question-btn,
.check-btn {
    flex: 1;
}

.secondary-btn {
    background: #718096;
}

.secondary-btn:hover:not(:disabled) {
    background: #4a5568;
}

/* Story Content */
.story-content {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    white-space: pre-wrap;
}

/* Questions */
.question {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid #667eea;
}

.question h3 {
    color: #4a5568;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.options {
    display: grid;
    gap: 0.5rem;
}

.option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.option:hover {
    background: #e2e8f0;
}

.option input[type="radio"] {
    margin: 0;
}

.option.correct {
    background: #c6f6d5;
    border: 2px solid #38a169;
}

.option.incorrect {
    background: #fed7d7;
    border: 2px solid #e53e3e;
}

.option.correct-answer {
    background: #bee3f8;
    border: 2px solid #3182ce;
}

/* Results */
.results {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1.5rem;
    text-align: center;
}

.score {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.score.excellent { color: #38a169; }
.score.good { color: #3182ce; }
.score.fair { color: #d69e2e; }
.score.poor { color: #e53e3e; }

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

.spinner.large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
}

.loading-content p {
    margin-top: 1rem;
    color: #4a5568;
    font-size: 1.1rem;
}

/* Error Message */
.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #e53e3e;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .form-section,
    .story-section,
    .questions-section {
        padding: 1.5rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .question-btn,
    .check-btn {
        width: 100%;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}