/* Self-hosted Outfit variable font */
@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 300 900;
    font-display: swap;
    src: url('fonts/Outfit-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 300 900;
    font-display: swap;
    src: url('fonts/Outfit-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --primary: #4f8ff7;
    --primary-bold: #2563eb;
    --secondary: #6ba3f9;
    --accent: #fbbf24;
    --bg-deep: #0b1120;
    --bg-card: #161f33;
    --bg-elevated: #1c2742;
    --bg-surface: #243352;
    --border-subtle: rgba(255,255,255,0.07);
    --border-card: rgba(255,255,255,0.1);
    --border-hover: rgba(255,255,255,0.18);
    --text-primary: #eef2f7;
    --text-secondary: #a0aec0;
    --text-muted: #9aa8bf;
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-xl: 30px;
    --shadow-card: 0 2px 8px rgba(0,0,0,0.25), 0 0 0 1px var(--border-card);
    --shadow-elevated: 0 8px 24px rgba(0,0,0,0.35), 0 0 0 1px var(--border-card);
    --shadow-button: 0 2px 6px rgba(0,0,0,0.3);
    --font-heading: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-mono: 'Outfit', system-ui, monospace;
}

/* Text versions of the unit colors: lightened for dark mode by
   StudyEngine._setReadableTextColors; light mode uses the colors as they are. */
:root {
    --primary-text: var(--primary-text-dark, var(--primary));
    --secondary-text: var(--secondary-text-dark, var(--secondary));
    --accent-text: var(--accent-text-dark, var(--accent));
}

/* Light mode */
body.light-mode {
    --primary-text: var(--primary-bold);
    --secondary-text: var(--secondary);
    --accent-text: var(--accent);
    --primary: #2563eb;
    --primary-bold: #1d4ed8;
    --secondary: #3b82f6;
    --accent: #b45309;
    --bg-deep: #f1f5f9;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --bg-surface: #e2e8f0;
    --border-subtle: rgba(0,0,0,0.06);
    --border-card: rgba(0,0,0,0.1);
    --border-hover: rgba(0,0,0,0.18);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #526175;
    --success: #15803d;
    --danger: #dc2626;
    --warning: #b45309;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 0 0 1px var(--border-card);
    --shadow-elevated: 0 4px 12px rgba(0,0,0,0.1), 0 0 0 1px var(--border-card);
    --shadow-button: 0 1px 3px rgba(0,0,0,0.1);
}

/* Light mode overrides for hardcoded rgba/alpha elements */
body.light-mode header {
    background: var(--bg-elevated);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body.light-mode .nav-tabs {
    background: var(--bg-card);
}

body.light-mode .nav-btn.active {
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

body.light-mode .activity-topbar {
    background: var(--bg-card);
}

body.light-mode .welcome-overlay {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

/* Flashcard — front face keeps white text on blue bg */
body.light-mode .fc-front {
    background: linear-gradient(145deg, var(--primary-bold) 0%, var(--primary) 50%, var(--secondary) 100%);
    color: white;
}
body.light-mode .fc-front .fc-label,
body.light-mode .fc-front .fc-flip-hint {
    color: rgba(255,255,255,0.7);
}
body.light-mode .fc-front .fc-cat-badge {
    background: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.85);
}
/* Flashcard — back face uses theme colors */
body.light-mode .fc-back {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-card);
}
body.light-mode .fc-back .fc-label {
    color: var(--text-muted);
}
body.light-mode .fc-back .fc-example {
    color: var(--text-secondary);
}
body.light-mode .fc-back .fc-cat-badge {
    background: var(--bg-surface);
    color: var(--text-secondary);
}
/* Flashcard — progress, nav, tips, completion */
body.light-mode .fc-progress-text {
    color: var(--text-primary);
}
body.light-mode .fc-dot {
    background: var(--border-card);
}
body.light-mode .fc-dot-current {
    background: var(--primary);
    box-shadow: 0 0 6px rgba(37, 99, 235, 0.4);
}
body.light-mode .fc-nav-btn {
    background: var(--bg-surface);
    border-color: var(--border-card);
    color: var(--text-secondary);
}
body.light-mode .fc-nav-btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
body.light-mode .fc-counter {
    color: var(--text-secondary);
}
body.light-mode .fc-rate-label {
    color: var(--text-secondary);
}
body.light-mode .fc-tips {
    color: var(--text-muted);
}
body.light-mode .fc-tips kbd {
    background: var(--bg-surface);
    border-color: var(--border-card);
}
body.light-mode .fc-complete h2 {
    color: var(--text-primary);
}
body.light-mode .fc-stat-label {
    color: var(--text-muted);
}
body.light-mode .flashcard-counter {
    color: var(--text-primary);
}
body.light-mode .mastery-progress-bar {
    color: var(--text-primary);
}

/* Typing — focus hint */
body.light-mode .typing-dark-box:not(.focused) .typing-focus-hint {
    background: var(--bg-card);
}
body.light-mode .typing-word.vocab-term.current {
    text-shadow: none;
}

/* Resource library */
body.light-mode .res-search-icon { color: var(--text-muted); }
body.light-mode .res-search-input {
    border-color: var(--border-card);
    background: var(--bg-card);
    color: var(--text-primary);
}
body.light-mode .res-search-input::placeholder { color: var(--text-muted); }
body.light-mode .res-search-input:focus {
    border-color: var(--primary);
    background: var(--bg-card);
}
body.light-mode .res-section { background: var(--bg-card); }
body.light-mode .res-category-header {
    background: var(--bg-surface);
    border-left-color: var(--primary);
}
body.light-mode .res-category-header:hover { background: rgba(0,0,0,0.04); }
body.light-mode .res-chevron { color: var(--text-muted); }
body.light-mode .res-header-title { color: var(--text-primary); }
body.light-mode .res-count-badge {
    color: var(--text-secondary);
    background: var(--bg-surface);
}
body.light-mode .res-term-card { border-top-color: var(--border-subtle); }
body.light-mode .res-term-name { color: var(--text-primary); }
body.light-mode .res-term-def { color: var(--text-secondary); }

/* Games — borders that use rgba white */
body.light-mode .wordle-cell { border-color: var(--border-card); }
body.light-mode .wordle-cell.filled { border-color: var(--border-hover); }
body.light-mode .wordle-key:hover { background: var(--bg-surface); }
body.light-mode .match-card-back { border-color: var(--border-card); }
body.light-mode .race-lane { border-color: var(--border-card); }
body.light-mode .falling-term { border-color: var(--border-card); }
body.light-mode .tl-card { border-color: var(--border-card); }
body.light-mode .tl-slot { border-color: var(--border-card); }
body.light-mode .tl-btn-reset { border-color: var(--border-card); }
body.light-mode .tl-btn-reset:hover { background: var(--bg-surface); }
body.light-mode .crossword-cell input { border-color: var(--border-card); }

/* Source analysis */
body.light-mode .source-classify-btn { border-color: var(--border-card); }
body.light-mode .source-question-option { border-color: var(--border-card); }
body.light-mode .source-breakdown { border-top-color: var(--border-subtle); }
body.light-mode .source-image { border-color: var(--border-card); }

/* Lightning */
body.light-mode .lightning-missed-item { border-bottom-color: var(--border-subtle); }
body.light-mode .lightning-leaderboard-table td,
body.light-mode .lightning-leaderboard-table th { border-bottom-color: var(--border-subtle); }

/* Misc — inputs, borders */
body.light-mode .answer-textarea { border-color: var(--border-card); }
body.light-mode .timer-field input { border-color: var(--border-card); }
body.light-mode .study-guide-textarea { border-color: var(--border-card); }
body.light-mode .login-input { border-color: var(--border-card); }
body.light-mode .study-guide-toggle { border-color: var(--border-card); }

/* Focus timer bar keeps white text */
body.light-mode .focus-timer-bar { color: white; }
body.light-mode .focus-timer-btn { color: white; }

/* Footer */
body.light-mode .app-footer { color: var(--text-muted); }


/* Achievement badges */
body.light-mode .ach-badge:hover { border-color: var(--border-hover); }

body.dyslexic-font {
    --font-heading: 'OpenDyslexic', 'Roboto', sans-serif !important;
    --font-body: 'OpenDyslexic', 'Lexend', sans-serif !important;
}

body.dyslexic-font * {
    font-family: var(--font-body) !important;
}

body.dyslexic-font h1, body.dyslexic-font h2, body.dyslexic-font h3,
body.dyslexic-font h4, body.dyslexic-font h5, body.dyslexic-font h6 {
    font-family: var(--font-heading) !important;
}

body.dyslexic-font .fas,
body.dyslexic-font .far,
body.dyslexic-font .fab,
body.dyslexic-font .fa,
body.dyslexic-font .fa-solid,
body.dyslexic-font .fa-regular,
body.dyslexic-font .fa-brands {
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Brands' !important;
}

@font-face {
    font-family: 'OpenDyslexic';
    src: url('fonts/OpenDyslexic-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'OpenDyslexic';
    src: url('fonts/OpenDyslexic-Bold.woff') format('woff');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    min-height: 100vh;
    padding: 0;
    color: var(--text-primary);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* HEADER */
header {
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 14px 30px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-card);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

header h1 {
    font-size: 1.6em;
    font-weight: 800;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: -0.02em;
    transition: font-size 0.3s ease;
}

header i {
    font-size: 0.9em;
    color: var(--accent-text);
}

header .subtitle {
    font-size: 0.95em;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 400;
    transition: all 0.3s ease;
}

header .essential-question {
    font-size: 0.9em;
    font-style: italic;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.student-greeting {
    color: var(--accent-text);
    font-size: 0.9em;
    font-weight: 600;
    margin-top: 2px;
    transition: all 0.3s ease;
}

/* Quiz date note under the essential question (unit.quizDate) */
.quiz-countdown {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    padding: 3px 12px;
    font-size: 0.82em;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
}

.quiz-countdown i { font-size: 0.95em; color: var(--text-muted); }
.quiz-countdown-date { font-weight: 600; }
.quiz-countdown-left::before { content: '\00b7'; margin-right: 6px; color: var(--text-muted); }
.quiz-countdown-soon { border-color: var(--accent); }
.quiz-countdown-soon .quiz-countdown-left { color: var(--accent-text); font-weight: 600; }

/* Collapsed header when activity is active */
body.activity-active header {
    padding: 8px 20px;
}

body.activity-active header h1 {
    font-size: 1em;
    margin-bottom: 0;
}

body.activity-active header .subtitle,
body.activity-active header .essential-question,
body.activity-active header .student-greeting,
body.activity-active header .quiz-countdown {
    display: none;
}

body.activity-active .nav-tabs {
    display: none;
}

/* Compact activity bar shown when activity is active */
.activity-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 99;
}

body.activity-active .activity-topbar {
    display: flex;
}

body.activity-active header {
    position: relative;
}

.activity-topbar-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9em;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-family: var(--font-body);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.activity-topbar-back:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.activity-topbar-title {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95em;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Phones: a long activity title pushed Study/Practice/Games 10-20px past the
   screen edge. The title now gives way (ellipsis) instead. */
@media (max-width: 480px) {
    .activity-topbar { padding: 8px 12px; }
}

.activity-topbar-nav {
    display: flex;
    gap: 4px;
}

.activity-topbar-nav button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8em;
    font-family: var(--font-body);
    font-weight: 600;
    transition: all 0.2s;
}

.activity-topbar-nav button:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

/* NAV TABS */
.nav-tabs {
    display: flex;
    gap: 6px;
    padding: 12px 20px;
    justify-content: center;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 99;
    flex-wrap: wrap;
    transition: all 0.3s ease;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    color: var(--text-muted);
    font-family: var(--font-body);
}

.nav-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--primary-bold);
    color: white;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.4);
}

/* SUB-NAV */
.sub-nav {
    display: none;
    gap: 8px;
    margin-bottom: 0;
    padding: 12px 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.sub-nav.active {
    display: flex;
}

.sub-nav-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    padding: 8px 18px;
    border-radius: var(--radius-lg);
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    color: var(--primary-text);
    font-family: var(--font-body);
}

.sub-nav-btn:hover, .sub-nav-btn.active {
    background: var(--primary-bold);
    color: white;
    border-color: var(--primary-bold);
}

/* SECTIONS */
.section {
    display: none;
    animation: fadeIn 0.25s ease;
    padding: 16px 20px;
}

.section.active {
    display: block;
}

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

/* HOME SECTION */
.home-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.card {
    background: var(--bg-elevated);
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-card);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-card);
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-elevated);
}

.card h2 {
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
    font-weight: 700;
}

.card h2 i {
    color: var(--accent-text);
    font-size: 0.9em;
}

.card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
    font-size: 0.9em;
}

.card-button {
    background: linear-gradient(135deg, var(--primary-bold) 0%, var(--primary) 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9em;
    transition: all 0.2s ease;
    width: 100%;
    font-family: var(--font-body);
    letter-spacing: 0.02em;
    box-shadow: var(--shadow-button);
}

.card-button:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.5);
    transform: translateY(-1px);
}

.card-button:disabled {
    background: var(--bg-surface);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.stats-container {
    background: var(--bg-elevated);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-card);
    margin-bottom: 10px;
    box-shadow: var(--shadow-card);
}

.stats-container h2 {
    color: var(--text-primary);
    font-size: 0.85em;
    font-weight: 700;
    margin-bottom: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.stat-box {
    background: var(--bg-surface);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--primary);
    position: relative;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.8em;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.stat-value {
    font-size: 1em;
    font-weight: 800;
    color: var(--text-primary);
}

.progress-bar {
    background: var(--bg-card);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
    border: 1px solid var(--border-subtle);
    position: relative;
}

.progress-fill {
    background: linear-gradient(90deg, var(--primary-bold) 0%, var(--primary) 60%, var(--success) 100%);
    height: 100%;
    transition: width 0.4s ease;
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(79, 143, 247, 0.25);
    font-size: 0;
    color: transparent;
}

.progress-label {
    display: none;
}

.progress-label-text {
    font-size: 0.78em;
    color: var(--text-muted);
    font-weight: 600;
}

.progress-label-pct {
    font-size: 0.85em;
    color: var(--primary-text);
    font-weight: 800;
}

/* Achievements section inside stats container */
.ach-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
}

/* Step-by-step flow on home page */
.home-continue {
    text-align: center;
    margin-bottom: 16px;
}
.home-continue-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 36px;
    font-size: 1.15em;
    font-weight: 700;
    font-family: var(--font-body);
    border: none;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}
.home-continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
.home-continue-btn i {
    font-size: 1.1em;
}
.home-continue-hint {
    margin-top: 8px;
    font-size: 0.85em;
    color: var(--text-muted);
}
.home-flow {
    margin-bottom: 10px;
}

.home-flow-title {
    color: var(--primary-text);
    font-size: 1em;
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
}

.home-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.home-step {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s;
}

.home-step:hover {
    border-color: var(--primary);
}

.home-step-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95em;
}

.home-step-content {
    flex: 1;
    min-width: 0;
}

.home-step-title {
    font-weight: 700;
    font-size: 0.95em;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.home-step-title i {
    color: var(--primary-text);
    margin-right: 4px;
}

.home-step-desc {
    font-size: 0.8em;
    color: var(--text-secondary);
    line-height: 1.4;
}

.home-step-cta {
    flex-shrink: 0;
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.8em;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    font-family: var(--font-body);
}

.home-step-cta:hover {
    background: var(--primary-bold);
    transform: scale(1.03);
}

@media (max-width: 480px) {
    .home-step {
        flex-wrap: wrap;
    }
    .home-step-cta {
        width: 100%;
        text-align: center;
        margin-top: 6px;
    }
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}

.badge {
    background: var(--bg-surface);
    padding: 14px;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border-card);
    transition: all 0.2s ease;
    cursor: pointer;
}

.badge:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.badge.unlocked {
    border-color: var(--primary);
    background: rgba(79, 143, 247, 0.12);
    box-shadow: 0 0 12px rgba(79, 143, 247, 0.15);
}

.badge-icon {
    font-size: 2.2em;
    margin-bottom: 6px;
    opacity: 0.4;
}

.badge.unlocked .badge-icon {
    opacity: 1;
}

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

.badge-description {
    font-size: 0.75em;
    color: var(--text-muted);
}

/* HISTORICAL QUOTE CARD */
.historical-quote-card {
    margin-top: 12px;
    padding: 0;
    overflow: hidden;
    border: 2px solid var(--primary);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, var(--bg-card) 40%);
}

.historical-quote-inner {
    display: flex;
    gap: 16px;
    padding: 18px 20px;
    align-items: center;
}

