/* ========== MAP Test Practice Mode Styles ========== */
/* Phase 1B scaffolding. Real layout polish lands in Phase 2. */
/* Visual grammar follows quiz-mode.css and skills-organizer.css. */

/* ---- Home-view launch buttons (chunky 3D tiles) ---- */
.map-launch-btn {
    padding: 16px 28px;
    font-size: 1.1rem;
    font-weight: 900;
    border: 2px solid var(--mq-rule);
    border-radius: var(--mq-r-md);
    background: var(--mq-paper);
    color: var(--mq-ink);
    cursor: pointer;
    box-shadow: 0 4px 0 0 var(--mq-rule);
    transition: transform 80ms ease, box-shadow 80ms ease, border-color 80ms ease;
}

.map-launch-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 0 0 var(--mq-rule);
}

.map-launch-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 0 var(--mq-rule);
}

.map-launch-k2 {
    border-color: var(--mq-teal);
    color: var(--mq-teal-d);
    box-shadow: 0 4px 0 0 var(--mq-teal);
    background: linear-gradient(180deg, #FFFFFF 0%, rgba(45, 212, 191, 0.10) 100%);
}
.map-launch-k2:hover { box-shadow: 0 5px 0 0 var(--mq-teal); }
.map-launch-k2:active { box-shadow: 0 2px 0 0 var(--mq-teal); }

.map-launch-35 {
    border-color: var(--mq-orange-d);
    color: var(--mq-orange-d);
    box-shadow: 0 4px 0 0 var(--mq-orange-d);
    background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 138, 61, 0.10) 100%);
}
.map-launch-35:hover { box-shadow: 0 5px 0 0 var(--mq-orange-d); }
.map-launch-35:active { box-shadow: 0 2px 0 0 var(--mq-orange-d); }

.map-launch-mixed {
    border-color: var(--mq-purple-d);
    color: var(--mq-purple);
    box-shadow: 0 4px 0 0 var(--mq-purple-d);
    background: linear-gradient(180deg, #FFFFFF 0%, var(--mq-purple-soft) 100%);
}
.map-launch-mixed:hover { box-shadow: 0 5px 0 0 var(--mq-purple-d); }
.map-launch-mixed:active { box-shadow: 0 2px 0 0 var(--mq-purple-d); }

/* ---- Top-nav MAP launcher dropdown ---- */
.map-nav-wrap {
    position: relative;
    display: inline-flex;
}

.map-nav-btn {
    background: var(--mq-purple) !important;
    color: #fff !important;
    border: 2px solid var(--mq-purple-d) !important;
    font-weight: 800;
    box-shadow: 0 3px 0 0 var(--mq-purple-d);
    transition: transform 80ms ease, box-shadow 80ms ease;
}

.map-nav-btn:hover {
    box-shadow: 0 4px 0 0 var(--mq-purple-d);
    transform: translateY(-1px);
}
.map-nav-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 0 var(--mq-purple-d);
}

.map-nav-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: var(--mq-paper);
    border: 2px solid var(--mq-rule);
    border-radius: var(--mq-r-md);
    box-shadow: var(--mq-shadow-card);
    z-index: 1000;
    min-width: 168px;
}

.map-nav-wrap.open .map-nav-menu {
    display: flex;
}

.map-nav-wrap.open .nav-bubble-tip {
    display: none !important;
}

.map-nav-menu button {
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--mq-ink);
    background: var(--mq-paper);
    border: 2px solid var(--mq-rule);
    border-radius: var(--mq-r-sm);
    cursor: pointer;
    text-align: left;
    box-shadow: 0 2px 0 0 var(--mq-rule);
    transition: transform 80ms ease, box-shadow 80ms ease, border-color 80ms ease;
}

.map-nav-menu button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 0 0 var(--mq-rule-2);
}
.map-nav-menu button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 0 var(--mq-rule);
}

.map-nav-menu .map-nav-k2 {
    border-color: var(--mq-teal);
    color: var(--mq-teal-d);
    box-shadow: 0 2px 0 0 var(--mq-teal);
    background: linear-gradient(180deg, #FFFFFF 0%, rgba(45, 212, 191, 0.08) 100%);
}
.map-nav-menu .map-nav-k2:hover { box-shadow: 0 3px 0 0 var(--mq-teal); }

.map-nav-menu .map-nav-35 {
    border-color: var(--mq-orange-d);
    color: var(--mq-orange-d);
    box-shadow: 0 2px 0 0 var(--mq-orange-d);
    background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 138, 61, 0.08) 100%);
}
.map-nav-menu .map-nav-35:hover { box-shadow: 0 3px 0 0 var(--mq-orange-d); }

.map-nav-menu .map-nav-mixed {
    border-color: var(--mq-purple);
    color: var(--mq-purple);
    box-shadow: 0 2px 0 0 var(--mq-purple);
    background: linear-gradient(180deg, #FFFFFF 0%, var(--mq-purple-soft) 100%);
}
.map-nav-menu .map-nav-mixed:hover { box-shadow: 0 3px 0 0 var(--mq-purple); }

/* ---- Selector view ---- */
.map-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 22px;
    background: var(--mq-paper);
    border: 2px solid var(--mq-rule);
    border-bottom: 2px solid var(--mq-rule);
    border-radius: var(--mq-r-lg) var(--mq-r-lg) 0 0;
    box-shadow: var(--mq-shadow-rule);
}

.map-header h2 {
    margin: 0;
    flex: 1;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--mq-ink);
    letter-spacing: -0.01em;
}

.map-header .back-btn {
    padding: 8px 16px;
    border-radius: var(--mq-r-sm);
    border: 2px solid var(--mq-rule);
    background: var(--mq-paper);
    color: var(--mq-ink-2);
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 2px 0 0 var(--mq-rule);
    transition: transform 80ms ease, box-shadow 80ms ease, border-color 80ms ease, color 80ms ease;
}

.map-header .back-btn:hover {
    border-color: var(--mq-purple-l);
    color: var(--mq-purple);
    box-shadow: 0 2px 0 0 var(--mq-purple-l);
    transform: translateY(-1px);
}

.map-tier-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 32px;
    max-width: 900px;
    margin: 0 auto;
}

.map-tier-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px 28px;
    border-radius: var(--mq-r-xl);
    border: 2px solid var(--mq-rule);
    background: var(--mq-paper);
    cursor: pointer;
    color: var(--mq-ink);
    box-shadow: 0 5px 0 0 var(--mq-rule);
    transition: transform 80ms ease, box-shadow 80ms ease, border-color 80ms ease;
}

.map-tier-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 0 var(--mq-rule-2);
}
.map-tier-card:active {
    transform: translateY(2px);
    box-shadow: 0 3px 0 0 var(--mq-rule);
}

.map-tier-k2 {
    border-color: var(--mq-teal);
    box-shadow: 0 5px 0 0 var(--mq-teal);
    background: linear-gradient(180deg, #FFFFFF 0%, rgba(45, 212, 191, 0.10) 100%);
}
.map-tier-k2:hover { box-shadow: 0 6px 0 0 var(--mq-teal); }

.map-tier-35 {
    border-color: var(--mq-orange-d);
    box-shadow: 0 5px 0 0 var(--mq-orange-d);
    background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 138, 61, 0.10) 100%);
}
.map-tier-35:hover { box-shadow: 0 6px 0 0 var(--mq-orange-d); }

.tier-icon {
    font-size: 2.6rem;
}

.tier-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--mq-ink);
    letter-spacing: -0.01em;
}

.tier-sub {
    font-size: 0.9rem;
    color: var(--mq-muted);
    font-weight: 700;
}

.map-section {
    padding: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

.map-section h3 {
    margin: 0 0 12px;
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--mq-ink);
    letter-spacing: -0.01em;
}

