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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: white;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.screen {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    min-height: 400px;
}

.hidden {
    display: none;
}

/* Chapter Selection */
.progress-management {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-left: 4px solid #667eea;
}

.progress-management h3 {
    margin: 0 0 15px 0;
    color: #667eea;
    font-size: 1.2rem;
}

.progress-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.import-section {
    display: flex;
    align-items: center;
}

.import-export-message {
    margin-top: 15px;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.import-export-message.success {
    background: #e8f5e8;
    color: #4CAF50;
    border: 1px solid #c8e6c9;
}

.import-export-message.error {
    background: #ffeaea;
    color: #f44336;
    border: 1px solid #ffcdd2;
}

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

.chapter-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.chapter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    background: linear-gradient(135deg, #45a049, #4CAF50);
}

.chapter-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.chapter-meta {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 10px;
    font-weight: 500;
}

.chapter-description {
    font-size: 0.95rem;
    line-height: 1.4;
    opacity: 0.9;
}

/* Chapter Info */
.chapter-info {
    text-align: center;
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 12px;
    border-left: 4px solid #4CAF50;
}

.chapter-info h2 {
    color: #4CAF50;
    margin: 10px 0 8px 0;
    font-size: 1.8rem;
}

.chapter-info p {
    color: #666;
    line-height: 1.5;
    margin: 0;
}

/* Life System */
.life-system {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.life-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.life-label {
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

#lives-count {
    font-size: 1.2rem;
    letter-spacing: 2px;
}

#lives-count.low-lives {
    animation: pulse 1.5s infinite;
}

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

.life-timer {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
    padding: 5px 10px;
    background: #f0f0f0;
    border-radius: 20px;
    display: inline-block;
}

.no-lives-message {
    font-size: 0.9rem;
    color: #f44336;
    font-weight: 600;
    padding: 8px 12px;
    background: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: 20px;
    display: inline-block;
    margin-top: 5px;
}

/* Quiz Selection Screen */
.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.quiz-btn {
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.quiz-title {
    font-size: 1rem;
    margin-bottom: 5px;
}

.quiz-score {
    font-size: 0.9rem;
    margin-bottom: 3px;
    opacity: 0.9;
}

.quiz-stars {
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: #FFD700;
    text-shadow: 0 0 2px rgba(0,0,0,0.3);
}

.quiz-btn.available {
    background: #4CAF50;
    color: white;
}

.quiz-btn.available:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.quiz-btn.completed {
    background: #2196F3;
    color: white;
}

.quiz-btn.completed:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

.quiz-btn.locked {
    background: #ddd;
    color: #999;
    cursor: not-allowed;
}

.progress-summary {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    border-left: 5px solid #3498db;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.progress-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: center;
}

.progress-item, .score-item {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.progress-label, .score-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
    font-weight: 500;
}

.progress-value, .score-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.progress-text {
    display: block;
    font-size: 0.8rem;
    color: #7f8c8d;
}

.total-score-display {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9ff;
    border-radius: 10px;
    border: 2px solid #667eea;
}

.total-score-display p {
    margin: 0;
    font-weight: bold;
    color: #667eea;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.total-stars {
    font-size: 1.5rem;
    letter-spacing: 3px;
    color: #FFD700;
    text-shadow: 0 0 3px rgba(0,0,0,0.3);
}

/* Quiz Screen */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.quiz-header h2 {
    color: #333;
}

.progress {
    color: #666;
    font-weight: bold;
}

.question-container {
    margin-bottom: 30px;
}

#question-text {
    font-size: 1.3rem;
    margin-bottom: 25px;
    line-height: 1.5;
    color: #333;
}

.options {
    display: grid;
    gap: 15px;
}

.option-btn {
    padding: 15px 20px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.option-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.option-btn.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.option-btn.correct {
    border-color: #4CAF50;
    background: #4CAF50;
    color: white;
}

.option-btn.incorrect {
    border-color: #f44336;
    background: #f44336;
    color: white;
}

/* Explanation Section */
.explanation {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9ff;
    border-left: 4px solid #667eea;
    border-radius: 8px;
    animation: fadeIn 0.5s ease-in;
}

.explanation-label {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 8px;
    font-size: 1rem;
}

.explanation-content {
    color: #333;
    line-height: 1.5;
    font-size: 0.95rem;
}

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

.quiz-actions {
    display: flex;
    gap: 15px;
    justify-content: space-between;
    margin-top: 30px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* Quiz Summary Screen */
.summary-content {
    text-align: center;
}

.summary-content h3 {
    margin-bottom: 20px;
    color: #333;
}

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

#score-text {
    font-size: 1.5rem;
    color: #333;
    display: block;
    margin-bottom: 15px;
}

.score-percentage {
    font-size: 3rem;
    font-weight: bold;
    color: #667eea;
}

.answers-review {
    margin: 30px 0;
    text-align: left;
}

.answer-item {
    padding: 15px;
    margin: 10px 0;
    border-radius: 8px;
    border-left: 4px solid;
}

.answer-item.correct {
    background: #e8f5e8;
    border-color: #4CAF50;
}

.answer-item.incorrect {
    background: #ffeaea;
    border-color: #f44336;
}

.answer-question {
    font-weight: bold;
    margin-bottom: 5px;
}

.answer-details {
    font-size: 0.9rem;
    color: #666;
}

.answer-explanation {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #555;
    font-style: italic;
}

.summary-actions {
    display: flex;
    gap: 15px;
    justify-content: space-between;
    margin-top: 30px;
}

/* Completion Screen */
.completion-content {
    text-align: center;
}

.completion-content h3 {
    margin-bottom: 20px;
    color: #333;
}

.final-stats {
    margin: 30px 0;
    font-size: 1.2rem;
}

.final-stats p {
    margin: 10px 0;
}

.completion-actions {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

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

    header h1 {
        font-size: 2rem;
    }

    .screen {
        padding: 20px;
    }

    .life-system {
        padding: 10px;
        margin-bottom: 20px;
    }

    .life-display {
        flex-direction: column;
        gap: 5px;
        margin-bottom: 8px;
    }

    #lives-count {
        font-size: 1.1rem;
    }

    .life-timer {
        font-size: 0.8rem;
    }

    .quiz-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 10px;
    }

    .quiz-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .quiz-actions {
        flex-direction: column;
    }

    .summary-actions {
        flex-direction: column;
    }

    .progress-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .progress-management {
        padding: 15px;
        margin: 15px 0;
    }
}