/* Lexend: a typeface designed for easier reading. Buttons and inputs do
   not take the page font by default, so they are told to. */
button, input, select, textarea { font-family: inherit; }

body {
    font-family: 'Lexend', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0984e3 0%, #d63031 100%);
    color: #333;
    text-align: center;
    margin: 0;
    padding: 12px;
    min-height: 100vh;
}
#app-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 22px 26px;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.25);
}
.welcome-header {
    background: linear-gradient(to right, #d63031, #0984e3);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 25px;
    border: 3px solid #fff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.welcome-header h1 {
    margin: 0;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.welcome-header p {
    font-size: 18px;
    font-weight: bold;
    color: #f1f2f6;
}
.btn {
    display: inline-block;
    padding: 15px 25px;
    margin: 10px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    background-color: #0984e3;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0,0,0,0.3);
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-geo { background-color: #0984e3; }      
.btn-civics { background-color: #d63031; }   
.btn-math { background-color: #192a56; }     
.btn-ela { background-color: #c23616; }      

.btn-submit { background-color: #27ae60; color: white; font-size: 21px; width: 100%; margin: 8px 0 0; padding: 12px 25px; }
.btn-next { background-color: var(--theme, #0984e3); font-size: 21px; width: 100%; margin: 10px 0 0; padding: 12px 25px; }
.btn-home { background-color: #2f3640; }

/* ═══════════ QUIZ SCREEN ═══════════
   Kid text sizes (feedback_kid_text_size): question 26px, everything a
   student reads 21px, labels 16px or more. Each subject has its own color. */
#quiz-screen {
    --theme: #0a74c2; --theme-dark: #075a97; --theme-soft: #e7f2fb;
    text-align: left;
}
#quiz-screen[data-subject="civics"] { --theme: #c0392b; --theme-dark: #922b21; --theme-soft: #fcebe9; }
#quiz-screen[data-subject="math"]   { --theme: #6c3fc4; --theme-dark: #4f2b97; --theme-soft: #f0eafb; }
#quiz-screen[data-subject="ela"]    { --theme: #c75c0c; --theme-dark: #9a4508; --theme-soft: #fdf0e5; }

.quiz-banner {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, var(--theme), var(--theme-dark));
    color: #fff; border-radius: 18px; padding: 10px 16px;
}
.quiz-icon {
    flex: 0 0 auto; font-size: 32px; line-height: 1;
    background: rgba(255,255,255,0.18); border-radius: 14px; padding: 6px 8px;
}
.quiz-banner-text { flex: 1 1 auto; min-width: 0; }
.quiz-banner h2 { margin: 0; font-size: 22px; font-weight: 700; color: #fff; }
.quiz-progress { margin: 0; font-size: 17px; font-weight: 500; color: rgba(255,255,255,0.92); }
.streak {
    flex: 0 0 auto; background: #fff; color: #b93e00; font-weight: 700; font-size: 17px;
    border-radius: 999px; padding: 6px 14px; box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    animation: pop 0.35s ease-out both;
}

.quiz-banner { margin-bottom: 12px; }
.progress-track { height: 10px; background: rgba(255,255,255,0.28); border-radius: 999px; margin: 6px 0 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: #FFD44D; border-radius: 999px; transition: width 0.5s ease; }

/* Short answers sit in a 2 x 2 grid of big tiles; long ones stay one per row. */
#options-container.grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }

.question-card {
    background: var(--theme-soft); border: 3px solid var(--theme);
    border-radius: 18px; padding: 12px 18px; margin-bottom: 10px;
}
.speak-row { display: flex; align-items: flex-start; gap: 12px; margin: 0; }

/* Picture beside the question; tap it to see it big */
.q-main { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.q-main .hint-toggle { margin: 0 0 0 54px; }
.question-card.has-pic { display: flex; align-items: center; gap: 16px; }
.question-card.has-pic .q-main { flex: 1 1 auto; min-width: 0; }
/* Long answers stack one per row; a smaller picture keeps the question on one screen. */
.question-card.compact-pic .q-pic { flex-basis: 200px; }
.q-pic {
    position: relative; flex: 0 0 250px; padding: 0; margin: 0;
    background: #fff; border: 2px solid var(--theme); border-radius: 12px;
    cursor: zoom-in; overflow: hidden; transition: transform 0.15s;
}
.q-pic:hover { transform: scale(1.03); }
.q-pic img { display: block; width: 100%; height: auto; }
.q-pic-zoom {
    position: absolute; right: 6px; bottom: 6px; font-size: 18px; line-height: 1;
    background: #fff; border-radius: 50%; padding: 5px; box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.pic-zoom {
    position: fixed; inset: 0; z-index: 10000; background: rgba(15, 23, 42, 0.82);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    padding: 20px; cursor: zoom-out;
}
.pic-zoom[hidden] { display: none; }
.pic-zoom img { max-width: min(92vw, 1000px); max-height: 78vh; width: auto; height: auto; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
.pic-zoom img[src$=".svg"] { width: min(92vw, 1000px, calc(78vh * 1.6)); }
.btn-note { margin: 2px 0 0; font-size: 16px; color: #4a5563; }

@media (max-width: 700px) {
    .question-card.has-pic { flex-direction: column; align-items: stretch; }
    .q-pic { flex-basis: auto; max-width: 340px; align-self: center; }
}
.question-text { font-size: 26px; font-weight: 600; line-height: 1.4; color: #1b1b1b; }

/* The 🔊 that sits on the LEFT of what it reads. Tap to read, tap to stop (⏹). */
.spk-btn {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 50%; font-size: 20px; line-height: 1;
    background: #fff; border: 2px solid var(--theme, #0a74c2); cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.12); transition: transform 0.15s, background 0.15s;
    user-select: none;
}
.spk-btn:hover { transform: scale(1.08); }
.spk-btn:focus-visible { outline: 3px solid #1b1b1b; outline-offset: 2px; }
.spk-btn.on { background: #FFD44D; border-color: #1b1b1b; }

/* The word being read: a real marker yellow with dark ink, not a pale tint. */
.w.hl { background: #FFD44D; color: #1b1b1b; border-radius: 4px; box-shadow: 0 0 0 2px #FFD44D; }

.hint-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    background: #fff4d6; color: #7a4a00; border: 2px solid #f0b429; border-radius: 999px;
    font-size: 18px; font-weight: 600; padding: 6px 18px; cursor: pointer;
    transition: background 0.15s;
}
.hint-toggle:hover { background: #ffe9a8; }
.hint-box {
    background: #fff8e1; border: 3px dashed #f0b429; border-radius: 16px;
    padding: 10px 16px; margin: 0 0 4px; font-size: 21px; line-height: 1.45; color: #4a3400;
    animation: drop-in 0.25s ease-out both;
}

#quiz-screen, #result-screen { display: none; }
.option-btn {
    position: relative;
    display: flex; align-items: center; gap: 14px;
    width: 100%; padding: 7px 16px; margin: 8px 0;
    background: #fff; color: #1b1b1b;
    border: 3px solid #d5dbe3; border-radius: 16px;
    font-size: 21px; font-weight: 500; line-height: 1.35;
    cursor: pointer; text-align: left;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.option-btn:hover { border-color: var(--theme); background: var(--theme-soft); }
.option-btn:active { transform: scale(0.99); }
.option-btn.selected { border-color: var(--theme); background: var(--theme-soft); box-shadow: 0 0 0 3px var(--theme); }
.locked .option-btn { cursor: default; }
.locked .option-btn:hover { border-color: #d5dbe3; background: #fff; }
.locked .option-btn:active { transform: none; }
.option-btn.is-right, .locked .option-btn.is-right:hover { background: #e3f7ea; border-color: #1e8449; box-shadow: 0 0 0 3px #1e8449; }
.option-btn.is-wrong, .locked .option-btn.is-wrong:hover { background: #fdecea; border-color: #c0392b; box-shadow: 0 0 0 3px #c0392b; }
.option-btn.show-right, .locked .option-btn.show-right:hover { border-color: #1e8449; border-style: dashed; background: #f1fbf4; }
.option-btn.is-right::after { content: '✅'; margin-left: auto; font-size: 24px; }
.option-btn.is-wrong::after { content: '❌'; margin-left: auto; font-size: 24px; }
.option-btn.show-right::after { content: '✅'; margin-left: auto; font-size: 24px; }

.feedback { border-radius: 16px; padding: 14px 18px; margin-top: 14px; font-size: 21px; line-height: 1.45; animation: drop-in 0.25s ease-out both; }
.feedback-right { background: #e3f7ea; border: 3px solid #1e8449; color: #14532d; }
.feedback-wrong { background: #fdecea; border: 3px solid #c0392b; color: #7f1d1d; }
.feedback-title { margin: 0 0 8px; font-size: 24px; font-weight: 700; }

/* Stars that fly out of a right answer */
.burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.burst span {
    position: absolute; left: -13px; top: -13px; font-size: 26px;
    animation: burst 0.8s ease-out forwards;
}
@keyframes burst {
    from { transform: rotate(var(--angle)) translateY(0) scale(0.4); opacity: 1; }
    to   { transform: rotate(var(--angle)) translateY(-90px) scale(1.1); opacity: 0; }
}
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes drop-in { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ═══════════ RESULTS ═══════════ */
.result-card { background: #f7f9fc; border: 3px solid #dfe6ee; border-radius: 20px; padding: 24px 18px; margin-bottom: 18px; }
.result-stars { display: flex; justify-content: center; gap: 6px; margin-bottom: 6px; }
.result-stars .star { font-size: 52px; filter: grayscale(1); opacity: 0.3; }
.result-stars .star.on { filter: none; opacity: 1; animation: pop 0.4s ease-out both; }
#result-title { margin: 6px 0 4px; font-size: 32px; color: #1b1b1b; }
.final-score { font-size: 26px; font-weight: 600; margin: 4px 0; color: #1b1b1b; }
.final-grade { font-size: 21px; margin: 4px 0 0; color: #4a5563; }

@media (prefers-reduced-motion: reduce) {
    .streak, .hint-box, .feedback, .result-stars .star.on { animation: none; }
    .progress-fill { transition: none; }
}

@media (max-width: 600px) {
    .quiz-banner { flex-wrap: wrap; }
    .quiz-icon { font-size: 36px; }
}

.score-board {
    margin-top: 30px;
    padding: 15px;
    background-color: #ecf0f1;
    border-radius: 10px;
    text-align: left;
    border: 2px solid #bdc3c7;
}
.score-board h3 {
    margin-top: 0;
    text-align: center;
    color: #c23616;
}
#score-list {
    list-style-type: none;
    padding: 0;
}
#score-list li {
    background: white;
    margin: 5px 0;
    padding: 10px;
    border-radius: 5px;
    border-left: 5px solid #0984e3;
    font-weight: bold;
    color: #2d3436;
}
/* --- Name Entry Screen --- */
#name-screen {
    display: block;
}
.name-entry-box {
    background: #f8f9fa;
    border: 2px solid #0984e3;
    border-radius: 15px;
    padding: 30px 25px;
    margin: 20px auto;
    max-width: 520px;
    text-align: center;
}
#student-name-input:focus {
    border-color: #d63031;
    box-shadow: 0 0 0 3px rgba(214,48,49,0.15);
}
/* --- Student sign-in (roster + student number, same as Math Fact Review) --- */
.login-box { text-align: left; }
.login-box label { display: block; font-size: 18px; font-weight: bold; color: #2c3e50; margin: 14px 0 6px; }
.login-box select,
.login-box input[type="password"],
.login-box input[type="text"] {
    width: 100%; box-sizing: border-box; font-size: 18px; padding: 12px 14px;
    border: 3px solid #0984e3; border-radius: 10px; outline: none; font-family: inherit; background: #fff;
}
.login-box select:focus, .login-box input:focus { border-color: #d63031; }
.login-error { color: #d63031; font-weight: bold; font-size: 16px; min-height: 22px; margin: 12px 0 6px; text-align: center; }
.student-bar {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    background: #f8f9fa; border: 2px solid #0984e3; border-radius: 50px;
    padding: 8px 12px 8px 20px; margin: 0 0 20px; color: #2c3e50; font-weight: 500; text-align: left;
}
.btn-switch { background: none; border: none; color: #636e72; cursor: pointer; font-size: 15px; text-decoration: underline; font-family: inherit; white-space: nowrap; }

/* --- Teacher Mode (answer key) --- */
.btn-teacher-link {
    display: block; margin: 30px auto 0; background: none; border: none;
    color: #636e72; font-size: 15px; font-family: inherit; text-decoration: underline; cursor: pointer;
}
.btn-teacher-link:hover { color: #2c3e50; }
.teacher-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; }
.teacher-toolbar h2 { margin: 0; color: #2c3e50; font-size: 24px; }
.teacher-actions { display: flex; gap: 8px; }
.btn-teacher-small {
    background: #2d3436; color: #fff; border: none; border-radius: 8px; padding: 8px 14px;
    font-size: 15px; font-family: inherit; font-weight: bold; cursor: pointer;
}
.btn-teacher-small:hover { background: #0984e3; }
.teacher-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.teacher-tab {
    flex: 1 1 140px; padding: 10px 12px; border: 2px solid #0984e3; border-radius: 10px;
    background: #fff; color: #0984e3; font-size: 16px; font-weight: bold; font-family: inherit; cursor: pointer;
}
.teacher-tab.active { background: #0984e3; color: #fff; }
.teacher-toggle { display: block; text-align: left; font-size: 15px; color: #2c3e50; margin: 6px 0; cursor: pointer; }
.teacher-count { text-align: left; color: #636e72; font-weight: bold; margin: 6px 0 14px; }
.teacher-card {
    text-align: left; background: #fff; border: 2px solid #dfe6e9; border-left: 6px solid #0984e3;
    border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; break-inside: avoid;
}
.teacher-qnum { display: inline-block; background: #0984e3; color: #fff; font-weight: bold; font-size: 13px; border-radius: 6px; padding: 2px 8px; }
.teacher-question { font-size: 18px; font-weight: bold; color: #2c3e50; margin: 8px 0 10px; }
.teacher-pic { display: block; width: 240px; max-width: 100%; border: 1px solid #dfe6e9; border-radius: 10px; margin: 0 0 10px; }
.teacher-options { list-style: none; padding: 0; margin: 0; }
.teacher-options li { padding: 7px 10px; border-radius: 8px; margin-bottom: 5px; font-size: 16px; }
.teacher-options li.correct { background: #e8f8ef; border: 2px solid #2ecc71; font-weight: bold; }
.teacher-options li.wrong { background: #f8f9fa; border: 1px solid #eee; color: #444; }
.teacher-mark { margin-right: 8px; }
.teacher-rationale { font-size: 14px; font-weight: normal; color: #555; margin: 4px 0 0 28px; }
.teacher-hint { font-size: 14px; color: #8e6c00; background: #fff8e1; border-radius: 8px; padding: 6px 10px; margin: 10px 0 0; }

@media print {
    body { background: #fff; padding: 0; }
    #app-container { box-shadow: none; max-width: none; padding: 0; }
    .teacher-actions, .teacher-tabs, .teacher-toggle { display: none; }
    .teacher-card { border: 1px solid #999; border-left: 4px solid #333; }
}