.historical-quote-portrait {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.historical-quote-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.historical-quote-text {
    flex: 1;
    min-width: 0;
}

.historical-quote-text blockquote {
    color: var(--text-primary);
    font-size: 1.05em;
    font-style: italic;
    line-height: 1.6;
    margin: 0 0 8px 0;
}

.historical-quote-author {
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 700;
}

.historical-quote-source {
    font-weight: 400;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

a.historical-quote-source:hover {
    color: var(--primary-text);
    text-decoration: underline;
}

.historical-quote-card {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.quote-cycle-hint {
    text-align: center;
    font-size: 0.8em;
    color: var(--text-muted);
    padding: 4px 0 8px;
    opacity: 0.6;
}

@media (max-width: 480px) {
    .historical-quote-inner {
        flex-direction: column;
        text-align: center;
    }
}

/* FLASHCARD SECTION — Anki-style SRS with 3D flip */
.fc-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 720px;
    margin: 0 auto;
}

/* Weak terms nudge */
.fc-weak-nudge {
    width: 100%;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.9em;
    color: var(--accent-text);
}
.fc-weak-nudge i { color: var(--accent-text); }
.fc-weak-nudge.fc-weak-active {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--accent);
}
.fc-weak-btn {
    background: #f59e0b;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    transition: background 0.2s;
}
.fc-weak-btn:hover { background: #d97706; }

/* Controls */
.fc-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}
.fc-filter {
    padding: 8px 14px;
    border: 2px solid var(--border-card);
    border-radius: 8px;
    font-size: 0.9em;
    cursor: pointer;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-family: var(--font-body);
}
.fc-ctrl-btn {
    background: none;
    border: 2px solid var(--primary);
    color: var(--primary-text);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.2s;
    font-family: var(--font-body);
}
.fc-ctrl-btn:hover {
    background: var(--primary);
    color: white;
}
.fc-options-toggle.active {
    background: var(--primary);
    color: white;
}
.fc-options-panel {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    padding-top: 8px;
}

/* Progress dots */
.fc-progress {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 4px 0;
}
.fc-progress-text {
    font-size: 0.85em;
    color: var(--text-primary);
    font-weight: 600;
}
.fc-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-hover);
    transition: all 0.2s;
}
.fc-dot-current {
    background: var(--primary);
    box-shadow: 0 0 6px rgba(79, 143, 247, 0.4);
    transform: scale(1.3);
}
.fc-dot-mastered { background: #22c55e; }
.fc-dot-again { background: #ef4444; }
.fc-dot-hard { background: #f97316; }

/* 3D Card Scene */
.fc-scene {
    width: 100%;
    min-height: 340px;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
}
.fc-card {
    width: 100%;
    height: 100%;
    min-height: 340px;
    position: relative;
    transition: transform 0.5s ease;
    transform-style: preserve-3d;
}
.fc-card.fc-flipped {
    transform: rotateX(180deg);
}
.fc-face {
    position: absolute;
    width: 100%;
    min-height: 340px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 32px;
    box-sizing: border-box;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}
.fc-front {
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #e2e8f0;
}
.fc-back {
    background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 100%);
    color: #1e293b;
    transform: rotateX(180deg);
}
.fc-label {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.6;
    margin-bottom: 16px;
    font-weight: 700;
}
.fc-content {
    font-size: 1.6em;
    line-height: 1.5;
    font-weight: 500;
    font-family: var(--font-heading);
}
.fc-back .fc-content {
    font-size: 1.2em;
    font-family: var(--font-body);
    font-weight: 400;
}
.fc-card-image {
    max-width: 220px;
    max-height: 200px;
    border-radius: 10px;
    object-fit: cover;
    margin: 0 auto 16px;
    display: block;
    border: 2px solid rgba(255,255,255,0.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
body.light-mode .fc-card-image {
    border-color: rgba(0,0,0,0.12);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.fc-example {
    margin-top: 14px;
    font-style: italic;
    font-size: 0.85em;
    opacity: 0.7;
    line-height: 1.5;
}
.fc-explain-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(250,204,21,0.4);
    background: rgba(250,204,21,0.1);
    color: #facc15;
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.fc-explain-btn:hover, .fc-explain-btn.active {
    background: rgba(250,204,21,0.2);
    border-color: rgba(250,204,21,0.6);
}
body.light-mode .fc-explain-btn {
    color: #a16207;
    border-color: rgba(161,98,7,0.3);
    background: rgba(250,204,21,0.1);
}
body.light-mode .fc-explain-btn:hover, body.light-mode .fc-explain-btn.active {
    background: rgba(250,204,21,0.2);
}
.fc-explain-box {
    margin-top: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(250,204,21,0.08);
    border-left: 3px solid #facc15;
    font-size: 0.88em;
    line-height: 1.6;
    color: var(--text-secondary);
    animation: fadeIn 0.2s ease;
}
body.light-mode .fc-explain-box {
    background: rgba(250,204,21,0.1);
    border-left-color: #a16207;
}
.fc-my-example-btn {
    border-color: rgba(59,130,246,0.3) !important;
    background: rgba(59,130,246,0.06) !important;
    color: #3b82f6 !important;
}
.fc-my-example-btn.active {
    background: rgba(59,130,246,0.15) !important;
}
.fc-my-example-box {
    margin-top: 10px;
    animation: fadeIn 0.2s ease;
}
.fc-my-example-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(59,130,246,0.3);
    background: rgba(59,130,246,0.06);
    color: #334155;
    font-family: var(--font-body);
    font-size: 0.88em;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}
.fc-my-example-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
.fc-my-example-input::placeholder {
    color: #94a3b8;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.fc-flip-hint {
    margin-top: 20px;
    font-size: 0.8em;
    opacity: 0.4;
    font-weight: 400;
}
.fc-cat-badge {
    position: absolute;
    top: 12px;
    right: 14px;
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.5px;
    z-index: 2;
}
.fc-back .fc-cat-badge {
    background: var(--bg-surface);
    color: var(--text-secondary);
}
.fc-tier-badge {
    position: absolute;
    top: 12px;
    left: 14px;
    background: rgba(245, 158, 11, 0.25);
    color: #f59e0b;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.5px;
    z-index: 2;
    text-transform: uppercase;
}
body.light-mode .fc-front .fc-tier-badge {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.85);
}
body.light-mode .fc-back .fc-tier-badge {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

/* Flashcard reading gate */
.fc-reading-gate { text-align: center; padding: 60px 20px; }
.fc-reading-gate-btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 28px; background: var(--primary); color: white; border: none; border-radius: 8px; font-size: 1em; font-weight: 600; cursor: pointer; transition: transform 0.2s; font-family: inherit; }
.fc-reading-gate-btn:hover { transform: scale(1.03); }
.fc-read-gate-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin: 0 0 16px; background: var(--bg-subtle, #fef3c7); border: 1px solid var(--border, #f59e0b); border-radius: 8px; color: var(--text-primary); font-size: 0.95em; line-height: 1.4; }
.fc-read-gate-banner i { color: var(--primary-text); font-size: 1.2em; flex-shrink: 0; }
.fc-read-gate-banner span { flex: 1; }
.fc-read-gate-banner-btn { padding: 6px 14px; background: var(--primary); color: white; border: none; border-radius: 6px; font-size: 0.9em; font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap; }
.fc-read-gate-banner-btn:hover { transform: scale(1.03); }

/* Term unlock progress */
.fc-term-progress { text-align: center; color: var(--text-secondary); font-size: 0.9em; padding: 8px 16px; background: var(--bg-surface); border-radius: 8px; margin-bottom: 12px; }

/* Textbook link on flashcard back */
.fc-textbook-link { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--primary-text); font-size: 0.85em; cursor: pointer; padding: 6px 0; margin-top: 8px; font-weight: 500; opacity: 0.8; transition: opacity 0.2s; font-family: inherit; }
.fc-textbook-link:hover { opacity: 1; text-decoration: underline; }
.fc-textbook-link i { font-size: 0.9em; }

/* "More" disclosure on the back face: keeps the definition the hero on flip;
   example, explanation, textbook link, and the personal-example textarea
   live behind this single toggle. */
.fc-more-wrap {
    margin-top: 18px;
    border-top: 1px solid rgba(0,0,0,0.08);
    padding-top: 12px;
}
.fc-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    font-family: inherit;
    opacity: 0.75;
    transition: opacity 0.2s;
}
.fc-more-btn:hover, .fc-more-btn.active { opacity: 1; }
.fc-more-btn i { font-size: 0.85em; }
.fc-more-panel {
    margin-top: 10px;
    animation: fadeIn 0.2s ease;
}
.fc-more-panel .fc-example { margin-top: 0; }

/* Confidence rating buttons */
.fc-confidence {
    width: 100%;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    text-align: center;
}
.fc-confidence.fc-visible {
    opacity: 1;
    max-height: 120px;
}
.fc-rate-label {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}
.fc-rate-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.fc-rate-btn {
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9em;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-family: var(--font-body);
    min-width: 72px;
}
.fc-rate-btn:hover { transform: translateY(-2px); }
.fc-rate-btn:active { transform: translateY(0); }
.fc-rate-again { background: #ef4444; color: white; }
.fc-rate-again:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(239,68,68,0.4); }
.fc-rate-hard { background: #f97316; color: white; }
.fc-rate-hard:hover { background: #ea580c; box-shadow: 0 4px 12px rgba(249,115,22,0.4); }
.fc-rate-good { background: #22c55e; color: white; }
.fc-rate-good:hover { background: #16a34a; box-shadow: 0 4px 12px rgba(34,197,94,0.4); }
.fc-rate-easy { background: #3b82f6; color: white; }
.fc-rate-easy:hover { background: #2563eb; box-shadow: 0 4px 12px rgba(59,130,246,0.4); }
.fc-rate-shortcut {
    font-size: 0.8em;
    opacity: 0.6;
    font-weight: 400;
}

/* Navigation */
.fc-nav {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: center;
}
.fc-nav-btn {
    background: var(--bg-surface);
    border: 2px solid var(--border-card);
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    transition: all 0.2s;
}
.fc-nav-btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.fc-nav-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}
.fc-counter {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* Keyboard tips */
.fc-tips {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 0.75em;
    color: var(--text-muted);
}
.fc-tips kbd {
    display: inline-block;
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: var(--font-body);
    font-size: 0.9em;
    margin-right: 2px;
}

/* Completion screen */
.fc-complete {
    text-align: center;
    padding: 40px 20px;
}
.fc-complete > i {
    font-size: 3em;
    color: #22c55e;
    margin-bottom: 16px;
}
.fc-complete h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.5em;
}
.fc-complete-stats {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.fc-complete-stats > div {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.fc-stat-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--accent-text);
}
.fc-stat-label {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: 4px;
}
.fc-weak-review-btn {
    margin-top: 8px;
    border-color: #f59e0b;
    color: #f59e0b;
}
.fc-weak-review-btn:hover {
    background: #f59e0b;
    color: white;
}

/* Keep .nav-button and .flashcard-nav for other activities that still use them */
.flashcard-nav {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}
.nav-button {
    background: linear-gradient(135deg, var(--primary-bold) 0%, var(--primary) 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: var(--font-body);
    box-shadow: var(--shadow-button);
}
.nav-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.5);
}
.nav-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.flashcard-counter {
    color: var(--text-primary);
    font-weight: 600;
}

/* Mobile adjustments for flashcards */
@media (max-width: 600px) {
    .fc-scene { min-height: 280px; }
    .fc-card { min-height: 280px; }
    .fc-face { min-height: 280px; padding: 28px 20px; }
    .fc-content { font-size: 1.3em; }
    .fc-back .fc-content { font-size: 1em; }
    .fc-rate-btn { min-width: 60px; padding: 8px 12px; font-size: 0.8em; }
    .fc-rate-shortcut { display: none; }
}

/* Flashcard Tutorial */
.fc-tutorial {
    max-width: 520px;
    margin: 0 auto;
    padding: 40px 28px;
    text-align: center;
}
.fc-tutorial-icon {
    font-size: 2.5em;
    color: var(--primary-text);
    margin-bottom: 12px;
}
.fc-tutorial h2 {
    color: var(--text-primary);
    font-size: 1.4em;
    margin-bottom: 24px;
}
.fc-tutorial-steps {
    text-align: left;
    margin: 0 auto 20px;
    max-width: 440px;
}
.fc-tutorial-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.fc-tutorial-step:last-child {
    border-bottom: none;
}
.fc-tutorial-step i {
    color: var(--primary-text);
    margin-top: 3px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.fc-tutorial-step span {
    color: var(--text-secondary);
    font-size: 0.93em;
    line-height: 1.5;
}
.fc-tutorial-tip {
    background: rgba(250,204,21,0.1);
    border: 1px solid rgba(250,204,21,0.25);
    border-radius: 10px;
    padding: 12px 16px;
    margin: 16px auto 24px;
    max-width: 440px;
    text-align: left;
    font-size: 0.88em;
    line-height: 1.5;
    color: var(--text-secondary);
}
.fc-tutorial-tip i {
    color: #facc15;
    margin-right: 4px;
}
.fc-tutorial-start {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 28px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.fc-tutorial-start:hover {
    opacity: 0.9;
}
.fc-help-btn {
    min-width: auto !important;
    padding: 6px 10px !important;
}

/* TIMELINE SECTION */
/* TIMELINE - Compact redesign */
.tl-wrapper { background: var(--bg-elevated); padding: 24px; border-radius: 12px; border: 1px solid var(--border-card); box-shadow: var(--shadow-card); }
.tl-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.tl-header h2 { color: var(--text-primary); font-size: 1.3em; margin: 0; }
.tl-toggle-btn { background: none; border: 2px solid var(--primary); color: var(--primary-text); padding: 6px 14px; border-radius: 20px; cursor: pointer; font-size: 0.85em; font-weight: 600; transition: all 0.2s; }
.tl-toggle-btn:hover { background: var(--primary); color: white; }
.tl-instructions { color: var(--text-secondary); font-size: 0.9em; margin-bottom: 10px; line-height: 1.4; }
.tl-stats { color: var(--text-secondary); font-size: 0.85em; margin-bottom: 16px; }
.tl-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 16px; }
.tl-section-label { font-weight: 700; color: var(--text-muted); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.tl-pool { display: flex; flex-direction: column; gap: 6px; min-height: 100px; }
.tl-card { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bg-surface); border: 2px solid var(--border-subtle); border-radius: 8px; cursor: pointer; transition: all 0.15s; user-select: none; font-size: 0.95em; color: var(--text-primary); }
.tl-card:hover { border-color: var(--primary); background: rgba(37, 99, 235, 0.1); }
.tl-card.tl-selected { border-color: var(--accent); background: rgba(245, 158, 11, 0.1); box-shadow: 0 0 0 2px var(--accent); }
.tl-card-year { font-weight: 700; color: var(--primary-text); font-size: 0.85em; white-space: nowrap; }
.tl-card-title { font-weight: 500; color: var(--text-primary); }
.tl-slots { display: flex; flex-direction: column; gap: 6px; }
.tl-slot { display: flex; align-items: center; gap: 8px; padding: 6px; background: var(--bg-surface); border: 2px dashed var(--border-card); border-radius: 8px; min-height: 44px; transition: all 0.15s; cursor: pointer; }
.tl-slot:hover { border-color: var(--primary); }
.tl-slot.tl-slot-active { border-color: var(--accent); background: rgba(245, 158, 11, 0.1); }
.tl-slot-num { background: var(--primary); color: white; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8em; flex-shrink: 0; }
.tl-slot-drop { color: var(--text-muted); font-size: 0.85em; font-style: italic; }
.tl-slot .tl-card { margin: 0; border-style: solid; flex: 1; }
.tl-slot.tl-slot-correct { border-color: var(--success); background: rgba(34, 197, 94, 0.1); }
.tl-slot.tl-slot-correct .tl-slot-num { background: var(--success); }
.tl-slot.tl-slot-wrong { border-color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.tl-slot.tl-slot-wrong .tl-slot-num { background: var(--danger); }
.tl-btn-row { display: flex; gap: 10px; justify-content: center; }
.tl-btn { padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.95em; transition: all 0.2s; font-family: var(--font-body); }
.tl-btn-check { background: var(--primary); color: white; }
.tl-btn-check:hover { box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); }
.tl-btn-reset { background: var(--bg-surface); color: var(--text-secondary); border: 2px solid var(--border-card); }
.tl-btn-reset:hover { background: var(--bg-elevated); }
.tl-result { margin-top: 16px; padding: 16px; border-radius: 10px; display: none; font-weight: 500; }
.tl-result-success { background: rgba(34, 197, 94, 0.15); color: #86efac; display: block; }
.tl-result-error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; display: block; }
.tl-result-warn { background: rgba(245, 158, 11, 0.15); color: #fcd34d; display: block; }
.tl-answer-list { margin-top: 10px; }
.tl-answer-row { padding: 4px 0; font-weight: 400; font-size: 0.9em; }

@media (max-width: 700px) {
    .tl-layout { grid-template-columns: 1fr; }
    .tl-header { flex-direction: column; align-items: flex-start; }
}

/* PRACTICE SECTION */
.practice-container {
    background: var(--bg-elevated);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-card);
}

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

.question-text {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.option {
    background: var(--bg-surface);
    border: 2px solid var(--border-card);
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    box-shadow: var(--shadow-button);
    font-size: 1.05em;
    line-height: 1.5;
}

.option:hover {
    border-color: var(--primary);
    background: rgba(79, 143, 247, 0.12);
    transform: translateY(-1px);
}

.option.selected {
    background: rgba(79, 143, 247, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 143, 247, 0.2);
}

.option.correct {
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--success);
}

.option.incorrect {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
}

.explanation {
    background: rgba(37, 99, 235, 0.1);
    border-left: 4px solid var(--primary);
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    color: var(--text-secondary);
}

.test-score {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2) 0%, rgba(6, 182, 212, 0.15) 100%);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    margin: 30px 0;
    border: 1px solid var(--border-card);
}

.test-score-value {
    font-size: 3em;
    font-weight: bold;
    color: var(--accent-text);
    margin-bottom: 10px;
}

.test-score-label {
    font-size: 1.2em;
    color: var(--text-secondary);
}

/* PRACTICE TEST MASTERY */
.pt-mastery-header {
    background: var(--bg-elevated);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-card);
    margin-bottom: 20px;
    text-align: center;
}
.pt-mastery-title {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.pt-mastery-bar-wrap {
    width: 100%;
    height: 12px;
    background: var(--bg-surface);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}
.pt-mastery-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 6px;
    transition: width 0.5s ease;
    min-width: 0;
}
.pt-mastery-label {
    font-size: 0.95em;
    color: var(--text-secondary);
    margin-top: 4px;
}
.pt-sessions-label {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 4px;
}
.pt-session-info {
    text-align: center;
    padding: 20px;
}
.pt-info-text {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 1.05em;
}
.pt-all-mastered {
    text-align: center;
    padding: 40px 20px;
}
.pt-feedback-msg {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin: 16px 0;
    font-size: 0.95em;
}
.pt-feedback-perfect {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.3);
}
.pt-feedback-study {
    background: rgba(251, 191, 36, 0.12);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.25);
}

/* SHORT ANSWER SECTION */
.short-answer-container {
    background: var(--bg-elevated);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-card);
}

/* Question card grid */
.sa-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.sa-question-card {
    border: 2px solid var(--border-card);
    border-radius: 14px;
    padding: 0;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-body);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sa-question-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
    transform: translateY(-3px);
}
.sa-question-card.sa-completed {
    border-color: rgba(34,197,94,0.5);
}
.sa-card-accent {
    height: 6px;
    width: 100%;
    flex-shrink: 0;
}
.sa-card-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.sa-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sa-card-topic-badge {
    font-size: 1em;
    font-weight: 700;
    color: #0b1120;
    padding: 6px 16px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sa-card-check { color: #22c55e; font-size: 1.5em; }
.sa-card-summary {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.5em;
    line-height: 1.3;
}
.sa-card-terms {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.sa-card-term-chip {
    font-size: 0.95em;
    padding: 5px 14px;
    border-radius: 12px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}
.sa-card-term-more {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-weight: 600;
}

/* Question detail view */
.sa-content-area { display: none; }
.sa-content-area.sa-active { display: block; animation: slideDown 0.25s ease; }
.sa-back-btn {
    background: none; border: none; color: var(--text-muted);
    font-family: var(--font-body); font-size: 0.9em;
    cursor: pointer; padding: 0; margin-bottom: 16px;
    display: inline-flex; align-items: center; gap: 6px;
    transition: color 0.15s;
}
.sa-back-btn:hover { color: var(--primary-text); }
.sa-q-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 12px; flex-wrap: wrap;
}
.sa-q-num { color: var(--text-muted); font-size: 0.85em; }
.sa-q-topic-badge {
    background: rgba(var(--primary-rgb, 22,105,197), 0.12);
    color: var(--primary-text); padding: 3px 10px; border-radius: 6px;
    font-size: 0.8em; font-weight: 600;
}
.sa-question-text {
    color: var(--text-primary); font-size: 1.05em; font-weight: 600;
    line-height: 1.6; margin-bottom: 20px;
    padding: 16px; background: var(--bg-surface);
    border-radius: 10px; border-left: 4px solid var(--primary);
}
.sa-help-btn {
    background: var(--primary); color: #fff; border: none;
    padding: 12px 22px; border-radius: var(--radius-md);
    font-family: var(--font-body); font-size: 0.95em; font-weight: 600;
    cursor: pointer; margin: 4px 0 24px;
    display: inline-flex; align-items: center; gap: 8px;
    transition: background 0.15s;
}
.sa-help-btn:hover { background: var(--primary-bold); }
.sa-btn-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-top: 4px;
}
.sa-save-btn {
    background: var(--primary); color: #fff; border: none;
    padding: 10px 20px; border-radius: 10px; font-family: var(--font-body);
    font-size: 0.95em; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
    transition: opacity 0.15s;
}
.sa-save-btn:hover { opacity: 0.85; }
.sa-nav-btns { display: flex; gap: 8px; }
.sa-nav-btn {
    background: var(--bg-surface); border: 1px solid var(--border-card);
    color: var(--text-secondary); padding: 8px 14px; border-radius: 8px;
    font-family: var(--font-body); font-size: 0.85em; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    transition: border-color 0.15s, color 0.15s;
}
.sa-nav-btn:hover { border-color: var(--primary); color: var(--primary-text); }

@media (max-width: 640px) {
    .sa-card-grid { grid-template-columns: 1fr; }
    .sa-btn-row { flex-direction: column; align-items: stretch; }
    .sa-nav-btns { justify-content: center; }
}

.rubric {
    background: var(--bg-surface);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.rubric-title {
    font-weight: 600;
    color: var(--primary-text);
    margin-bottom: 10px;
}

.rubric-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rubric-item {
    color: var(--text-secondary);
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.rubric-item:before {
    content: "\2713";
    color: var(--primary-text);
    font-weight: bold;
    flex-shrink: 0;
}

.rubric-paragraph {
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}

.exemplar {
    background: rgba(37, 99, 235, 0.1);
    border-left: 4px solid var(--primary);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    color: var(--text-secondary);
}

.exemplar-title {
    font-weight: 600;
    color: var(--primary-text);
    margin-bottom: 10px;
}

.key-terms-box {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.key-terms-title {
    font-weight: 600;
    color: var(--accent-text);
    margin-bottom: 10px;
}

.key-terms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.key-term-chip {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--accent-text);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
}

.key-term-chip-clickable {
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.key-term-chip-clickable:hover {
    background: rgba(245, 158, 11, 0.28);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}
.key-term-chip-active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.key-term-chip-active:hover {
    background: var(--accent);
}

.key-term-details {
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--bg-elevated, #fff);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    line-height: 1.5;
}
.key-term-details-heading {
    font-weight: 700;
    font-size: 1.05em;
    color: var(--accent-text);
    margin-bottom: 6px;
}
.key-term-details-def {
    font-size: 0.95em;
    margin-bottom: 6px;
}
.key-term-details-simple {
    font-size: 0.92em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.key-term-details-example {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 8px;
}
.key-term-details-missing {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9em;
}
.key-term-details-actions {
    margin-top: 8px;
}
.key-term-details-tb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s;
}
.key-term-details-tb-btn:hover { transform: scale(1.03); }

.connection-pairings {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.connection-pairings-title {
    font-weight: 600;
    color: #86efac;
    margin-bottom: 10px;
}

.connection-pairing-item {
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid rgba(34, 197, 94, 0.15);
    border-radius: 8px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.95em;
    line-height: 1.5;
}

.sentence-starters {
    background: var(--bg-surface);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.sentence-starters-title {
    font-weight: 600;
    color: var(--primary-text);
    margin-bottom: 10px;
}

.starter-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.starter {
    color: var(--text-secondary);
    font-style: italic;
    padding-left: 15px;
}

.answer-textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 2px solid var(--border-card);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 1em;
    resize: vertical;
    margin: 15px 0;
    background: var(--bg-surface);
    color: var(--text-primary);
}

.answer-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* TOOLS SECTION */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.tool-card {
    background: var(--bg-elevated);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border-card);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
}

.tool-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-elevated);
}

.tool-card h2 {
    color: var(--text-primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 15px;
    flex: 1;
}

.tool-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
    font-family: var(--font-body);
}

.tool-button:hover {
    background: var(--secondary);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
}

/* MODALS */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-elevated);
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: slideIn 0.3s ease;
    border: 1px solid var(--border-hover);
    color: var(--text-primary);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--text-primary);
}

.timer-input {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.timer-field {
    display: flex;
    flex-direction: column;
}

.timer-field label {
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 5px;
}

.timer-field input {
    padding: 10px;
    border: 2px solid var(--border-card);
    border-radius: 8px;
    font-size: 1em;
    background: var(--bg-surface);
    color: var(--text-primary);
}

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

.print-settings {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.print-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.print-checkbox input {
    cursor: pointer;
}

.print-checkbox label {
    cursor: pointer;
    color: var(--text-primary);
}

.focused-instructions {
    background: rgba(37, 99, 235, 0.1);
    border-left: 4px solid var(--primary);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

/* STUDY GUIDE */
.study-guide-container {
    max-width: 800px;
    margin: 0 auto;
}

.study-guide-header {
    margin-bottom: 20px;
}

.study-guide-section {
    background: var(--bg-elevated);
    border-radius: 12px;
    border: 1px solid var(--border-card);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
}

.study-guide-section.review {
    border-left: 4px solid #f59e0b;
}

.study-guide-section.mastered {
    border-left: 4px solid #22c55e;
}

.study-guide-section.notes {
    border-left: 4px solid var(--primary);
}

.study-guide-cat {
    font-weight: 600;
    color: var(--primary-text);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 12px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-subtle);
}

.study-guide-term {
    padding: 6px 0;
    font-size: 0.95em;
    line-height: 1.5;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.study-guide-term.mastered {
    color: #86efac;
}

.study-guide-toggle {
    background: none;
    border: 1px solid var(--border-card);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    margin-top: 4px;
}

.study-guide-toggle:hover {
    background: var(--bg-surface);
}

.study-guide-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    border: 1px solid var(--border-card);
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    font-family: var(--font-body);
    background: var(--bg-surface);
    color: var(--text-primary);
}

/* FOCUSED STUDY MODE */
.focused-study-container {
    background: var(--bg-elevated);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-card);
    text-align: center;
    box-shadow: var(--shadow-card);
}

.timer-display {
    font-size: 4em;
    font-weight: bold;
    color: var(--accent-text);
    margin: 30px 0;
    font-family: 'Courier New', monospace;
}

.timer-label {
    color: var(--text-secondary);
    font-size: 1.2em;
    margin-bottom: 20px;
}

.timer-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 30px 0;
}

.timer-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1em;
    transition: all 0.3s ease;
}

.timer-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(22, 105, 197, 0.4);
}

.timer-btn.pause {
    background: linear-gradient(135deg, var(--accent) 0%, #d97706 100%);
}

.focused-study-tip {
    background: rgba(37, 99, 235, 0.1);
    border-left: 4px solid var(--primary);
    padding: 15px;
    border-radius: 8px;
    color: var(--text-secondary);
    margin-top: 30px;
}

/* PERSISTENT FOCUS TIMER BAR */
.focus-timer-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-family: var(--font-body);
    animation: slideDown 0.3s ease;
}

body.timer-active .container {
    padding-top: 36px;
}

body.timer-active header {
    top: 36px;
}

