/* =====================================================
   Exam CSS - Kid-Friendly Colorful Design
   PreSchool Assessment System
   ===================================================== */

/* ---- Variables ---- */
:root {
    --kid-bg: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #f5576c 75%, #ffecd2 100%);
    --kid-bg-alt: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    --kid-card: rgba(255, 255, 255, 0.95);
    --kid-card-glass: rgba(255, 255, 255, 0.85);
    --kid-text: #2d3748;
    --kid-text-light: #718096;
    --kid-primary: #667eea;
    --kid-success: #48bb78;
    --kid-danger: #fc8181;
    --kid-warning: #f6ad55;
    --kid-radius: 20px;
    --kid-radius-sm: 14px;
    --kid-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    --kid-shadow-lg: 0 15px 50px rgba(0, 0, 0, 0.15);
    --kid-font: 'Baloo 2', 'Quicksand', -apple-system, sans-serif;
    --kid-font-body: 'Quicksand', -apple-system, sans-serif;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.exam-body {
    font-family: var(--kid-font-body);
    background: var(--kid-bg);
    background-size: 400% 400%;
    animation: gradientShift 20s ease infinite;
    min-height: 100vh;
    color: var(--kid-text);
    overflow-x: hidden;
    position: relative;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    25% { background-position: 50% 0%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 100%; }
    100% { background-position: 0% 50%; }
}

/* ---- Floating Decorations ---- */
.floating-deco {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.deco {
    position: absolute;
    font-size: 28px;
    opacity: 0.4;
    animation: floatAround 15s ease-in-out infinite;
}

.deco-1 { top: 10%; left: 5%; animation-delay: 0s; animation-duration: 18s; }
.deco-2 { top: 20%; right: 8%; animation-delay: -3s; animation-duration: 22s; }
.deco-3 { top: 60%; left: 3%; animation-delay: -6s; animation-duration: 16s; }
.deco-4 { bottom: 15%; right: 5%; animation-delay: -2s; animation-duration: 20s; }
.deco-5 { top: 40%; left: 90%; animation-delay: -8s; animation-duration: 14s; }
.deco-6 { top: 75%; left: 50%; animation-delay: -4s; animation-duration: 19s; }
.deco-7 { top: 5%; left: 60%; animation-delay: -7s; animation-duration: 17s; }
.deco-8 { bottom: 30%; right: 15%; animation-delay: -1s; animation-duration: 21s; }

@keyframes floatAround {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(20px, -30px) rotate(10deg); }
    50% { transform: translate(-15px, -50px) rotate(-5deg); }
    75% { transform: translate(25px, -20px) rotate(8deg); }
}

/* ---- Exam Container ---- */
.exam-container {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* ---- Confetti Canvas ---- */
.confetti-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
}

/* ---- Mascot ---- */
.mascot-container {
    width: 120px; height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 25px rgba(255, 193, 7, 0.3);
    animation: mascotBounce 3s ease-in-out infinite;
    margin: 0 auto 16px;
}

.mascot-container.mascot-small {
    width: 80px; height: 80px;
}

.mascot-container.mascot-celebrate {
    animation: mascotCelebrate 1.5s ease-in-out infinite;
}

.mascot-emoji {
    font-size: 60px;
}

.mascot-small .mascot-emoji { font-size: 40px; }

@keyframes mascotBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.03); }
}

@keyframes mascotCelebrate {
    0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
    25% { transform: translateY(-15px) rotate(-5deg) scale(1.05); }
    75% { transform: translateY(-15px) rotate(5deg) scale(1.05); }
}

/* ---- Speech Bubble ---- */
.speech-bubble {
    background: var(--kid-card);
    border-radius: var(--kid-radius);
    padding: 24px 32px;
    box-shadow: var(--kid-shadow);
    position: relative;
    text-align: center;
    margin-bottom: 32px;
    font-size: 18px;
    line-height: 1.8;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-bottom: 16px solid var(--kid-card);
}

.speech-bubble p { margin-bottom: 4px; }
.speech-bubble strong { color: var(--kid-primary); }

/* ---- Welcome Screen ---- */
.exam-welcome {
    padding: 30px 0;
}

.welcome-sections {
    margin-top: 20px;
}

.section-title {
    font-family: var(--kid-font);
    font-size: 28px;
    text-align: center;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

.section-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.section-card {
    background: var(--kid-card-glass);
    backdrop-filter: blur(10px);
    border-radius: var(--kid-radius-sm);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--kid-shadow);
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.section-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--kid-shadow-lg);
    border-color: var(--accent, var(--kid-primary));
}

.section-card.completed {
    opacity: 0.7;
    border-color: var(--kid-success);
}

.section-card-icon {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent, var(--kid-primary)), rgba(255,255,255,0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-num {
    font-family: var(--kid-font);
    font-size: 22px;
    font-weight: 800;
    color: #fff;
}

.done-check { font-size: 24px; }

.section-card-body {
    flex: 1;
}

.section-card-body h3 {
    font-family: var(--kid-font);
    font-size: 18px;
    font-weight: 700;
    color: var(--kid-text);
    margin-bottom: 2px;
}

.section-card-info {
    font-size: 13px;
    color: var(--kid-text-light);
}

.welcome-complete {
    text-align: center;
    margin-top: 32px;
}

.welcome-footer {
    text-align: center;
    margin-top: 24px;
}

/* ---- Kid Buttons ---- */
.btn-kid {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    font-family: var(--kid-font);
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, var(--kid-primary), #764ba2);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    white-space: nowrap;
}

.btn-kid:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    color: #fff;
}

.btn-kid:active {
    transform: translateY(0) scale(0.97);
}

.btn-kid.btn-play {
    background: linear-gradient(135deg, #48bb78, #38a169);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
}

.btn-kid.btn-success {
    background: linear-gradient(135deg, #48bb78, #2f855a);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
    font-size: 20px;
    padding: 16px 40px;
}

.btn-kid.btn-big {
    font-size: 20px;
    padding: 16px 40px;
}

.btn-kid.btn-nav {
    padding: 10px 24px;
    font-size: 15px;
    min-width: 100px;
}

.btn-kid.btn-primary-kid {
    background: linear-gradient(135deg, var(--kid-primary), #764ba2);
}

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

.btn-ghost-kid {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--kid-font-body);
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}
.btn-ghost-kid:hover {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

/* ---- Exam Top Bar ---- */
.exam-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--kid-card-glass);
    backdrop-filter: blur(10px);
    border-radius: var(--kid-radius-sm);
    box-shadow: var(--kid-shadow);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.exam-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-back-kid {
    font-size: 14px;
    font-weight: 600;
    color: var(--kid-text-light);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 50px;
    background: rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}
.btn-back-kid:hover {
    background: rgba(0,0,0,0.1);
    color: var(--kid-text);
}

.exam-section-name {
    font-family: var(--kid-font);
    font-size: 18px;
    font-weight: 700;
    color: var(--kid-text);
}

.exam-progress-bar {
    flex: 1;
    height: 12px;
    background: rgba(0,0,0,0.08);
    border-radius: 100px;
    overflow: hidden;
    min-width: 120px;
}

.exam-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--theme-color, var(--kid-primary)), #f093fb);
    border-radius: 100px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.exam-score-display {
    font-family: var(--kid-font);
    font-size: 18px;
    font-weight: 700;
    color: #f6ad55;
    white-space: nowrap;
}

/* ---- Question Slides ---- */
.exam-questions-wrapper {
    position: relative;
    min-height: 400px;
}

@media (orientation: landscape) and (max-height: 500px) {
    .exam-questions-wrapper {
        min-height: 0;
    }
}

.exam-question-slide {
    display: none;
    animation: fadeSlideIn 0.4s ease-out;
}

.exam-question-slide.active {
    display: block;
}

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

.question-card-kid {
    background: var(--kid-card);
    border-radius: var(--kid-radius);
    padding: 32px;
    box-shadow: var(--kid-shadow-lg);
    text-align: center;
}

/* ---- Question Top Row (badge + TTS) ---- */
.question-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.question-badge {
    display: inline-block;
    padding: 4px 16px;
    background: linear-gradient(135deg, var(--kid-primary), #764ba2);
    color: #fff;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 700;
}

/* ---- TTS Button ---- */
.tts-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: linear-gradient(135deg, #f6ad55, #ed8936);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--kid-font);
    font-size: 14px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 3px 12px rgba(237, 137, 54, 0.35);
}

.tts-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 20px rgba(237, 137, 54, 0.5);
}

.tts-btn:active {
    transform: scale(0.95);
}

.tts-btn.speaking {
    animation: ttsPulse 1s ease-in-out infinite;
    background: linear-gradient(135deg, #48bb78, #38a169);
    box-shadow: 0 3px 15px rgba(72, 187, 120, 0.4);
}

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

.tts-icon {
    font-size: 20px;
    line-height: 1;
}

.tts-label {
    font-size: 13px;
}

/* ---- Large Emoji Illustration ---- */
.question-illustration {
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #fefce8, #fef3c7, #fde68a);
    border-radius: var(--kid-radius);
    border: 3px dashed #fbbf24;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.illustration-emojis {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.illustration-emoji {
    display: inline-block;
    animation: emojiPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.15));
}

