/* Quiz-specific styles */

.back-link {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.9;
}

.back-link:hover {
    opacity: 1;
}

/* Quiz Intro */
.quiz-intro {
    text-align: center;
    padding: 20px;
}

.quiz-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.quiz-intro h2 {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.quiz-intro p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.quiz-info {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--background);
    border-radius: var(--radius);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

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

.student-name-section {
    margin-bottom: 24px;
}

.student-name-section label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.student-name-section input {
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    width: 100%;
    max-width: 300px;
    text-align: center;
    transition: border-color 0.2s;
}

.logged-in-user {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: #eef2ff;
    border-radius: var(--radius);
}

.logged-in-user .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
}

.login-prompt {
    margin-bottom: 24px;
    padding: 20px;
    background: #fef3c7;
    border-radius: var(--radius);
    text-align: center;
}

.login-prompt p {
    margin: 0 0 16px 0;
    color: #92400e;
}

.login-prompt .btn {
    margin-bottom: 0;
}

.student-name-section input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-large {
    padding: 16px 48px;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

/* Quiz Header */
.quiz-header {
    margin-bottom: 24px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Question Container */
#question-container {
    min-height: 300px;
}

.question-card {
    animation: fadeIn 0.3s ease;
}

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

.quiz-question {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
    line-height: 1.5;
}

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

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

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

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

.quiz-option.correct {
    border-color: var(--secondary-color);
    background: #dcfce7;
}

.quiz-option.incorrect {
    border-color: #ef4444;
    background: #fee2e2;
}

.option-letter {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-color);
    border-radius: 50%;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

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

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

.quiz-option.incorrect .option-letter {
    background: #ef4444;
    color: white;
}

/* Quiz Navigation */
.quiz-navigation {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.quiz-navigation button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quiz-navigation button:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Results Screen */
.results-header {
    text-align: center;
    margin-bottom: 24px;
}

.results-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.score-display {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

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

.score-circle.excellent {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.score-circle.good {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.score-circle.needs-work {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--background);
    border-radius: var(--radius);
}

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

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

.results-breakdown {
    margin-bottom: 24px;
}

.breakdown-item {
    padding: 16px;
    background: var(--background);
    border-radius: var(--radius);
    margin-bottom: 12px;
    border-left: 4px solid var(--border-color);
}

.breakdown-item.correct {
    border-left-color: var(--secondary-color);
}

.breakdown-item.incorrect {
    border-left-color: #ef4444;
}

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

.breakdown-answer {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.breakdown-explanation {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-top: 8px;
}

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

/* History Screen */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--background);
    border-radius: var(--radius);
}

.stats-item {
    text-align: center;
    padding: 12px;
}

.stats-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stats-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-list {
    margin-bottom: 24px;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--background);
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.history-score {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    margin-right: 16px;
    flex-shrink: 0;
}

.history-score.excellent {
    background: var(--secondary-color);
}

.history-score.good {
    background: #3b82f6;
}

.history-score.needs-work {
    background: #f59e0b;
}

.history-details {
    flex: 1;
}

.history-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.history-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Chapter card improvements */
.chapter-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chapter-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.chapter-score {
    font-weight: 700;
    font-size: 0.9rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* ============ MATH QUESTION TYPES ============ */

/* Math question card */
.math-question {
    padding: 20px;
}

/* Number input */
.math-input-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 24px 0;
}

.math-input {
    padding: 16px 20px;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    border: 3px solid var(--border-color);
    border-radius: var(--radius);
    width: 150px;
    transition: border-color 0.2s;
}

.math-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.math-unit {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.math-submit-btn {
    margin-top: 16px;
}

/* Multi-input */
.multi-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin: 24px 0;
}

.multi-input-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.multi-input-field label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.multi-input-field .math-input {
    width: 120px;
}

/* Grid select (multiples, factors) */
.grid-select-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 10px;
    max-width: 400px;
    margin: 24px auto;
}

.grid-item {
    padding: 16px;
    font-size: 1.2rem;
    font-weight: 600;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.grid-item:hover {
    border-color: var(--primary-color);
    background: #f1f5f9;
}

.grid-item.selected {
    background: #ef4444;
    border-color: #dc2626;
    color: white;
    text-decoration: line-through;
}

/* Sequence */
.sequence-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0;
    padding: 20px;
    background: var(--background);
    border-radius: var(--radius);
}

.sequence-item {
    padding: 12px 16px;
    font-size: 1.2rem;
    font-weight: 600;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    min-width: 60px;
    text-align: center;
}

.sequence-gap {
    padding: 8px;
}

.sequence-input {
    width: 60px;
    padding: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    border: 2px dashed var(--primary-color);
    border-radius: var(--radius);
    background: #fef3c7;
}

.sequence-input:focus {
    outline: none;
    border-style: solid;
    background: white;
}

.sequence-arrow {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* Ordering */
.ordering-hint {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.ordering-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 300px;
    margin: 0 auto 24px;
}

.ordering-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: move;
    transition: all 0.2s;
}

.ordering-item:hover {
    border-color: var(--primary-color);
}

.ordering-handle {
    color: var(--text-secondary);
    margin-right: 12px;
    cursor: grab;
}

.ordering-value {
    flex: 1;
    font-weight: 600;
    font-size: 1.1rem;
}

.ordering-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ordering-btn {
    padding: 4px 8px;
    background: var(--border-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.ordering-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.ordering-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Remainder */
.remainder-container {
    text-align: center;
    margin: 24px 0;
}

.remainder-equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
    font-size: 2rem;
}

.remainder-number {
    font-weight: 700;
    color: var(--text-primary);
}

.remainder-operator,
.remainder-equals {
    color: var(--text-secondary);
}

.remainder-inputs {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
}

.remainder-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.remainder-field label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.remainder-field .math-input {
    width: 80px;
}

.remainder-r {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 600px) {
    .quiz-info,
    .results-stats {
        flex-direction: column;
        gap: 20px;
    }

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

    .quiz-navigation .btn {
        width: 100%;
    }

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

    .results-actions .btn {
        width: 100%;
    }

    .sequence-container {
        flex-direction: column;
    }

    .sequence-arrow {
        transform: rotate(90deg);
    }

    .remainder-equation {
        font-size: 1.5rem;
    }

    .grid-select-container {
        grid-template-columns: repeat(4, 1fr);
    }

    .mode-cards {
        flex-direction: column;
        align-items: stretch;
    }

    .hint-bubble {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .hint-button {
        font-size: 0.85rem;
        padding: 10px 16px;
    }
}

/* ============ QUIZ MODES ============ */
.quiz-modes { margin: 24px 0; }
.quiz-modes h3 { text-align: center; margin-bottom: 16px; color: var(--text-secondary); font-size: 1rem; }
.mode-cards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.mode-card {
    display: flex; flex-direction: column; align-items: center;
    padding: 20px 16px; background: var(--surface);
    border: 2px solid var(--border-color); border-radius: var(--radius);
    cursor: pointer; transition: all 0.2s; min-width: 110px;
    font-family: inherit;
}
.mode-card:hover, .mode-card.selected { border-color: var(--primary-color); background: #eef2ff; }
.mode-icon { font-size: 2rem; margin-bottom: 8px; }
.mode-name { font-weight: 700; font-size: 1rem; }
.mode-detail { font-size: 0.85rem; color: var(--text-secondary); }
.mode-xp { font-size: 0.75rem; color: var(--primary-color); margin-top: 4px; font-weight: 600; }

/* ============ HEADER TOP ROW ============ */
.header-top-row {
    display: flex; justify-content: space-between; align-items: center; width: 100%;
}
.header-top-row .back-link { margin: 0; }

/* ============ FEEDBACK OVERLAY ============ */
#question-container { position: relative; min-height: 200px; }

.feedback-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: var(--radius); z-index: 10;
    animation: feedbackAppear 0.3s ease;
    padding: 24px;
}
.feedback-correct { background: rgba(34, 197, 94, 0.95); color: white; }
.feedback-wrong { background: rgba(239, 68, 68, 0.92); color: white; }
.feedback-icon { font-size: 3rem; margin-bottom: 8px; font-weight: 700; }
.feedback-text { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.feedback-answer { font-size: 1rem; opacity: 0.9; margin-bottom: 6px; }
.feedback-explanation { font-size: 0.85rem; opacity: 0.85; max-width: 400px; text-align: center; }
.feedback-combo { font-size: 1.2rem; font-weight: 700; margin-top: 8px; animation: comboPulse 0.5s ease; }
.feedback-continue { margin-top: 16px; background: rgba(255,255,255,0.25); color: white; border: 2px solid rgba(255,255,255,0.5); padding: 8px 24px; border-radius: var(--radius); font-size: 1rem; cursor: pointer; font-weight: 600; transition: background 0.2s; }
.feedback-continue:hover { background: rgba(255,255,255,0.4); }

/* Combo banner during quiz */
.combo-banner {
    text-align: center; padding: 8px; font-weight: 700; font-size: 1.1rem;
    color: #ea580c; background: #fff7ed; border-radius: var(--radius);
    margin-bottom: 12px; animation: comboPulse 0.4s ease;
}

@keyframes feedbackAppear { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
@keyframes comboPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* ============ HINT SYSTEM ============ */

/* Hint button */
.hint-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 16px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-family: inherit;
}
.hint-button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    transform: translateY(-1px);
}
.hint-button .hint-icon {
    font-size: 1.1rem;
}
.hint-button .hint-penalty {
    font-size: 0.75rem;
    opacity: 0.7;
    font-weight: 400;
}
.hint-button.used {
    border-style: solid;
    background: #fefce8;
    border-color: #fbbf24;
    color: #92400e;
}
.hint-button.used:hover {
    background: #fef9c3;
    border-color: #f59e0b;
}
.hint-button.solve-btn {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #fca5a5;
    color: #991b1b;
}
.hint-button.solve-btn:hover {
    background: #fee2e2;
    border-color: #ef4444;
}

/* Hint bubble (inline in question card) */
.hint-bubble {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 12px 0;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 2px solid #fde68a;
    border-radius: 12px;
    animation: hintAppear 0.3s ease;
}
.hint-bubble .hint-dragon-mini {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
}
.hint-bubble-text {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: #78350f;
    line-height: 1.4;
}
.hint-bubble-text strong {
    color: #92400e;
}

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

/* Eliminated options (multiple choice) */
.quiz-option.hint-eliminated {
    opacity: 0.3;
    pointer-events: none;
    text-decoration: line-through;
    border-color: #e2e8f0;
    background: #f8fafc;
}
.quiz-option.hint-eliminated .option-letter {
    background: #e2e8f0;
    color: #94a3b8;
}

/* Revealed correct option */
.quiz-option.hint-correct {
    border-color: #22c55e;
    background: #dcfce7;
    pointer-events: none;
}
.quiz-option.hint-correct .option-letter {
    background: #22c55e;
    color: white;
}

/* Grid items eliminated / revealed */
.grid-item.hint-eliminated {
    opacity: 0.25;
    pointer-events: none;
    border-color: #e2e8f0;
    background: #f8fafc;
}
.grid-item.hint-revealed {
    border-color: #22c55e;
    background: #dcfce7;
    color: #166534;
    font-weight: 700;
}

/* Ordering items locked */
.ordering-item.hint-locked {
    background: #dcfce7;
    border-color: #22c55e;
    pointer-events: none;
}
.ordering-item.hint-locked .ordering-handle {
    color: #22c55e;
}
.ordering-item.hint-locked .ordering-buttons {
    visibility: hidden;
}
.ordering-item.hint-locked::after {
    content: '\1F512';
    font-size: 0.8rem;
    margin-left: 8px;
}

/* Range text for number input hints */
.hint-range-text {
    text-align: center;
    padding: 10px 16px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    font-weight: 600;
    color: #92400e;
    margin: 8px 0 16px;
    font-size: 1rem;
}

/* Revealed input field */
.math-input.hint-field-revealed {
    border-color: #22c55e;
    background: #dcfce7;
    color: #166534;
}

/* Sequence rule text */
.hint-rule-text {
    text-align: center;
    padding: 8px 14px;
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: var(--radius);
    font-weight: 600;
    color: #1e40af;
    margin: 8px 0;
    font-size: 0.95rem;
}

/* Hint badge in results breakdown */
.hint-used-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 10px;
    color: #92400e;
    margin-left: 8px;
    vertical-align: middle;
}

/* Solve reveal highlight */
.hint-solve-answer {
    text-align: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border: 2px solid #22c55e;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1.2rem;
    color: #166534;
    margin: 12px 0;
    animation: hintAppear 0.3s ease;
}