.focus-timer-bar.paused {
    background: linear-gradient(135deg, var(--accent) 0%, #d97706 100%);
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.focus-timer-display {
    font-size: 1.1em;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 2px;
}

.focus-timer-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.focus-timer-btn:hover {
    background: rgba(255,255,255,0.35);
}

.focus-timer-btn.exit:hover {
    background: rgba(220,38,38,0.8);
}

/* KEYBOARD SHORTCUTS */
.shortcuts-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.shortcut-item {
    background: var(--bg-surface);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.shortcut-key {
    background: var(--bg-card);
    padding: 5px 10px;
    border-radius: 5px;
    font-family: monospace;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.shortcut-description {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* COMMAND PALETTE */
.cmd-palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: min(20vh, 160px);
    animation: cmdFadeIn 0.15s ease;
}

@keyframes cmdFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cmd-palette {
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: 14px;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.05);
    overflow: hidden;
    animation: cmdSlideIn 0.2s ease;
}

@keyframes cmdSlideIn {
    from { transform: translateY(-12px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.cmd-palette-input-wrap {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    gap: 12px;
}

.cmd-palette-search-icon {
    color: var(--text-muted);
    font-size: 0.95em;
    flex-shrink: 0;
}

.cmd-palette-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1em;
    font-family: inherit;
    outline: none;
}

.cmd-palette-input::placeholder {
    color: var(--text-muted);
}

.cmd-palette-hint {
    color: var(--text-muted);
    font-size: 0.75em;
    background: var(--bg-card);
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.cmd-palette-list {
    max-height: 340px;
    overflow-y: auto;
    padding: 6px 0;
}

.cmd-palette-category {
    padding: 8px 18px 4px;
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.cmd-palette-item {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    cursor: pointer;
    gap: 12px;
    transition: background 0.1s;
}

.cmd-palette-item:hover,
.cmd-palette-item.selected {
    background: var(--bg-surface);
}

.cmd-palette-item-icon {
    color: var(--text-secondary);
    width: 20px;
    text-align: center;
    font-size: 0.9em;
    flex-shrink: 0;
}

.cmd-palette-item.selected .cmd-palette-item-icon {
    color: var(--primary-text);
}

.cmd-palette-item-label {
    color: var(--text-primary);
    font-size: 0.92em;
}

.cmd-palette-empty {
    padding: 24px 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9em;
}

/* ACTIVITY PICKER */
.activity-picker h2 {
    color: white;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.activity-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.activity-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.activity-card p {
    flex: 1;
}

.activity-card .card-button {
    margin-top: auto;
}

/* Category visual differentiation. Study cards use the unit's primary so
   the Start buttons match the unit theme; Practice and Games keep their
   semantic purple/green so students can still distinguish activity types
   at a glance (per the original design choice). */
.activity-card.category-study { border-top: 4px solid var(--primary); }
.activity-card.category-study h2 { color: var(--accent-text); }
.activity-card.category-study .card-button { background: var(--primary-bold); }
.activity-card.category-study .card-button:hover { background: var(--primary); }

.activity-card.category-practice { border-top: 4px solid #a78bfa; }
.activity-card.category-practice h2 { color: #c4b5fd; }
.activity-card.category-practice .card-button { background: #7c3aed; }
.activity-card.category-practice .card-button:hover { background: #8b5cf6; }

.activity-card.category-games { border-top: 4px solid #34d399; }
.activity-card.category-games h2 { color: #6ee7b7; }
.activity-card.category-games .card-button { background: #059669; }
.activity-card.category-games .card-button:hover { background: #10b981; }

/* Subtitle on external-link cards (e.g. simulation launcher warning) */
.external-link-subtitle {
    font-size: 0.85em;
    font-style: italic;
    opacity: 0.75;
    margin-top: -8px;
    margin-bottom: 8px;
    flex: 0;
}

/* LOGIN PROMPT */
.login-prompt {
    position: fixed;
    bottom: 76px;
    right: 20px;
    z-index: 100;
}

.login-prompt.hidden {
    display: none;
}

.save-progress-btn {
    background: linear-gradient(135deg, var(--primary-bold), var(--primary));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1em;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(79, 143, 247, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
}

.save-progress-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

/* LOGIN INPUT */
.login-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-card);
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    background: var(--bg-surface);
    color: var(--text-primary);
}

.login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* UTILITY CLASSES */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-box {
        padding: 14px;
    }

    .stat-value {
        font-size: 1.3em;
    }

    .flashcard {
        min-height: 250px;
        padding: 25px;
    }

    .flashcard-content {
        font-size: 1.2em;
    }

    .timer-display {
        font-size: 2.5em;
    }

    .nav-tabs {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 10px;
    }

    .modal-content {
        margin: 20px;
        max-width: calc(100% - 40px);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-box {
        padding: 12px;
    }

    .stat-value {
        font-size: 1.1em;
    }

    .stat-label {
        font-size: 0.8em;
    }
}

/* WORDLE */
.wordle-container { max-width: 500px; margin: 0 auto; text-align: center; }
.wordle-clue { background: var(--bg-elevated); padding: 20px; border-radius: 12px; margin-bottom: 20px; border: 1px solid var(--border-card); color: var(--text-primary); box-shadow: var(--shadow-card); }
.wordle-clue-label { color: var(--primary-text); font-weight: 600; margin-bottom: 8px; }
.wordle-grid { display: flex; flex-direction: column; gap: 5px; align-items: center; margin-bottom: 20px; }
.wordle-row { display: flex; gap: 5px; }
/* Long terms (Independence = 12 letters) ran 130px off a phone screen; cells shrink to fit. */
.wordle-cell { width: min(50px, calc((100vw - 48px - (var(--wordle-n, 5) - 1) * 5px) / var(--wordle-n, 5))); height: auto; aspect-ratio: 1; border: 2px solid var(--border-card); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.5em; font-weight: bold; text-transform: uppercase; transition: all 0.3s ease; color: var(--text-primary); }
.wordle-cell.correct { background: #22c55e; border-color: #22c55e; color: white; }
.wordle-cell.present { background: #eab308; border-color: #eab308; color: white; }
.wordle-cell.absent { background: #6b7280; border-color: #6b7280; color: white; }
.wordle-cell.filled { border-color: var(--border-hover); }
.wordle-input-area { margin-bottom: 20px; }
.wordle-input { padding: 12px 20px; font-size: 1.2em; border: 2px solid var(--primary); border-radius: 8px; text-transform: uppercase; text-align: center; width: 200px; font-weight: bold; letter-spacing: 4px; background: var(--bg-card); color: var(--text-primary); }
.wordle-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2); }
.wordle-keyboard { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.wordle-keyboard-row { display: flex; gap: 4px; }
.wordle-key { padding: 10px 14px; border: none; border-radius: 6px; font-size: 0.9em; font-weight: 600; cursor: pointer; background: var(--bg-surface); color: var(--text-primary); transition: all 0.2s; min-width: 35px; }
.wordle-key:hover { background: var(--bg-elevated); }
.wordle-key.correct { background: #22c55e; color: white; }
.wordle-key.present { background: #eab308; color: white; }
.wordle-key.absent { background: #6b7280; color: white; }
.wordle-key.wide { padding: 10px 20px; font-size: 0.8em; }
/* Phones: cells and keys shrink so the grid and keyboard fit a 360px screen. */
@media (max-width: 480px) {
    .wordle-cell { font-size: 1.1em; border-radius: 6px; }
    .wordle-keyboard-row { gap: 3px; width: 100%; justify-content: center; }
    .wordle-key { padding: 10px 0; min-width: 0; flex: 1 1 0; max-width: 34px; font-size: 0.85em; }
    .wordle-key.wide { padding: 10px 6px; flex: 1.5 1 0; max-width: 56px; font-size: 0.7em; }
}
.wordle-message { padding: 15px; border-radius: 10px; margin: 15px 0; font-weight: 600; font-size: 1.1em; }
.wordle-message.win { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.wordle-message.lose { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

/* HANGMAN */
.hangman-container { max-width: 600px; margin: 0 auto; text-align: center; }
.hangman-clue { background: var(--bg-elevated); padding: 20px; border-radius: 12px; margin-bottom: 20px; border: 1px solid var(--border-card); color: var(--text-primary); box-shadow: var(--shadow-card); }
.hangman-figure { position: relative; width: 200px; height: 250px; margin: 0 auto 20px; }
.hangman-part { position: absolute; transition: opacity 0.3s; opacity: 0; }
.hangman-part.visible { opacity: 1; }
.hangman-base { bottom: 0; left: 20px; width: 160px; height: 4px; background: var(--text-secondary); }
.hangman-pole { bottom: 0; left: 60px; width: 4px; height: 200px; background: var(--text-secondary); }
.hangman-top { top: 50px; left: 60px; width: 80px; height: 4px; background: var(--text-secondary); }
.hangman-rope { top: 50px; left: 136px; width: 4px; height: 30px; background: var(--text-secondary); }
.hangman-head { top: 80px; left: 120px; width: 36px; height: 36px; border: 4px solid var(--text-secondary); border-radius: 50%; }
.hangman-body-part { top: 120px; left: 136px; width: 4px; height: 50px; background: var(--text-secondary); }
.hangman-left-arm { top: 130px; left: 100px; width: 40px; height: 4px; background: var(--text-secondary); transform: rotate(30deg); transform-origin: right; }
.hangman-right-arm { top: 130px; left: 138px; width: 40px; height: 4px; background: var(--text-secondary); transform: rotate(-30deg); transform-origin: left; }
.hangman-left-leg { top: 166px; left: 108px; width: 35px; height: 4px; background: var(--text-secondary); transform: rotate(30deg); transform-origin: right; }
.hangman-right-leg { top: 166px; left: 138px; width: 35px; height: 4px; background: var(--text-secondary); transform: rotate(-30deg); transform-origin: left; }
.hangman-word { font-size: 2em; letter-spacing: 8px; font-weight: bold; color: var(--primary-text); margin: 20px 0; font-family: 'Courier New', monospace; }
.hangman-letters { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 400px; margin: 0 auto 20px; }
.hangman-letter-btn { width: 40px; height: 40px; border: 2px solid var(--primary); border-radius: 8px; background: var(--bg-card); font-size: 1em; font-weight: 600; cursor: pointer; transition: all 0.2s; color: var(--primary-text); }
.hangman-letter-btn:hover:not(:disabled) { background: var(--primary); color: white; }
.hangman-letter-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.hangman-letter-btn.correct-letter { background: rgba(34, 197, 94, 0.15); border-color: var(--success); color: #86efac; }
.hangman-letter-btn.wrong-letter { background: rgba(239, 68, 68, 0.15); border-color: var(--danger); color: #fca5a5; }
.hangman-stats { display: flex; justify-content: center; gap: 20px; margin-bottom: 15px; }
.hangman-stat { background: var(--bg-card); padding: 8px 16px; border-radius: 8px; font-weight: 600; color: var(--text-primary); }
.hangman-kyler { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; border: 1px solid var(--border-card); user-select: none; }
.hangman-kyler input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.hangman-kyler:has(input:checked) { border-color: var(--accent); color: var(--accent-text); }
.hangman-clue.hangman-clue-hidden { color: var(--text-muted); font-style: italic; border-style: dashed; }

/* FLIP MATCH */
.flip-match-container { max-width: 800px; margin: 0 auto; }
.flip-match-controls { display: flex; justify-content: center; gap: 15px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.flip-match-stats { display: flex; justify-content: center; gap: 20px; margin-bottom: 20px; }
.flip-match-stat { background: var(--bg-card); padding: 10px 20px; border-radius: 10px; font-weight: 600; border: 1px solid var(--border-card); color: var(--text-primary); }
.match-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.match-grid.easy { grid-template-columns: repeat(4, 1fr); }
.match-grid.medium { grid-template-columns: repeat(4, 1fr); }
.match-grid.hard { grid-template-columns: repeat(6, 1fr); }
.match-card { perspective: 1000px; height: 120px; cursor: pointer; }
.match-card-inner { position: relative; width: 100%; height: 100%; transition: transform 0.5s; transform-style: preserve-3d; }
.match-card.flipped .match-card-inner { transform: rotateY(180deg); }
.match-card-front, .match-card-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 8px; text-align: center; font-size: 0.85em; }
.match-card-front { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; font-size: 1.5em; }
.match-card-back { background: var(--bg-card); transform: rotateY(180deg); border: 2px solid var(--border-card); color: var(--text-primary); font-weight: 600; line-height: 1.3; overflow: hidden; }
.match-card.matched .match-card-back { border-color: #22c55e; box-shadow: 0 0 15px rgba(34, 197, 94, 0.3); }
.match-card.matched { pointer-events: none; }
.flip-match-win { background: rgba(34, 197, 94, 0.15); padding: 20px; border-radius: 12px; text-align: center; margin-top: 20px; border: 1px solid rgba(34, 197, 94, 0.2); }
.flip-match-win h2 { color: #86efac; margin-bottom: 10px; }
@media (max-width: 768px) {
    .match-grid.hard { grid-template-columns: repeat(4, 1fr); }
    .match-card { height: 100px; }
    .match-card-back { font-size: 0.75em; }
}

/* TYPING RACE */
.race-container { max-width: 700px; margin: 0 auto; }
.race-track { background: var(--bg-elevated); padding: 20px; border-radius: 12px; margin-bottom: 20px; border: 1px solid var(--border-card); box-shadow: var(--shadow-card); }
.race-lane { position: relative; height: 50px; background: var(--bg-surface); border-radius: 8px; margin-bottom: 10px; overflow: hidden; border: 2px solid var(--border-subtle); }
.race-lane-label { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 0.8em; font-weight: 600; color: var(--text-muted); z-index: 1; }
.race-car { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 30px; border-radius: 5px; transition: left 0.5s ease; display: flex; align-items: center; justify-content: center; font-size: 1.2em; left: 0; }
.race-car.player { background: var(--primary); }
.race-car.ai-1 { background: #ef4444; }
.race-car.ai-2 { background: #f59e0b; }
.race-car.ai-3 { background: #8b5cf6; }
.race-finish-line { position: absolute; right: 0; top: 0; bottom: 0; width: 3px; background: repeating-linear-gradient(#333 0, #333 5px, white 5px, white 10px); }
.race-definition { background: var(--bg-elevated); padding: 20px; border-radius: 12px; margin-bottom: 15px; border: 1px solid var(--border-card); text-align: center; box-shadow: var(--shadow-card); }
.race-definition-label { color: var(--primary-text); font-weight: 600; margin-bottom: 8px; font-size: 0.9em; }
.race-definition-text { font-size: 1.1em; color: var(--text-primary); line-height: 1.5; }
.race-input-area { text-align: center; margin-bottom: 20px; }
.race-input { padding: 12px 20px; font-size: 1.2em; border: 2px solid var(--primary); border-radius: 8px; text-align: center; width: 300px; background: var(--bg-card); color: var(--text-primary); }
.race-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2); }
.race-progress-text { text-align: center; color: var(--text-secondary); font-weight: 600; margin-bottom: 15px; }
.race-results { background: var(--bg-elevated); padding: 25px; border-radius: 12px; text-align: center; border: 1px solid var(--border-card); box-shadow: var(--shadow-card); }
.race-results h2 { color: var(--text-primary); margin-bottom: 15px; }
.race-placement { font-size: 2em; font-weight: bold; margin-bottom: 10px; }
.race-results-stats { display: flex; justify-content: center; gap: 20px; margin: 15px 0; flex-wrap: wrap; }
.race-start-screen { text-align: center; padding: 40px; }
.race-countdown { font-size: 4em; font-weight: bold; color: var(--primary-text); }

/* FILL IN BLANK */
.fib-container { max-width: 700px; margin: 0 auto; }
.fib-heading { text-align: center; color: var(--text-primary); margin-bottom: 8px; }
.fib-mode-desc { text-align: center; color: var(--text-secondary); margin-bottom: 20px; font-size: 1.1em; }
.fib-mode-row { display: flex; gap: 16px; justify-content: center; margin-bottom: 16px; }
.fib-mode-btn { padding: 16px 32px; border-radius: 12px; border: 2px solid var(--primary); background: var(--bg-elevated); color: var(--primary-text); font-size: 1.1em; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 8px; }
.fib-mode-btn:hover { background: var(--primary); color: white; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(22,105,197,0.3); }
.fib-mode-hint { text-align: center; color: var(--text-muted); font-size: 0.85em; }

/* Progress */
.fib-progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.fib-progress-text { color: var(--text-secondary); font-weight: 600; font-size: 0.9em; white-space: nowrap; }
.fib-progress-bar { flex: 1; height: 8px; background: var(--bg-surface); border-radius: 4px; overflow: hidden; }
.fib-progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }

/* Sentence card (one at a time) */
.fib-sentence-card { background: var(--bg-elevated); padding: 20px; border-radius: 12px; border: 1px solid var(--border-card); line-height: 1.8; font-size: 1.1em; color: var(--text-primary); box-shadow: var(--shadow-card); }
.fib-sentence-card.fib-single { padding: 28px 24px; font-size: 1.15em; min-height: 80px; }

/* Blank slots */
.blank-slot { display: inline-block; min-width: 120px; padding: 4px 12px; border-bottom: 3px solid var(--primary); text-align: center; cursor: pointer; transition: all 0.2s; margin: 0 4px; font-weight: 600; color: var(--primary-text); border-radius: 4px; }
.blank-slot:hover { background: rgba(22, 105, 197, 0.1); }
.blank-slot.filled { background: rgba(22, 105, 197, 0.1); border-bottom-color: var(--primary); }

/* Word bank */
.word-bank { background: var(--bg-elevated); padding: 20px; border-radius: 12px; margin-top: 20px; border: 1px solid var(--border-card); box-shadow: var(--shadow-card); }
.word-bank-title { color: var(--primary-text); font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.word-bank-terms { display: flex; flex-wrap: wrap; gap: 8px; }
.word-bank-term { padding: 8px 16px; border: 2px solid var(--primary); border-radius: 20px; background: var(--bg-surface); cursor: pointer; font-weight: 600; color: var(--primary-text); transition: all 0.2s; font-size: 0.95em; }
.word-bank-term:hover:not(.used):not(.selected) { background: var(--primary); color: white; }
.word-bank-term.selected { background: var(--primary); color: white; transform: scale(1.05); }
.word-bank-term.used { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

/* Type input */
.fib-type-row { margin-top: 20px; }
.fib-type-input { width: 100%; padding: 14px 18px; border-radius: 12px; border: 2px solid var(--border-card); background: var(--bg-surface); color: var(--text-primary); font-size: 1.1em; font-weight: 500; outline: none; transition: border-color 0.2s; box-sizing: border-box; }
.fib-type-input:focus { border-color: var(--primary); }
.fib-type-input::placeholder { color: var(--text-muted); }

/* Navigation */
.fib-nav-row { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 12px; }
.fib-nav-btn { display: flex; align-items: center; gap: 6px; }
.fib-btn-disabled { opacity: 0.4; pointer-events: none; }
.fib-check-btn { background: var(--success); border-color: var(--success); }
.fib-check-btn:hover { filter: brightness(1.1); }

/* Dot indicators */
.fib-dots { display: flex; justify-content: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.fib-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bg-surface); border: 2px solid var(--border-card); cursor: pointer; transition: all 0.2s; }
.fib-dot.active { border-color: var(--primary); transform: scale(1.3); }
.fib-dot.answered { background: var(--primary); border-color: var(--primary); }

/* Results */
.fib-results-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.fib-result-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border-card); }
.fib-result-correct { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.3); }
.fib-result-incorrect { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.3); }
.fib-result-num { font-weight: 700; color: var(--text-secondary); min-width: 24px; padding-top: 2px; }
.fib-result-content { flex: 1; }
.fib-result-sentence { color: var(--text-primary); line-height: 1.6; font-size: 1em; }
.fib-answer-correct { font-weight: 700; color: var(--success); text-decoration: underline; text-decoration-color: var(--success); }
.fib-answer-incorrect { font-weight: 700; color: var(--error); text-decoration: line-through; }
.fib-correct-label { color: var(--success); font-size: 0.85em; font-weight: 600; margin-top: 4px; }
.fib-result-icon { font-size: 1.1em; padding-top: 2px; }
.fib-result-correct .fib-result-icon { color: var(--success); }
.fib-result-incorrect .fib-result-icon { color: var(--error); }
.fib-score-summary { text-align: center; padding: 20px; background: var(--bg-elevated); border-radius: 12px; border: 1px solid var(--border-card); margin-bottom: 16px; }
.fib-score-big { font-size: 2em; font-weight: 800; }
.fib-perfect { color: var(--success); font-weight: 600; margin-top: 4px; }
.fib-feedback-msg { color: var(--text-secondary); font-size: 0.9em; margin-top: 8px; font-style: italic; }
.fib-correct-answer { font-size: 0.8em; color: #22c55e; font-weight: 600; margin-left: 8px; }
.fib-score { background: var(--bg-elevated); padding: 20px; border-radius: 12px; text-align: center; margin-top: 20px; border: 1px solid var(--border-card); color: var(--text-primary); box-shadow: var(--shadow-card); }

/* TERM CATCHER */
.catcher-container { max-width: 600px; margin: 0 auto; }
.catcher-header { display: flex; justify-content: space-between; align-items: center; background: var(--bg-elevated); padding: 15px 20px; border-radius: 12px 12px 0 0; border: 1px solid var(--border-card); border-bottom: none; color: var(--text-primary); }
.catcher-score-display { font-weight: bold; color: var(--primary-text); font-size: 1.2em; }
.catcher-lives { font-size: 1.3em; }
.catcher-combo { font-weight: 600; color: var(--accent-text); }
.catcher-definition { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; padding: 15px 20px; text-align: center; font-weight: 500; font-size: 1.05em; line-height: 1.4; }
.catcher-game-area { position: relative; height: 400px; background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-surface) 100%); border: 1px solid var(--border-card); border-top: none; overflow: hidden; border-radius: 0 0 12px 12px; }
.falling-term { position: absolute; padding: 10px 20px; border-radius: 25px; font-weight: 600; cursor: pointer; transition: background 0.15s, transform 0.15s; white-space: nowrap; font-size: 0.95em; user-select: none; z-index: 2; }
.falling-term:hover { transform: scale(1.1); }
.falling-term { background: var(--bg-surface); color: var(--text-primary); border: 2px solid var(--border-card); }
.falling-term.flash-green { background: #22c55e !important; color: white !important; }
.falling-term.flash-red { background: #ef4444 !important; color: white !important; }
.catcher-start-screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(15, 23, 42, 0.95); z-index: 10; color: var(--text-primary); }
.catcher-start-btn { padding: 15px 40px; font-size: 1.3em; }
.catcher-game-over { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(15, 23, 42, 0.95); z-index: 10; color: var(--text-primary); }
.catcher-final-score { font-size: 3em; font-weight: bold; color: var(--primary-text); }

/* LIGHTNING ROUND */
.lightning-container { max-width: 600px; margin: 0 auto; text-align: center; }
.lightning-timer-bar { width: 100%; height: 8px; background: var(--bg-surface); border-radius: 4px; margin-bottom: 20px; overflow: hidden; }
.lightning-timer-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 1s linear; border-radius: 4px; }
.lightning-timer-fill.warning { background: linear-gradient(90deg, #ef4444, #f59e0b); }
.lightning-score-bar { display: flex; justify-content: center; gap: 30px; margin-bottom: 20px; }
.lightning-score-item { font-weight: 600; font-size: 1.2em; }
.lightning-score-item .label { color: var(--text-muted); font-size: 0.8em; display: block; }
.lightning-definition { background: var(--bg-elevated); padding: 25px; border-radius: 12px; margin-bottom: 20px; border: 1px solid var(--border-card); min-height: 100px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-card); }
.lightning-definition-text { font-size: 1.15em; line-height: 1.5; color: var(--text-primary); }
.lightning-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.lightning-option { padding: 15px; border: 2px solid var(--border-card); border-radius: 10px; background: var(--bg-surface); color: var(--text-primary); cursor: pointer; font-weight: 600; font-size: 1em; transition: all 0.2s; box-shadow: var(--shadow-button); }
.lightning-option:hover { border-color: var(--primary); background: rgba(79, 143, 247, 0.12); transform: translateY(-1px); }
.lightning-option.correct-flash { background: rgba(34, 197, 94, 0.15); border-color: var(--success); color: #86efac; }
.lightning-option.wrong-flash { background: rgba(239, 68, 68, 0.15); border-color: var(--danger); color: #fca5a5; }
.lightning-countdown { font-size: 5em; font-weight: bold; color: var(--primary-text); animation: pulse 0.5s ease-in-out; }
@keyframes pulse { 0% { transform: scale(0.5); opacity: 0; } 50% { transform: scale(1.2); } 100% { transform: scale(1); opacity: 1; } }
.lightning-results { background: var(--bg-elevated); padding: 30px; border-radius: 12px; border: 1px solid var(--border-card); color: var(--text-primary); box-shadow: var(--shadow-card); }
.lightning-final-score { font-size: 3em; font-weight: bold; color: var(--primary-text); margin: 15px 0; }
.lightning-missed { text-align: left; margin-top: 20px; }
.lightning-missed-item { padding: 10px; border-bottom: 1px solid var(--border-subtle); display: flex; justify-content: space-between; }
.lightning-leaderboard { margin-top: 20px; }
.lightning-leaderboard-table { width: 100%; border-collapse: collapse; }
.lightning-leaderboard-table td, .lightning-leaderboard-table th { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); }
.lightning-leaderboard-table th { color: var(--primary-text); font-weight: 600; }

/* CROSSWORD */
.crossword-container { display: flex; gap: 20px; align-items: flex-start; }
.crossword-grid-wrapper { flex-shrink: 0; }
.crossword-grid { border-collapse: collapse; }
.crossword-cell { width: 36px; height: 36px; position: relative; }
.crossword-cell input { width: 100%; height: 100%; border: 1px solid var(--border-card); text-align: center; font-size: 1.1em; font-weight: bold; text-transform: uppercase; padding: 0; background: var(--bg-surface); color: var(--text-primary); }
.crossword-cell input:focus { outline: none; background: rgba(37, 99, 235, 0.2); }
.crossword-cell.black { background: var(--bg-deep); }
.crossword-cell.black input { display: none; }
.crossword-cell .cell-number { position: absolute; top: 1px; left: 2px; font-size: 0.6em; color: var(--text-muted); z-index: 1; pointer-events: none; }
.crossword-cell.highlighted input { background: rgba(245, 158, 11, 0.15); }
.crossword-cell.active input { background: rgba(37, 99, 235, 0.25); }
.crossword-cell input.correct { background: rgba(34, 197, 94, 0.15); }
.crossword-cell input.incorrect { background: rgba(239, 68, 68, 0.15); }
.crossword-clues { flex: 1; max-height: 500px; overflow-y: auto; }
.crossword-clues h3 { color: var(--primary-text); margin: 15px 0 10px; }
.crossword-clue { padding: 8px 12px; cursor: pointer; border-radius: 6px; transition: background 0.2s; font-size: 0.9em; line-height: 1.4; color: var(--text-primary); }
.crossword-clue:hover { background: rgba(37, 99, 235, 0.1); }
.crossword-clue.active { background: rgba(37, 99, 235, 0.2); }
.crossword-clue-number { font-weight: bold; color: var(--primary-text); margin-right: 5px; }
.crossword-controls { display: flex; gap: 10px; margin-top: 15px; flex-wrap: wrap; }
@media (max-width: 768px) {
    .crossword-container { flex-direction: column; }
    .crossword-cell { width: 30px; height: 30px; }
    .crossword-cell input { font-size: 0.9em; }
}

/* TOAST NOTIFICATIONS */
/* Toasts drop in from the top, under the nav bar: at the bottom edge they
   covered game controls (Wordle's keyboard, the Save Progress button) on
   short Chromebook viewports. */
.toast {
    position: fixed;
    top: 92px;
    left: 50%;
    transform: translateX(-50%) translateY(-40px);
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    max-width: 90%;
    text-align: center;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.toast-success { background: #22c55e; }
.toast-error { background: #ef4444; }
.toast-info { background: #3b82f6; }

/* ACCESSIBILITY */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* SOURCE ANALYSIS */
.source-analysis-container { max-width: 700px; margin: 0 auto; }
.source-intro { background: var(--bg-elevated); padding: 30px; border-radius: 12px; text-align: center; border: 1px solid var(--border-card); color: var(--text-primary); box-shadow: var(--shadow-card); }
.source-sift-card { background: rgba(37, 99, 235, 0.1); border: 2px solid var(--primary); border-radius: 12px; padding: 20px; margin-top: 20px; text-align: left; color: var(--text-primary); }
.source-sift-step { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.source-sift-step:last-child { margin-bottom: 0; }
.source-sift-letter { background: var(--primary); color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-size: 0.95em; }
.source-progress { width: 100%; height: 8px; background: var(--bg-surface); border-radius: 4px; margin-bottom: 8px; overflow: hidden; }
.source-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 4px; transition: width 0.3s; }
.source-progress-text { text-align: center; color: var(--text-secondary); font-size: 0.9em; margin-bottom: 16px; }
.source-card { background: var(--bg-elevated); border-radius: 12px; border: 1px solid var(--border-card); padding: 28px; margin-bottom: 16px; position: relative; box-shadow: var(--shadow-card); }
.source-format-badge { display: inline-block; background: var(--primary); color: white; padding: 4px 14px; border-radius: 20px; font-size: 0.8em; font-weight: 600; margin-bottom: 12px; }
.source-title { font-size: 1.4em; color: var(--text-primary); margin-bottom: 10px; }
.source-meta { display: flex; gap: 20px; color: var(--text-secondary); font-size: 1.05em; font-weight: 600; margin-bottom: 16px; flex-wrap: wrap; }
.source-meta i { margin-right: 4px; color: var(--primary-text); }
.source-image-wrap { text-align: center; margin-bottom: 16px; position: relative; cursor: pointer; }
.source-image { max-width: 100%; max-height: 400px; border-radius: 8px; border: 1px solid #e2e8f0; object-fit: contain; transition: opacity 0.2s; }
.source-image:hover { opacity: 0.85; }
.source-image-zoom-hint { font-size: 0.8em; color: var(--text-muted); margin-top: 6px; opacity: 0.7; }
.source-image-zoom-hint i { margin-right: 4px; }
.source-lightbox { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.92); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity 0.2s; }
.source-lightbox.active { opacity: 1; }
.source-lightbox-close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: white; font-size: 2em; cursor: pointer; z-index: 10000; line-height: 1; padding: 8px; }
.source-lightbox-close:hover { color: #f59e0b; }
.source-lightbox-img { max-width: 95vw; max-height: 80vh; object-fit: contain; border-radius: 8px; }
.source-lightbox-caption { color: rgba(255,255,255,0.8); font-size: 0.95em; margin-top: 12px; text-align: center; }
.source-excerpt { background: rgba(245, 158, 11, 0.08); border-left: 4px solid var(--accent); padding: 16px 20px; border-radius: 0 8px 8px 0; margin-bottom: 16px; line-height: 1.6; color: var(--text-primary); }
.source-cartoon-desc { font-weight: 600; color: var(--primary-text); margin-bottom: 8px; }
.source-context { background: var(--bg-surface); border-radius: 8px; padding: 14px 18px; color: var(--text-secondary); font-size: 0.95em; line-height: 1.5; }
.source-classify-prompt { background: var(--bg-elevated); border-radius: 12px; border: 1px solid var(--border-card); padding: 24px; text-align: center; margin-bottom: 16px; box-shadow: var(--shadow-card); }
.source-classify-prompt h3 { color: var(--text-primary); margin-bottom: 16px; font-size: 1.15em; }
.source-classify-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.source-classify-btn { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border: 2px solid var(--border-card); border-radius: 10px; background: var(--bg-surface); cursor: pointer; font-size: 1em; transition: all 0.2s; text-align: left; color: var(--text-primary); }
.source-classify-btn i { font-size: 1.5em; color: var(--primary-text); flex-shrink: 0; }
.source-classify-btn:hover { border-color: var(--primary); background: rgba(37, 99, 235, 0.1); }
.source-classify-btn.correct { border-color: var(--success); background: rgba(34, 197, 94, 0.15); }
.source-classify-btn.correct i { color: var(--success); }
.source-classify-btn.wrong { border-color: var(--danger); background: rgba(239, 68, 68, 0.15); }
.source-classify-btn.wrong i { color: var(--danger); }
.source-feedback-msg { padding: 16px 20px; border-radius: 10px; font-weight: 500; line-height: 1.5; }
.source-feedback-msg.correct { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.source-feedback-msg.wrong { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.source-feedback-msg.small { padding: 10px 16px; font-size: 0.95em; }
.source-feedback-msg i { margin-right: 6px; }
.source-question-card { background: var(--bg-elevated); border-radius: 12px; border: 1px solid var(--border-card); padding: 24px; box-shadow: var(--shadow-card); }
.source-question-num { color: var(--primary-text); font-weight: 600; font-size: 0.85em; margin-bottom: 8px; }
.source-question-text { font-size: 1.1em; color: var(--text-primary); margin-bottom: 16px; line-height: 1.5; }
.source-question-options { display: flex; flex-direction: column; gap: 8px; }
.source-question-option { padding: 12px 16px; border: 2px solid var(--border-card); border-radius: 8px; background: var(--bg-surface); cursor: pointer; font-size: 0.95em; text-align: left; transition: all 0.2s; color: var(--text-primary); }
.source-question-option:hover { border-color: var(--primary); background: rgba(37, 99, 235, 0.1); }
.source-question-option.correct { border-color: var(--success); background: rgba(34, 197, 94, 0.15); color: #86efac; }
.source-question-option.wrong { border-color: var(--danger); background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.source-results { background: var(--bg-elevated); padding: 30px; border-radius: 12px; border: 1px solid var(--border-card); text-align: center; color: var(--text-primary); box-shadow: var(--shadow-card); }
.source-final-score { font-size: 3em; font-weight: bold; color: var(--primary-text); margin: 15px 0; }
.source-perf-msg { font-weight: 600; margin-bottom: 20px; font-size: 1.05em; }
.source-breakdown { text-align: left; margin-top: 20px; border-top: 1px solid var(--border-subtle); padding-top: 16px; }
.source-breakdown-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); font-size: 0.95em; }
.source-breakdown-questions { margin-left: auto; color: var(--text-muted); font-size: 0.85em; }

@media (max-width: 600px) {
    .source-classify-buttons { grid-template-columns: 1fr; }
    .source-card { padding: 20px; }
    .source-title { font-size: 1.2em; }
}

/* RESOURCE LIBRARY */
.res-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
}

.res-search-wrap {
    position: relative;
    margin-bottom: 20px;
}

.res-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95em;
    pointer-events: none;
}

.res-search-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    border: 2px solid var(--border-card);
    border-radius: 50px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 1em;
    font-family: var(--font-body);
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.res-search-input::placeholder {
    color: var(--text-muted);
}

.res-search-input:focus {
    border-color: var(--accent);
    background: var(--bg-card);
}

.res-sections {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.res-section {
    background: var(--bg-elevated);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-card);
}

.res-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-left: 4px solid var(--accent);
    background: var(--bg-surface);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.res-category-header:hover {
    background: var(--bg-card);
}

.res-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.res-chevron {
    font-size: 0.8em;
    color: var(--text-muted);
    transition: transform 0.25s;
}

.res-collapsed .res-chevron {
    transform: rotate(-90deg);
}

.res-header-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05em;
    color: var(--text-primary);
}

.res-count-badge {
    font-size: 0.8em;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    padding: 3px 10px;
    border-radius: 20px;
    font-family: var(--font-body);
}

.res-terms-list {
    transition: max-height 0.3s ease;
}

.res-collapsed .res-terms-list {
    display: none;
}

.res-term-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    border-top: 1px solid var(--border-subtle);
}
.res-term-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
}

.res-term-info {
    flex: 1;
    min-width: 0;
}

.res-term-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.res-term-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1em;
    color: var(--text-primary);
}
.res-mastery-badge {
    font-size: 0.7em;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}
.res-mastery-mastered {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}
.res-mastery-study {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.res-mastery-learning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.res-term-def {
    font-size: 0.9em;
    color: var(--text-secondary);
    line-height: 1.45;
}

.res-links {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: flex-start;
}

.res-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78em;
    font-family: var(--font-body);
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.2s, transform 0.15s;
    white-space: nowrap;
}

.res-link-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.res-link-kiddle {
    background: #2e7d32;
    color: #fff;
}

.res-link-wiki {
    background: #546e7a;
    color: #fff;
}

.res-link-youtube {
    background: #c62828;
    color: #fff;
}

@media (max-width: 600px) {
    .res-term-card {
        flex-direction: column;
        gap: 10px;
    }

    .res-links {
        width: 100%;
    }

    .res-link-btn {
        flex: 1;
        justify-content: center;
        padding: 7px 10px;
    }

    .res-search-input {
        padding: 12px 14px 12px 40px;
        font-size: 0.95em;
    }

    .res-category-header {
        padding: 12px 14px;
    }

    .res-term-card {
        padding: 12px 14px;
    }
}

/* ACHIEVEMENTS */
.ach-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

@media (max-width: 600px) {
    .ach-grid {
        gap: 6px;
    }
}

.ach-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 4px 2px;
    box-shadow: var(--shadow-card);
}

.ach-badge:hover {
    transform: translateY(-2px);
    border-color: var(--border-card);
}

.ach-badge.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.ach-badge.unlocked {
    border: 2px solid #f59e0b;
    opacity: 1;
}

.ach-badge .ach-icon {
    font-size: 1.2em;
    margin-bottom: 2px;
    color: var(--primary-text);
}

.ach-badge.locked .ach-icon {
    color: #6b7280;
}

.ach-badge .ach-name {
    font-size: 0.8em;
    text-align: center;
    line-height: 1.1;
    color: var(--text-primary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ach-badge.secret {
    border: 2px solid #a855f7;
    background: rgba(168, 85, 247, 0.15);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.2);
}

.ach-badge.secret .ach-icon {
    color: #a855f7;
}

.confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -10px;
    width: 10px;
    height: 10px;
    animation: confetti-fall 1.5s ease-in forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* APP FOOTER */
.app-footer {
    text-align: center;
    padding: 10px 16px;
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.85em;
}

.footer-fun-fact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    font-size: 0.9em;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 6px;
    padding: 8px 12px;
    background: rgba(251, 191, 36, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.footer-fun-fact i {
    color: var(--accent-text);
    margin-top: 2px;
    flex-shrink: 0;
}

.footer-edit-profile {
    display: inline-block;
    margin-left: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9em;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
}
.footer-edit-profile:hover {
    color: var(--primary-text);
    background: rgba(96, 165, 250, 0.1);
}
.footer-edit-profile i { margin-right: 4px; }

.footer-privacy {
    display: inline-block;
    margin-left: 12px;
    color: var(--text-muted);
    font-size: 0.9em;
    text-decoration: none;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
}
.footer-privacy:hover {
    color: var(--primary-text);
    background: rgba(96, 165, 250, 0.1);
}
.footer-privacy i { margin-right: 4px; }

/* LEADERBOARD */
.lb-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-surface);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.lb-tab {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.lb-tab:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.lb-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.lb-tab i {
    margin-right: 4px;
}

.lb-content {
    min-height: 200px;
}

.lb-explainer {
    text-align: center;
    font-size: 0.8em;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 500;
}

/* Podium — top 3 visual */
.lb-podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 16px 0;
}

.lb-podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: var(--radius-md);
    padding: 16px 12px 12px;
    border: 2px solid var(--border-card);
    background: var(--bg-elevated);
    transition: transform 0.2s;
    width: 120px;
}

.lb-podium-place:hover {
    transform: translateY(-4px);
}

.lb-place-1 {
    border-color: #f59e0b;
    background: linear-gradient(180deg, rgba(245,158,11,0.12) 0%, var(--bg-elevated) 100%);
    padding-bottom: 20px;
    min-height: 160px;
    order: 2;
}

.lb-place-2 {
    border-color: #9ca3af;
    background: linear-gradient(180deg, rgba(156,163,175,0.1) 0%, var(--bg-elevated) 100%);
    min-height: 130px;
    order: 1;
}

.lb-place-3 {
    border-color: #d97706;
    background: linear-gradient(180deg, rgba(217,119,6,0.08) 0%, var(--bg-elevated) 100%);
    min-height: 110px;
    order: 3;
}

.lb-medal {
    font-size: 2em;
    margin-bottom: 8px;
}

.lb-podium-name {
    font-weight: 700;
    font-size: 0.9em;
    color: var(--text-primary);
    text-align: center;
    word-break: break-word;
    margin-bottom: 4px;
}

.lb-podium-score {
    font-size: 0.8em;
    font-weight: 800;
    color: var(--primary-text);
}

/* Ranking list */
.lb-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s;
}

.lb-row:hover {
    border-color: var(--primary);
}

.lb-row-me {
    border-color: var(--accent);
    background: linear-gradient(90deg, rgba(245,158,11,0.08) 0%, var(--bg-elevated) 30%);
}

.lb-rank {
    flex-shrink: 0;
    width: 36px;
    font-weight: 800;
    font-size: 0.9em;
    color: var(--text-muted);
    text-align: center;
}

.lb-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.95em;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-you-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-size: 0.8em;
    font-weight: 700;
    vertical-align: middle;
}

.lb-stats {
    display: flex;
    gap: 12px;
    font-size: 0.78em;
    color: var(--text-muted);
}

.lb-score {
    flex-shrink: 0;
    font-weight: 800;
    font-size: 0.95em;
    color: var(--primary-text);
    min-width: 60px;
    text-align: right;
}

.lb-class-row {
    border-left: 3px solid var(--primary);
}

/* Class battle bar chart */
.lb-class-bar-wrap {
    margin-bottom: 20px;
}

.lb-class-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.lb-class-bar-label {
    flex-shrink: 0;
    width: 100px;
    font-weight: 600;
    font-size: 0.85em;
    color: var(--text-primary);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-class-bar-track {
    flex: 1;
    height: 28px;
    background: var(--bg-surface);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-subtle);
}

.lb-class-bar-fill {
    height: 100%;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    font-size: 0.75em;
    font-weight: 700;
    color: white;
    min-width: 40px;
    transition: width 0.6s ease;
}

.lb-class-bar-fill.bar-1 { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.lb-class-bar-fill.bar-2 { background: linear-gradient(90deg, var(--primary-bold), var(--primary)); }
.lb-class-bar-fill.bar-3 { background: linear-gradient(90deg, #10b981, #34d399); }
.lb-class-bar-fill.bar-4 { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.lb-class-bar-fill.bar-5 { background: linear-gradient(90deg, #ef4444, #f87171); }
.lb-class-bar-fill.bar-6 { background: linear-gradient(90deg, #ec4899, #f472b6); }

@media (max-width: 600px) {
    .lb-podium-place { width: 90px; padding: 12px 8px 8px; }
    .lb-medal { font-size: 1.5em; }
    .lb-podium-name { font-size: 0.8em; }
    .lb-stats { display: none; }
    .lb-class-bar-label { width: 70px; font-size: 0.75em; }
}

/* DYSLEXIC FONT TOGGLE */
/* ===================== Settings FAB & Panel ===================== */
.settings-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-elevated);
    border: 2px solid var(--border-card);
    color: var(--text-secondary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1em;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    z-index: 1100;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.settings-fab:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: scale(1.08);
}
body.light-mode .settings-fab {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.settings-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1099;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.settings-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.settings-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 320px;
    max-width: 100vw;
    background: var(--bg-card);
    border-top-left-radius: 16px;
    border-top-right-radius: 0;
    box-shadow: -4px -4px 24px rgba(0, 0, 0, 0.3);
    z-index: 1101;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.settings-panel.open {
    transform: translateY(0);
}
body.light-mode .settings-panel {
    box-shadow: -4px -4px 24px rgba(0, 0, 0, 0.1);
}

.settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.settings-panel-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1em;
    color: var(--text-primary);
}
.settings-panel-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1em;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.settings-panel-close:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.settings-panel-body {
    padding: 8px 0 16px;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 20px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95em;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}
.settings-row:hover {
    background: var(--bg-surface);
}
.settings-row-icon {
    width: 28px;
    text-align: center;
    font-size: 1.05em;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.settings-row-label {
    flex: 1;
    font-weight: 500;
}
.settings-row-toggle {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--border-card);
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.settings-row-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.settings-row-toggle.on {
    background: var(--primary);
}
.settings-row-toggle.on::after {
    transform: translateX(18px);
}
.settings-row-shortcut {
    flex-shrink: 0;
}
.settings-row-shortcut kbd {
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.8em;
    font-family: var(--font-body);
    color: var(--text-muted);
}

/* Mobile: full-width panel */
@media (max-width: 480px) {
    .settings-fab {
        width: 44px;
        height: 44px;
        font-size: 1em;
        right: 12px;
        bottom: 12px;
    }
    .settings-panel {
        width: 100vw;
        border-top-right-radius: 16px;
    }
}

/* --- Mastery Gating --- */

.activity-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
    filter: grayscale(30%);
}

.activity-card.locked:hover {
    transform: none;
    box-shadow: none;
}

.activity-card.locked .card-button {
    background: #999;
    cursor: not-allowed;
}

.unlock-count {
    font-size: 0.8rem;
    color: var(--primary-text);
    font-weight: 600;
    margin-top: 4px;
    padding: 4px 10px;
    background: rgba(22, 105, 197, 0.08);
    border-radius: 12px;
    display: inline-block;
}

.mastery-progress-bar {
    text-align: center;
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}

.mastery-progress-bar .progress-bar {
    margin-top: 6px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Typing Practice (monkeytype-inspired) --- */

.typing-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 16px;
}

.typing-title {
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 6px;
    font-size: 1.2rem;
    font-family: var(--font-mono);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.typing-description {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 20px;
    font-size: 0.82rem;
    font-family: var(--font-mono);
}

/* Passage selector tabs — monkeytype style */
.typing-pill-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 24px;
}

.typing-pill {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    letter-spacing: 0.01em;
}

.typing-pill:hover {
    color: var(--text-primary);
    border-bottom-color: var(--border-hover);
}

.typing-pill.active {
    color: var(--primary-text);
    border-bottom-color: var(--primary);
}

.typing-pill.completed {
    color: var(--text-muted);
}

.typing-pill.completed.active {
    color: var(--primary-text);
}

.typing-pill-check {
    color: var(--success);
    font-weight: 700;
    font-size: 0.9em;
}

/* Dark typing box */
.typing-dark-box {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 28px 32px;
    position: relative;
    cursor: text;
    box-shadow: var(--shadow-elevated);
    margin-bottom: 12px;
    border: 1px solid var(--border-card);
}

/* Stats bar */
.typing-stats {
    display: flex;
    justify-content: flex-start;
    gap: 20px;
    margin-bottom: 16px;
    font-family: var(--font-mono);
}

.typing-stat {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.typing-stat-value {
    font-weight: 600;
    color: var(--primary-text);
    font-size: 1.6rem;
}

.typing-stat-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Passage display — constrained to ~3 lines */
.typing-passage-display {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    line-height: 2.2;
    max-height: calc(1.5rem * 2.2 * 3);
    overflow: hidden;
    position: relative;
    scroll-behavior: smooth;
}

/* Words */
.typing-word {
    display: inline;
    color: var(--text-muted);
    transition: color 0.15s;
    border-radius: 3px;
}

.typing-word.current {
    color: var(--text-primary);
}

.typing-word.current.typing-active {
    color: var(--text-primary);
}

.typing-word.current.typing-error {
    color: var(--danger);
}

/* Character-level cursor */
.typing-char {
    position: relative;
}

.typing-char.cursor::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.05em;
    width: 3px;
    height: 1.3em;
    background: var(--accent);
    animation: typing-blink 1s step-end infinite;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
}

.typing-char.typed-correct {
    color: var(--text-primary);
}

.typing-char.typed-incorrect {
    color: var(--danger);
    text-decoration: underline;
    text-decoration-color: var(--danger);
}

.typing-char.typed-extra {
    color: var(--danger);
    opacity: 0.7;
}

@keyframes typing-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.typing-word.correct {
    color: var(--text-secondary);
}

.typing-word.incorrect {
    color: var(--danger);
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

/* Vocab terms — accent highlight */
.typing-word.vocab-term {
    color: var(--accent-text);
    font-weight: 700;
}

.typing-word.vocab-term.current {
    color: var(--accent-text);
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.3);
}

.typing-word.vocab-term.correct {
    color: var(--text-secondary);
    font-weight: 700;
}

.typing-word.vocab-term.incorrect {
    color: var(--danger);
    font-weight: 700;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

/* Hidden input */
.typing-hidden-input {
    /* Visually hidden but not zero-sized: some phone browsers will not raise
       the keyboard for a 0x0 input. */
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    top: 0;
    left: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    pointer-events: none;
}

/* Textbook highlighter */
/* The site's default theme is dark; body.light-mode is the light theme. */
mark.tb-hl { background: rgba(250, 204, 21, 0.32); color: inherit; border-radius: 2px; padding: 0 1px; cursor: pointer; -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background 0.2s; }
mark.tb-hl:hover { background: rgba(250, 204, 21, 0.5); }
mark.tb-hl.tb-hl-flash { background: rgba(250, 204, 21, 0.75); outline: 2px solid var(--accent, #f59e0b); }
body.light-mode mark.tb-hl { background: rgba(250, 204, 21, 0.5); }
body.light-mode mark.tb-hl:hover { background: rgba(250, 204, 21, 0.75); }
.tb-hl-btn { position: fixed; z-index: 1200; display: inline-flex; align-items: center; gap: 6px; background: var(--primary); color: #fff; border: none; border-radius: 999px; padding: 9px 16px; font-family: inherit; font-size: 0.9em; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,0.28); cursor: pointer; touch-action: manipulation; }
.tb-hl-btn:active { transform: scale(0.97); }
.tb-hl-panel { margin-top: 14px; border-top: 1px solid var(--border-card); padding-top: 10px; }
.tb-sidebar.collapsed .tb-hl-panel { display: none; }
.tb-hl-panel-title { display: flex; align-items: center; gap: 6px; font-size: 0.75em; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; padding-left: 10px; }
.tb-hl-hint { font-size: 0.75em; color: var(--text-secondary); opacity: 0.85; line-height: 1.4; padding: 0 10px; }
.tb-hl-item { display: block; width: 100%; background: none; border: none; border-left: 3px solid rgba(250, 204, 21, 0.85); text-align: left; color: var(--text-secondary); font-size: 0.78em; padding: 6px 8px; margin-bottom: 2px; cursor: pointer; font-family: inherit; line-height: 1.35; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; transition: all 0.15s; }
.tb-hl-item:hover { background: var(--bg-surface); color: var(--text-primary); }
.tb-hl-item-sec { display: block; font-size: 0.9em; opacity: 0.7; margin-top: 2px; }

/* Go Deeper: curated links per category (Resource Library + end of chapter) */
.gd-box { background: var(--bg-card, #f9fafb); border: 1px solid var(--border-color, rgba(0,0,0,0.08)); border-left: 4px solid var(--accent, #f59e0b); border-radius: 12px; padding: 14px 16px; margin: 0 0 14px; text-align: left; }
.gd-textbook { margin: 22px 0 10px; }
.gd-head { font-weight: 700; color: var(--primary-text); font-size: 1em; margin-bottom: 2px; }
.gd-head i { color: var(--accent-text, #b45309); margin-right: 2px; }
.gd-intro { color: var(--text-secondary, #6b7280); font-size: 0.85em; margin: 0 0 10px; }
.gd-links { display: flex; flex-wrap: wrap; gap: 8px; }
.gd-chip { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: #fff; font-size: 0.9em; line-height: 1.25; max-width: 100%; transition: transform 0.15s, box-shadow 0.15s; }
.gd-chip:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,0.18); color: #fff; }
.gd-chip > i:first-child { font-size: 1.2em; flex-shrink: 0; }
.gd-chip-text { display: flex; flex-direction: column; min-width: 0; }
.gd-chip-title { font-weight: 600; }
.gd-chip-meta { font-size: 0.8em; opacity: 0.9; }
.gd-chip-ext { font-size: 0.75em; opacity: 0.8; flex-shrink: 0; }
.gd-chip-video { background: #c62828; }
.gd-chip-reading { background: #1d4ed8; }
.gd-chip-reference { background: #546e7a; }
@media (max-width: 600px) {
    .gd-links { flex-direction: column; }
    .gd-chip { width: 100%; box-sizing: border-box; }
}

/* Who Am I? */
.wai-mode-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.wai-mode-note { color: var(--text-secondary, #6b7280); font-size: 0.85em; max-width: 420px; margin: 0 auto; line-height: 1.4; }
.wai-answer-form { margin-bottom: 16px; }
.wai-answer-row { display: flex; gap: 8px; }
.wai-answer-input { flex: 1; min-width: 0; padding: 12px 14px; font-size: 1.05em; border: 2px solid var(--primary); border-radius: 10px; background: var(--bg-card, white); color: var(--text-primary, #1f2937); }
.wai-answer-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2); }
.wai-wrong-note { color: #b45309; font-size: 0.9em; margin-bottom: 8px; text-align: left; }

/* Focus hint overlay */
.typing-focus-hint {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--text-muted);
    background: var(--bg-card);
    opacity: 0.92;
    border-radius: 16px;
    z-index: 2;
    cursor: text;
}

.typing-dark-box:not(.focused) .typing-focus-hint {
    display: flex;
}

/* Source citation */
.typing-citation {
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-align: center;
    font-style: italic;
    line-height: 1.5;
    padding: 0 8px;
}

/* Term snippet section */
.typing-snippet-section {
    width: 100%;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}
.typing-snippet-title {
    color: var(--text-primary);
    font-size: 1em;
    margin: 0 0 4px 0;
    font-weight: 600;
}
.typing-snippet-desc {
    color: var(--text-muted);
    font-size: 0.8em;
    margin: 0 0 10px 0;
}
.typing-snippet-pills {
    gap: 6px;
}
.typing-term-pill {
    font-size: 0.8em;
    padding: 5px 12px;
}
.typing-term-pill.weak-term {
    border-color: var(--warning);
    color: var(--accent-text);
}
.typing-term-pill.weak-term:hover {
    background: rgba(245, 158, 11, 0.15);
}
.typing-term-header {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 10px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    line-height: 1.5;
}
.typing-term-header strong {
    color: var(--accent-text);
}

/* Completion screen */
.typing-complete {
    text-align: center;
    padding: 30px 20px;
}

.typing-complete-title {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 28px;
    font-family: var(--font-mono);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.typing-complete-stats {
    display: flex;
    justify-content: center;
    gap: 56px;
    margin-bottom: 32px;
}

.typing-complete-stat {
    text-align: center;
}

.typing-complete-stat-value {
    font-size: 3rem;
    font-weight: 600;
    color: var(--primary-text);
    font-family: var(--font-mono);
}

.typing-complete-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 6px;
    letter-spacing: 0.03em;
}

.typing-retry-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 0;
    padding: 8px 0;
    font-size: 0.85rem;
    font-weight: 400;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: color 0.15s;
    border-bottom: 1px solid transparent;
}

.typing-retry-btn:hover {
    color: var(--primary-text);
    border-bottom-color: var(--primary);
}

/* Responsive */
@media (max-width: 600px) {
    .typing-dark-box {
        padding: 20px 16px;
    }

    .typing-passage-display {
        font-size: 1.15rem;
        line-height: 2;
        max-height: calc(1.15rem * 2 * 3);
    }

    .typing-pill {
        padding: 6px 14px;
        font-size: 0.82rem;
    }
}

/* Welcome Screen */
.welcome-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease;
}

.welcome-card {
    background: #fefcf8;
    border-radius: 20px;
    padding: 44px 40px 36px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255,255,255,0.1);
    text-align: center;
    animation: welcomeCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes welcomeCardIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.welcome-card h1 {
    font-family: var(--font-heading);
    color: var(--primary-text);
    font-size: 1.9em;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.welcome-card .welcome-subtitle {
    color: #6b7280;
    margin-bottom: 30px;
    font-size: 0.95em;
    line-height: 1.5;
}

.welcome-card label {
    display: block;
    text-align: left;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.welcome-name-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 1.05em;
    font-family: var(--font-body);
    margin-bottom: 24px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.welcome-name-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 105, 197, 0.15);
}

.welcome-period-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.welcome-period-btn {
    padding: 10px 22px;
    border: 2px solid #d1d5db;
    border-radius: 25px;
    background: white;
    font-size: 0.95em;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s;
    color: #374151;
}

.welcome-period-btn:hover {
    border-color: var(--primary);
    color: var(--primary-text);
    background: #f0f7ff;
}

.welcome-period-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.welcome-period-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(22, 105, 197, 0.3);
}

.welcome-go-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.welcome-go-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(22, 105, 197, 0.4);
}

.welcome-go-btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

.welcome-go-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.welcome-guest-link {
    display: block;
    margin: 12px auto 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85em;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 4px 8px;
    transition: color 0.2s;
}
.welcome-guest-link:hover {
    color: var(--text-secondary);
}

.welcome-overlay.fade-out {
    animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* TOWER DEFENSE */
.td-mobile-block { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.td-mobile-block i.fa-chess-rook { font-size: 3em; color: var(--primary-text); margin-bottom: 16px; display: block; }
.td-mobile-block h3 { color: var(--text-primary); font-size: 1.4em; margin-bottom: 12px; }
.td-mobile-block p { font-size: 1em; line-height: 1.6; margin-bottom: 8px; }

.td-loading { text-align: center; padding: 60px 20px; color: var(--text-secondary); font-size: 1.2em; }

/* Start screen */
.td-start-screen { max-width: 600px; margin: 0 auto; text-align: center; padding: 20px; }
.td-title { color: var(--text-primary); font-size: 2em; margin-bottom: 8px; }
.td-desc { color: var(--text-secondary); font-size: 1.05em; margin-bottom: 24px; line-height: 1.5; }
.td-tower-preview { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 24px; }
.td-preview-card { background: var(--bg-elevated); border: 2px solid var(--border-card); border-radius: 12px; padding: 14px 16px; text-align: center; width: 100px; }
.td-preview-card i { font-size: 1.5em; margin-bottom: 6px; }
.td-preview-name { font-weight: 700; color: var(--text-primary); font-size: 0.9em; }
.td-preview-cost { color: var(--text-muted); font-size: 0.8em; margin-top: 2px; }
.td-best { color: var(--text-secondary); margin-bottom: 16px; font-size: 0.95em; }
.td-start-btn { font-size: 1.1em; padding: 12px 32px; }

/* Game wrapper */
.td-game-wrapper { position: relative; max-width: 900px; margin: 0 auto; }

/* HUD */
.td-hud { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--bg-elevated); border-radius: 12px 12px 0 0; border: 1px solid var(--border-card); border-bottom: none; flex-wrap: wrap; }
.td-hud-item { color: var(--text-primary); font-weight: 600; font-size: 0.9em; display: flex; align-items: center; gap: 6px; }
.td-coins::before { content: '\f51e'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: #eab308; }
.td-hp-bar { display: inline-block; width: 80px; height: 12px; background: var(--bg-surface); border-radius: 6px; overflow: hidden; vertical-align: middle; }
.td-hp-fill { height: 100%; background: #22c55e; border-radius: 6px; transition: width 0.3s, background 0.3s; }

/* Canvas */
.td-canvas-wrap { width: 100%; height: 450px; background: #1a2332; border-left: 1px solid var(--border-card); border-right: 1px solid var(--border-card); cursor: crosshair; }
@media (max-width: 768px) { .td-canvas-wrap { height: 350px; } }
@media (max-width: 480px) {
    .td-canvas-wrap { height: 300px; }
    .td-shop { flex-wrap: wrap; }
    .td-shop-btn { font-size: 0.75em; padding: 6px 8px; }
}

/* Shop */
.td-shop { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--bg-elevated); border-radius: 0 0 12px 12px; border: 1px solid var(--border-card); border-top: none; flex-wrap: wrap; }
.td-shop-btn { padding: 8px 14px; border-radius: 8px; border: 2px solid var(--border-card); background: var(--bg-surface); color: var(--text-primary); font-weight: 600; font-size: 0.85em; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 4px; }
.td-shop-btn:hover:not(.disabled) { border-color: var(--primary); background: rgba(22,105,197,0.1); }
.td-shop-btn.selected { border-color: var(--primary); background: var(--primary); color: white; }
.td-shop-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.td-shop-cost { color: #eab308; font-size: 0.85em; }
.td-wave-btn { padding: 8px 18px; border-radius: 8px; border: 2px solid #22c55e; background: rgba(34,197,94,0.15); color: #22c55e; font-weight: 700; font-size: 0.9em; cursor: pointer; transition: all 0.2s; margin-left: auto; }
.td-wave-btn:hover { background: #22c55e; color: white; }

/* Question overlay */
.td-question-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.75); display: flex; align-items: center; justify-content: center; z-index: 10; border-radius: 12px; }
.td-question-card { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 16px; padding: 28px 24px; max-width: 500px; width: 90%; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.td-q-timer { font-size: 2em; font-weight: 800; color: var(--primary-text); margin-bottom: 8px; }
.td-q-streak { color: #eab308; font-weight: 700; font-size: 0.9em; margin-bottom: 8px; }
.td-q-text { color: var(--text-primary); font-size: 1.1em; line-height: 1.5; margin-bottom: 20px; }
.td-q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.td-q-option { padding: 12px 16px; border-radius: 10px; border: 2px solid var(--border-card); background: var(--bg-surface); color: var(--text-primary); font-size: 1em; font-weight: 500; cursor: pointer; transition: all 0.15s; text-align: left; }
.td-q-option:hover { border-color: var(--primary); background: rgba(22,105,197,0.1); }
@media (max-width: 500px) { .td-q-options { grid-template-columns: 1fr; } }

/* Question feedback */
.td-q-feedback { text-align: center; padding: 24px; border-radius: 16px; }
.td-q-feedback i { font-size: 2.5em; margin-bottom: 8px; display: block; }
.td-q-feedback div { font-size: 1.2em; font-weight: 600; color: var(--text-primary); }
.td-q-correct i { color: #22c55e; }
.td-q-wrong i { color: #ef4444; }

/* Game over overlay */
.td-gameover-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 20; border-radius: 12px; }
.td-gameover-card { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 16px; padding: 32px 28px; max-width: 400px; width: 90%; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.td-go-win { color: #22c55e; font-size: 2em; }
.td-go-lose { color: #ef4444; font-size: 2em; }
.td-go-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.td-go-stat { background: var(--bg-surface); padding: 12px; border-radius: 8px; display: flex; flex-direction: column; gap: 4px; }
.td-go-stat span { color: var(--text-secondary); font-size: 0.85em; }
.td-go-stat strong { color: var(--text-primary); font-size: 1.3em; }

/* Tower preview desc */
.td-preview-desc { color: var(--text-muted); font-size: 0.8em; margin-top: 4px; line-height: 1.3; }
.td-preview-card { width: 120px; }

.td-upgrade-hint { color: var(--text-muted); font-size: 0.75em; font-style: italic; }

/* Upgrade toast */
.td-upgrade-toast { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); background: var(--bg-card); border: 1px solid #eab308; color: #eab308; padding: 8px 20px; border-radius: 20px; font-weight: 600; font-size: 0.9em; z-index: 15; animation: fadeIn 0.2s ease, fadeOut 0.3s ease 1.7s forwards; pointer-events: none; white-space: nowrap; }

/* ── MAP QUIZ ──────────────────────────────────────────────────────── */
.mq-start-screen { max-width: 600px; margin: 0 auto; text-align: center; padding: 30px 20px; }
.mq-title { color: var(--text-primary); font-size: 1.8em; margin-bottom: 12px; }
.mq-desc { color: var(--text-secondary); font-size: 1.05em; line-height: 1.6; margin-bottom: 20px; }
.mq-best { color: var(--text-muted); font-size: 0.95em; margin-bottom: 16px; }
.mq-start-btn { font-size: 1.1em; padding: 12px 32px; }

.mq-game-wrapper { max-width: 950px; margin: 0 auto; }
.mq-topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--bg-elevated); border-radius: 12px 12px 0 0; border: 1px solid var(--border-card); border-bottom: none; gap: 8px; flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.mq-prompt { color: var(--text-primary); font-size: 1.1em; }
.mq-prompt strong { color: var(--accent-text); }
.mq-score-area { display: flex; align-items: center; gap: 16px; }
.mq-score { color: var(--primary-text); font-weight: 700; font-size: 1.1em; }
.mq-timer { color: var(--text-muted); font-size: 0.9em; font-variant-numeric: tabular-nums; }

.mq-map-wrap { background: #1a3a5c; border: 1px solid var(--border-card); border-radius: 0; cursor: pointer; overflow: hidden; max-height: calc(100vh - 150px); display: flex; align-items: center; justify-content: center; }
.mq-map { width: 100%; height: auto; display: block; }

.mq-region-path { cursor: pointer; transition: opacity 0.15s, fill 0.3s; stroke-linejoin: round; }
.mq-region-path:hover { opacity: 0.75; stroke: #ffffff; stroke-width: 2; }
.mq-region:focus-visible { outline: 2px solid #fff; outline-offset: -2px; border-radius: 2px; }
.mq-region:focus-visible .mq-region-path { opacity: 0.8; }
.mq-region-path.mq-correct { cursor: default; opacity: 0.85; }
.mq-region-path.mq-correct:hover { opacity: 0.85; stroke: #ffffff; stroke-width: 2; }
.mq-region-path.mq-wrong { fill: #ef4444 !important; animation: mq-flash 0.5s ease; }
.mq-region-path.mq-hint { fill: #fbbf24 !important; stroke: #fbbf24 !important; stroke-width: 4 !important; animation: mq-pulse 0.6s ease 4; }

@keyframes mq-flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes mq-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.mq-feedback { text-align: center; padding: 8px 16px; background: var(--bg-elevated); border-radius: 0 0 12px 12px; border: 1px solid var(--border-card); border-top: none; min-height: 18px; font-weight: 600; font-size: 0.9em; transition: color 0.2s; }
.mq-feedback-correct { color: #22c55e; }
.mq-feedback-hint { color: #fbbf24; }
.mq-feedback-wrong { color: #ef4444; }

.mq-results { max-width: 500px; margin: 0 auto; text-align: center; padding: 40px 20px; }
.mq-results-icon { font-size: 3em; color: var(--primary-text); margin-bottom: 16px; display: block; }
.mq-results-icon.gold { color: #eab308; }
.mq-results-title { color: var(--text-primary); font-size: 1.6em; margin-bottom: 24px; }
.mq-results-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.mq-stat { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.mq-stat-label { color: var(--text-muted); font-size: 0.85em; }
.mq-stat-value { color: var(--text-primary); font-size: 1.4em; font-weight: 700; }
.mq-new-best { color: #eab308; font-weight: 700; font-size: 1.1em; margin-bottom: 16px; }
.mq-btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 600px) {
    .mq-topbar { flex-direction: column; text-align: center; }
    .mq-prompt { font-size: 1em; }
}

/* Map Quiz Mode Selector */
.mq-mode-selector { max-width: 700px; }
.mq-mode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.mq-mode-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 12px; background: var(--bg-card); border: 2px solid var(--border-card); border-radius: 14px; cursor: pointer; transition: all 0.2s; text-align: center; }
.mq-mode-card:hover { border-color: var(--primary); background: var(--bg-elevated); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.mq-mode-card.mq-mode-locked { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.5); }
.mq-mode-card.mq-mode-locked:hover { border-color: var(--border-card); background: var(--bg-card); transform: none; box-shadow: none; }
.mq-mode-icon { font-size: 1.8em; color: var(--primary-text); }
.mq-mode-locked .mq-mode-icon { color: var(--text-muted); }
.mq-mode-title { font-weight: 700; font-size: 1em; color: var(--text-primary); }
.mq-mode-desc { font-size: 0.82em; color: var(--text-muted); line-height: 1.4; }

/* Image-based Map Quiz */
.mq-image-map-wrap { position: relative; border: 1px solid var(--border-card); overflow: hidden; background: #1a3a5c; }
.mq-image-map { width: 100%; height: auto; display: block; user-select: none; -webkit-user-drag: none; }
.mq-hotspot { position: absolute; cursor: pointer; border: 2px dashed transparent; border-radius: 4px; transition: border-color 0.2s, background-color 0.3s; box-sizing: border-box; }
.mq-hotspot:hover { border-color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.08); }
.mq-hotspot-correct { background: rgba(34,197,94,0.35) !important; border: 2px solid rgba(34,197,94,0.7) !important; cursor: default; pointer-events: none; }
.mq-hotspot-wrong { background: rgba(239,68,68,0.4) !important; border: 2px solid rgba(239,68,68,0.7) !important; animation: mq-flash 0.5s ease; }
.mq-hotspot-label { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 10px; font-weight: 700; color: #fff; background: rgba(0,0,0,0.7); padding: 2px 6px; border-radius: 4px; pointer-events: none; }

@media (max-width: 600px) {
    .mq-mode-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .mq-mode-card { padding: 14px 8px; }
    .mq-mode-icon { font-size: 1.4em; }
    .mq-hotspot-label { font-size: 8px; bottom: -14px; }
}

/* Map Quiz Leaderboard */
.mq-leaderboard-wrap { margin-top: 32px; max-width: 600px; margin-left: auto; margin-right: auto; }
.mq-lb-tabs { display: flex; gap: 0; margin-bottom: 0; border-bottom: 2px solid var(--border-card); }
.mq-lb-tab { flex: 1; padding: 10px 16px; background: none; border: none; color: var(--text-muted); font-weight: 600; font-size: 0.9em; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.mq-lb-tab:hover { color: var(--text-primary); }
.mq-lb-tab.active { color: var(--primary-text); border-bottom-color: var(--primary); }

.mq-lb-heading { color: var(--text-primary); font-size: 1.1em; margin: 16px 0 12px; }
.mq-lb-heading i { color: var(--accent-text); margin-right: 6px; }
.mq-lb-empty { text-align: center; color: var(--text-muted); padding: 24px; font-size: 0.95em; }

.mq-lb-list { display: flex; flex-direction: column; gap: 4px; }
.mq-lb-row { display: grid; grid-template-columns: 50px 1fr 60px 60px; align-items: center; padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 8px; gap: 8px; }
.mq-lb-row.mq-lb-me { border-color: var(--primary); background: rgba(22,105,197,0.08); }
.mq-lb-rank { font-weight: 700; color: var(--text-muted); font-size: 0.9em; }
.mq-lb-rank.mq-lb-gold { color: #eab308; }
.mq-lb-rank.mq-lb-silver { color: #94a3b8; }
.mq-lb-rank.mq-lb-bronze { color: #d97706; }
.mq-lb-name { color: var(--text-primary); font-weight: 600; font-size: 0.9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mq-lb-you { margin-left: 6px; font-size: 0.7em; background: var(--primary); color: white; padding: 1px 6px; border-radius: 8px; font-weight: 700; vertical-align: middle; }
.mq-lb-score { color: var(--primary-text); font-weight: 700; font-size: 0.9em; text-align: right; }
.mq-lb-time { color: var(--text-muted); font-size: 0.85em; text-align: right; font-variant-numeric: tabular-nums; }

.mq-lb-bars { display: flex; flex-direction: column; gap: 10px; }
.mq-lb-bar-item { display: flex; align-items: center; gap: 10px; }
.mq-lb-bar-label { width: 100px; flex-shrink: 0; color: var(--text-primary); font-weight: 600; font-size: 0.85em; text-align: right; }
.mq-lb-bar-track { flex: 1; height: 28px; background: var(--bg-surface); border-radius: 6px; overflow: hidden; }
.mq-lb-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 6px; display: flex; align-items: center; justify-content: flex-end; padding: 0 8px; color: white; font-size: 0.75em; font-weight: 600; transition: width 0.6s ease; white-space: nowrap; }
.mq-lb-bar-count { width: 70px; flex-shrink: 0; color: var(--text-muted); font-size: 0.75em; }

@media (max-width: 500px) {
    .mq-lb-row { grid-template-columns: 40px 1fr 50px 50px; padding: 8px; }
    .mq-lb-bar-label { width: 70px; font-size: 0.75em; }
}

/* ── MUSIC PLAYER ──────────────────────────────────────────────────── */
body.music-active .container {
    padding-bottom: 60px;
}

.music-player {
    position: fixed;
    bottom: 16px;
    left: 16px;
    width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevated);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    animation: slideUp 0.3s ease;
}

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

.music-title-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--primary-text);
    font-weight: 600;
    font-size: 0.9em;
    min-height: 20px;
}

.music-title-bar i { font-size: 0.85em; }
.music-title-bar span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.music-collapse-btn, .music-close-btn {
    position: absolute;
    top: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75em;
    padding: 4px;
    z-index: 2;
    transition: color 0.2s;
}
.music-collapse-btn { right: 32px; }
.music-close-btn { right: 8px; }
.music-collapse-btn:hover, .music-close-btn:hover { color: var(--text-primary); }

.music-body {
    display: flex;
    flex-direction: column;
    padding: 0 14px 12px;
    gap: 8px;
}

.music-artist {
    color: var(--text-secondary);
    font-size: 0.8em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.music-progress-wrap {
    width: 100%;
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    cursor: pointer;
    overflow: hidden;
}

.music-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s linear;
}

.music-time-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.music-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.music-ctrl-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1em;
    padding: 6px;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
}
.music-ctrl-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.music-play-btn {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
}
.music-play-btn:hover {
    background: var(--primary-bold);
    color: white;
}

.music-vol-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.8em;
}

.music-vol-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.music-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}
.music-vol-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.music-artist-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.music-artist-row .music-artist { flex: 1; }

.music-info-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8em;
    padding: 2px 4px;
    transition: color 0.2s;
}
.music-info-btn:hover { color: var(--primary-text); }

.music-artist-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    animation: fadeIn 0.2s ease;
}
.music-artist-portrait {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-card);
    align-self: center;
}
.music-artist-name {
    font-weight: 600;
    font-size: 0.85em;
    color: var(--text-primary);
}
.music-artist-years {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.9em;
}
.music-artist-bio {
    font-size: 0.75em;
    color: var(--text-secondary);
    line-height: 1.4;
}

.music-mode-btn {
    font-size: 0.85em;
    position: relative;
}
.music-mode-btn.active {
    color: var(--primary-text);
}
.music-loop-one {
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 0.6em;
    font-weight: 700;
    color: var(--primary-text);
    line-height: 1;
}

.music-playlist {
    max-height: 180px;
    overflow-y: auto;
    border-top: 1px solid var(--border-subtle);
    padding-top: 6px;
    margin-top: 4px;
}
.music-playlist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.music-playlist-item:hover {
    background: var(--bg-surface);
}
.music-playlist-item.active {
    background: rgba(79, 143, 247, 0.12);
}
.music-playlist-num {
    color: var(--text-muted);
    font-size: 0.75em;
    min-width: 18px;
}
.music-playlist-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}
.music-playlist-title {
    font-size: 0.82em;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.music-playlist-item.active .music-playlist-title {
    color: var(--primary-text);
    font-weight: 600;
}
.music-playlist-artist {
    font-size: 0.7em;
    color: var(--text-muted);
}

/* Mobile: full width */
@media (max-width: 480px) {
    .music-player {
        left: 8px;
        right: 8px;
        width: calc(100% - 16px);
        max-width: 280px;
        bottom: 8px;
    }
}

/* ===================== Sketch & Match ===================== */
.sm-wrapper {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}
.sm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.sm-mode-btn {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
    font-family: var(--font-body);
    transition: background 0.2s, transform 0.15s;
}
.sm-mode-btn:hover {
    background: var(--primary);
    color: #fff;
}
.sm-mode-flash {
    animation: smFlash 0.4s ease;
}
@keyframes smFlash {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.sm-score {
    font-size: 1.3em;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-primary);
}
.sm-mode-label {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-bottom: 20px;
    font-family: var(--font-body);
}
.sm-prompt {
    text-align: center;
    margin-bottom: 24px;
}
.sm-prompt-image {
    max-width: 260px;
    max-height: 220px;
    border-radius: 12px;
    object-fit: cover;
    border: 3px solid var(--primary);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    margin: 0 auto;
    display: block;
}
body.light-mode .sm-prompt-image {
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
.sm-prompt-fallback {
    padding: 40px;
    color: var(--text-muted);
    font-style: italic;
}
.sm-prompt-term {
    font-size: 1.6em;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-primary);
    margin-bottom: 6px;
}
.sm-prompt-def {
    font-size: 1em;
    color: var(--text-secondary);
    font-family: var(--font-body);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Text choices (image-to-term mode) */
.sm-choices-text {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}
.sm-choice-btn {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 14px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-family: var(--font-body);
    font-weight: 500;
    transition: border-color 0.2s, background 0.2s, transform 0.1s;
    text-align: center;
}
.sm-choice-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb, 22,105,197), 0.08);
    transform: translateY(-2px);
}
.sm-choice-btn:disabled {
    cursor: default;
    opacity: 0.85;
}
.sm-choice-btn.sm-correct {
    border-color: #22c55e;
    background: rgba(34,197,94,0.12);
    color: #16a34a;
}
body.light-mode .sm-choice-btn.sm-correct {
    background: rgba(34,197,94,0.1);
}
.sm-choice-btn.sm-wrong {
    border-color: #ef4444;
    background: rgba(239,68,68,0.12);
    color: #dc2626;
}
body.light-mode .sm-choice-btn.sm-wrong {
    background: rgba(239,68,68,0.08);
}

/* Image choices (term-to-image mode) */
.sm-choices-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.sm-choice-img-btn {
    background: var(--card-bg);
    border: 3px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    padding: 6px;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    overflow: hidden;
}
.sm-choice-img-btn:hover:not(:disabled) {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}
.sm-choice-img-btn:disabled {
    cursor: default;
}
.sm-choice-img-btn img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}
.sm-choice-img-btn.sm-correct {
    border-color: #22c55e;
    box-shadow: 0 0 12px rgba(34,197,94,0.3);
}
.sm-choice-img-btn.sm-wrong {
    border-color: #ef4444;
    box-shadow: 0 0 12px rgba(239,68,68,0.3);
}

/* Feedback */
.sm-feedback {
    text-align: center;
    font-size: 1.1em;
    font-weight: 600;
    font-family: var(--font-heading);
    min-height: 32px;
    margin-bottom: 8px;
    transition: opacity 0.2s;
}
.sm-feedback-correct {
    color: #22c55e;
}
.sm-feedback-wrong {
    color: #ef4444;
}
.sm-feedback-wrong strong {
    color: var(--text-primary);
}

/* Streak */
.sm-streak {
    text-align: center;
    font-size: 0.95em;
    color: #f59e0b;
    font-weight: 600;
    font-family: var(--font-heading);
    margin-bottom: 12px;
}
.sm-streak i {
    color: #f97316;
}

/* Results screen */
.sm-results {
    text-align: center;
    padding: 40px 20px;
}
.sm-results h2 {
    font-family: var(--font-heading);
    font-size: 1.8em;
    color: var(--text-primary);
    margin: 0 0 12px;
}
.sm-result-score {
    font-size: 1.2em;
    color: var(--text-secondary);
    font-family: var(--font-body);
    margin-bottom: 8px;
}
.sm-result-streak {
    color: #f59e0b;
    font-weight: 600;
    font-family: var(--font-heading);
    margin-bottom: 16px;
}
.sm-result-streak i {
    color: #f97316;
}
.sm-result-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-family: var(--font-body);
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
}
.sm-result-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}
.sm-result-btn-alt {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}
.sm-result-btn-alt:hover {
    border-color: var(--primary);
    filter: none;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .sm-wrapper { padding: 12px; }
    .sm-prompt-image { max-width: 200px; max-height: 180px; }
    .sm-prompt-term { font-size: 1.3em; }
    .sm-choices-text { grid-template-columns: 1fr; }
    .sm-choices-images { grid-template-columns: 1fr 1fr; gap: 8px; }
    .sm-choice-img-btn img { height: 90px; }
    .sm-choice-btn { padding: 12px; font-size: 0.9em; }
    .sm-results h2 { font-size: 1.4em; }
}

/* ── SIFT Practice ───────────────────────────────────────────── */
.sift-container { max-width: 800px; margin: 0 auto; padding: 10px 0; }
.sift-heading { color: var(--text-primary); font-family: var(--font-heading); margin-bottom: 12px; }
.sift-desc { color: var(--text-secondary); line-height: 1.6; margin-bottom: 20px; }
.sift-stats { color: var(--text-muted); font-size: 0.9em; margin-bottom: 16px; }
.sift-start-btn { width: 100%; font-size: 1.1em; margin-top: 8px; }

/* SIFT method card */
.sift-method-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}
.sift-method-title { color: var(--primary-text); margin-bottom: 14px; font-size: 1.1em; }
.sift-step-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.sift-step-row:last-child { margin-bottom: 0; }
.sift-step-letter {
    background: var(--primary);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1em;
    flex-shrink: 0;
}
.sift-step-content { color: var(--text-secondary); line-height: 1.5; padding-top: 4px; }

/* Progress */
.sift-progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sift-progress-text { color: var(--text-muted); font-size: 0.85em; white-space: nowrap; }
.sift-progress-bar { flex: 1; height: 6px; background: var(--bg-surface); border-radius: 3px; overflow: hidden; }
.sift-progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }

/* Source card */
.sift-source-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 20px;
}
.sift-source-img { width: 100%; max-height: 300px; overflow: hidden; }
.sift-source-img img { width: 100%; height: auto; display: block; }
.sift-source-meta { padding: 20px; }
.sift-source-title { color: var(--text-primary); font-size: 1.3em; margin-bottom: 4px; }
.sift-source-subtitle { color: var(--text-secondary); font-size: 0.9em; margin-bottom: 14px; font-style: italic; }

.sift-details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-bottom: 14px; }
.sift-detail-row { display: flex; align-items: center; gap: 8px; font-size: 0.85em; }
.sift-detail-row i { color: var(--text-muted); width: 14px; text-align: center; }
.sift-detail-label { color: var(--text-muted); }
.sift-detail-value { color: var(--text-primary); font-weight: 600; }
a.sift-detail-link { color: var(--primary-text); text-decoration: underline; cursor: pointer; }
a.sift-detail-link:hover { opacity: 0.8; }
.sift-source-desc { color: var(--text-secondary); line-height: 1.5; font-size: 0.95em; }

/* SIFT walkthrough */
.sift-walkthrough {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}
.sift-walkthrough-heading { color: var(--text-primary); font-size: 1em; margin-bottom: 14px; }
.sift-wt-step { margin-bottom: 14px; }
.sift-wt-step:last-child { margin-bottom: 0; }
.sift-wt-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.sift-wt-letter {
    background: var(--primary);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.8em;
    flex-shrink: 0;
}
.sift-wt-label { color: var(--text-secondary); font-size: 0.9em; line-height: 1.4; padding-top: 2px; }
.sift-wt-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9em;
    resize: vertical;
    box-sizing: border-box;
}
.sift-wt-textarea:focus { outline: none; border-color: var(--primary); }

/* Verdict */
.sift-verdict-section { text-align: center; margin-bottom: 20px; }
.sift-verdict-label { color: var(--text-primary); font-size: 1.05em; margin-bottom: 12px; }
.sift-verdict-btns { display: flex; gap: 12px; justify-content: center; }
.sift-verdict-btn {
    padding: 14px 32px;
    border-radius: 10px;
    border: 2px solid var(--border-card);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sift-verdict-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.15); }
.sift-btn-reliable.selected { background: rgba(34, 197, 94, 0.15); border-color: #22c55e; color: #22c55e; }
.sift-btn-unreliable.selected { background: rgba(239, 68, 68, 0.15); border-color: #ef4444; color: #ef4444; }
.sift-btn-disabled { opacity: 0.4; cursor: not-allowed; }

/* Navigation */
.sift-nav-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.sift-nav-btn { font-size: 1em; }
.sift-finish-btn { background: var(--primary); color: #fff; }

/* Results */
.sift-score { text-align: center; margin-bottom: 24px; }
.sift-score-big { font-size: 2em; font-weight: 800; }
.sift-perfect { color: var(--success); font-weight: 600; margin-top: 4px; }
.sift-results-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }

.sift-result-card {
    background: var(--bg-card);
    border: 2px solid var(--border-card);
    border-radius: 12px;
    padding: 16px;
}
.sift-result-correct { border-color: rgba(34, 197, 94, 0.4); }
.sift-result-wrong { border-color: rgba(239, 68, 68, 0.4); }

.sift-result-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.sift-result-title { color: var(--text-primary); font-weight: 700; font-size: 1.05em; flex: 1; }
.sift-result-badge {
    font-size: 0.75em;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}
.sift-badge-reliable { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.sift-badge-unreliable { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.sift-your-answer { color: var(--error); font-size: 0.85em; margin-bottom: 6px; font-style: italic; }
.sift-result-explanation { color: var(--text-secondary); font-size: 0.9em; line-height: 1.5; margin-bottom: 8px; }

.sift-detail-toggle {
    background: none;
    border: none;
    color: var(--primary-text);
    font-family: var(--font-body);
    font-size: 0.85em;
    cursor: pointer;
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sift-detail-toggle:hover { text-decoration: underline; }

.sift-detail-breakdown { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.sift-breakdown-step { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.sift-breakdown-step:last-child { margin-bottom: 0; }
.sift-breakdown-letter {
    background: var(--bg-surface);
    color: var(--primary-text);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75em;
    flex-shrink: 0;
}
.sift-breakdown-step div { color: var(--text-secondary); font-size: 0.85em; line-height: 1.4; }

.sift-your-notes-heading { color: var(--text-muted); font-size: 0.8em; font-weight: 600; margin-top: 12px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.sift-your-note { color: var(--text-secondary); font-size: 0.85em; font-style: italic; margin-bottom: 4px; }

@media (max-width: 600px) {
    .sift-details-grid { grid-template-columns: 1fr; }
    .sift-verdict-btns { flex-direction: column; }
    .sift-verdict-btn { justify-content: center; }
}

/* ===== Textbook Mode ===== */
.tb-wrapper { max-width: 900px; margin: 0 auto; padding: 0 16px 40px; }

/* Top bar: segments + level picker */
.tb-top-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; padding-top: 14px; flex-wrap: wrap;
}

/* Segment nav */
.tb-seg-nav {
    display: flex; gap: 6px; flex-wrap: wrap;
}
.tb-seg-btn {
    background: var(--bg-card); border: 1px solid var(--border-card);
    color: var(--text-secondary); padding: 6px 14px; border-radius: var(--radius-md);
    font-size: 0.82em; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; gap: 4px; font-family: inherit;
}
.tb-seg-btn:hover { border-color: var(--primary); color: var(--text-primary); }
.tb-seg-btn.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Reading level picker */
.tb-level-picker {
    display: flex; gap: 4px;
}
.tb-level-btn {
    padding: 5px 10px; border-radius: 8px; border: 1.5px solid var(--border-color);
    background: var(--bg-card); color: var(--text-secondary); cursor: pointer;
    font-family: inherit; font-size: 0.8em; font-weight: 500;
    transition: all 0.2s ease; display: flex; align-items: center; gap: 4px;
}
.tb-level-btn:hover {
    border-color: var(--primary); color: var(--primary-text);
}
.tb-level-btn.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.tb-level-btn i { font-size: 0.85em; }

/* Reading level prompt (first-time) */
.tb-level-prompt { text-align: center; padding: 60px 20px; max-width: 740px; margin: 0 auto; }  /* four 160px level cards in one row */
.tb-level-cards { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.tb-level-card { background: var(--bg-elevated); border: 2px solid var(--border-card); border-radius: 12px; padding: 24px 20px; width: 160px; cursor: pointer; transition: all 0.2s; text-align: center; font-family: inherit; }
.tb-level-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

/* Body: sidebar + reading area */
.tb-body {
    display: flex; gap: 16px; align-items: flex-start;
}

/* Sidebar section tabs */
.tb-sidebar {
    width: 220px; flex-shrink: 0; position: sticky; top: 80px;
    transition: width 0.25s ease, opacity 0.25s ease;
}
.tb-sidebar.collapsed { width: 40px; }
.tb-sidebar.collapsed .tb-tab-list { display: none; }
.tb-sidebar-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    background: var(--bg-card); border: 1px solid var(--border-card);
    color: var(--text-secondary); cursor: pointer; margin-bottom: 8px;
    font-size: 0.85em; transition: all 0.2s; font-family: inherit;
}
.tb-sidebar-toggle:hover { border-color: var(--primary); color: var(--primary-text); }
.tb-tab-list {
    display: flex; flex-direction: column; gap: 2px;
}
.tb-tab {
    display: flex; align-items: center; gap: 8px; width: 100%;
    background: none; border: none; border-left: 3px solid transparent;
    color: var(--text-secondary); padding: 8px 10px; cursor: pointer;
    text-align: left; font-size: 0.82em; transition: all 0.15s;
    font-family: inherit; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.tb-tab:hover { background: var(--bg-surface); color: var(--text-primary); }
.tb-tab.active {
    background: rgba(79, 143, 247, 0.1); color: var(--primary-text);
    border-left-color: var(--primary); font-weight: 600;
}
.tb-tab.read { color: var(--text-muted); }
.tb-tab-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%; font-size: 0.75em; font-weight: 700;
    background: var(--bg-surface); color: var(--text-muted); flex-shrink: 0;
}
.tb-tab.active .tb-tab-num { background: var(--primary); color: #fff; }
.tb-tab-label {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Reading area */
.tb-reading {
    background: var(--bg-card); border: 1px solid var(--border-card);
    border-radius: var(--radius-md); padding: 28px 24px;
    box-shadow: var(--shadow-card); margin-bottom: 16px;
    flex: 1; min-width: 0;
}

.tb-section-heading {
    font-size: 1.3em; font-weight: 700; color: var(--text-primary);
    margin-bottom: 6px; padding-left: 14px;
    border-left: 4px solid var(--primary);
    display: flex; align-items: center; gap: 10px;
}
.tb-link-btn {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 0.6em; padding: 4px 6px; border-radius: var(--radius-sm);
    opacity: 0; transition: all 0.2s; flex-shrink: 0;
}
.tb-section-heading:hover .tb-link-btn { opacity: 1; }
.tb-link-btn:hover { color: var(--primary-text); background: rgba(79, 143, 247, 0.1); }
.tb-link-btn.copied { color: var(--success); opacity: 1; }

.tb-source-note {
    font-size: 0.78em; color: var(--text-muted); margin-bottom: 18px;
    font-style: italic;
}

/* Figure / image */
.tb-figure {
    margin: 0 0 20px 0; border-radius: var(--radius-md); overflow: hidden;
    background: var(--bg-surface); border: 1px solid var(--border-card);
}
.tb-figure-img {
    width: 100%; height: auto; display: block;
    object-fit: cover; max-height: 400px;
}
.tb-figure-caption {
    padding: 10px 14px; font-size: 0.82em; line-height: 1.5;
    color: var(--text-secondary); border-top: 1px solid var(--border-card);
}
.tb-figure-credit {
    color: var(--text-muted); font-style: italic; font-size: 0.9em;
}
/* Float variants for inline placement */
.tb-figure-right {
    float: right; width: 45%; margin: 0 0 16px 20px;
}
.tb-figure-left {
    float: left; width: 45%; margin: 0 20px 16px 0;
}

/* Content typography */
.tb-content {
    color: var(--text-primary); font-size: 1.02em; line-height: 1.75;
}
.tb-content p { margin-bottom: 14px; }
.tb-content strong { color: var(--text-primary); font-weight: 700; }
.tb-content ul, .tb-content ol { margin: 10px 0 14px 20px; }
.tb-content li { margin-bottom: 6px; }

/* Vocab highlighting */
.tb-vocab {
    text-decoration: underline; text-decoration-style: dotted;
    text-decoration-color: var(--accent); text-underline-offset: 3px;
    cursor: pointer; transition: background 0.15s;
}
.tb-vocab:hover { background: rgba(251, 191, 36, 0.15); border-radius: 3px; }

/* Vocab popup */
.tb-vocab-popup {
    position: fixed; z-index: 9999; background: var(--bg-elevated);
    border: 1px solid var(--border-hover); border-radius: var(--radius-md);
    padding: 14px 16px; max-width: 340px; width: max-content;
    box-shadow: var(--shadow-elevated); opacity: 0;
    transform: translateY(4px); transition: opacity 0.15s, transform 0.15s;
    pointer-events: auto;
}
.tb-vocab-popup.visible { opacity: 1; transform: translateY(0); }
.tb-popup-term {
    font-weight: 700; font-size: 1.05em; color: var(--accent-text); margin-bottom: 6px;
}
.tb-popup-def { color: var(--text-primary); font-size: 0.9em; line-height: 1.5; margin-bottom: 8px; }
.tb-popup-simple {
    color: var(--text-secondary); font-size: 0.82em; line-height: 1.4;
    background: rgba(251, 191, 36, 0.08); padding: 8px 10px;
    border-radius: var(--radius-sm); border-left: 3px solid var(--accent);
}
.tb-popup-simple i { color: var(--accent-text); margin-right: 2px; }

/* Callout boxes */
.tb-callout {
    border-radius: var(--radius-md); padding: 16px 18px;
    margin: 20px 0; border-left: 4px solid;
}
.tb-callout-title {
    font-weight: 700; font-size: 0.9em; margin-bottom: 8px;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.tb-callout-text { font-size: 0.95em; line-height: 1.6; color: var(--text-primary); }

/* Key Idea */
.tb-callout-key {
    background: rgba(251, 191, 36, 0.08); border-color: var(--accent);
}
.tb-callout-key .tb-callout-title { color: var(--accent-text); }
.tb-callout-key .tb-callout-title i { color: var(--accent-text); }

/* Primary Source */
.tb-callout-source {
    background: rgba(79, 143, 247, 0.06); border-color: var(--primary);
}
.tb-callout-source .tb-callout-title { color: var(--primary-text); }
.tb-quote {
    font-style: italic; font-size: 1em; line-height: 1.7;
    color: var(--text-primary); margin: 8px 0; padding: 0;
    border: none; quotes: none;
}
.tb-quote-attr {
    font-size: 0.85em; color: var(--text-muted); text-align: right; margin-top: 6px;
}

/* Stop & Think */
.tb-callout-think {
    background: rgba(52, 211, 153, 0.06); border-color: var(--success);
}
.tb-callout-think .tb-callout-title { color: var(--success); }
.tb-think-hint {
    font-size: 0.85em; color: var(--text-muted); margin-top: 10px;
    font-style: italic;
}
.tb-think-hint i { color: var(--success); }

/* Quick Check */
.tb-callout-qc {
    background: rgba(79, 143, 247, 0.06); border-color: var(--secondary);
}
.tb-callout-qc .tb-callout-title { color: var(--secondary-text); }
.tb-qc-question {
    font-size: 0.95em; font-weight: 600; color: var(--text-primary);
    margin-bottom: 12px; line-height: 1.5;
}
.tb-qc-options { display: flex; flex-direction: column; gap: 8px; }
.tb-qc-option {
    background: var(--bg-surface); border: 1px solid var(--border-card);
    color: var(--text-primary); padding: 10px 14px; border-radius: var(--radius-sm);
    cursor: pointer; text-align: left; font-size: 0.9em; transition: all 0.15s;
}
.tb-qc-option:hover:not(:disabled) {
    border-color: var(--primary); background: rgba(79, 143, 247, 0.08);
}
.tb-qc-option.correct {
    border-color: var(--success); background: rgba(52, 211, 153, 0.12);
    color: var(--success); font-weight: 600;
}
.tb-qc-option.wrong {
    border-color: var(--danger); background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
}
.tb-qc-option:disabled { cursor: default; opacity: 0.8; }
.tb-qc-explanation {
    margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
    font-size: 0.88em; line-height: 1.5;
}
.tb-qc-explanation.correct { background: rgba(52, 211, 153, 0.1); color: var(--success); }
.tb-qc-explanation.wrong { background: rgba(248, 113, 113, 0.08); color: var(--danger); }
.tb-qc-explanation i { margin-right: 4px; }

/* Mark as Read button */
.tb-mark-read {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; margin-top: 24px; padding: 12px;
    background: var(--bg-surface); border: 2px dashed var(--border-card);
    color: var(--text-secondary); border-radius: var(--radius-md);
    cursor: pointer; font-size: 0.95em; font-weight: 600; transition: all 0.2s;
}
.tb-mark-read:hover:not(.read) {
    border-color: var(--primary); color: var(--primary-text);
    background: rgba(79, 143, 247, 0.06);
}
.tb-mark-read.read {
    border-style: solid; border-color: var(--success);
    background: rgba(52, 211, 153, 0.08); color: var(--success);
    cursor: default;
}

/* Section navigation */
.tb-nav-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-subtle);
}
.tb-nav-btn {
    background: var(--bg-surface); border: 1px solid var(--border-card);
    color: var(--text-primary); padding: 8px 16px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 0.9em; transition: all 0.15s;
    display: flex; align-items: center; gap: 6px;
}
.tb-nav-btn:hover { border-color: var(--primary); color: var(--primary-text); }
.tb-nav-next-seg {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.tb-nav-next-seg:hover { opacity: 0.9; color: #fff; }
.tb-nav-pos { color: var(--text-muted); font-size: 0.85em; }

/* Progress bar */
.tb-progress-wrap {
    max-width: 680px; margin: 0 auto; padding: 0 4px;
}
.tb-progress-bar {
    height: 6px; background: var(--bg-surface); border-radius: 3px;
    overflow: hidden; margin-bottom: 6px;
}
.tb-progress-fill {
    height: 100%; background: var(--primary); border-radius: 3px;
    transition: width 0.4s ease;
}
.tb-progress-label {
    font-size: 0.8em; color: var(--text-muted); text-align: center;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .tb-reading { padding: 20px 16px; }
    .tb-top-bar { flex-direction: column; align-items: stretch; gap: 8px; }
    .tb-seg-nav { justify-content: center; }
    .tb-seg-btn { padding: 5px 10px; font-size: 0.75em; }
    .tb-seg-btn i { display: none; }
    .tb-level-picker { justify-content: center; }
    .tb-level-btn { padding: 4px 8px; font-size: 0.75em; }
    .tb-body { flex-direction: column; }
    .tb-sidebar { width: 100%; position: static; }
    .tb-sidebar.collapsed { width: 100%; }
    .tb-tab-list { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .tb-tab {
        border-left: none; border-bottom: 2px solid transparent;
        border-radius: var(--radius-sm); padding: 5px 8px; font-size: 0.75em;
    }
    .tb-tab.active { border-left-color: transparent; border-bottom-color: var(--primary); }
    .tb-tab-label { max-width: 90px; }
    .tb-section-heading { font-size: 1.15em; }
    .tb-figure-right, .tb-figure-left { float: none; width: 100%; margin: 0 0 16px 0; }
    .tb-figure-img { max-height: 280px; }
    .tb-content { font-size: 0.95em; }
    .tb-vocab-popup { max-width: calc(100vw - 32px); }
}

/* --- Nudge suggestions --- */
.nudge-section { margin-bottom: 20px; }
.nudge-title {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.nudge-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.nudge-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    text-align: left;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}
.nudge-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.nudge-card-icon {
    font-size: 1.4em;
    color: var(--primary-text);
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}
.nudge-card-text { flex: 1; }
.nudge-card-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95em;
}
.nudge-card-reason {
    font-size: 0.82em;
    color: var(--text-secondary);
    margin-top: 2px;
}
.nudge-card-arrow {
    color: var(--text-muted);
    font-size: 0.85em;
    flex-shrink: 0;
}

/* ── 1861 Map: Tooltip ── */
.mq-1861-tooltip { position: absolute; z-index: 20; background: var(--bg-elevated); border: 1px solid var(--border-card); border-radius: 10px; padding: 12px 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.25); pointer-events: none; min-width: 160px; max-width: 240px; }
.mq-1861-tooltip-name { font-weight: 700; font-size: 1.05em; color: var(--text-primary); margin-bottom: 4px; }
.mq-1861-tooltip-badge { display: inline-block; font-size: 0.75em; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-bottom: 6px; color: #fff; }
.mq-1861-badge-union { background: #4a7fb5; }
.mq-1861-badge-confederate { background: #b05a5a; }
.mq-1861-badge-border { background: #b8942f; color: #1a1a1a; }
.mq-1861-badge-territory { background: #6a8a6a; }
.mq-1861-tooltip-status { color: var(--text-secondary); font-size: 0.9em; }
.mq-1861-tooltip-capital { color: var(--text-muted); font-size: 0.85em; margin-top: 2px; }

/* ── 1861 Map: Mobile MC buttons ── */
.mq-1861-mc-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 16px; }
.mq-1861-mc-btn { padding: 14px 8px; font-size: 0.95em; font-weight: 600; border: 2px solid var(--border-card); border-radius: 10px; background: var(--bg-card); color: var(--text-primary); cursor: pointer; transition: all 0.2s; text-align: center; word-break: break-word; }
.mq-1861-mc-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--bg-elevated); }
.mq-1861-mc-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.mq-1861-mc-btn:disabled { cursor: default; opacity: 0.6; }
.mq-1861-mc-correct { background: rgba(34,197,94,0.15) !important; border-color: #22c55e !important; color: #22c55e !important; }
.mq-1861-mc-wrong { background: rgba(239,68,68,0.15) !important; border-color: #ef4444 !important; color: #ef4444 !important; text-decoration: line-through; }
.mq-1861-mc-hint { border-color: #fbbf24 !important; animation: mq-pulse 0.6s ease 3; }

/* ── 1861 Map: Mobile map (context only) ── */
.mq-1861-mobile-map { max-height: 35vh; pointer-events: none; }

/* ── 1861 Map: Mobile Learn cards ── */
.mq-1861-mobile-learn { max-width: 700px; text-align: left; }
.mq-1861-mobile-learn-map { max-height: 30vh; pointer-events: none; margin-bottom: 16px; border-radius: 8px; overflow: hidden; }
.mq-1861-mobile-learn-map .mq-region-path { transition: fill 0.3s, stroke 0.3s; }
.mq-1861-section-heading { color: var(--text-primary); font-size: 1.1em; margin: 24px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--border-card); }
.mq-1861-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mq-1861-info-card { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 10px; padding: 12px; }
.mq-1861-card-name { font-weight: 700; color: var(--text-primary); font-size: 0.95em; margin-bottom: 4px; }
.mq-1861-card-detail { color: var(--text-muted); font-size: 0.82em; line-height: 1.5; }

@media (max-width: 500px) {
    .mq-1861-card-grid { grid-template-columns: 1fr; }
    .mq-1861-mc-wrap { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────
   CIVIL WAR MAP ACTIVITY
   ───────────────────────────────────────────────────────── */
.cw-map-screen { display: flex; flex-direction: column; gap: 16px; padding: 0; }
.cw-map-menu { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 14px; padding: 24px; text-align: center; max-width: 700px; margin: 0 auto; }
.cw-map-menu h2 { color: var(--text-primary); margin: 0 0 8px; font-size: 1.6em; }
.cw-map-menu-desc { color: var(--text-secondary); margin: 0 0 24px; line-height: 1.5; }
.cw-map-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cw-map-mode-card { background: var(--bg-elevated); border: 1px solid var(--border-card); border-radius: 12px; padding: 20px 16px; cursor: pointer; text-align: center; color: var(--text-primary); font: inherit; transition: transform 0.15s, border-color 0.15s; }
.cw-map-mode-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.cw-map-mode-icon { font-size: 1.8em; color: var(--accent-text); margin-bottom: 8px; }
.cw-map-mode-card h3 { color: var(--text-primary); margin: 0 0 6px; font-size: 1.1em; }
.cw-map-mode-card p { color: var(--text-muted); font-size: 0.85em; line-height: 1.4; margin: 0; }
.cw-map-best { margin-top: 16px; padding: 8px 12px; background: var(--bg-elevated); border-radius: 8px; color: var(--text-secondary); font-size: 0.9em; display: inline-block; }

.cw-map-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 10px; gap: 12px; }
.cw-map-back-btn { background: transparent; border: 1px solid var(--border-card); color: var(--text-primary); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 0.9em; white-space: nowrap; }
.cw-map-back-btn:hover { background: var(--bg-elevated); }
.cw-map-header-info { display: flex; gap: 16px; color: var(--text-secondary); font-size: 0.9em; flex-wrap: wrap; }
.cw-map-score { font-weight: 700; color: var(--accent-text); }

.cw-map-svg-wrap { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 12px; overflow: hidden; }
.cw-map-svg { display: block; width: 100%; height: auto; max-height: 70vh; background: #b3d8e8; }
.cw-map-states .cw-map-state {
    fill: #5d8c6c;
    stroke: #f4ead5;
    stroke-width: 0.6;
    stroke-linejoin: round;
}
.cw-map-states .cw-map-state-CA { fill: #4a7058; }
.cw-map-lakes .cw-map-lake { fill: #b3d8e8; stroke: none; }
.cw-map-rivers .cw-map-river {
    fill: none;
    stroke: #2752c8;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.cw-map-cities .cw-map-city { cursor: pointer; }
.cw-map-cities .cw-map-city-dot { transition: r 0.15s, stroke-width 0.15s; }
.cw-map-cities .cw-map-city:hover .cw-map-city-dot { r: 9; stroke-width: 3; }
.cw-map-cities .cw-map-city.selected .cw-map-city-dot { r: 11; stroke: var(--accent); stroke-width: 3; }
.cw-map-cities .cw-map-city.cw-map-flash-correct .cw-map-city-dot { fill: #22c55e; r: 12; stroke: #fff; stroke-width: 3; }
.cw-map-cities .cw-map-city.cw-map-flash-wrong .cw-map-city-dot { fill: #ef4444; r: 11; stroke: #fff; stroke-width: 3; }
.cw-map-leader { stroke: var(--text-muted); stroke-width: 1; opacity: 0.6; }
.cw-map-label {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 12px;
    fill: #1a2738;
    pointer-events: none;
    font-weight: 700;
    paint-order: stroke;
    stroke: rgba(244, 234, 213, 0.95);
    stroke-width: 3;
    stroke-linejoin: round;
}

.cw-map-panel { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 12px; padding: 16px; }
.cw-map-panel-quiz { text-align: center; }
.cw-map-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.cw-map-legend-item { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 0.9em; }
.cw-map-legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; }
.cw-map-panel-hint { color: var(--text-muted); font-size: 0.9em; margin: 0; }
.cw-map-panel-name-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.cw-map-panel-name { color: var(--text-primary); margin: 0; font-size: 1.2em; }
.cw-map-panel-badge { padding: 3px 10px; border-radius: 12px; font-size: 0.75em; font-weight: 600; color: #fff; text-transform: uppercase; letter-spacing: 0.5px; }
.cw-map-badge-battle { background: #7A1F1F; }
.cw-map-badge-capital { background: #4A5568; }
.cw-map-badge-strategic { background: #5a7a9a; }
.cw-map-panel-desc { color: var(--text-secondary); line-height: 1.5; margin: 0 0 12px; }
.cw-map-panel-close { background: var(--bg-elevated); border: 1px solid var(--border-card); color: var(--text-primary); padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 0.9em; }

.cw-map-prompt { padding: 8px 0; }
.cw-map-prompt-label { color: var(--text-muted); font-size: 0.85em; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 1px; }
.cw-map-prompt-name { color: var(--accent-text); font-size: 1.6em; font-weight: 700; margin-bottom: 4px; }
.cw-map-prompt-hint { color: var(--text-secondary); font-size: 0.9em; }

.cw-map-feedback { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 12px 20px; border-radius: 10px; color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 1000; animation: cwMapFeedback 1.4s ease forwards; }
.cw-map-feedback.correct { background: #22c55e; }
.cw-map-feedback.wrong { background: #ef4444; }
@keyframes cwMapFeedback {
    0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

.cw-map-results-heading { color: var(--accent-text); margin: 0 0 16px; font-size: 1.6em; }
.cw-map-results-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.cw-map-stat { background: var(--bg-elevated); padding: 12px 8px; border-radius: 8px; }
.cw-map-stat-label { display: block; color: var(--text-muted); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.cw-map-stat-value { display: block; color: var(--text-primary); font-weight: 700; font-size: 1.1em; }
.cw-map-results-newbest { color: #fbbf24; font-weight: 700; margin-bottom: 16px; }
.cw-map-results-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.cw-map-btn { padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; font-weight: 600; font-size: 0.95em; }
.cw-map-btn-primary { background: var(--accent); color: #fff; }
.cw-map-btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-card); }
/* Results-panel variants used by the state/colony map activities. */
.cw-map-results-summary { color: var(--text-secondary); margin: 0 0 16px; }
.cw-map-results-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.cw-map-results-btn { padding: 10px 20px; border-radius: 8px; border: 1px solid var(--border-card); background: var(--bg-elevated); color: var(--text-primary); cursor: pointer; font-weight: 600; font-size: 0.95em; }
.cw-map-results-btn:hover { background: var(--bg-card); }
.cw-map-results-btn.primary { background: var(--accent); color: #fff; border-color: transparent; }

@media (max-width: 600px) {
    .cw-map-modes { grid-template-columns: 1fr; }
    .cw-map-results-stats { grid-template-columns: 1fr; }
    .cw-map-label { font-size: 14px; }
}

/* ─────────────────────────────────────────────────────────
   UNDERGROUND RAILROAD MAP ACTIVITY
   ───────────────────────────────────────────────────────── */
.ugrr-map-screen { display: flex; flex-direction: column; gap: 16px; padding: 0; }
.ugrr-map-header { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 12px; padding: 16px 20px; position: relative; }
.ugrr-map-toggle-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
}
.ugrr-map-toggle-btn:hover { background: var(--bg-surface); }
.ugrr-map-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}
.ugrr-map-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.88em;
}
.ugrr-map-legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
}
.ugrr-map-title { color: var(--text-primary); margin: 0 0 4px; font-size: 1.5em; }
.ugrr-map-subtitle { color: var(--text-secondary); margin: 0; font-size: 0.92em; line-height: 1.5; }

.ugrr-map-svg-wrap { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 12px; overflow: hidden; }
.ugrr-map-svg { display: block; width: 100%; height: auto; max-height: 70vh; background: #b3d8e8; }

/* Base map (states + lakes) reuses .cw-map-state and .cw-map-lake classes.
   Routes drawn on top in dark red so they read as paths-of-people, not
   waterways. */
.ugrr-map-routes .ugrr-map-route {
    fill: none;
    stroke: #6e1f10;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.7;
    pointer-events: none;
}

/* Cities — clickable, with the unit's accent color */
.ugrr-map-cities .ugrr-map-city { cursor: pointer; }
.ugrr-map-cities .ugrr-map-city-dot {
    /* fill set inline via SVG attribute so per-category colors apply */
    transition: r 0.15s, stroke-width 0.15s;
}
.ugrr-map-cities .ugrr-map-city:hover .ugrr-map-city-dot { r: 9; stroke-width: 3; }
.ugrr-map-cities .ugrr-map-city.selected .ugrr-map-city-dot {
    r: 11; stroke-width: 3;
}
.ugrr-map-label {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    font-weight: 700;
    fill: #1a2738;
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(244, 234, 213, 0.95);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Info panel */
.ugrr-map-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 16px 20px;
}
.ugrr-map-panel-hint {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    font-size: 0.95em;
}
.ugrr-map-panel-name-row {
    display: flex;
    gap: 12px;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}
.ugrr-map-panel-name {
    color: var(--text-primary);
    margin: 0;
    font-size: 1.3em;
}
.ugrr-map-panel-role {
    color: var(--accent-text);
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ugrr-map-panel-section-label {
    color: var(--text-muted);
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 12px;
    margin-bottom: 4px;
}
.ugrr-map-panel-person, .ugrr-map-panel-detail {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    font-size: 0.95em;
}
.ugrr-map-panel-close {
    margin-top: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
}
.ugrr-map-panel-close:hover { background: var(--bg-surface); }

@media (max-width: 600px) {
    .ugrr-map-label { font-size: 13px; }
}

/* === 50 States Map ============================================== */
/* Polygon-click map. Reuses cw-map layout classes (panel, header, etc.)
   for visual consistency with the other two maps, and adds fs-* classes
   for the state-polygon-specific bits.                                */

.fs-map .fs-map-svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 50vh;
    background: #b3d8e8;
}
/* Prompt above the map, and the whole map on screen: on a 1366x768 Chromebook
   (~660px viewport under the site header) a 70vh map pushed the "Find: ___"
   panel below the fold on every question. */
.fs-map .cw-map-header { order: -2; }
.fs-map .cw-map-panel { order: -1; }
/* Landscape screens (Chromebooks, laptops): panel beside the map, and the map
   sized by the height that is actually free, instead of a full-width panel
   stacked above a map capped at 50vh (which left a ~350px map on a 1366px
   display). Phones keep the stacked layout above. */
@media (min-width: 900px) {
    .fs-map.cw-map-screen {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 320px;
        grid-template-rows: auto 1fr;
        align-items: start;
    }
    /* Header (Back + score) and prompt stack in the right column; the map
       takes the full height of the left column and the card hugs it. */
    .fs-map .cw-map-header { grid-column: 2; grid-row: 1; }
    .fs-map .cw-map-panel { grid-column: 2; grid-row: 2; position: sticky; top: 8px; }
    .fs-map .cw-map-svg-wrap { grid-column: 1; grid-row: 1 / span 2; justify-self: center; width: fit-content; max-width: 100%; }
    .fs-map .fs-map-svg {
        width: auto;
        max-width: 100%;
        height: calc(100vh - 115px);
        min-height: 320px;
        max-height: 800px;
    }
}

.fs-state .fs-state-path {
    fill: var(--primary, #4a90d9);
    stroke: #fff;
    stroke-width: 1;
    transition: fill 0.15s ease;
    cursor: pointer;
}
.fs-state.hover .fs-state-path {
    fill: var(--primary-bold, #2d6cb3);
}
.fs-state.selected .fs-state-path {
    fill: var(--accent, #f4b400);
    stroke: var(--primary-bold, #2d6cb3);
    stroke-width: 1.5;
}
.fs-state.fs-flash-correct .fs-state-path {
    fill: #2ecc71;
    stroke: #1f8a4d;
}
.fs-state.fs-flash-wrong .fs-state-path {
    fill: #e74c3c;
    stroke: #a3271e;
}
/* Answered (dimmed) state in Quiz mode. No distinction between right and
   wrong — both look the same — so students don't see a map of their mistakes
   mid-quiz. Still clickable (and still counts as a wrong answer if clicked
   for the wrong prompt), so students don't get a free "process of elimination"
   advantage on the last few questions. Flash classes (correct/wrong) win
   until the 1.4s timer clears. */
.fs-state.fs-answered .fs-state-path {
    fill: #4a5568;
    opacity: 0.45;
}
.fs-state.fs-answered-correct .fs-state-path {
    fill: #2ecc71;
    stroke: #1f8a4d;
    opacity: 0.9;
}
.fs-state-hitbox {
    cursor: pointer;
    pointer-events: all;
}

/* Quiz progress bar — lives above the "Find:" prompt in the right panel.
   Glanceable counterpart to the header text "Question X of 50". */
.fs-progress {
    margin-bottom: 16px;
}
.fs-progress-label {
    font-size: 0.85em;
    color: var(--text-muted, #6b7280);
    margin-bottom: 6px;
    text-align: center;
}
.fs-progress-bar {
    height: 8px;
    background: var(--bg-surface, #e5e7eb);
    border-radius: 4px;
    overflow: hidden;
}
.fs-progress-fill {
    height: 100%;
    background: var(--primary, #4a90d9);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.fs-state-label {
    fill: #fff;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

@media (max-width: 600px) {
    .fs-state-label { font-size: 9px; }
}

/* ===================== Colonial Regions Map ===================== */
.cr-legend-panel { display: flex; flex-direction: column; gap: 6px; }
.cr-legend-row { display: flex; align-items: center; gap: 8px; font-size: 0.95em; color: var(--text-primary); }
.cr-legend-row.cr-legend-done { opacity: 0.6; }
.cr-legend-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }
.cr-region-pickers { display: flex; flex-direction: column; gap: 16px; margin: 16px 0; }
.cr-picker-row { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cr-picker-label { font-weight: 600; color: var(--text-primary); font-size: 0.95em; }
.cr-swatches { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.cr-swatch { width: 40px; height: 40px; border-radius: 8px; border: 3px solid transparent; cursor: pointer; transition: transform 0.15s, border-color 0.15s; }
.cr-swatch:hover { transform: scale(1.1); }
.cr-swatch.selected { border-color: var(--text-primary); transform: scale(1.15); box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--text-primary); }
.cr-go-btn { display: block; margin: 16px auto 0; font-size: 1em; }
.cr-go-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cr-back-btn { display: block; margin: 8px auto 0; }
.cr-color-progress { color: var(--text-muted); font-size: 0.85em; margin: 4px 0 8px; }
.cr-colony.cr-painted { pointer-events: none; }
.cr-colony.cr-painted .fs-state-path { stroke: #fff; stroke-width: 1.5; }
.cr-region-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cr-region-btn { padding: 10px 16px; border-radius: 8px; border: 2px solid var(--border-card); border-left-width: 5px; background: var(--bg-elevated); color: var(--text-primary); cursor: pointer; font-weight: 600; font-size: 0.95em; text-align: left; transition: background 0.15s; }
.cr-region-btn:hover { background: var(--bg-card); }
.cr-panel-others { color: var(--text-muted); font-size: 0.85em; margin: 4px 0 0; }

/* ===================== Colonial Geography Map =================== */
/* Labels sit on colored fills; paint-order draws a white halo under the glyphs. */
.cg-colony-label, .cg-lake-label, .cg-river-label, .cg-mountain-label, .cg-feature-label, .cg-proclamation-label, .cg-city-label {
    font-family: 'Outfit', system-ui, sans-serif; paint-order: stroke; stroke: rgba(255,255,255,0.9); stroke-width: 2.5px; stroke-linejoin: round;
}
.cg-colony-label { fill: #2b2b2b; font-size: 12px; font-weight: 700; }
.cg-lake-label { fill: #1b4f73; font-size: 9px; font-style: italic; stroke: rgba(140,196,228,0.9); }
.cg-river-label { fill: #1b4f73; font-size: 9px; font-style: italic; font-weight: 600; }
.cg-ocean-label { fill: #155e8a; font-family: 'Outfit', system-ui, sans-serif; font-size: 16px; font-style: italic; letter-spacing: 6px; opacity: 0.45; }
.cg-mountain-label { fill: #6b4c2a; font-size: 8.5px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; }
.cg-feature-label { fill: #4a4a4a; font-size: 9px; font-style: italic; font-weight: 600; }
.cg-proclamation-label { fill: #b91c1c; font-size: 8.5px; font-weight: 700; letter-spacing: 1px; }
.cg-city-label { fill: #1a1a1a; font-size: 10px; font-weight: 700; }
.cg-city { cursor: pointer; }
.cg-city:hover .cg-city-dot { r: 6; }
.cg-city.selected .cg-city-dot { r: 7; stroke-width: 2.5; }
.cg-city.cg-flash-correct .cg-city-dot { fill: #22c55e; r: 7; }
.cg-city.cg-flash-wrong .cg-city-dot { fill: #ef4444; r: 7; }
.cg-city.cg-answered .cg-city-dot { fill: #4a5568; opacity: 0.5; }
.cg-city-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; color: #fff; font-size: 0.75em; font-weight: 600; margin-bottom: 8px; }
.cg-fort:hover .cg-city-dot, .cg-fort.selected .cg-city-dot { stroke-width: 2.5; }
.cg-legend { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.cg-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cg-legend-star { display: inline-block; width: 10px; text-align: center; color: #7c3aed; font-size: 13px; line-height: 10px; flex-shrink: 0; }

/* ===================== Hover lifts disabled ===================== */
/* A hover translateY moves the element out from under a pointer resting near
   its bottom edge; the hover ends, it drops back, re-hovers, and bounces
   (reported on Chromebooks). Keep the border/shadow feedback, drop the lift. */
.card:hover, .card-button:hover, .home-continue-btn:hover, .badge:hover, .fc-rate-btn:hover,
.option:hover, .sa-question-card:hover, .key-term-chip-clickable:hover, .tool-card:hover,
.save-progress-btn:hover, .fib-mode-btn:hover, .lightning-option:hover, .res-link-btn:hover,
.ach-badge:hover, .lb-podium-place:hover, .welcome-go-btn:hover:not(:disabled), .mq-mode-card:hover,
.sm-choice-btn:hover:not(:disabled), .sm-choice-img-btn:hover:not(:disabled), .sm-result-btn:hover,
.sift-verdict-btn:hover, .tb-level-card:hover, .nudge-card:hover, .cw-map-mode-card:hover {
    transform: none;
}

/* ===================== Chromebook fit (1366x768, ~660px viewport) ========= */
/* Measured on a 1366x660 viewport: Hangman's letter buttons started at
   y=604, Wordle's keyboard at y=677, Flip Match's last row at 718. These keep
   the controls students need on the first screen. */
@media (min-width: 900px) {
    /* Hangman: the 250px figure sits beside the word and letters. Children
       keep the DOM order stats, clue, figure, word, message, letters, button. */
    .hangman-container { max-width: 720px; display: grid; grid-template-columns: 200px 1fr; column-gap: 28px; align-items: center; }
    .hangman-container > * { grid-column: 1 / -1; }
    .hangman-figure { grid-column: 1; grid-row: 3 / span 3; margin: 0; }
    .hangman-word, .hangman-word + div, .hangman-letters { grid-column: 2; }
    .hangman-letters { max-width: 412px; }   /* 9 letters per row: 3 rows, not 4 */
}
@media (max-height: 740px) {
    .hangman-clue, .wordle-clue { padding: 12px 16px; margin-bottom: 12px; }
    .hangman-stats { margin-bottom: 8px; }
    .hangman-word { margin: 10px 0; font-size: 1.6em; }
    .wordle-cell { width: min(38px, calc((100vw - 48px - (var(--wordle-n, 5) - 1) * 4px) / var(--wordle-n, 5))); font-size: 1.2em; }
    .wordle-grid { gap: 4px; margin-bottom: 10px; }
    .wordle-row { gap: 4px; }
    .wordle-key { padding: 7px 10px; min-width: 30px; font-size: 0.85em; }
    .wordle-key.wide { padding: 7px 14px; }
    .wordle-message { margin: 8px 0; padding: 10px; }
    .match-card { height: 100px; }
    .flip-match-controls, .flip-match-stats { margin-bottom: 10px; }
    .tb-level-prompt { padding: 30px 20px; }
}

/* ===================== 13 Colonies: Maddy's Madness Mode ======== */
.cw-map-mode-madness { border-color: rgba(251, 191, 36, 0.45); }
.cw-map-mode-madness .cw-map-mode-icon { color: var(--accent); }
.cw-map-mode-card.locked { opacity: 0.55; cursor: not-allowed; }
.cw-map-mode-card.locked:hover { border-color: var(--border-card); }
.cw-map-best-madness { margin-left: 8px; color: var(--accent-text); }
.cw-map-timer { font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.cw-map-results-madness { border-color: rgba(251, 191, 36, 0.6); color: var(--accent-text); }
/* No 300ms tap delay or double-tap zoom on the map: taps register immediately. */
.fs-map-svg { touch-action: manipulation; }
/* Madness runs go full screen; the map takes the whole display. */
#activity-container:fullscreen { background: var(--bg-deep); padding: 12px 16px; overflow: auto; }
#activity-container:fullscreen .fs-map-svg { height: calc(100vh - 48px); max-height: none; }

/* ===================== Feedback FAB & Modal ===================== */
.feedback-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--bg-elevated);
    border: 2px solid var(--border-card);
    color: var(--text-secondary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1em;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    z-index: 1100;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.feedback-fab:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: scale(1.08);
}
body.light-mode .feedback-fab {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.feedback-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.feedback-modal-card {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
}
.feedback-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-card);
}
.feedback-modal-header h3 {
    margin: 0;
    font-size: 1.05em;
}
.feedback-modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1em;
    cursor: pointer;
    padding: 4px 8px;
}
.feedback-modal-close:hover { color: var(--text-primary); }

.feedback-modal-body { padding: 18px; }

.feedback-type-group {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}
.feedback-type-option {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border-card);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-size: 0.95em;
}
.feedback-type-option input { margin: 0; }
.feedback-type-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(0,0,0,0.04);
}
.feedback-type-option i { color: var(--primary-text); }

.feedback-field-label {
    display: block;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin: 10px 0 4px;
}
.feedback-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--border-card);
    border-radius: 6px;
    background: var(--bg-base, var(--bg-elevated));
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95em;
    resize: vertical;
}
.feedback-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.feedback-status {
    min-height: 1.2em;
    margin: 10px 0 6px;
    font-size: 0.9em;
    color: var(--text-secondary);
}
.feedback-status-error { color: #c0392b; }
.feedback-status-success { color: #2f855a; }

.feedback-submit-btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s;
}
.feedback-submit-btn:hover { transform: scale(1.02); }

/* ===========================================================================
   RESPONSE BUILDER — guided short-answer wizard (Option-A top stepper)
   Namespaced .rb-*. Launched hidden from the Short Answer activity.
   =========================================================================== */
.rb-screen {
    max-width: 920px;
    margin: 0 auto;
}

/* --- Top stepper --------------------------------------------------------- */
.rb-steps {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-card);
}
.rb-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    text-align: center;
}
/* connector line between dots */
.rb-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 14px;
    left: calc(50% + 18px);
    right: calc(-50% + 18px);
    height: 2px;
    background: var(--border-card);
}
.rb-done:not(:last-child)::after {
    background: var(--success);
}
.rb-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    font-weight: 700;
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 2px solid var(--border-card);
    position: relative;
    z-index: 1;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.rb-active .rb-dot {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.rb-done .rb-dot {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.rb-step-label {
    font-size: 0.78em;
    color: var(--text-muted);
    line-height: 1.3;
    max-width: 13ch;
}
.rb-active .rb-step-label {
    color: var(--text-primary);
    font-weight: 600;
}
.rb-done .rb-step-label {
    color: var(--text-secondary);
}

/* --- Pinned question context --------------------------------------------- */
.rb-q-context {
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 24px;
}
.rb-q-label {
    font-size: 0.72em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-text);
    font-weight: 700;
    margin-bottom: 4px;
}
.rb-q-text {
    color: var(--text-primary);
    font-size: 1em;
    font-weight: 600;
    line-height: 1.5;
}

/* --- Step body ----------------------------------------------------------- */
.rb-step-body {
    min-height: 220px;
    animation: slideDown 0.2s ease;
}
.rb-h {
    color: var(--text-primary);
    font-size: 1.25em;
    font-weight: 700;
    font-family: var(--font-heading);
    margin-bottom: 8px;
}
.rb-sub {
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.5;
    margin-bottom: 18px;
}

/* --- Step 1: Unpack ------------------------------------------------------ */
.rb-unpack-q {
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    color: var(--text-primary);
    font-size: 1.02em;
    font-weight: 600;
    line-height: 1.55;
    margin-bottom: 22px;
}
.rb-restate-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.92em;
    font-weight: 600;
    margin-bottom: 8px;
}
.rb-restate {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 2px solid var(--border-card);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.98em;
    line-height: 1.5;
    resize: vertical;
    background: var(--bg-surface);
    color: var(--text-primary);
}
.rb-restate:focus {
    outline: none;
    border-color: var(--primary);
}

/* --- Step 2: Read -------------------------------------------------------- */
.rb-read-title {
    color: var(--primary-text);
    font-size: 1.05em;
    font-weight: 700;
    margin-bottom: 12px;
}
.rb-read-passage {
    max-width: 70ch;
    line-height: 1.75;
    font-size: 1em;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    white-space: pre-wrap;
}
.rb-read-fallback {
    color: var(--text-secondary);
    font-size: 0.98em;
    line-height: 1.6;
    background: var(--bg-surface);
    border: 1px dashed var(--border-card);
    border-radius: var(--radius-md);
    padding: 18px 20px;
}

/* --- Step 3: Terms ------------------------------------------------------- */
.rb-term-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.rb-term-chip {
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.92em;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.rb-term-chip:hover {
    border-color: var(--primary);
    color: var(--primary-text);
}
.rb-term-chip-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.rb-term-chip-active:hover {
    color: #fff;
}
.rb-term-details {
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 16px 18px;
}

/* --- Step 5: Draft ------------------------------------------------------- */
.rb-draft-cols {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 20px;
    align-items: start;
}
.rb-draft-outline {
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 16px;
}
.rb-outline-title {
    font-size: 0.8em;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 12px;
}
.rb-outline-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-elevated);
    border-left: 4px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 0.92em;
    line-height: 1.5;
}
.rb-outline-claim { border-left-color: var(--primary); }
.rb-outline-evidence { border-left-color: var(--success); }
.rb-outline-reasoning { border-left-color: var(--accent); }
.rb-outline-role {
    font-size: 0.7em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
}
.rb-draft-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.rb-draft-text {
    width: 100%;
    box-sizing: border-box;
    min-height: 240px;
    padding: 14px 16px;
    border: 2px solid var(--border-card);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 1em;
    line-height: 1.6;
    resize: vertical;
    background: var(--bg-surface);
    color: var(--text-primary);
}
.rb-draft-text:focus {
    outline: none;
    border-color: var(--primary);
}
.rb-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.rb-starter {
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    color: var(--text-secondary);
    padding: 7px 13px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.85em;
    font-style: italic;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.rb-starter:hover {
    border-color: var(--primary);
    color: var(--primary-text);
}

/* --- Nav ----------------------------------------------------------------- */
.rb-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--border-card);
}
.rb-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, opacity 0.15s;
}
.rb-btn:hover {
    border-color: var(--primary);
    color: var(--primary-text);
}
.rb-btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.rb-btn-primary:hover {
    color: #fff;
    opacity: 0.88;
}
.rb-btn-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- Responsive: laptop/Chromebook + narrow widths ---------------------- */
@media (max-width: 760px) {
    /* Draft view: stack the plan and the textarea so neither is squeezed */
    .rb-draft-cols {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 600px) {
    /* Keep the stepper from overflowing: shrink labels and stop them wrapping */
    .rb-steps {
        gap: 4px;
    }
    .rb-step-label {
        font-size: 0.66em;
        max-width: 9ch;
    }
}

/* --- Step 4: Claim / Evidence / Reasoning plan builder ------------------- */
.rb-cer-skel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 18px 0 6px;
}
.rb-cer-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px;
    align-items: stretch;
}
.rb-cer-role {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    padding: 10px 8px;
    border-radius: var(--radius-md);
    color: #fff;
    font-weight: 700;
    font-size: 0.92em;
    letter-spacing: 0.4px;
}
.rb-cer-role-claim { background: var(--primary-bold); }
.rb-cer-role-evidence { background: #1a6b43; } /* deep green: white text on light --success (#34d399) is only ~1.6:1; this is ~5.8:1 (WCAG AA) */
.rb-cer-role-reasoning { background: var(--secondary); }
.rb-cer-role-hint {
    font-weight: 500;
    font-size: 0.78em;
    line-height: 1.25;
    opacity: 0.92;
    letter-spacing: 0;
}
.rb-cer-drop {
    display: flex;
    align-items: center;
    min-height: 58px;
    padding: 12px 16px;
    border: 2px dashed var(--border-card);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.rb-cer-drop:hover {
    border-color: var(--primary);
}
.rb-cer-drop-filled {
    border-style: solid;
    border-color: var(--border-card);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: default;
}
.rb-cer-drop-correct {
    border-color: var(--success);
    background: rgba(52, 211, 153, 0.12);
}
.rb-cer-drop-shake {
    border-style: solid;
    border-color: var(--danger);
    background: rgba(248, 113, 113, 0.12);
    animation: rb-shake 0.42s ease;
}
@keyframes rb-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-7px); }
    80% { transform: translateX(7px); }
}
.rb-coach {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 4px 0 14px;
    padding: 12px 16px;
    border: 1px solid var(--danger);
    background: rgba(248, 113, 113, 0.1);
    border-radius: var(--radius-md);
}
.rb-coach-ic {
    font-size: 1.3em;
    line-height: 1.3;
}
.rb-coach-txt {
    color: var(--text-primary);
    font-size: 0.95em;
    line-height: 1.5;
}
.rb-pool-h {
    margin: 6px 0 8px;
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
}
.rb-pool {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rb-pool-chip {
    width: 100%;
    text-align: left;
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.95em;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.rb-pool-chip:hover {
    border-color: var(--primary);
}
.rb-pool-chip-picked {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}
.rb-pool-chip-placed {
    opacity: 0.4;
    text-decoration: line-through;
    cursor: not-allowed;
    pointer-events: none;
}
@media (max-width: 600px) {
    /* Narrow widths: let the role box shrink so the dropzone keeps room */
    .rb-cer-row {
        grid-template-columns: 96px 1fr;
        gap: 8px;
    }
    .rb-cer-role {
        font-size: 0.82em;
        padding: 8px 5px;
    }
    .rb-cer-role-hint {
        font-size: 0.7em;
    }
}

/* Short answer / response builder: where to find the evidence */
.sa-look-at { margin: 8px 0 14px; padding: 10px 14px; border-left: 3px solid var(--accent, #B8893B); background: var(--bg-surface); border-radius: 6px; color: var(--text-primary); font-size: 0.95em; line-height: 1.45; }
.sa-look-at strong { color: var(--accent, #B8893B); }

/* Maps hub: still maps (handout and primary-source maps) */
.map-still { max-width: 980px; margin: 0 auto; padding: 8px 4px 24px; }
.map-still h2 { margin: 8px 0 12px; color: var(--text-primary); }
.map-still-back { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-weight: 600; padding: 6px 0; font-family: var(--font-body); }
.map-still figure { margin: 0; }
.map-still img { width: 100%; height: auto; border-radius: 10px; display: block; background: #fff; }
.map-still figcaption { margin-top: 8px; color: var(--text-secondary); font-size: 0.9em; line-height: 1.4; }
.map-still-credit { font-style: italic; opacity: 0.85; }
.map-still-q { margin-top: 16px; padding: 14px 16px; border-left: 3px solid var(--accent, #B8893B); background: var(--bg-surface); border-radius: 8px; line-height: 1.5; color: var(--text-primary); }
.map-still-qtext { font-weight: 700; margin-bottom: 6px; }
.map-still-q strong { color: var(--accent, #B8893B); }

/* ---- Read aloud (textbook Listen) ---- */
.tb-listen { margin: -4px 0 14px; }
.ra-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ra-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ra-btn {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 36px; padding: 6px 12px;
    border: 1px solid var(--border, rgba(127,127,127,0.35)); border-radius: 8px;
    background: var(--bg-card, transparent); color: var(--text-primary);
    font: inherit; font-size: 0.9em; font-weight: 600; cursor: pointer;
}
.ra-btn:hover, .ra-btn:focus-visible { border-color: var(--primary); }
.ra-listen { background: var(--primary); border-color: var(--primary); color: #fff; }
.ra-speed {
    min-height: 36px; padding: 4px 8px; border-radius: 8px;
    border: 1px solid var(--border, rgba(127,127,127,0.35));
    background: var(--bg-card, transparent); color: var(--text-primary); font: inherit; font-size: 0.9em;
}
::highlight(ra-sent) { background-color: #ffd54f; color: #1a1a1a; }
.ra-cur { background: #ffd54f; color: #1a1a1a; border-radius: 4px; }