.rit-chip-grid,
.domain-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.rit-chip,
.domain-chip {
    padding: 8px 16px;
    border-radius: 999px;
    border: 2px solid var(--mq-rule);
    background: var(--mq-paper);
    color: var(--mq-ink-2);
    cursor: pointer;
    font-weight: 800;
    font-size: 0.88rem;
    box-shadow: 0 2px 0 0 var(--mq-rule);
    transition: transform 80ms ease, box-shadow 80ms ease, border-color 80ms ease, color 80ms ease, background 80ms ease;
}

.rit-chip:hover,
.domain-chip:hover {
    border-color: var(--mq-purple-l);
    color: var(--mq-purple);
    box-shadow: 0 3px 0 0 var(--mq-purple-l);
    transform: translateY(-1px);
}

.rit-chip:active,
.domain-chip:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 0 var(--mq-rule);
}

.rit-chip.selected,
.domain-chip.selected {
    background: var(--mq-purple-soft);
    color: var(--mq-purple);
    border-color: var(--mq-purple);
    box-shadow: 0 2px 0 0 var(--mq-purple);
}

.rit-chip .chip-count {
    font-weight: 800;
    color: var(--mq-muted);
    background: var(--mq-rule);
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
    font-size: 0.72rem;
}
.rit-chip.selected .chip-count {
    background: var(--mq-purple);
    color: #fff;
}

.map-mode-toggle {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.map-mode-toggle button {
    flex: 1;
    min-width: 140px;
    padding: 16px 14px;
    border-radius: var(--mq-r-md);
    border: 2px solid var(--mq-rule);
    background: var(--mq-paper);
    color: var(--mq-ink);
    cursor: pointer;
    font-weight: 800;
    font-size: 0.95rem;
    box-shadow: 0 3px 0 0 var(--mq-rule);
    transition: transform 80ms ease, box-shadow 80ms ease, border-color 80ms ease, background 80ms ease, color 80ms ease;
}

.map-mode-toggle button > span {
    display: inline-block;
    margin-top: 4px;
    font-weight: 700;
    color: var(--mq-muted);
    font-size: 0.78rem;
}

.map-mode-toggle button:hover {
    transform: translateY(-1px);
    border-color: var(--mq-purple-l);
    box-shadow: 0 4px 0 0 var(--mq-purple-l);
}

.map-mode-toggle button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 0 var(--mq-rule);
}

.map-mode-toggle button.selected {
    background: var(--mq-purple-soft);
    color: var(--mq-purple);
    border-color: var(--mq-purple);
    box-shadow: 0 3px 0 0 var(--mq-purple);
}
.map-mode-toggle button.selected > span {
    color: var(--mq-purple);
    opacity: 0.85;
}

/* ---- Session view ---- */
.map-session-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(90deg, rgba(38, 198, 218, 0.1), rgba(255, 159, 28, 0.1));
    border-bottom: 2px solid rgba(0, 0, 0, 0.06);
    font-weight: 600;
}

.map-mode-tag {
    padding: 4px 10px;
    border-radius: 6px;
    background: #1565c0;
    color: #fff;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.map-mode-tag.simulation {
    background: #7b1fa2;
}

.map-mode-tag.practice {
    background: #4caf50;
}

/* ---- MAP question navigator (dots strip + back/forward) ---- */
.map-nav-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.map-nav-dots {
    display: flex;
    flex: 1;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}