/* Size tiers based on emoji count */
.emojis-large .illustration-emoji {
    font-size: 72px;
}

.emojis-medium .illustration-emoji {
    font-size: 56px;
}

.emojis-small .illustration-emoji {
    font-size: 44px;
}

@keyframes emojiPop {
    from { transform: scale(0) rotate(-15deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.question-text-kid {
    font-family: var(--kid-font);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.6;
    color: var(--kid-text);
    margin-bottom: 24px;
    white-space: pre-wrap;
}

.question-media {
    margin-bottom: 24px;
}
.question-media img {
    max-width: 100%;
    max-height: 350px;
    border-radius: var(--kid-radius);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    border: 3px solid #e2e8f0;
}

/* ---- Options Grid ---- */
.options-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.options-2 { grid-template-columns: repeat(2, 1fr); }
.options-3 { grid-template-columns: repeat(3, 1fr); }
.options-4 { grid-template-columns: repeat(2, 1fr); }

.option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #f7fafc;
    border: 3px solid #e2e8f0;
    border-radius: var(--kid-radius-sm);
    cursor: pointer;
    font-family: var(--kid-font-body);
    font-size: 16px;
    font-weight: 600;
    color: var(--kid-text);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: left;
    min-height: 60px;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--kid-primary);
    background: #eef2ff;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.option-btn:active:not(:disabled) {
    transform: scale(0.97);
}

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

.option-btn.correct {
    border-color: var(--kid-success) !important;
    background: #f0fff4 !important;
    animation: correctPulse 0.5s ease;
}

.option-btn.wrong {
    border-color: var(--kid-danger) !important;
    background: #fff5f5 !important;
    animation: wrongShake 0.5s ease;
}

.option-btn:disabled {
    cursor: default;
    opacity: 0.8;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.option-letter {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--kid-primary), #764ba2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    flex-shrink: 0;
}

.option-text {
    flex: 1;
}

/* ---- Option TTS Speaker ---- */
.option-tts {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #f6ad55, #ed8936);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(237, 137, 54, 0.3);
    opacity: 0.7;
}

.option-tts:hover {
    opacity: 1;
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(237, 137, 54, 0.5);
}

.option-tts:active {
    transform: scale(0.9);
}

.option-tts.option-speaking {
    opacity: 1;
    background: linear-gradient(135deg, #48bb78, #38a169);
    box-shadow: 0 2px 10px rgba(72, 187, 120, 0.4);
    animation: ttsPulse 1s ease-in-out infinite;
}

/* Independent speaker controls remain available after answers are disabled. */
.option-choice {
    position: relative;
    display: flex;
    min-width: 0;
}

.option-choice > .option-btn {
    width: 100%;
    padding-right: 62px;
}

.option-choice > .option-tts {
    position: absolute;
    right: 8px;
    top: 50%;
    margin-top: -22px;
    width: 44px;
    height: 44px;
    border: 0;
    padding: 0;
}

.exam-audio-panel {
    display: none !important;
    padding: 6px 10px;
    margin-bottom: 6px;
    border-radius: 10px;
    background: #eef2ff;
    color: #24325a;
    font-size: 13px;
    flex-shrink: 0;
}

.exam-audio-panel audio {
    display: block;
    width: 100%;
    max-width: 360px;
    margin-top: 6px;
}

.exam-audio-panel a {
    display: inline-block;
    margin: 6px 0;
}

.exam-audio-panel[hidden], .exam-audio-panel [hidden] {
    display: none;
}

/* ---- Question Feedback ---- */
.question-feedback {
    display: none;
    padding: 14px 20px;
    border-radius: var(--kid-radius-sm);
    margin-top: 16px;
    font-family: var(--kid-font);
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    animation: feedbackPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes feedbackPop {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.feedback-correct {
    background: linear-gradient(135deg, #c6f6d5, #9ae6b4);
    color: #22543d;
}

.feedback-wrong {
    background: linear-gradient(135deg, #fed7d7, #feb2b2);
    color: #742a2a;
}

/* ---- Exam Navigation ---- */
.exam-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 24px;
    padding: 16px 0;
}

.exam-dots {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.exam-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.exam-dot.active {
    background: #fff;
    transform: scale(1.3);
    border-color: var(--kid-primary);
}

.exam-dot.answered {
    background: var(--kid-success);
}

.exam-complete-section {
    text-align: center;
    margin-top: 20px;
    animation: fadeSlideIn 0.5s ease;
}

/* ---- EQ Form ---- */
.exam-eq {
    padding: 30px 0;
}

.eq-header {
    text-align: center;
    margin-bottom: 32px;
}

.eq-title {
    font-family: var(--kid-font);
    font-size: 28px;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.eq-subtitle {
    font-size: 16px;
    color: rgba(255,255,255,0.9);
    margin-top: 8px;
}

.eq-hint {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    margin-top: 4px;
}

.eq-category-card {
    background: var(--kid-card);
    border-radius: var(--kid-radius);
    padding: 28px;
    box-shadow: var(--kid-shadow);
    margin-bottom: 20px;
}

.eq-category-title {
    font-family: var(--kid-font);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--kid-text);
}

.eq-category-desc {
    font-size: 14px;
    color: var(--kid-text-light);
    margin-bottom: 20px;
}

.eq-questions {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.eq-question-item {
    padding: 16px 0;
    border-bottom: 1px solid #e2e8f0;
}
.eq-question-item:last-child { border-bottom: none; }

.eq-question-text {
    display: block;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--kid-text);
}

.eq-rating-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.eq-rating-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.eq-rating-option input[type="radio"] {
    display: none;
}

.eq-rating-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    width: 100%;
    transition: all 0.3s ease;
    cursor: pointer;
}

.eq-rating-option input:checked + .eq-rating-label {
    border-color: var(--kid-primary);
    background: #eef2ff;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.15);
}

.eq-rating-stars { font-size: 16px; }
.eq-rating-text { font-size: 14px; font-weight: 500; color: var(--kid-text); }

.eq-notes-card {
    background: var(--kid-card);
    border-radius: var(--kid-radius);
    padding: 28px;
    box-shadow: var(--kid-shadow);
    margin-bottom: 20px;
}

.form-textarea-kid {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    font-family: var(--kid-font-body);
    font-size: 15px;
    resize: vertical;
    outline: none;
    color: var(--kid-text);
    transition: all 0.3s ease;
}

.form-textarea-kid:focus {
    border-color: var(--kid-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.eq-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ---- Result Screen ---- */
.exam-result {
    padding: 30px 0;
}

.result-celebration {
    text-align: center;
    margin-bottom: 40px;
}

.celebration-stars {
    position: relative;
    height: 60px;
    margin-bottom: 10px;
}

.star {
    position: absolute;
    font-size: 28px;
    animation: starFloat 3s ease-in-out infinite;
}

.star-1 { left: 10%; animation-delay: 0s; }
.star-2 { left: 30%; animation-delay: 0.5s; }
.star-3 { left: 50%; animation-delay: 1s; }
.star-4 { left: 70%; animation-delay: 1.5s; }
.star-5 { left: 85%; animation-delay: 0.3s; }

@keyframes starFloat {
    0%, 100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 0.8; }
    50% { transform: translateY(-20px) scale(1.2) rotate(10deg); opacity: 1; }
}

.result-title {
    font-family: var(--kid-font);
    font-size: 40px;
    color: #fff;
    text-shadow: 0 3px 15px rgba(0,0,0,0.2);
    margin-bottom: 4px;
}

.result-student-name {
    font-family: var(--kid-font);
    font-size: 28px;
    color: #ffecd2;
    text-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.result-subtitle {
    font-size: 16px;
    color: rgba(255,255,255,0.85);
    margin-top: 8px;
}

/* ---- Result Score Cards ---- */
.result-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.result-score-card {
    background: var(--kid-card);
    border-radius: var(--kid-radius);
    padding: 28px;
    box-shadow: var(--kid-shadow-lg);
    text-align: center;
    border-top: 5px solid var(--card-color, var(--kid-primary));
    transition: all 0.3s ease;
}

.result-score-card:hover {
    transform: translateY(-5px);
}

.result-score-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.result-score-name {
    font-family: var(--kid-font);
    font-size: 18px;
    font-weight: 700;
    color: var(--kid-text);
    margin-bottom: 8px;
}

.result-score-percent {
    font-family: var(--kid-font);
    font-size: 40px;
    font-weight: 800;
    color: var(--card-color, var(--kid-primary));
    line-height: 1;
    margin-bottom: 8px;
}

.result-score-level {
    margin-bottom: 16px;
}

/* Level badge overrides for kid theme */
.exam-body .level-badge {
    font-family: var(--kid-font-body);
}

.result-child-scores {
    border-top: 1px solid #e2e8f0;
    padding-top: 16px;
    margin-top: 12px;
}

.result-child-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
}

.result-child-name {
    flex: 1;
    text-align: left;
    font-weight: 600;
    color: var(--kid-text-light);
}

.mini-progress {
    width: 80px;
    height: 8px;
    background: #edf2f7;
    border-radius: 100px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.8s ease;
}

.mini-progress-fill.progress-excellent { background: linear-gradient(90deg, #48bb78, #68d391); }
.mini-progress-fill.progress-good { background: linear-gradient(90deg, #ed8936, #f6ad55); }
.mini-progress-fill.progress-needs-help { background: linear-gradient(90deg, #fc8181, #feb2b2); }

.result-child-pct {
    font-weight: 700;
    min-width: 35px;
    text-align: right;
    color: var(--kid-text);
}

.result-actions {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* ---- Fullscreen Toggle Button ---- */
.fullscreen-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: linear-gradient(135deg, var(--kid-primary), #764ba2);
    color: #fff;
    font-size: 20px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.35);
    flex-shrink: 0;
}

.fullscreen-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.5);
}

.fullscreen-btn:active {
    transform: scale(0.9);
}

.fs-icon {
    line-height: 1;
    pointer-events: none;
}

/* ---- Fullscreen Mode Base ---- */
.exam-body:fullscreen,
.exam-body:-webkit-full-screen {
    background-size: 400% 400%;
}

.exam-body:fullscreen .floating-deco,
.exam-body:-webkit-full-screen .floating-deco {
    display: none;
}

.exam-body:fullscreen .exam-container,
.exam-body:-webkit-full-screen .exam-container {
    max-width: 100%;
    padding: 8px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.exam-body:fullscreen .exam-section,
.exam-body:-webkit-full-screen .exam-section {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ---- Fullscreen Topbar Compact ---- */
.exam-body:fullscreen .exam-topbar,
.exam-body:-webkit-full-screen .exam-topbar {
    flex-direction: row;
    gap: 10px;
    padding: 6px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.exam-body:fullscreen .exam-section-name,
.exam-body:-webkit-full-screen .exam-section-name {
    font-size: 14px;
}

.exam-body:fullscreen .btn-back-kid,
.exam-body:-webkit-full-screen .btn-back-kid {
    padding: 4px 10px;
    font-size: 12px;
}

.exam-body:fullscreen .exam-progress-bar,
.exam-body:-webkit-full-screen .exam-progress-bar {
    height: 8px;
}

/* ---- Fullscreen Questions Area ---- */
.exam-body:fullscreen .exam-questions-wrapper,
.exam-body:-webkit-full-screen .exam-questions-wrapper {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.exam-body:fullscreen .exam-question-slide.active,
.exam-body:-webkit-full-screen .exam-question-slide.active {
    height: 100%;
}

.exam-body:fullscreen .question-card-kid,
.exam-body:-webkit-full-screen .question-card-kid {
    height: 100%;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---- Fullscreen: Landscape Layout (side-by-side) ---- */
@media (orientation: landscape) {
    .exam-body:fullscreen .question-card-kid,
    .exam-body:-webkit-full-screen .question-card-kid {
        flex-direction: row;
        gap: 16px;
        align-items: stretch;
        text-align: left;
    }

    /* Left column: badge, illustration, question text, TTS */
    .exam-body:fullscreen .question-card-kid .question-top-row,
    .exam-body:-webkit-full-screen .question-card-kid .question-top-row {
        position: absolute;
        top: 8px; left: 12px; right: 12px;
        margin-bottom: 0;
        z-index: 2;
    }

    .exam-body:fullscreen .question-card-kid .question-illustration,
    .exam-body:fullscreen .question-card-kid .question-text-kid,
    .exam-body:fullscreen .question-card-kid .question-media,
    .exam-body:-webkit-full-screen .question-card-kid .question-illustration,
    .exam-body:-webkit-full-screen .question-card-kid .question-text-kid,
    .exam-body:-webkit-full-screen .question-card-kid .question-media {
        /* These go in the left column via the natural flow */
    }

    /* Create left/right columns using a wrapper approach */
    .exam-body:fullscreen .question-card-kid,
    .exam-body:-webkit-full-screen .question-card-kid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr auto;
        gap: 8px 16px;
        padding-top: 40px; /* space for top-row */
        position: relative;
    }

    .exam-body:fullscreen .question-top-row,
    .exam-body:-webkit-full-screen .question-top-row {
        grid-column: 1 / -1;
        grid-row: 1;
        position: static;
        margin-bottom: 0;
    }

    .exam-body:fullscreen .question-illustration,
    .exam-body:-webkit-full-screen .question-illustration {
        grid-column: 1;
        grid-row: 2;
        margin-bottom: 0;
        padding: 10px;
        min-height: auto;
        align-self: center;
    }

    .exam-body:fullscreen .question-text-kid,
    .exam-body:-webkit-full-screen .question-text-kid {
        grid-column: 1;
        grid-row: 3;
        font-size: 16px;
        margin-bottom: 0;
        align-self: start;
    }

    /* When no illustration, text takes full left area */
    .exam-body:fullscreen .question-card-kid:not(:has(.question-illustration)) .question-text-kid,
    .exam-body:-webkit-full-screen .question-card-kid:not(:has(.question-illustration)) .question-text-kid {
        grid-row: 2 / 4;
        font-size: 20px;
        align-self: center;
    }

    .exam-body:fullscreen .question-media,
    .exam-body:-webkit-full-screen .question-media {
        grid-column: 1;
        grid-row: 2;
        margin-bottom: 0;
    }

    .exam-body:fullscreen .question-media img,
    .exam-body:-webkit-full-screen .question-media img {
        max-height: 140px;
    }

    .exam-body:fullscreen .options-grid,
    .exam-body:-webkit-full-screen .options-grid {
        grid-column: 2;
        grid-row: 2 / 4;
        align-self: center;
        margin-bottom: 0;
    }

    .exam-body:fullscreen .options-grid.options-2,
    .exam-body:fullscreen .options-grid.options-3,
    .exam-body:fullscreen .options-grid.options-4,
    .exam-body:-webkit-full-screen .options-grid.options-2,
    .exam-body:-webkit-full-screen .options-grid.options-3,
    .exam-body:-webkit-full-screen .options-grid.options-4 {
        grid-template-columns: 1fr;
    }

    .exam-body:fullscreen .option-btn,
    .exam-body:-webkit-full-screen .option-btn {
        padding: 10px 14px;
        min-height: auto;
        font-size: 14px;
    }

    .exam-body:fullscreen .option-letter,
    .exam-body:-webkit-full-screen .option-letter {
        width: 28px; height: 28px;
        font-size: 13px;
    }

    .exam-body:fullscreen .question-feedback,
    .exam-body:-webkit-full-screen .question-feedback {
        grid-column: 1 / -1;
        padding: 8px 14px;
        font-size: 14px;
        margin-top: 0;
    }

    /* Illustration sizes - smaller in landscape fullscreen */
    .exam-body:fullscreen .emojis-large .illustration-emoji,
    .exam-body:-webkit-full-screen .emojis-large .illustration-emoji {
        font-size: 48px;
    }
    .exam-body:fullscreen .emojis-medium .illustration-emoji,
    .exam-body:-webkit-full-screen .emojis-medium .illustration-emoji {
        font-size: 38px;
    }
    .exam-body:fullscreen .emojis-small .illustration-emoji,
    .exam-body:-webkit-full-screen .emojis-small .illustration-emoji {
        font-size: 30px;
    }
}

/* ---- Fullscreen: Portrait Layout ---- */
@media (orientation: portrait) {
    .exam-body:fullscreen .question-card-kid,
    .exam-body:-webkit-full-screen .question-card-kid {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .exam-body:fullscreen .question-text-kid,
    .exam-body:-webkit-full-screen .question-text-kid {
        font-size: 18px;
    }

    .exam-body:fullscreen .emojis-large .illustration-emoji,
    .exam-body:-webkit-full-screen .emojis-large .illustration-emoji {
        font-size: 56px;
    }
    .exam-body:fullscreen .emojis-medium .illustration-emoji,
    .exam-body:-webkit-full-screen .emojis-medium .illustration-emoji {
        font-size: 44px;
    }
}

/* ---- Fullscreen Nav Compact ---- */
.exam-body:fullscreen .exam-nav,
.exam-body:-webkit-full-screen .exam-nav {
    padding: 6px 0;
    margin-top: 4px;
    flex-shrink: 0;
    gap: 8px;
}

.exam-body:fullscreen .btn-kid.btn-nav,
.exam-body:-webkit-full-screen .btn-kid.btn-nav {
    padding: 6px 16px;
    font-size: 13px;
    min-width: 80px;
}

.exam-body:fullscreen .exam-dot,
.exam-body:-webkit-full-screen .exam-dot {
    width: 10px; height: 10px;
}

.exam-body:fullscreen .exam-complete-section,
.exam-body:-webkit-full-screen .exam-complete-section {
    margin-top: 4px;
    flex-shrink: 0;
}

.exam-body:fullscreen .exam-complete-section .btn-kid,
.exam-body:-webkit-full-screen .exam-complete-section .btn-kid {
    font-size: 16px;
    padding: 10px 28px;
}

/* ---- Fullscreen TTS btn smaller ---- */
.exam-body:fullscreen .tts-btn,
.exam-body:-webkit-full-screen .tts-btn,
.exam-body.pseudo-fullscreen .tts-btn {
    padding: 5px 12px;
    font-size: 12px;
}

.exam-body:fullscreen .tts-icon,
.exam-body:-webkit-full-screen .tts-icon,
.exam-body.pseudo-fullscreen .tts-icon {
    font-size: 16px;
}

/* ============================================
   PSEUDO-FULLSCREEN (iOS Safari + fallback)
   Mirrors all :fullscreen rules for browsers
   that don't support the Fullscreen API.
   Uses position:fixed to cover the entire viewport.
   ============================================ */

/* Base: fill viewport */
.exam-body.pseudo-fullscreen {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99999;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    /* iOS safe areas */
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    background-size: 400% 400%;
}

.exam-body.pseudo-fullscreen .floating-deco {
    display: none;
}

.exam-body.pseudo-fullscreen .exam-container {
    max-width: 100%;
    padding: 8px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.exam-body.pseudo-fullscreen .exam-section {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Topbar compact */
.exam-body.pseudo-fullscreen .exam-topbar {
    flex-direction: row;
    gap: 10px;
    padding: 6px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.exam-body.pseudo-fullscreen .exam-section-name { font-size: 14px; }
.exam-body.pseudo-fullscreen .btn-back-kid { padding: 4px 10px; font-size: 12px; }
.exam-body.pseudo-fullscreen .exam-progress-bar { height: 8px; }

/* Questions area */
.exam-body.pseudo-fullscreen .exam-questions-wrapper {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.exam-body.pseudo-fullscreen .exam-question-slide.active {
    height: 100%;
}

.exam-body.pseudo-fullscreen .question-card-kid {
    height: 100%;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Portrait: stacked layout with scrollable content */
@media (orientation: portrait) {
    .exam-body.pseudo-fullscreen .question-card-kid {
        overflow-y: auto;
    }
    .exam-body.pseudo-fullscreen .question-text-kid {
        font-size: 17px;
    }
    .exam-body.pseudo-fullscreen .emojis-large .illustration-emoji { font-size: 48px; }
    .exam-body.pseudo-fullscreen .emojis-medium .illustration-emoji { font-size: 38px; }

    .exam-body.pseudo-fullscreen .options-grid.options-2,
    .exam-body.pseudo-fullscreen .options-grid.options-3,
    .exam-body.pseudo-fullscreen .options-grid.options-4 {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .exam-body.pseudo-fullscreen .option-btn {
        padding: 10px 12px;
        min-height: 44px;
        font-size: 15px;
    }
}

/* Landscape: side-by-side layout */
@media (orientation: landscape) {
    .exam-body.pseudo-fullscreen .question-card-kid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr auto;
        gap: 6px 14px;
        padding-top: 38px;
        position: relative;
        overflow: hidden;
    }

    .exam-body.pseudo-fullscreen .question-top-row {
        grid-column: 1 / -1;
        grid-row: 1;
        margin-bottom: 0;
    }

    .exam-body.pseudo-fullscreen .question-illustration {
        grid-column: 1;
        grid-row: 2;
        margin-bottom: 0;
        padding: 8px;
        min-height: auto;
        align-self: center;
    }

    .exam-body.pseudo-fullscreen .question-text-kid {
        grid-column: 1;
        grid-row: 3;
        font-size: 15px;
        margin-bottom: 0;
        align-self: start;
    }

    .exam-body.pseudo-fullscreen .question-card-kid:not(:has(.question-illustration)) .question-text-kid {
        grid-row: 2 / 4;
        font-size: 18px;
        align-self: center;
    }

    .exam-body.pseudo-fullscreen .question-media {
        grid-column: 1;
        grid-row: 2;
        margin-bottom: 0;
    }

    .exam-body.pseudo-fullscreen .question-media img {
        max-height: 120px;
    }

    .exam-body.pseudo-fullscreen .options-grid {
        grid-column: 2;
        grid-row: 2 / 4;
        align-self: center;
        margin-bottom: 0;
    }

    .exam-body.pseudo-fullscreen .options-grid.options-2,
    .exam-body.pseudo-fullscreen .options-grid.options-3,
    .exam-body.pseudo-fullscreen .options-grid.options-4 {
        grid-template-columns: 1fr;
    }

    .exam-body.pseudo-fullscreen .option-btn {
        padding: 8px 12px;
        min-height: auto;
        font-size: 13px;
    }

    .exam-body.pseudo-fullscreen .option-letter {
        width: 26px; height: 26px;
        font-size: 12px;
    }

    .exam-body.pseudo-fullscreen .question-feedback {
        grid-column: 1 / -1;
        padding: 6px 12px;
        font-size: 13px;
    }

    .exam-body.pseudo-fullscreen .emojis-large .illustration-emoji { font-size: 42px; }
    .exam-body.pseudo-fullscreen .emojis-medium .illustration-emoji { font-size: 34px; }
    .exam-body.pseudo-fullscreen .emojis-small .illustration-emoji { font-size: 26px; }
}

/* Nav compact */
.exam-body.pseudo-fullscreen .exam-nav {
    padding: 5px 0;
    margin-top: 4px;
    flex-shrink: 0;
    gap: 8px;
    /* Account for bottom safe area (home bar) */
    padding-bottom: max(5px, env(safe-area-inset-bottom, 0));
}

.exam-body.pseudo-fullscreen .btn-kid.btn-nav {
    padding: 6px 16px;
    font-size: 13px;
    min-width: 80px;
}

.exam-body.pseudo-fullscreen .exam-dot {
    width: 10px; height: 10px;
}

.exam-body.pseudo-fullscreen .exam-complete-section {
    margin-top: 4px;
    flex-shrink: 0;
}

.exam-body.pseudo-fullscreen .exam-complete-section .btn-kid {
    font-size: 16px;
    padding: 10px 28px;
}

/* ============================================
   COMPACT MODE — Mobile Portrait & Landscape
   Targets any screen where height is limited.
   Locks EVERYTHING to viewport — ZERO scroll.
   ============================================ */
@media (max-height: 900px) {
    /* Lock html + body to exact viewport */
    html:has(.exam-section) {
        height: 100dvh;
        height: 100vh; /* fallback */
        overflow: hidden;
    }

    html:has(.exam-section) .exam-body {
        height: 100dvh;
        height: 100vh;
        max-height: 100dvh;
        max-height: 100vh;
        min-height: 0;
        overflow: hidden;
    }

    html:has(.exam-section) .floating-deco {
        display: none;
    }

    html:has(.exam-section) .exam-container {
        max-width: 100%;
        padding: 6px 10px;
        height: 100%;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .exam-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }

    /* ---- Topbar: single-row compact ---- */
    .exam-section .exam-topbar {
        flex-direction: row;
        gap: 8px;
        padding: 5px 10px;
        margin-bottom: 4px;
        border-radius: 10px;
        flex-shrink: 0;
    }

    .exam-section .exam-section-name { font-size: 13px; }
    .exam-section .btn-back-kid { padding: 3px 8px; font-size: 11px; }
    .exam-section .exam-progress-bar { height: 7px; min-width: 80px; }
    .exam-section .exam-score-display { font-size: 14px; }
    .exam-section .fullscreen-btn { width: 30px; height: 30px; font-size: 15px; }

    /* ---- Questions: fill remaining space ---- */
    .exam-questions-wrapper {
        flex: 1;
        min-height: 0 !important;
        overflow: hidden;
    }

    .exam-question-slide.active {
        height: 100%;
    }

    .question-card-kid {
        height: 100%;
        padding: 8px 12px;
        overflow: hidden;
        border-radius: 12px;
    }

    /* ---- Nav: ultra compact ---- */
    .exam-nav {
        padding: 3px 0;
        margin-top: 2px;
        flex-shrink: 0;
        gap: 6px;
    }

    .btn-kid.btn-nav {
        padding: 5px 14px;
        font-size: 12px;
        min-width: 70px;
        border-radius: 30px;
    }

    .exam-dot { width: 9px; height: 9px; }

    .exam-complete-section {
        margin-top: 2px;
        flex-shrink: 0;
    }
    .exam-complete-section .btn-kid {
        font-size: 14px;
        padding: 6px 20px;
    }

    /* ---- TTS compact ---- */
    .tts-btn { padding: 4px 10px; font-size: 11px; }
    .tts-icon { font-size: 15px; }
    .question-badge { padding: 2px 10px; font-size: 11px; }
    .question-top-row { margin-bottom: 4px; }

    .confetti-canvas { position: fixed; }
}

/* ======== PORTRAIT compact (stacked layout) ======== */
@media (orientation: portrait) and (max-height: 900px) {
    .question-card-kid {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .question-illustration {
        margin-bottom: 6px;
        padding: 8px 12px;
        min-height: 0;
        flex-shrink: 0;
    }

    .emojis-large .illustration-emoji { font-size: 44px; }
    .emojis-medium .illustration-emoji { font-size: 36px; }
    .emojis-small .illustration-emoji { font-size: 28px; }
    .illustration-emojis { gap: 4px; }

    .question-text-kid {
        font-size: 16px;
        line-height: 1.4;
        margin-bottom: 6px;
        flex-shrink: 0;
    }

    .question-media img { max-height: 100px; }

    .options-grid {
        flex: 1;
        min-height: 0;
        align-self: stretch;
        margin-bottom: 0;
    }

    .options-grid.options-2,
    .options-grid.options-3,
    .options-grid.options-4 {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .option-btn {
        padding: 8px 10px;
        min-height: 0;
        font-size: 14px;
        border-width: 2px;
        border-radius: 10px;
        gap: 8px;
    }

    .option-letter {
        width: 26px; height: 26px;
        font-size: 12px;
    }

    .question-feedback {
        padding: 6px 12px;
        font-size: 13px;
        margin-top: 4px;
        border-radius: 8px;
        flex-shrink: 0;
    }
}

/* ======== LANDSCAPE compact (2-column grid) ======== */
@media (orientation: landscape) and (max-height: 500px) {
    .question-card-kid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr;
        gap: 4px 14px;
        text-align: left;
    }

    .question-top-row {
        grid-column: 1 / -1;
        grid-row: 1;
        margin-bottom: 0;
    }

    .question-illustration {
        grid-column: 1;
        grid-row: 2;
        margin-bottom: 0;
        padding: 6px;
        min-height: 0;
        align-self: center;
        border-radius: 10px;
    }

    .emojis-large .illustration-emoji { font-size: 36px; }
    .emojis-medium .illustration-emoji { font-size: 30px; }
    .emojis-small .illustration-emoji { font-size: 24px; }
    .illustration-emojis { gap: 3px; }

    .question-text-kid {
        grid-column: 1;
        font-size: 14px;
        line-height: 1.3;
        margin-bottom: 0;
        align-self: start;
    }

    .question-card-kid:has(.question-illustration) .question-text-kid {
        grid-row: 3;
    }
    .question-card-kid:not(:has(.question-illustration)) .question-text-kid {
        grid-row: 2;
        font-size: 16px;
        align-self: center;
    }

    .question-media {
        grid-column: 1;
        grid-row: 2;
        margin-bottom: 0;
    }
    .question-media img { max-height: 100px; border-radius: 8px; }

    .options-grid {
        grid-column: 2;
        grid-row: 2 / -1;
        align-self: center;
        margin-bottom: 0;
    }

    .options-grid.options-2,
    .options-grid.options-3,
    .options-grid.options-4 {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .option-btn {
        padding: 7px 10px;
        min-height: 0;
        font-size: 13px;
        border-width: 2px;
        border-radius: 10px;
        gap: 6px;
    }

    .option-letter {
        width: 22px; height: 22px;
        font-size: 11px;
    }

    .question-feedback {
        grid-column: 1 / -1;
        padding: 5px 10px;
        font-size: 12px;
        margin-top: 0;
        border-radius: 8px;
    }
}

/* ---- Welcome Compact Layout (Viewport-fit) ---- */

/* Lock welcome page to viewport on mobile */
html:has(.exam-welcome) .exam-body {
    height: 100dvh;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

html:has(.exam-welcome) .floating-deco {
    display: none;
}

html:has(.exam-welcome) .exam-container {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px 12px;
    max-width: 600px;
}

.exam-welcome {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    gap: 8px;
}

/* ---- Header Card: mascot + greeting + progress ---- */
.welcome-header-card {
    background: var(--kid-card-glass);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: var(--kid-shadow);
    flex-shrink: 0;
}

.welcome-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.welcome-mascot-mini {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(255, 193, 7, 0.25);
    flex-shrink: 0;
    animation: mascotBounce 3s ease-in-out infinite;
}

.mascot-emoji-mini {
    font-size: 28px;
}

.welcome-greeting {
    flex: 1;
    min-width: 0;
}

.welcome-greeting-text {
    font-family: var(--kid-font);
    font-size: 16px;
    font-weight: 700;
    color: var(--kid-text);
    line-height: 1.3;
    margin-bottom: 2px;
}

.welcome-greeting-text strong {
    color: var(--kid-primary);
}

.welcome-greeting-sub {
    font-size: 13px;
    color: var(--kid-text-light);
    font-weight: 500;
}

/* ---- Inline Progress ---- */
.welcome-progress-inline {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.welcome-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--kid-text-light);
}

.welcome-progress-bar-mini {
    height: 8px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 100px;
    overflow: hidden;
}

.welcome-progress-fill-mini {
    height: 100%;
    background: linear-gradient(90deg, #48bb78, #38a169);
    border-radius: 100px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.welcome-progress-fill-mini::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ---- Section List Area ---- */
.welcome-sections-area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-title-compact {
    font-family: var(--kid-font);
    font-size: 18px;
    text-align: center;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    margin-bottom: 8px;
    flex-shrink: 0;
}

.section-cards-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.section-cards-scroll::-webkit-scrollbar {
    width: 3px;
}

.section-cards-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.section-cards-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

/* ---- Compact Section Card ---- */
.section-card-compact {
    background: var(--kid-card-glass);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.section-card-compact:active {
    transform: scale(0.98);
}

.section-card-compact.completed {
    opacity: 0.75;
    border-color: var(--kid-success);
}

.section-card-icon-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent, var(--kid-primary)), rgba(255,255,255,0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-num-sm {
    font-family: var(--kid-font);
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}

.done-check-sm {
    font-size: 18px;
}

.section-card-body-sm {
    flex: 1;
    min-width: 0;
}

.section-card-body-sm h3 {
    font-family: var(--kid-font);
    font-size: 14px;
    font-weight: 700;
    color: var(--kid-text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.section-card-info-sm {
    font-size: 11px;
    color: var(--kid-text-light);
    margin-top: 1px;
}

/* Mini progress */
.section-mini-progress {
    height: 4px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 100px;
    overflow: hidden;
    margin-top: 4px;
}

.section-mini-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.8s ease;
}

/* Done badge */
.section-done-badge-sm {
    font-size: 16px;
    flex-shrink: 0;
}

/* Play button */
.btn-play-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: #fff;
    font-size: 16px;
    text-decoration: none;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(72, 187, 120, 0.35);
    transition: all 0.2s ease;
}

.btn-play-sm:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 16px rgba(72, 187, 120, 0.5);
    color: #fff;
}

.btn-play-sm:active {
    transform: scale(0.92);
}

/* ---- Bottom Area ---- */
.welcome-bottom {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 6px;
}

.welcome-complete-btn {
    width: 100%;
    justify-content: center;
    font-size: 15px !important;
    padding: 12px 20px !important;
    animation: completePulse 2s ease-in-out infinite;
}

@keyframes completePulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(72, 187, 120, 0.7); }
}

.welcome-back-btn {
    font-size: 12px !important;
    padding: 6px 14px !important;
    opacity: 0.7;
}

.welcome-back-btn:hover {
    opacity: 1;
}

/* ---- Desktop: more spacious ---- */
@media (min-width: 769px) {
    html:has(.exam-welcome) .exam-body {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    html:has(.exam-welcome) .floating-deco {
        display: block;
    }

    html:has(.exam-welcome) .exam-container {
        height: auto;
        padding: 20px;
        max-width: 700px;
    }

    .exam-welcome {
        gap: 16px;
    }

    .welcome-header-card {
        padding: 24px 28px;
        border-radius: var(--kid-radius);
    }

    .welcome-mascot-mini {
        width: 64px;
        height: 64px;
    }

    .mascot-emoji-mini {
        font-size: 36px;
    }

    .welcome-greeting-text {
        font-size: 20px;
    }

    .welcome-greeting-sub {
        font-size: 15px;
    }

    .welcome-progress-bar-mini {
        height: 12px;
    }

    .welcome-progress-info {
        font-size: 14px;
    }

    .section-title-compact {
        font-size: 26px;
        margin-bottom: 14px;
    }

    .section-cards-scroll {
        gap: 10px;
        overflow-y: visible;
    }

    .section-card-compact {
        padding: 16px 20px;
        gap: 14px;
        border-radius: var(--kid-radius-sm);
    }

    .section-card-icon-sm {
        width: 46px;
        height: 46px;
    }

    .section-num-sm {
        font-size: 20px;
    }

    .section-card-body-sm h3 {
        font-size: 17px;
        white-space: normal;
    }

    .section-card-info-sm {
        font-size: 13px;
    }

    .btn-play-sm {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .welcome-complete-btn {
        max-width: 380px;
        font-size: 18px !important;
        padding: 16px 32px !important;
    }

    .welcome-back-btn {
        font-size: 14px !important;
        padding: 10px 20px !important;
    }

    .welcome-bottom {
        gap: 10px;
        padding-top: 12px;
    }
}

/* ---- Result Overall Card ---- */
.result-overall-card {
    text-align: center;
    margin-bottom: 28px;
    padding: 24px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    border-radius: var(--kid-radius);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.result-overall-circle {
    position: relative;
    width: 130px;
    height: 130px;
    margin: 0 auto 12px;
}

.result-overall-svg {
    width: 100%;
    height: 100%;
    transform: rotate(0deg);
}

.result-overall-svg circle:first-of-type {
    stroke: rgba(255, 255, 255, 0.15);
}

.result-overall-svg circle:last-of-type {
    animation: circleGrow 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    stroke-dashoffset: 326.7;
}

@keyframes circleGrow {
    from { stroke-dasharray: 0 326.7; }
}

.result-overall-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--kid-font);
    font-size: 36px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.result-overall-label {
    font-family: var(--kid-font);
    font-size: 15px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

/* ---- Responsive (mobile adjustments) ---- */
@media (max-width: 768px) {
    /* Container */
    .exam-container {
        padding: 14px 12px;
    }

    /* Mascot & Welcome */
    .mascot-container {
        width: 80px;
        height: 80px;
        margin-bottom: 12px;
    }

    .mascot-emoji {
        font-size: 40px;
    }

    .speech-bubble {
        font-size: 15px;
        padding: 18px 20px;
        line-height: 1.7;
        margin-bottom: 24px;
        border-radius: 16px;
    }

    .speech-bubble::before {
        border-left-width: 12px;
        border-right-width: 12px;
        border-bottom-width: 12px;
        top: -12px;
    }

    /* Section title */
    .section-title {
        font-size: 22px;
        margin-bottom: 16px;
    }

    /* Section cards */
    .section-cards {
        gap: 10px;
    }

    .section-card {
        padding: 16px;
        gap: 14px;
        flex-wrap: nowrap;
        border-radius: 12px;
    }

    .section-card-icon {
        width: 42px;
        height: 42px;
    }

    .section-num {
        font-size: 18px;
    }

    .section-card-body h3 {
        font-size: 15px;
    }

    .section-card-info {
        font-size: 12px;
    }

    .btn-kid.btn-play {
        padding: 10px 20px;
        font-size: 14px;
    }

    /* Welcome footer */
    .welcome-complete {
        margin-top: 24px;
    }

    .welcome-footer {
        margin-top: 20px;
    }

    /* EQ form */
    .eq-title {
        font-size: 22px;
    }

    .eq-subtitle {
        font-size: 14px;
    }

    .eq-category-card {
        padding: 20px 16px;
        border-radius: 16px;
        margin-bottom: 14px;
    }

    .eq-category-title {
        font-size: 17px;
    }

    .eq-category-desc {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .eq-question-text {
        font-size: 14px;
    }

    .eq-rating-label {
        padding: 12px 14px;
        border-radius: 10px;
        gap: 8px;
        min-height: 48px;
    }

    .eq-rating-stars {
        font-size: 15px;
    }

    .eq-rating-text {
        font-size: 13px;
    }

    .eq-notes-card {
        padding: 20px 16px;
        border-radius: 16px;
    }

    .form-textarea-kid {
        font-size: 16px; /* prevents iOS zoom */
        padding: 12px 14px;
        border-radius: 12px;
        min-height: 100px;
    }

    .eq-actions {
        flex-direction: column;
        gap: 10px;
    }

    .eq-actions .btn-kid {
        width: 100%;
        justify-content: center;
        min-height: 48px;
    }

    /* Buttons */
    .btn-kid {
        min-height: 44px;
    }

    .btn-kid.btn-big {
        font-size: 17px;
        padding: 14px 32px;
    }

    .btn-kid.btn-success {
        font-size: 17px;
        padding: 14px 32px;
    }

    /* Result screen */
    .exam-result {
        padding: 20px 0;
    }

    .result-celebration {
        margin-bottom: 28px;
    }

    .celebration-stars {
        height: 45px;
    }

    .star {
        font-size: 22px;
    }

    .result-title {
        font-size: 26px;
    }

    .result-student-name {
        font-size: 22px;
    }

    .result-subtitle {
        font-size: 14px;
        margin-top: 6px;
    }

    /* Result cards */
    .result-cards {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-bottom: 24px;
    }

    .result-score-card {
        padding: 22px 18px;
        border-radius: 16px;
        border-top-width: 4px;
    }

    .result-score-card:hover {
        transform: none; /* disable hover on mobile */
    }

    .result-score-icon {
        font-size: 32px;
    }

    .result-score-name {
        font-size: 16px;
    }

    .result-score-percent {
        font-size: 34px;
    }

    .result-child-item {
        margin-bottom: 8px;
        font-size: 12px;
    }

    .result-child-name {
        font-size: 12px;
    }

    .mini-progress {
        width: 60px;
        height: 6px;
    }

    .result-child-pct {
        font-size: 12px;
    }

    /* Result actions */
    .result-actions {
        gap: 10px;
    }

    .result-actions .btn-kid {
        width: 100%;
        max-width: 320px;
    }

    .result-actions .btn-ghost-kid {
        width: 100%;
        max-width: 320px;
        text-align: center;
        justify-content: center;
    }

    /* Topbar */
    .exam-topbar {
        padding: 10px 14px;
        gap: 10px;
        border-radius: 12px;
        margin-bottom: 14px;
    }

    .exam-section-name {
        font-size: 14px;
    }

    .btn-back-kid {
        padding: 5px 12px;
        font-size: 12px;
    }

    .exam-progress-bar {
        height: 10px;
        min-width: 80px;
    }

    .exam-score-display {
        font-size: 15px;
    }

    .fullscreen-btn {
        width: 36px;
        height: 36px;
        font-size: 17px;
    }

    /* Question card */
    .question-card-kid {
        padding: 22px 18px;
        border-radius: 16px;
    }

    .question-text-kid {
        font-size: 20px;
        margin-bottom: 18px;
    }

    .question-badge {
        font-size: 12px;
        padding: 3px 14px;
    }

    /* Illustration */
    .question-illustration {
        padding: 14px;
        border-radius: 14px;
        margin-bottom: 16px;
    }

    .emojis-large .illustration-emoji {
        font-size: 56px;
    }

    .emojis-medium .illustration-emoji {
        font-size: 44px;
    }

    .emojis-small .illustration-emoji {
        font-size: 34px;
    }

    /* Options */
    .options-grid.options-2,
    .options-grid.options-3,
    .options-grid.options-4 {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .option-btn {
        padding: 14px 16px;
        min-height: 52px;
        font-size: 15px;
        border-radius: 12px;
    }

    .option-letter {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    /* Feedback */
    .question-feedback {
        font-size: 15px;
        padding: 12px 16px;
        border-radius: 12px;
    }

    /* Navigation */
    .exam-nav {
        padding: 10px 0;
        margin-top: 16px;
        gap: 12px;
    }

    .btn-kid.btn-nav {
        padding: 10px 20px;
        font-size: 14px;
        min-width: 90px;
    }

    .exam-dot {
        width: 12px;
        height: 12px;
    }

    .exam-dots {
        gap: 6px;
    }

    /* Complete section button */
    .exam-complete-section {
        margin-top: 14px;
    }

    .exam-complete-section .btn-kid {
        font-size: 16px;
        padding: 12px 28px;
        width: 100%;
        max-width: 320px;
        justify-content: center;
    }

    /* TTS */
    .tts-btn {
        padding: 6px 14px;
        font-size: 13px;
    }

    .tts-icon {
        font-size: 17px;
    }

    /* Media */
    .question-media img {
        max-height: 200px;
    }

    /* Ghost kid button */
    .btn-ghost-kid {
        padding: 10px 18px;
        font-size: 13px;
    }

    /* New components mobile */
    .welcome-progress-card {
        padding: 16px 18px;
        margin-bottom: 18px;
        border-radius: 16px;
    }

    .welcome-progress-label {
        font-size: 14px;
    }

    .welcome-progress-count {
        font-size: 12px;
    }

    .welcome-progress-bar {
        height: 12px;
    }

    .welcome-progress-pct {
        font-size: 18px;
    }

    .section-done-badge {
        font-size: 11px;
        padding: 5px 12px;
    }

    .welcome-complete-card {
        padding: 24px 18px;
        border-radius: 16px;
    }

    .welcome-complete-icon {
        font-size: 44px;
    }

    .welcome-complete-text {
        font-size: 16px;
        margin-bottom: 16px;
    }

    .result-overall-card {
        padding: 20px 16px;
        margin-bottom: 22px;
        border-radius: 16px;
    }

    .result-overall-circle {
        width: 110px;
        height: 110px;
    }

    .result-overall-number {
        font-size: 30px;
    }

    .result-overall-label {
        font-size: 14px;
    }
}

/* ---- Small phone (≤ 480px) ---- */
@media (max-width: 480px) {
    .exam-container {
        padding: 10px 8px;
    }

    .mascot-container {
        width: 64px;
        height: 64px;
    }

    .mascot-emoji {
        font-size: 32px;
    }

    .speech-bubble {
        font-size: 14px;
        padding: 14px 16px;
        border-radius: 14px;
        margin-bottom: 18px;
    }

    .section-title {
        font-size: 20px;
    }

    .section-card {
        padding: 14px 12px;
    }

    .section-card-icon {
        width: 38px;
        height: 38px;
    }

    .section-card-body h3 {
        font-size: 14px;
    }

    .result-title {
        font-size: 22px;
    }

    .result-student-name {
        font-size: 18px;
    }

    .result-score-card {
        padding: 18px 14px;
    }

    .result-score-percent {
        font-size: 28px;
    }

    .result-score-name {
        font-size: 14px;
    }

    .question-card-kid {
        padding: 16px 14px;
    }

    .question-text-kid {
        font-size: 17px;
    }

    .option-btn {
        padding: 12px 14px;
        font-size: 14px;
        min-height: 48px;
    }

    .option-letter {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .emojis-large .illustration-emoji {
        font-size: 44px;
    }

    .emojis-medium .illustration-emoji {
        font-size: 36px;
    }

    .emojis-small .illustration-emoji {
        font-size: 28px;
    }

    .eq-category-card {
        padding: 16px 12px;
    }

    .eq-category-title {
        font-size: 15px;
    }

    .eq-rating-label {
        padding: 10px 12px;
    }

    .exam-topbar {
        padding: 8px 10px;
        gap: 6px;
    }

    .exam-section-name {
        font-size: 12px;
    }

    .btn-back-kid {
        padding: 4px 10px;
        font-size: 11px;
    }

    .btn-kid.btn-nav {
        padding: 8px 16px;
        font-size: 13px;
        min-width: 80px;
    }

    /* New components small phone */
    .welcome-progress-card {
        padding: 14px;
    }

    .welcome-progress-label {
        font-size: 13px;
    }

    .welcome-progress-bar {
        height: 10px;
    }

    .welcome-progress-pct {
        font-size: 16px;
    }

    .welcome-complete-icon {
        font-size: 36px;
    }

    .welcome-complete-text {
        font-size: 14px;
    }

    .result-overall-circle {
        width: 90px;
        height: 90px;
    }

    .result-overall-number {
        font-size: 24px;
    }

    .result-overall-label {
        font-size: 12px;
    }

    .section-done-badge {
        font-size: 10px;
        padding: 4px 10px;
    }
}

/* Intro is visible from the first render; readiness follows completed downloads. */
body.tts-intro-open { overflow: hidden; }

.tts-intro {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 24px;
    background: radial-gradient(ellipse at top left, #dff7f2, transparent 65%), #f2f0ff;
}

.tts-intro[hidden], .tts-intro [hidden] { display: none; }

.tts-intro-card {
    width: 100%;
    max-width: 430px;
    margin: auto;
    padding: 32px 24px 24px;
    border: 1px solid #fff;
    border-radius: 28px;
    background: #ffffffed;
    box-shadow: 0 18px 60px #45407515;
    color: #29324b;
    text-align: center;
    font-family: var(--kid-font-body, sans-serif);
}

.tts-intro-spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto 22px;
    border: 4px solid #eae7f5;
    border-top-color: #7762ca;
    border-radius: 50%;
    animation: ttsIntroSpin 1s linear infinite;
}

@keyframes ttsIntroSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .tts-intro-spinner { animation: none; }
}

.tts-intro h1 {
    margin: 0 0 12px;
    font-size: clamp(24px, 6vw, 30px);
    line-height: 1.25;
}

#ttsIntroStatus {
    min-height: 3em;
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.5;
}

.tts-intro progress {
    display: block;
    width: 100%;
    height: 10px;
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    background: #eae7f5;
    accent-color: #7762ca;
}

.tts-intro progress::-webkit-progress-bar { background: #eae7f5; border-radius: 8px; }
.tts-intro progress::-webkit-progress-value { background: #7762ca; border-radius: 8px; }
.tts-intro progress::-moz-progress-bar { background: #7762ca; border-radius: 8px; }
#ttsIntroCount { margin: 14px 0 0; font-size: 16px; line-height: 1.4; color: #45405e; }
.tts-intro-back { display: inline-block; margin-top: 18px; padding: 10px; font-size: 14px; color: #69648b; }
.tts-intro :focus-visible { outline: 3px solid #36a79b; outline-offset: 3px; }

@media (max-height: 540px) {
    .tts-intro { padding: 12px; }
    .tts-intro-card { padding: 18px; }
    .tts-intro-spinner { margin-bottom: 12px; }
    #ttsIntroStatus { margin-bottom: 10px; }
}

/* =====================================================
   MOBILE LESSON UI
   Fit ordinary questions and all answers in the available phone viewport.
   This intentionally overrides the older height-based compact mode.
   ===================================================== */
@media (max-width: 768px) {
    html:has(.exam-section),
    html:has(.exam-section) .exam-body {
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
    }

    html:has(.exam-section) .exam-container {
        width: 100%;
        height: 100dvh;
        min-height: 0;
        padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        display: flex;
        overflow: hidden;
    }

    .exam-section {
        width: 100%;
        min-height: 0;
        display: flex;
        flex: 1;
        flex-direction: column;
        gap: 8px;
        overflow: hidden;
    }

    .exam-section button,
    .exam-section a {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .exam-section button:focus-visible,
    .exam-section a:focus-visible {
        outline: 4px solid #fbbf24;
        outline-offset: 3px;
    }

    .exam-body .exam-section .exam-topbar {
        position: relative;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        min-height: 60px;
        margin: 0;
        padding: 6px 8px 12px;
        border-radius: 16px;
        flex: 0 0 auto;
    }

    .exam-topbar-left {
        min-width: 0;
        gap: 8px;
    }

    .exam-body .exam-section .btn-back-kid {
        width: 48px;
        height: 48px;
        min-width: 48px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 15px;
        background: #eef2ff;
        color: #4c51bf;
        font-size: 0;
    }

    .btn-back-kid .action-icon {
        font-size: 28px;
        line-height: 1;
    }

    .btn-back-kid .action-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .exam-section .exam-section-name {
        min-width: 0;
        overflow: hidden;
        color: #26324b;
        font-size: clamp(15px, 4vw, 18px);
        line-height: 1.2;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .exam-topbar-right {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .exam-section .exam-score-display {
        min-height: 40px;
        padding: 0 8px;
        display: inline-flex;
        align-items: center;
        border-radius: 12px;
        background: #fff8e8;
        font-size: 16px;
    }

    .exam-section .fullscreen-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        border-radius: 15px;
        font-size: 23px;
    }

    .exam-section .exam-progress-bar {
        position: absolute;
        right: 10px;
        bottom: 4px;
        left: 10px;
        width: auto;
        height: 6px;
        min-width: 0;
    }

    .exam-body .exam-section .exam-questions-wrapper {
        min-height: 0 !important;
        flex: 1 1 auto;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .exam-questions-wrapper::-webkit-scrollbar {
        display: none;
    }

    .exam-question-slide.active {
        height: 100%;
        min-height: 0;
    }

    .exam-body .exam-section .question-card-kid {
        width: 100%;
        height: 100%;
        min-height: min-content;
        padding: 12px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        overflow: visible;
        border-radius: 18px;
        text-align: center;
    }

    .exam-body .exam-section .question-top-row {
        min-height: 48px;
        flex: 0 0 auto;
        margin-bottom: 8px;
    }

    .exam-section .question-badge {
        padding: 7px 13px;
        font-size: 14px;
        line-height: 1.2;
    }

    .exam-section .tts-btn {
        min-width: 104px;
        min-height: 48px;
        margin: 0;
        padding: 8px 14px;
        justify-content: center;
        gap: 7px;
        border-radius: 16px;
        font-size: 16px;
    }

    .exam-section .tts-icon {
        font-size: 24px;
    }

    .exam-section .tts-label {
        font-size: 15px;
    }

    .exam-body .exam-section .question-illustration {
        width: 100%;
        min-height: min-content;
        max-height: 150px;
        flex: 1 1 auto;
        margin-bottom: 8px;
        padding: 8px;
        border-width: 2px;
        border-radius: 16px;
    }

    .exam-body .exam-section .illustration-emojis {
        display: grid;
        grid-template-columns: repeat(var(--illustration-columns, 5), minmax(0, 1fr));
        justify-items: center;
        gap: 4px;
        max-width: 100%;
    }

    .exam-body .exam-section .illustration-emoji { line-height: 1.15; }
    .exam-body .exam-section .emojis-large .illustration-emoji { font-size: clamp(38px, 13vw, 60px); }
    .exam-body .exam-section .emojis-medium .illustration-emoji { font-size: clamp(32px, 9vw, 44px); }
    .exam-body .exam-section .emojis-small .illustration-emoji { font-size: clamp(26px, 7vw, 34px); }

    .exam-body .exam-section .question-text-kid,
    .exam-body.pseudo-fullscreen .question-card-kid:not(:has(.question-illustration)) .question-text-kid {
        margin-bottom: 10px;
        flex: 0 0 auto;
        /* Template indentation must not become blank lines above the question. */
        white-space: normal;
        color: #202b43;
        font-size: clamp(20px, 5.4vw, 24px);
        line-height: 1.35;
    }

    .exam-body .exam-section .question-media {
        margin-bottom: 8px;
        flex: 0 0 auto;
    }

    .exam-section .question-media img {
        max-height: min(120px, 18dvh);
        object-fit: contain;
    }

    .exam-body .exam-section .options-grid,
    .exam-body .exam-section .options-grid.options-2,
    .exam-body .exam-section .options-grid.options-3,
    .exam-body .exam-section .options-grid.options-4 {
        width: 100%;
        min-height: auto;
        margin: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        flex: 0 0 auto;
        margin-top: auto;
    }

    .exam-body .exam-section .option-choice {
        min-height: 100px;
    }

    .exam-body .exam-section .option-btn {
        position: relative;
        min-width: 0;
        min-height: 100px;
        padding: 10px 8px 54px;
        justify-content: center;
        gap: 0;
        border-width: 3px;
        border-radius: 16px;
        text-align: center;
        font-size: clamp(18px, 5vw, 22px);
        line-height: 1.3;
    }

    .exam-body .exam-section .option-text { overflow-wrap: anywhere; }
    .exam-body .exam-section .option-number { font-size: 28px; line-height: 1; font-weight: 800; }

    .exam-body .exam-section .option-letter {
        position: absolute;
        bottom: 10px;
        left: 10px;
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    .exam-body .exam-section .option-choice > .option-tts {
        right: 8px;
        top: auto;
        bottom: 7px;
        width: 44px;
        height: 44px;
        margin-top: 0;
        border: 2px solid #fff;
        font-size: 21px;
        opacity: 1;
    }

    .exam-body .exam-section .question-feedback {
        flex: 0 0 auto;
        margin-top: 8px;
        padding: 8px 10px;
        border-radius: 14px;
        font-size: 16px;
        line-height: 1.4;
    }

    .exam-section .question-feedback:empty { display: none !important; }

    .exam-body .exam-section .exam-nav {
        min-height: 56px;
        margin: 0;
        padding: 4px 0 0;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 6px;
        flex: 0 0 auto;
    }

    .exam-body .exam-section .btn-kid.btn-nav {
        min-width: 78px;
        min-height: 52px;
        padding: 8px 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        border-radius: 18px;
        font-size: 14px;
    }

    .btn-nav .nav-icon {
        font-size: 22px;
        line-height: 1;
    }

    .btn-nav .nav-label {
        font-size: 13px;
        font-weight: 800;
    }

    .exam-section .exam-dots {
        min-width: 0;
        display: flex;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 0;
        overflow-x: auto;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
    }

    .exam-section .exam-dots::-webkit-scrollbar { display: none; }

    .exam-body .exam-section .exam-dot {
        position: relative;
        width: 28px;
        height: 48px;
        min-width: 28px;
        padding: 0;
        border: 0;
        background: transparent;
        transform: none;
        scroll-snap-align: center;
    }

    .exam-section .exam-dot::before {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 10px;
        height: 10px;
        content: '';
        border: 2px solid transparent;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.5);
        transform: translate(-50%, -50%);
        transition: width .2s ease, height .2s ease, background .2s ease;
    }

    .exam-section .exam-dot.answered::before { background: var(--kid-success); }
    .exam-section .exam-dot.active::before {
        width: 17px;
        height: 17px;
        border-color: #fff;
        background: var(--kid-primary);
    }

    .exam-body .exam-section .exam-complete-section {
        margin: 0;
        flex: 0 0 auto;
    }

    .exam-body .exam-section .exam-complete-section .btn-kid {
        width: 100%;
        min-height: 58px;
        max-width: none;
        padding: 12px 20px;
        justify-content: center;
        border-radius: 18px;
        font-size: 18px;
    }

    .tts-intro {
        padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    }

    .tts-intro-card {
        padding: 30px 20px 22px;
        border-radius: 24px;
    }

    #ttsIntroStatus {
        font-size: 17px;
    }

    .tts-intro-back {
        min-height: 48px;
        padding: 13px 18px;
    }
}

@media (max-width: 390px) {
    .exam-section .exam-score-display { display: none; }
    .exam-body .exam-section .btn-kid.btn-nav { min-width: 58px; padding: 8px 10px; }
    .btn-nav .nav-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

/* Short phone viewports include the space occupied by Safari's browser bars. */
@media (max-width: 768px) and (max-height: 620px) {
    .exam-body .exam-section .question-card-kid { padding: 9px; }
    .exam-body .exam-section .question-top-row { margin-bottom: 6px; }
    .exam-body .exam-section .question-illustration { padding: 6px; }
    .exam-body .exam-section .question-text-kid { margin-bottom: 8px; }
    /* Once answered, make room for feedback while retaining every answer. */
    .exam-body .exam-section .question-card-kid:has(.question-feedback:not(:empty)) .question-illustration {
        display: none;
    }
}

@media print {
    .tts-intro { display: none !important; }
    .exam-body { background: #fff; }
    .floating-deco, .confetti-canvas, .exam-nav, .result-actions, .eq-actions, .fullscreen-btn { display: none !important; }
    .question-card-kid, .section-card, .result-score-card, .eq-category-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

.question-inline-icon {
    display: inline-grid;
    place-items: center;
    min-width: 1.8em;
    min-height: 1.8em;
    margin-right: .3em;
    border-radius: .55em;
    background: rgba(108, 99, 255, .1);
    font-size: .8em;
    line-height: 1;
    vertical-align: middle;
}