.map-nav-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e0e0e0;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform .1s;
    padding: 0;
}
.map-nav-dot:hover { transform: scale(1.2); }
.map-nav-dot.correct { background: #4caf50; }
.map-nav-dot.wrong { background: #f44336; }
.map-nav-dot.unanswered { background: #e0e0e0; }
.map-nav-dot.current { border-color: #1565c0; transform: scale(1.3); }
.map-nav-arrow {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1565c0;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
}
.map-nav-arrow:disabled {
    background: #bdbdbd;
    cursor: not-allowed;
}
.map-nav-arrow:hover:not(:disabled) { background: #0d47a1; }

.map-review-banner {
    background: #fff3cd;
    padding: 8px 16px;
    text-align: center;
    border-bottom: 1px solid #ffe082;
    font-weight: 600;
    color: #6d4c00;
}
.map-review-banner button {
    margin-left: 12px;
    padding: 6px 14px;
    background: #1565c0;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

.dark .map-nav-bar { background: rgba(30, 30, 30, 0.95); border-bottom-color: rgba(255, 255, 255, 0.08); }
.dark .map-nav-dot { background: #555; }
.dark .map-nav-dot.unanswered { background: #555; }
.dark .map-review-banner { background: #3a2e0a; color: #ffd54f; border-bottom-color: #6d4c00; }

/* ---- Results view ---- */
.rit-summary {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
    padding: 32px;
    max-width: 1100px;
    margin: 0 auto;
}

.rit-overall {
    padding: 32px;
    border-radius: 24px;
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    color: #fff;
    text-align: center;
}

.rit-label {
    font-size: 0.95rem;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.rit-value {
    font-size: 5rem;
    font-weight: 900;
    margin: 8px 0;
}

.rit-band {
    font-size: 1.1rem;
    opacity: 0.9;
}

.rit-domains {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.rit-domain-card {
    padding: 16px;
    border-radius: 12px;
    background: #f5f5f5;
}

.rit-domain-card .dname {
    font-weight: 700;
}

.rit-domain-card .drit {
    font-size: 1.6rem;
    font-weight: 800;
}

.rit-ready {
    padding: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

.rit-ready h3 {
    margin: 0 0 12px;
}

.ready-cols {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.ready-col h4 {
    margin: 0 0 8px;
    padding: 8px;
    border-radius: 6px;
    color: #fff;
    text-align: center;
}

.ready-col.reinforce h4 {
    background: #ff9800;
}

.ready-col.develop h4 {
    background: #4caf50;
}

.ready-col.introduce h4 {
    background: #1e88e5;
}

.rit-actions {
    display: flex;
    gap: 12px;
    padding: 24px;
    max-width: 1100px;
    margin: 0 auto;
    justify-content: center;
    flex-wrap: wrap;
}

.rit-actions .primary-btn {
    padding: 14px 28px;
    background: #1565c0;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

.rit-actions .secondary-btn {
    padding: 14px 28px;
    background: #fff;
    color: #1565c0;
    border: 2px solid #1565c0;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

/* ---- Dark mode (tokens already remap; only override colors that don't) ---- */
.dark .rit-chip,
.dark .domain-chip,
.dark .map-mode-toggle button {
    background: var(--mq-paper);
    color: var(--mq-ink-2);
    border-color: var(--mq-rule);
}

.dark .rit-chip.selected,
.dark .domain-chip.selected,
.dark .map-mode-toggle button.selected {
    background: rgba(124, 92, 230, 0.18);
    color: var(--mq-purple-l);
    border-color: var(--mq-purple-l);
    box-shadow: 0 2px 0 0 var(--mq-purple-l);
}
.dark .rit-chip.selected .chip-count {
    background: var(--mq-purple-l);
    color: var(--mq-ink);
}

.dark .rit-domain-card {
    background: #2a2a2a;
    color: #eee;
}

.dark .rit-actions .secondary-btn {
    background: transparent;
    color: #64b5f6;
    border-color: #64b5f6;
}

/* ===== Multi-select check widget ===== */
.msc-grid {
    display: grid;
    /* min 180px gives long labels (e.g. "Pentagonal Bipyramid") room to breathe
       on a single line; auto-fit lets short labels still pack tightly. */
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px 0;
}
.msc-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    min-height: 48px;
    transition: all .15s;
    color: #222;
    text-align: left;
    /* Long labels wrap at word boundaries; only break a word as a last resort
       so we never see ugly "Pentagona/l Bipyrami/d" splits. */
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.25;
}
.msc-opt .msc-label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
}
.msc-opt:hover:not(:disabled) {
    border-color: #1565c0;
    transform: translateY(-1px);
}
.msc-opt:disabled {
    cursor: default;
}
.msc-opt.selected {
    background: #e3f2fd;
    border-color: #1565c0;
}
.msc-opt.selected .msc-mark::before { content: '\2611'; }
.msc-opt .msc-mark {
    font-size: 1.4rem;
    line-height: 1;
}
.msc-opt .msc-mark::before { content: '\2610'; }
.msc-opt .msc-image {
    max-width: 64px;
    max-height: 64px;
    object-fit: contain;
}
.msc-opt .msc-visual svg {
    max-width: 64px;
    max-height: 64px;
    pointer-events: none;
}
.msc-opt .msc-visual svg * {
    pointer-events: none;
}
.msc-counter {
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 8px;
    font-weight: 600;
    color: #555;
    display: inline-block;
}
.msc-submit {
    margin-top: 16px;
    padding: 14px 32px;
    background: #1565c0;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
}
.msc-submit:disabled {
    background: #bbb;
    cursor: not-allowed;
}
.msc-opt.large {
    min-height: 64px;
    font-size: 1.15rem;
}
.dark .msc-opt {
    background: #2a2a2a;
    color: #eee;
    border-color: rgba(255, 255, 255, 0.2);
}
.dark .msc-opt.selected {
    background: rgba(21, 101, 192, 0.3);
}
.dark .msc-counter {
    background: #2a2a2a;
    color: #ccc;
}
.msc-opt.correct-flash {
    background: #c8e6c9;
    border-color: #2e7d32;
}
.msc-opt.wrong-flash {
    background: #ffcdd2;
    border-color: #c62828;
}
/* Locked-correct: a correct selection that the student got on a partial-correct
   submit. Stays green for the rest of the question; can't be deselected. */
.msc-opt.locked-correct,
.msc-opt.locked-correct.selected {
    background: #2e7d32;
    border-color: #1b5e20;
    color: #fff;
    cursor: default;
    position: relative;
    box-shadow: 0 2px 6px rgba(46, 125, 50, 0.3);
}
.msc-opt.locked-correct:hover {
    border-color: #1b5e20;
    transform: none;
}
.msc-opt.locked-correct .msc-mark::before { content: '\2611'; color: #fff; }
.msc-opt.locked-correct::after {
    content: '\2713';
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
}
.dark .msc-opt.locked-correct,
.dark .msc-opt.locked-correct.selected {
    background: #1b5e20;
    border-color: #0d3d12;
    color: #fff;
}
/* Persistent wrong: a tile the student selected that was incorrect.
   Stays red on the grid after submit so the student can SEE which pick
   was wrong; clears as soon as they click the tile (re-evaluating). */
.msc-opt.wrong-persistent {
    background: #ffcdd2;
    border-color: #c62828;
    color: #b71c1c;
}
.dark .msc-opt.wrong-persistent {
    background: rgba(198, 40, 40, 0.35);
    border-color: #c62828;
    color: #ffcdd2;
}
/* Missed-correct: a tile the student should have selected but didn't.
   Amber/yellow so it reads as "you missed this" rather than "wrong." */
.msc-opt.missed-correct {
    background: #fff3cd;
    border-color: #f9a825;
    color: #6d4c00;
    position: relative;
}
.msc-opt.missed-correct::after {
    content: 'missed';
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #6d4c00;
    background: rgba(249, 168, 37, 0.25);
    border-radius: 4px;
    padding: 1px 6px;
}
.dark .msc-opt.missed-correct {
    background: rgba(249, 168, 37, 0.25);
    border-color: #f9a825;
    color: #ffe082;
}
.dark .msc-opt.missed-correct::after {
    color: #ffe082;
    background: rgba(249, 168, 37, 0.35);
}

/* ===== Ten-frame widget ===== */
.tf-frame {
    display: inline-grid;
    gap: 4px;
    padding: 12px;
    background: #fafafa;
    border: 2px solid #999;
    border-radius: 8px;
    margin: 12px auto;
}
.tf-frame.tf-10 {
    grid-template-columns: repeat(5, 60px);
    grid-template-rows: repeat(2, 60px);
}
.tf-frame.tf-20 {
    grid-template-columns: repeat(5, 60px);
    grid-template-rows: repeat(4, 60px);
}
.tf-cell {
    width: 60px;
    height: 60px;
    background: #fff;
    border: 2px solid #777;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    padding: 0;
}
.tf-cell:hover { background: #f0f0f0; }
.tf-cell.filled {
    background: #1976d2;
    border-color: #0d47a1;
}
.tf-cell.filled::after {
    content: '\25CF';
    color: #fff;
    font-size: 2.4rem;
    line-height: 1;
}
.tf-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin: 8px 0;
}
.tf-btn {
    padding: 10px 16px;
    border: 2px solid #1565c0;
    background: #fff;
    color: #1565c0;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    min-width: 44px;
}
.tf-btn:hover { background: #e3f2fd; }
.tf-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}
.tf-counter {
    display: block;
    text-align: center;
    padding: 8px 14px;
    background: #f5f5f5;
    border-radius: 8px;
    font-weight: 600;
    color: #333;
    font-size: 1.05rem;
    margin: 8px auto;
    max-width: 240px;
}
.tf-submit {
    margin-top: 12px;
    padding: 14px 32px;
    background: #1565c0;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
.tf-submit:disabled {
    background: #bbb;
    cursor: not-allowed;
}
.tf-frame.large.tf-10,
.tf-frame.large.tf-20 {
    grid-template-columns: repeat(5, 72px);
}
.tf-frame.large.tf-10 { grid-template-rows: repeat(2, 72px); }
.tf-frame.large.tf-20 { grid-template-rows: repeat(4, 72px); }
.tf-frame.large .tf-cell {
    width: 72px;
    height: 72px;
}
.tf-cell.correct-flash {
    background: #2e7d32;
    border-color: #1b5e20;
}
.tf-cell.wrong-flash {
    background: #c62828;
    border-color: #b71c1c;
}
.dark .tf-frame {
    background: #1f1f1f;
    border-color: #555;
}
.dark .tf-cell {
    background: #2a2a2a;
    border-color: #555;
}
.dark .tf-counter {
    background: #2a2a2a;
    color: #ddd;
}
.dark .tf-btn {
    background: transparent;
    color: #64b5f6;
    border-color: #64b5f6;
}

/* ===== dnd-generic widget (order + categorize modes) ===== */
.dnd-host { padding: 16px 0; position: relative; }
.dnd-prompt { margin-bottom: 12px; font-weight: 600; }
.dnd-hint { color: #666; font-size: 0.9rem; margin-bottom: 8px; font-style: italic; }
.dnd-order-caption { font-size: 0.95rem; color: #1565c0; margin-bottom: 6px; font-weight: 600; }
.dnd-tiles-tray {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 12px; background: #f5f5f5;
    border-radius: 8px; min-height: 60px;
    margin-bottom: 16px;
}
.dnd-tiles-tray.over { background: #e8f5e9; outline: 2px dashed #2e7d32; }
.dnd-tile {
    padding: 12px 16px; background: #fff;
    border: 2px solid #1565c0; border-radius: 8px;
    cursor: grab; font-weight: 700; font-size: 1.05rem;
    user-select: none; transition: all .15s;
    min-width: 56px; max-width: 100%;
    text-align: center;
    color: #1565c0;
    /* Long labels wrap at word boundaries inside the tile rather than
       overflowing the tray or breaking mid-word. */
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.2;
}
.dnd-tile:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.dnd-tile:focus { outline: 3px solid #ffd54f; outline-offset: 2px; }
.dnd-tile:active { cursor: grabbing; }
.dnd-tile.tile-active { background: #ffeb3b; border-color: #f9a825; color: #6d4c00; }
/* Shape-match click-then-click selection ring (additive to the yellow active
   background — gives a stronger, more visible cue for the click-to-pick flow). */
.dnd-shape-match-host .dnd-tile[data-selected="1"] {
    outline: 3px solid #1e88e5;
    outline-offset: 2px;
}
.dnd-tile.dragging { opacity: 0.5; }
.dnd-tile.large { padding: 18px 24px; font-size: 1.25rem; min-width: 72px; }
/* Rich tiles render an SVG/HTML payload (clocks, etc.). The tile becomes a
   visual container — strip the default text padding and let the inner SVG/HTML
   define the natural size. The slot still expands to fit. */
.dnd-tile.rich {
    padding: 6px;
    background: #fff;
    border-color: #1565c0;
    color: inherit;
    font-weight: 400;
    line-height: 1;
}
.dnd-tile.rich svg, .dnd-tile.rich > div { display: block; }
.dnd-slot.filled .dnd-tile.rich { padding: 4px; }
/* Order mode */
.dnd-slots {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 12px; background: #fafafa;
    border: 2px dashed #aaa; border-radius: 8px;
    min-height: 76px; align-items: center;
}
.dnd-slot {
    min-width: 80px; min-height: 56px;
    border: 2px dashed #ccc; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; color: #aaa; font-size: 0.85rem;
    transition: all .15s; padding: 4px;
    cursor: pointer;
    /* Allow placed tiles with long labels to expand the slot vertically. */
    height: auto;
    overflow: visible;
}
.dnd-slot:focus { outline: 3px solid #ffd54f; outline-offset: 2px; }
.dnd-slot.over { background: #e3f2fd; border-color: #1565c0; }
.dnd-slot.filled { border-style: solid; background: #fff; color: inherit; }
.dnd-slot.filled .dnd-tile { margin: 0; }
/* Categorize mode */
.dnd-bins {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.dnd-bin {
    padding: 12px; background: #fafafa;
    border: 2px solid #ccc; border-radius: 12px;
    min-height: 100px;
    cursor: pointer;
}
.dnd-bin:focus { outline: 3px solid #ffd54f; outline-offset: 2px; }
.dnd-bin-label {
    font-weight: 700; padding: 4px 8px;
    background: #1565c0; color: #fff;
    border-radius: 6px; display: inline-block;
    margin-bottom: 8px;
}
.dnd-bin.over { background: #e3f2fd; border-color: #1565c0; }
.dnd-bin-tiles {
    display: flex; flex-wrap: wrap; gap: 8px;
    min-height: 50px;
}
.dnd-submit {
    margin-top: 16px; padding: 14px 32px;
    background: #1565c0; color: #fff;
    border: none; border-radius: 12px;
    font-weight: 700; font-size: 1.05rem;
    cursor: pointer; display: block;
    margin-left: auto; margin-right: auto;
}
.dnd-submit:disabled { background: #bbb; cursor: not-allowed; }
.dnd-tile.correct-flash { background: #c8e6c9; border-color: #2e7d32; color: #1b5e20; }
.dnd-tile.wrong-flash { background: #ffcdd2; border-color: #c62828; color: #b71c1c; }

/* ----- Shape-match dnd mode (drag names onto shape figures) ----- */
.dnd-shape-match-host .dnd-shape-bins {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.dnd-shape-match-host .dnd-shape-bin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #fff;
    border: 2px solid #cfd8dc;
    border-radius: 14px;
    min-height: 170px;
}
.dnd-shape-match-host .dnd-shape-bin.over {
    background: #e3f2fd;
    border-color: #1565c0;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
}
.dnd-shape-match-host .dnd-shape-figure {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 110px;
    pointer-events: none;
}
.dnd-shape-match-host .dnd-shape-figure svg { max-width: 100%; max-height: 100%; }
.dnd-shape-match-host .dnd-shape-slot {
    width: 100%;
    min-height: 44px;
    border-top: 2px dashed #b0bec5;
    border-radius: 0 0 10px 10px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    background: #fafafa;
}
.dnd-shape-match-host .dnd-shape-placeholder {
    color: #90a4ae;
    font-size: 0.78rem;
    font-style: italic;
    user-select: none;
}
.dnd-shape-match-host .dnd-shape-tray {
    background: #f1f8e9;
    border: 2px dashed #aed581;
}
.dark .dnd-shape-match-host .dnd-shape-bin {
    background: #2a2a2a;
    border-color: #555;
}
.dark .dnd-shape-match-host .dnd-shape-slot {
    background: #1f1f1f;
    border-top-color: #555;
}
.dark .dnd-shape-match-host .dnd-shape-tray {
    background: #1e2a1e;
    border-color: #558b2f;
}
.dark .dnd-tiles-tray, .dark .dnd-slots, .dark .dnd-bin { background: #2a2a2a; }
.dark .dnd-tile { background: #333; color: #eee; border-color: #64b5f6; }
.dark .dnd-tile.tile-active { background: #f9a825; color: #fff; }
.dark .dnd-prompt { color: #eee; }
.dark .dnd-hint { color: #aaa; }

/* TTS read-aloud icon for dnd tiles + bin labels.
   Small 🔊 button shown next to each tile/bin label so emergent readers
   can have the option spoken to them. Click handler in dnd-generic.js
   stops propagation so it never starts a drag or selects the tile. */
.dnd-tts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-left: 6px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0.45;
    border-radius: 50%;
    transition: opacity 0.15s, background 0.15s, transform 0.1s;
    flex-shrink: 0;
    vertical-align: middle;
    user-select: none;
}
.dnd-tts-btn:hover,
.dnd-tts-btn:focus {
    opacity: 1;
    background: rgba(30, 136, 229, 0.18);
    transform: scale(1.1);
    outline: none;
}
.dnd-tts-btn:focus-visible {
    outline: 2px solid #ffd54f;
    outline-offset: 2px;
}
.dnd-tile-label {
    display: inline-block;
    vertical-align: middle;
}
.dnd-bin-label {
    /* override the inline-block above to lay the label + TTS icon out as a row */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.dark .dnd-tts-btn:hover,
.dark .dnd-tts-btn:focus {
    background: rgba(100, 181, 246, 0.25);
}

/* ===== Hot-spot widget (Phase 4 P0 #4) ===== */
.hs-host { padding: 16px 0; }
.hs-stage { position: relative; display: inline-block; max-width: 100%; }
.hs-bg-wrap { display: inline-block; max-width: 100%; }
.hs-bg-wrap > svg { display: block; max-width: 100%; height: auto; }
.hs-bg { display: block; max-width: 100%; height: auto; }
.hs-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.hs-overlay > * { pointer-events: auto; cursor: pointer; transition: fill .15s, stroke .15s; outline: none; }
.hs-overlay > *:focus { stroke: #1565c0 !important; stroke-width: 4 !important; }
.hs-overlay > *.hs-region:hover { fill: rgba(255, 235, 59, 0.3); stroke: #f9a825; stroke-width: 3; }
.hs-overlay > *.hs-region.selected { fill: rgba(76, 175, 80, 0.4) !important; stroke: #2e7d32 !important; stroke-width: 3 !important; }
.hs-overlay > *.hs-region.correct-flash { fill: rgba(46, 125, 50, 0.5) !important; stroke: #1b5e20 !important; }
.hs-overlay > *.hs-region.wrong-flash { fill: rgba(198, 40, 40, 0.5) !important; stroke: #b71c1c !important; }
.hs-counter { padding: 8px 14px; background: #f5f5f5; border-radius: 8px; font-weight: 600; color: #333; display: inline-block; margin: 8px 0; }
.hs-submit { margin-top: 16px; padding: 14px 32px; background: #1565c0; color: #fff; border: none; border-radius: 12px; font-weight: 700; font-size: 1.05rem; cursor: pointer; display: block; margin-left: auto; margin-right: auto; }
.hs-submit:disabled { background: #bbb; cursor: not-allowed; }
.hs-host.large .hs-submit { padding: 18px 40px; font-size: 1.2rem; }
.dark .hs-counter { background: #2a2a2a; color: #ccc; }

/* ===== Place-Symmetry-Lines widget ===== */
.psl-host { padding: 16px 0; text-align: center; }
.psl-stage { display: inline-block; max-width: 100%; }
.psl-svg { display: block; max-width: 360px; width: 100%; height: auto; margin: 0 auto; overflow: visible; }
.psl-cand { cursor: pointer; outline: none; }
.psl-cand:focus .psl-line { stroke: #1565c0 !important; stroke-width: 3 !important; stroke-dasharray: none !important; }
.psl-cand:hover .psl-line { stroke: #f9a825; stroke-width: 2.5; }
.psl-cand.selected .psl-line { stroke: #e53935; stroke-width: 3; stroke-dasharray: none; }
.psl-counter { padding: 8px 14px; background: #f5f5f5; border-radius: 8px; font-weight: 600; color: #333; display: inline-block; margin: 8px 0; }
.psl-submit { margin-top: 12px; padding: 14px 32px; background: #1565c0; color: #fff; border: none; border-radius: 12px; font-weight: 700; font-size: 1.05rem; cursor: pointer; display: block; margin-left: auto; margin-right: auto; }
.psl-submit:disabled { background: #bbb; cursor: not-allowed; }
.dark .psl-counter { background: #2a2a2a; color: #ccc; }

/* ===== Numpad-input widget (Phase 4 P0 #5) ===== */
.np-host { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 0; }
.np-display { display: flex; align-items: baseline; gap: 8px; padding: 14px 20px; background: #fff; border: 3px solid #1565c0; border-radius: 12px; min-width: 200px; max-width: 100%; min-height: 56px; justify-content: center; transition: background .15s, border-color .15s; box-sizing: border-box; overflow: hidden; }
.np-display input { font-size: 2rem; font-weight: 700; text-align: center; border: none; outline: none; width: 100%; min-width: 0; max-width: 320px; background: transparent; color: #1565c0; text-overflow: ellipsis; }
/* Shrink the digits when the answer string gets long so multi-digit values
   (5+ chars) never get clipped by the bordered display. */
.np-display input.np-shrink-1 { font-size: 1.6rem; }
.np-display input.np-shrink-2 { font-size: 1.3rem; }
.np-display input.np-shrink-3 { font-size: 1.05rem; letter-spacing: -0.5px; }
.np-display .np-unit { font-size: 1rem; color: #555; font-weight: 600; }
.np-pad { display: grid; grid-template-columns: repeat(4, 64px); gap: 8px; }
.np-btn { width: 64px; height: 64px; background: #fff; border: 2px solid #1565c0; color: #1565c0; border-radius: 12px; font-size: 1.4rem; font-weight: 700; cursor: pointer; transition: all .1s; user-select: none; padding: 0 4px; overflow: hidden; }
/* The action keys (Clr / Submit) need a smaller font so the word fits the
   64px square; otherwise "Submit" gets sliced to "Subm". */
.np-btn.np-clear, .np-btn.np-submit { font-size: 0.95rem; letter-spacing: 0; }
.np-btn.large.np-clear, .np-btn.large.np-submit { font-size: 1.05rem; }
.np-btn:hover { background: #e3f2fd; transform: translateY(-1px); }
.np-btn:active { transform: translateY(1px); }
.np-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.np-btn.np-action { background: #1565c0; color: #fff; }
.np-btn.np-action:hover { background: #1976d2; }
.np-btn.np-submit { grid-column: span 1; background: #2e7d32; color: #fff; border-color: #1b5e20; }
.np-btn.np-submit:hover { background: #388e3c; }
.np-btn.np-clear { background: #ff9800; color: #fff; border-color: #f57c00; }
.np-btn.np-clear:hover { background: #fb8c00; }
.np-btn.large { width: 80px; height: 80px; font-size: 1.6rem; }
.np-pad.large { grid-template-columns: repeat(4, 80px); }
.np-display.flash-correct { border-color: #2e7d32; background: #c8e6c9; }
.np-display.flash-correct input { color: #1b5e20; }
.np-display.flash-wrong { border-color: #c62828; background: #ffcdd2; }
.np-display.flash-wrong input { color: #b71c1c; }
.dark .np-display { background: #2a2a2a; }
.dark .np-display input { color: #64b5f6; }
.dark .np-btn { background: #2a2a2a; color: #64b5f6; border-color: #64b5f6; }
.dark .np-btn:hover { background: #1a3a5a; }

/* Print analog: a labeled answer blank with optional unit */
.np-print { padding: 6px 0; }
.np-print-prompt { font-size: 1rem; margin-bottom: 6px; }
.np-print-blank { font-size: 1.3rem; padding-top: 10px; }
.np-print-unit { color: #555; font-weight: 600; margin-left: 6px; }

/* ============================================================
   number-line-extended widget — Phase 4 P0 widget #6
   ============================================================ */
.nle-host { padding: 16px 0; position: relative; }
.nle-host.large .nle-svg { max-width: 760px; }
.nle-svg { width: 100%; max-width: 640px; height: auto; display: block; margin: 0 auto; touch-action: none; overflow: visible; }
.nle-axis { stroke: #555; stroke-width: 2; }
.nle-tick-major { stroke: #555; stroke-width: 2; }
.nle-tick-minor { stroke: #aaa; stroke-width: 1; }
.nle-tick-label { font-size: 14px; fill: #333; text-anchor: middle; font-family: sans-serif; }
.nle-marker { fill: #1565c0; stroke: #0d47a1; stroke-width: 2; cursor: grab; }
.nle-marker:active { cursor: grabbing; }
.nle-marker:focus { outline: 3px solid #ffeb3b; outline-offset: 2px; }
.nle-marker-label { font-size: 12px; fill: #fff; font-weight: 700; text-anchor: middle; pointer-events: none; }
.nle-marker.correct-flash { fill: #2e7d32; stroke: #1b5e20; }
.nle-marker.wrong-flash { fill: #c62828; stroke: #b71c1c; }
.nle-tray { display: flex; gap: 8px; padding: 12px; background: #f5f5f5; border-radius: 8px; margin: 12px 0; min-height: 60px; align-items: center; justify-content: center; flex-wrap: wrap; }
.nle-tray-item { padding: 8px 14px; background: #fff; border: 2px solid #1565c0; border-radius: 8px; font-weight: 700; cursor: pointer; color: #1565c0; font-size: 1rem; }
.nle-tray-item.selected { background: #1565c0; color: #fff; box-shadow: 0 0 0 3px #ffeb3b; }
.nle-tray-item.placed { opacity: 0.4; cursor: not-allowed; background: #eee; border-color: #aaa; color: #666; }
.nle-instr { color: #666; font-size: 0.9rem; margin: 8px 0; text-align: center; font-style: italic; }
.nle-submit { margin-top: 16px; padding: 14px 32px; background: #1565c0; color: #fff; border: none; border-radius: 12px; font-weight: 700; font-size: 1.05rem; cursor: pointer; display: block; margin-left: auto; margin-right: auto; }
.nle-submit:disabled { background: #bbb; cursor: not-allowed; }
.dark .nle-svg .nle-tick-label { fill: #ddd; }
.dark .nle-tray { background: #2a2a2a; }
.dark .nle-tray-item { background: #333; color: #64b5f6; border-color: #64b5f6; }
.dark .nle-tray-item.selected { background: #64b5f6; color: #1a1a1a; }
.dark .nle-tray-item.placed { background: #1a1a1a; border-color: #555; color: #777; }

/* Print analog */
.nle-print { padding: 6px 0; }
.nle-print-prompt { font-size: 1rem; margin-bottom: 6px; }
.nle-print-instr { font-style: italic; font-weight: 600; color: #555; font-size: 0.85rem; text-align: center; }

/* ============================================================
   Clock-set widget (Phase 6 P1 #1) — interactive analog clock
   ============================================================ */
.cs-host { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 0; position: relative; }
.cs-clock { width: 240px; height: 240px; touch-action: none; overflow: visible; }
.cs-face { fill: #fff; stroke: #333; stroke-width: 4; }
.cs-tick { stroke: #333; }
.cs-tick-major { stroke-width: 3; }
.cs-tick-minor { stroke-width: 1; }
.cs-numeral { font-size: 22px; fill: #333; text-anchor: middle; dominant-baseline: middle; font-weight: 700; font-family: 'Nunito', Arial, sans-serif; }
.cs-hand { stroke-linecap: round; cursor: grab; transition: filter .1s; }
.cs-hand:active { cursor: grabbing; }
.cs-hand:focus { filter: drop-shadow(0 0 4px #ffeb3b); outline: none; }
.cs-hand.cs-hour { stroke: #1565c0; stroke-width: 6; }
.cs-hand.cs-minute { stroke: #ef5350; stroke-width: 4; }
.cs-pivot { fill: #333; }
.cs-controls { display: grid; grid-template-columns: auto auto; gap: 8px 16px; align-items: center; }
.cs-row { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cs-readout { display: inline-block; min-width: 28px; text-align: center; font-weight: 700; font-size: 1.05rem; }
.cs-btn { width: 44px; height: 44px; background: #fff; border: 2px solid #1565c0; color: #1565c0; border-radius: 8px; font-size: 1.3rem; font-weight: 700; cursor: pointer; }
.cs-btn:hover { background: #e3f2fd; }
.cs-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cs-digital { font-size: 1.6rem; font-weight: 700; padding: 6px 16px; background: #f5f5f5; border-radius: 8px; color: #333; font-family: 'Courier New', monospace; }
.cs-submit { margin-top: 12px; padding: 14px 32px; background: #1565c0; color: #fff; border: none; border-radius: 12px; font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.cs-submit:disabled { background: #bbb; cursor: not-allowed; }
.cs-clock.flash-correct .cs-face { fill: #c8e6c9; stroke: #2e7d32; }
.cs-clock.flash-wrong .cs-face { fill: #ffcdd2; stroke: #c62828; }
.cs-host.large .cs-clock { width: 300px; height: 300px; }
.cs-host.large .cs-btn { width: 52px; height: 52px; font-size: 1.5rem; }

.dark .cs-face { fill: #2a2a2a; stroke: #ccc; }
.dark .cs-numeral { fill: #eee; }
.dark .cs-tick { stroke: #ccc; }
.dark .cs-pivot { fill: #ccc; }
.dark .cs-digital { background: #2a2a2a; color: #eee; }
.dark .cs-btn { background: #2a2a2a; color: #64b5f6; border-color: #64b5f6; }
.dark .cs-btn:hover { background: #1a1a1a; }

/* Print analog for clock-set */
.cs-print { padding: 6px 0; page-break-inside: avoid; }
.cs-print-prompt { font-size: 1rem; margin-bottom: 6px; }
.cs-print-instr { font-style: italic; font-weight: 600; color: #555; font-size: 0.85rem; text-align: center; margin-top: 4px; }

/* MAP immersion: floating Audio toggle (always visible during a session) */
.map-audio-toggle {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 9999;
    padding: 8px 14px;
    border-radius: 999px;
    border: 2px solid #1565c0;
    background: #fff;
    color: #1565c0;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.15s, transform 0.1s;
}
.map-audio-toggle:hover { background: #e3f2fd; transform: translateY(-1px); }
.map-audio-toggle:active { transform: translateY(1px); }
.map-audio-toggle.audio-on { background: #1565c0; color: #fff; border-color: #0d47a1; }
.map-audio-toggle.audio-off { background: #fff; color: #757575; border-color: #bdbdbd; }

/* MAP immersion: floating End Session button (always visible, top-left) */
.map-end-btn {
    position: fixed;
    top: 12px;
    left: 16px;
    z-index: 9999;
    padding: 8px 14px;
    border-radius: 999px;
    background: #fff;
    color: #c62828;
    border: 2px solid #c62828;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all .15s;
}
.map-end-btn:hover { background: #ffe5e5; transform: translateY(-1px); }
.map-end-btn:active { transform: translateY(1px); }

/* MAP cross-tier opt-in banner — bottom toast that asks the student
   if they want to add the other tier's pool mid-session. */
.map-cross-tier-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 14px 20px;
    border-radius: 12px;
    border: 2px solid #1565c0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    max-width: 500px;
    text-align: center;
    color: #222;
}
.map-cross-tier-banner button {
    margin: 0 6px;
    padding: 6px 16px;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 700;
}
.map-cross-tier-banner .yes {
    background: #1565c0;
    color: #fff;
    border: none;
}
.map-cross-tier-banner .no {
    background: #fff;
    color: #1565c0;
    border: 2px solid #1565c0;
}
.dark .map-cross-tier-banner { background: #2a2a2a; color: #eee; border-color: #64b5f6; }
.dark .map-cross-tier-banner .yes { background: #64b5f6; color: #1a1a1a; }
.dark .map-cross-tier-banner .no { background: transparent; color: #64b5f6; border-color: #64b5f6; }

/* ============================================================
   pv-disks-build widget — drag colored disks into PV zones
   ============================================================ */
.pvb-host { position: relative; padding: 12px 4px; }
.pvb-zone { transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease; }
.pvb-zone.pvb-zone-over { background: rgba(33,150,243,0.10); transform: scale(1.02); }
.pvb-zone.pvb-zone-flash { background: rgba(76,175,80,0.18); }
.pvb-zone.pvb-zone-reject { background: rgba(244,67,54,0.18); animation: pvb-shake 0.32s ease; }
@keyframes pvb-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
}
.pvb-disk:focus, .pvb-palette-disk:focus { outline: 3px solid #1976d2; outline-offset: 2px; }
.pvb-disk-active { outline: 3px solid #ffb300 !important; outline-offset: 3px; box-shadow: 0 0 0 4px rgba(255,179,0,0.30) !important; }
.pvb-dragging { opacity: 0.45; cursor: grabbing !important; }
.pvb-palette { transition: background 0.18s ease; }
.pvb-palette.pvb-palette-over { background: rgba(244,67,54,0.10); }
.pvb-disk.correct-flash { box-shadow: 0 0 0 4px rgba(46,125,50,0.55) !important; }
.pvb-disk.wrong-flash { box-shadow: 0 0 0 4px rgba(198,40,40,0.55) !important; }
.pvb-host.pvb-large .pvb-disk,
.pvb-host.pvb-large .pvb-palette-disk { transform: scale(1.15); margin: 4px; }

/* ============================================================
   compose-fraction-tiles widget — drag unit fractions into target
   ============================================================ */
.cft-host { padding: 14px 8px; text-align: center; position: relative; }
.cft-prompt { font-size: 1rem; font-weight: 700; color: var(--text-bright); margin-bottom: 6px; }
.cft-hint { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 14px; }
.cft-target-wrap { margin: 14px auto; display: inline-block; }
.cft-target-label { font-size: 0.9rem; font-weight: 700; color: #1565c0; margin-bottom: 6px; }
.cft-target-bar {
    position: relative;
    margin: 0 auto;
    border: 2px solid #37474f;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    transition: box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.cft-target-bar.over { background: rgba(33,150,243,0.10); border-color: #1976d2; }
.cft-target-bar.cft-target-complete { box-shadow: 0 0 0 3px rgba(46,125,50,0.45); border-color: #2e7d32; }
.cft-target-bar.correct-flash { background: rgba(76,175,80,0.18); border-color: #2e7d32; box-shadow: 0 0 0 4px rgba(46,125,50,0.40); }
.cft-target-bar.wrong-flash { background: rgba(244,67,54,0.18); border-color: #c62828; animation: cft-shake 0.32s ease; }
@keyframes cft-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
}
.cft-target-mask {
    position: absolute; top: 0; bottom: 0;
    background: repeating-linear-gradient(45deg, rgba(0,0,0,0.06), rgba(0,0,0,0.06) 6px, rgba(0,0,0,0.12) 6px, rgba(0,0,0,0.12) 12px);
    pointer-events: none;
}
.cft-target-marker {
    position: absolute; top: 0; bottom: 0; width: 0;
    border-left: 2px dashed #c62828;
    pointer-events: none;
}
.cft-placed-row {
    display: flex; align-items: center; height: 100%; padding: 0 4px;
    pointer-events: none;
}
.cft-sum-readout {
    margin-top: 8px; font-size: 0.95rem; color: var(--text-bright);
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.cft-palette {
    margin: 16px auto;
    padding: 12px;
    border: 2px dashed #b0bec5;
    border-radius: 10px;
    min-height: 70px;
    background: rgba(0,0,0,0.02);
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
    transition: background 0.18s ease;
}
.cft-palette.over { background: rgba(244,67,54,0.05); border-color: #ef6c00; }
.cft-tile {
    cursor: grab;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 700;
    background: #fff;
    transition: transform 0.12s ease, box-shadow 0.18s ease;
    display: inline-flex; align-items: center; justify-content: center;
    user-select: none;
}
.cft-tile:hover:not([disabled]) { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.cft-tile.cft-tile-active { outline: 3px solid #ffb300; outline-offset: 3px; box-shadow: 0 0 0 4px rgba(255,179,0,0.30); }
.cft-tile.cft-dragging { opacity: 0.45; cursor: grabbing; }
.cft-tile.cft-tile-placed { cursor: default; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); }
.cft-submit { margin-top: 12px; }

/* ============================================================
   compose-shape-blocks widget — drag pattern blocks into outline
   ============================================================ */
.csb-host { padding: 14px 8px; text-align: center; position: relative; }
.csb-prompt { font-size: 1rem; font-weight: 700; color: var(--text-bright); margin-bottom: 6px; }
.csb-hint { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 14px; }
.csb-stage { display: inline-block; max-width: 100%; margin: 0 auto; }
.csb-target-svg { display: block; max-width: 420px; width: 100%; height: auto; margin: 0 auto; overflow: visible; }
.csb-snap { cursor: pointer; outline: none; transition: transform 0.18s ease; }
.csb-snap:hover .csb-snap-outline { stroke: #1976d2; stroke-width: 2; }
.csb-snap:focus .csb-snap-outline { stroke: #1565c0 !important; stroke-width: 2.5 !important; }
.csb-snap.over .csb-snap-outline { stroke: #2e7d32; stroke-width: 2.5; fill: rgba(76,175,80,0.12); }
.csb-snap.csb-snap-reject { animation: csb-reject 0.32s ease; }
@keyframes csb-reject {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
.csb-counter { margin: 8px 0; font-size: 0.95rem; font-weight: 600; color: var(--text-bright); }
.csb-palette {
    margin: 14px auto;
    padding: 12px;
    border: 2px dashed #b0bec5;
    border-radius: 10px;
    min-height: 90px;
    background: rgba(0,0,0,0.02);
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center;
}
.csb-tile {
    cursor: grab;
    padding: 6px 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.10);
    display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
    transition: transform 0.12s ease, box-shadow 0.18s ease;
    user-select: none;
}
.csb-tile:hover:not([disabled]) { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.csb-tile.csb-tile-active { outline: 3px solid #ffb300; outline-offset: 3px; box-shadow: 0 0 0 4px rgba(255,179,0,0.30); }
.csb-tile.csb-dragging { opacity: 0.45; cursor: grabbing; }
.csb-tile-label { font-size: 0.75rem; font-weight: 600; color: #455a64; text-transform: capitalize; }
.csb-submit { margin-top: 12px; }

/* ============================================================
   coin-builder widget — interactive fewest-coins answer type
   ============================================================ */
.coinb-host {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}
.coinb-target-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #fff8e1 0%, #fff3e0 100%);
    border: 2px solid #ffb74d;
    border-radius: 14px;
}
.coinb-target { text-align: left; }
.coinb-target-label {
    font-size: 0.85rem;
    color: #6d4c41;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.coinb-target-value {
    font-size: 2.1rem;
    font-weight: 800;
    color: #e65100;
    line-height: 1.1;
}
.coinb-readout {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    min-width: 140px;
}
.coinb-readout-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 1.05rem;
}
.coinb-readout-label { color: #555; font-weight: 600; }
.coinb-total-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1565c0;
    transition: color 0.18s ease;
}
.coinb-total-value.match { color: #2e7d32; }
.coinb-total-value.over { color: #c62828; }
.coinb-total-value.correct-flash { color: #2e7d32; }
.coinb-total-value.wrong-flash { color: #c62828; }
.coinb-count-value { font-weight: 700; color: #333; }
.coinb-section-title {
    font-weight: 700;
    color: #455a64;
    font-size: 0.95rem;
    margin-bottom: 8px;
    text-align: center;
}
.coinb-answer-section,
.coinb-palette-section {
    background: #fafafa;
    border: 2px dashed #cfd8dc;
    border-radius: 12px;
    padding: 12px;
}
.coinb-palette-section {
    background: #f5f5f5;
    border-style: solid;
    border-color: #e0e0e0;
}
.coinb-answer-area {
    min-height: 72px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
}
.coinb-empty {
    color: #888;
    font-style: italic;
    font-size: 0.95rem;
    padding: 14px;
}
.coinb-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: flex-end;
}
.coinb-coin {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border-radius: 10px;
    min-width: 56px;
    min-height: 56px;
    transition: transform 0.12s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.coinb-coin:hover:not(:disabled) {
    transform: translateY(-2px);
    background: rgba(21, 101, 192, 0.08);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.coinb-coin:active:not(:disabled) { transform: translateY(0); }
.coinb-coin:focus-visible { outline: 3px solid #ffeb3b; outline-offset: 2px; }
.coinb-coin:disabled { cursor: default; opacity: 0.7; }
.coinb-palette-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #37474f;
}
.coinb-answer-coin:hover:not(:disabled) {
    background: rgba(198, 40, 40, 0.10);
    box-shadow: 0 4px 10px rgba(198,40,40,0.18);
}
.coinb-answer-coin.correct-flash { background: rgba(46, 125, 50, 0.18); box-shadow: 0 0 0 3px #2e7d32; }
.coinb-answer-coin.wrong-flash { background: rgba(198, 40, 40, 0.18); box-shadow: 0 0 0 3px #c62828; }
.coinb-submit {
    margin: 6px auto 0;
    padding: 12px 32px;
    background: #1565c0;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    display: block;
    min-width: 160px;
}
.coinb-submit:disabled { background: #bbb; cursor: not-allowed; }

/* Dark mode */
.dark .coinb-target-row {
    background: linear-gradient(135deg, #3a2c10 0%, #2e2310 100%);
    border-color: #c47820;
}
.dark .coinb-target-label { color: #ffcc80; }
.dark .coinb-target-value { color: #ffb74d; }
.dark .coinb-readout-label { color: #bbb; }
.dark .coinb-total-value { color: #64b5f6; }
.dark .coinb-count-value { color: #eee; }
.dark .coinb-section-title { color: #b0bec5; }
.dark .coinb-answer-section { background: #1e1e1e; border-color: #455a64; }
.dark .coinb-palette-section { background: #262626; border-color: #424242; }
.dark .coinb-empty { color: #888; }
.dark .coinb-palette-label { color: #cfd8dc; }
.dark .coinb-coin:hover:not(:disabled) { background: rgba(100, 181, 246, 0.15); }

/* ============================================================ */
/* vocab-match widget                                            */
/* ============================================================ */
.vmh-host {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    padding: 12px;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}
.vmh-instructions {
    font-size: 0.95rem;
    color: #555;
    text-align: center;
    font-style: italic;
}
.vmh-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}
.vmh-left-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.vmh-right-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.vmh-pool {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 80px;
    padding: 10px;
    background: #f5f5f5;
    border: 2px dashed #cfd8dc;
    border-radius: 12px;
    transition: background 0.15s, border-color 0.15s;
}
.vmh-pool.vmh-over {
    background: #e3f2fd;
    border-color: #1565c0;
}
.vmh-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
    gap: 8px;
}
.vmh-arrow {
    align-self: center;
    color: #90a4ae;
    font-size: 1.4rem;
    user-select: none;
}
.vmh-card {
    box-sizing: border-box;
    width: 100%;
    min-height: 64px;
    padding: 12px 14px;
    background: #fff;
    border: 2px solid #cfd8dc;
    border-radius: 12px;
    font-size: 1.05rem;
    line-height: 1.35;
    color: #263238;
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    text-align: center;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.08s;
}
.vmh-card:hover:not(.vmh-locked) {
    border-color: #1565c0;
    box-shadow: 0 2px 6px rgba(21, 101, 192, 0.18);
}
.vmh-card:focus-visible {
    outline: 3px solid #1565c0;
    outline-offset: 2px;
}
.vmh-card .vmh-text {
    font-weight: 600;
    word-break: break-word;
}
.vmh-card .vmh-text-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}
.vmh-speak {
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.08s;
    flex: 0 0 auto;
}
.vmh-speak:hover {
    background: #1565c0;
    color: #fff;
    border-color: #1565c0;
}
.vmh-speak:active {
    transform: scale(0.92);
}
.vmh-speak:focus-visible {
    outline: 2px solid #1565c0;
    outline-offset: 2px;
}
.vmh-card .vmh-speak {
    width: 24px;
    height: 24px;
}
.vmh-card .vmh-model {
    width: 100%;
    display: flex;
    justify-content: center;
}
.vmh-card .vmh-model svg,
.vmh-card .vmh-model img {
    max-width: 100%;
    height: auto;
}
.vmh-card[data-selected="1"] {
    outline: 3px solid #1565c0;
    outline-offset: 2px;
    background: #e3f2fd;
}
.vmh-card.vmh-dragging {
    opacity: 0.45;
}
.vmh-slot {
    box-sizing: border-box;
    min-height: 64px;
    padding: 10px;
    background: #fafafa;
    border: 2px dashed #cfd8dc;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
.vmh-slot.vmh-over {
    background: #e3f2fd;
    border-color: #1565c0;
}
.vmh-slot-hint {
    font-size: 0.85rem;
    color: #90a4ae;
    font-style: italic;
}
.vmh-slot .vmh-right.vmh-in-slot {
    width: 100%;
    margin: 0;
}
.vmh-left.vmh-over {
    background: #e3f2fd;
    border-color: #1565c0;
}

/* Correct + locked state — green like other widgets (msc, dnd, etc.). */
.vmh-card.vmh-correct.vmh-locked,
.vmh-slot.vmh-correct.vmh-locked {
    background: #c8e6c9;
    border-color: #2e7d32;
    color: #1b5e20;
    cursor: default;
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.25);
}
.vmh-card.vmh-correct.vmh-locked:hover { box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.25); }

/* Wrong-flash animation — red shake for ~520ms then revert. */
@keyframes vmh-wrong-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}
.vmh-card.vmh-wrong-flash,
.vmh-slot.vmh-wrong-flash {
    background: #ffcdd2;
    border-color: #c62828;
    color: #b71c1c;
    animation: vmh-wrong-shake 0.32s ease;
}

/* Mobile: stack the two columns. */
@media (max-width: 640px) {
    .vmh-grid {
        grid-template-columns: 1fr;
    }
    .vmh-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .vmh-arrow { display: none; }
}

/* Dark mode */
.dark .vmh-instructions { color: #b0bec5; }
.dark .vmh-pool {
    background: #262626;
    border-color: #455a64;
}
.dark .vmh-pool.vmh-over {
    background: rgba(100, 181, 246, 0.12);
    border-color: #64b5f6;
}
.dark .vmh-card {
    background: #1e1e1e;
    border-color: #455a64;
    color: #eceff1;
}
.dark .vmh-card:hover:not(.vmh-locked) {
    border-color: #64b5f6;
    box-shadow: 0 2px 6px rgba(100, 181, 246, 0.22);
}
.dark .vmh-card[data-selected="1"] {
    background: rgba(100, 181, 246, 0.18);
    outline-color: #64b5f6;
}
.dark .vmh-slot {
    background: #1a1a1a;
    border-color: #455a64;
}
.dark .vmh-slot.vmh-over {
    background: rgba(100, 181, 246, 0.12);
    border-color: #64b5f6;
}
.dark .vmh-slot-hint { color: #78909c; }
.dark .vmh-card.vmh-correct.vmh-locked,
.dark .vmh-slot.vmh-correct.vmh-locked {
    background: rgba(76, 175, 80, 0.30);
    border-color: #66bb6a;
    color: #c8e6c9;
}
.dark .vmh-card.vmh-wrong-flash,
.dark .vmh-slot.vmh-wrong-flash {
    background: rgba(198, 40, 40, 0.32);
    border-color: #ef5350;
    color: #ffcdd2;
}


/* ---- Items-per-session slider (chunky 3D) ---- */
.map-item-slider-wrap {
    margin-bottom: 14px;
}
.map-item-slider-wrap label {
    font-weight: 800;
    color: var(--mq-ink-2);
    font-size: 0.95rem;
}
.map-section input[type="range"],
.map-item-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    background: transparent;
    cursor: pointer;
    margin: 8px 0 4px;
}
.map-section input[type="range"]::-webkit-slider-runnable-track,
.map-item-slider::-webkit-slider-runnable-track {
    height: 10px;
    background: var(--mq-rule);
    border-radius: 999px;
    border: 0;
}
.map-section input[type="range"]::-moz-range-track,
.map-item-slider::-moz-range-track {
    height: 10px;
    background: var(--mq-rule);
    border-radius: 999px;
    border: 0;
}
.map-section input[type="range"]::-webkit-slider-thumb,
.map-item-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--mq-purple);
    border: 3px solid #fff;
    box-shadow: 0 2px 0 0 var(--mq-purple-d);
    margin-top: -6px;
    cursor: pointer;
    transition: transform 80ms ease, box-shadow 80ms ease;
}
.map-section input[type="range"]::-moz-range-thumb,
.map-item-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--mq-purple);
    border: 3px solid #fff;
    box-shadow: 0 2px 0 0 var(--mq-purple-d);
    cursor: pointer;
    transition: transform 80ms ease, box-shadow 80ms ease;
}
.map-section input[type="range"]:active::-webkit-slider-thumb,
.map-item-slider:active::-webkit-slider-thumb {
    transform: translateY(1px);
    box-shadow: 0 1px 0 0 var(--mq-purple-d);
}
.map-section input[type="range"]:focus,
.map-item-slider:focus { outline: none; }
