:root {
    --bg-base: #0c0a13;
    --bg-surface: #151222;
    --bg-card: #1c182d;
    --bg-card-hover: #231f38;
    --border: #2d2645;
    --border-active: #a855f7;
    --text-main: #f3f0fa;
    --text-muted: #958ea8;
    --accent: #a855f7;
    --accent-glow: rgba(168, 85, 247, 0.25);
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.15);
    --green-border: rgba(34, 197, 94, 0.4);
    --amber: #f59e0b;
    --amber-bg: rgba(245, 158, 11, 0.15);
    --amber-border: rgba(245, 158, 11, 0.4);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --header-h: 56px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    line-height: 1.5;
}

.app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    position: relative;
}

.app-header {
    height: var(--header-h);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--green);
    box-shadow: 0 0 10px var(--green);
    animation: livePulse 2s infinite ease-in-out;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.brand-name {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.05em;
    color: var(--text-main);
}

.brand-tag {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    background: linear-gradient(135deg, #a855f7, #ec4899);
    border-radius: var(--radius-sm);
    color: white;
    letter-spacing: 0.08em;
}

.student-profile {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    padding: 3px 6px 3px 10px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.btn-leave {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 12px;
    transition: color 150ms ease, background 150ms ease;
}

.btn-leave:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.12);
}

.btn-stats {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(168, 85, 247, 0.14);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #e9d5ff;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 14px;
    transition: background 150ms ease, border-color 150ms ease, transform 120ms ease;
}

.btn-stats:hover,
.btn-stats.active {
    background: rgba(168, 85, 247, 0.28);
    border-color: #a855f7;
    color: #ffffff;
}

.btn-stats:active {
    transform: scale(0.94);
}

.stats-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 8, 16, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 95;
    animation: fadeIn 180ms ease;
}

.stats-sheet {
    width: 100%;
    max-width: 480px;
    max-height: 78vh;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-active);
    border-radius: 20px 20px 0 0;
    padding: 10px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.65), 0 0 24px rgba(168, 85, 247, 0.18);
    animation: statsSheetUp 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes statsSheetUp {
    from { transform: translateY(100%); opacity: 0.5; }
    to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 540px) {
    .stats-modal-overlay {
        align-items: center;
        padding: 20px;
    }
    .stats-sheet {
        max-width: 420px;
        border: 1px solid rgba(168, 85, 247, 0.4);
        border-radius: 16px;
        padding: 16px;
        animation: statsModalZoom 200ms cubic-bezier(0.22, 1, 0.36, 1);
    }
    .stats-sheet-handle {
        display: none;
    }
}

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

.stats-sheet-handle {
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.18);
    margin: 0 auto 2px;
}

.stats-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-sheet-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #c084fc;
}

.stats-sheet-title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-main);
}

.stats-sheet-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.btn-close-stats {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 150ms ease, background 150ms ease;
}

.btn-close-stats:hover {
    color: #fff;
    background: var(--bg-card-hover);
}

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

.stats-summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stats-card-val {
    font-size: 16px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.stats-card-lbl {
    font-size: 10px;
    color: var(--text-muted);
}

.stats-summary-card.is-ok .stats-card-val { color: #4ade80; }
.stats-summary-card.is-q .stats-card-val { color: #fbbf24; }
.stats-summary-card.is-rx .stats-card-val { color: #38bdf8; }
.stats-summary-card.is-combo .stats-card-val { color: #e879f9; }

.stats-leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: 46vh;
    padding-right: 2px;
}

.stats-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 13px;
}

.stats-row.is-me {
    border-color: rgba(168, 85, 247, 0.55);
    background: rgba(168, 85, 247, 0.1);
}

.stats-row.is-top-1 {
    border-color: rgba(250, 204, 21, 0.45);
    background: linear-gradient(90deg, rgba(250, 204, 21, 0.1), var(--bg-card));
}

.stats-rank {
    width: 18px;
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;
}

.stats-row.is-top-1 .stats-rank { color: #facc15; }
.stats-row.is-top-2 .stats-rank { color: #cbd5e1; }
.stats-row.is-top-3 .stats-rank { color: #f59e0b; }

.stats-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    flex-shrink: 0;
}

.stats-row.is-away,
.stats-row.is-left {
    opacity: 0.55;
}

.stats-row.is-away .stats-dot,
.stats-row.is-left .stats-dot {
    background: #64748b;
    box-shadow: none;
}

.stats-name {
    flex: 1;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stats-me-tag {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 6px;
    background: rgba(168, 85, 247, 0.28);
    color: #e9d5ff;
}

.stats-row-badges {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.stat-badge {
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 2px 6px;
    border-radius: 6px;
}

.stat-badge.is-ok { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.stat-badge.is-q { background: rgba(245, 158, 11, 0.2); color: #fde68a; }
.stat-badge.is-combo { background: rgba(232, 121, 249, 0.22); color: #f5d0fe; }
.stat-badge.is-rx { background: rgba(56, 189, 248, 0.18); color: #bae6fd; }

.stats-row-idle {
    font-size: 11px;
    color: var(--text-muted);
}

.stats-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 8, 16, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.ended-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.ended-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: var(--purple-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.ended-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.ended-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.connection-banner {
    background-color: rgba(245, 158, 11, 0.2);
    border-bottom: 1px solid var(--amber-border);
    color: #fde68a;
    padding: 8px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideDown 0.2s ease;
}

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

.hidden {
    display: none !important;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.view-panel {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Join View */
.join-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.join-title {
    font-size: 20px;
    font-weight: 700;
}

.join-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.form-group input {
    background-color: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 16px;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.15s ease;
}

.form-group input:focus {
    border-color: var(--border-active);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.btn {
    border: none;
    border-radius: var(--radius-md);
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.15s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.error-text {
    font-size: 13px;
    color: #f87171;
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

/* Session View */
.lecture-header-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}

.lesson-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lesson-badge {
    background-color: rgba(168, 85, 247, 0.2);
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
}

.lesson-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Active Step Card */
.active-step-card {
    background: linear-gradient(180deg, #241d3b 0%, #1c182d 100%);
    border: 1px solid var(--border-active);
    box-shadow: 0 4px 20px var(--accent-glow);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.active-step-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.active-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent);
    animation: livePulse 1.5s infinite;
}

.active-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--accent);
}

.active-step-title {
    font-size: 19px;
    font-weight: 700;
    color: #ffffff;
}

.active-step-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* Feedback buttons live in the sticky dock: compact row above the reactions grid */
.feedback-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px 12px 0;
}

.feedback-btn {
    padding: 8px;
    border-radius: var(--radius-md);
    font-size: 13px;
    border: 1px solid transparent;
}

.feedback-btn svg {
    width: 16px;
    height: 16px;
}

.btn-success {
    background-color: var(--green-bg);
    border-color: var(--green-border);
    color: #4ade80;
}

.btn-success.active {
    background-color: var(--green);
    border-color: var(--green);
    color: #0c0a13;
    font-weight: 700;
}

.btn-warning {
    background-color: var(--amber-bg);
    border-color: var(--amber-border);
    color: #fbbf24;
}

.btn-warning.active {
    background-color: var(--amber);
    border-color: var(--amber);
    color: #0c0a13;
    font-weight: 700;
}

/* Sticky reactions dock ("lesson dashboard") pinned right under the app header.
   Negative margins cancel .view-panel padding so the dock spans edge to edge. */
.reactions-dock {
    position: sticky;
    top: var(--header-h);
    z-index: 9;
    margin: -16px -16px 0;
    background: rgba(21, 18, 34, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

/* Lesson "dashboard": fixed 6-column grid, so 18 reactions form exactly 3 compact rows.
   Top padding leaves room for streak badges above the first row. */
.reactions-row {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    padding: 10px 12px 9px;
}

/* Reaction accent palette: one place per reaction, consumed via --rx / --rx-rgb */
.reaction-pill[data-reaction="like"] { --rx: #38bdf8; --rx-rgb: 56, 189, 248; }
.reaction-pill[data-reaction="fire"] { --rx: #f97316; --rx-rgb: 249, 115, 22; }
.reaction-pill[data-reaction="clap"] { --rx: #fbbf24; --rx-rgb: 251, 191, 36; }
.reaction-pill[data-reaction="heart"] { --rx: #ec4899; --rx-rgb: 236, 72, 153; }
.reaction-pill[data-reaction="rocket"] { --rx: #c084fc; --rx-rgb: 192, 132, 252; }
.reaction-pill[data-reaction="idea"] { --rx: #facc15; --rx-rgb: 250, 204, 21; }
.reaction-pill[data-reaction="coffee"] { --rx: #f59e0b; --rx-rgb: 245, 158, 11; }
.reaction-pill[data-reaction="shock"] { --rx: #a855f7; --rx-rgb: 168, 85, 247; }
.reaction-pill[data-reaction="sleep"] { --rx: #06b6d4; --rx-rgb: 6, 182, 212; }
.reaction-pill[data-reaction="g0"] { --rx: #fb7185; --rx-rgb: 251, 113, 133; }
.reaction-pill[data-reaction="g1"] { --rx: #2dd4bf; --rx-rgb: 45, 212, 191; }
.reaction-pill[data-reaction="g2"] { --rx: #818cf8; --rx-rgb: 129, 140, 248; }
.reaction-pill[data-reaction="lol"] { --rx: #fde047; --rx-rgb: 253, 224, 71; }
.reaction-pill[data-reaction="gem"] { --rx: #67e8f9; --rx-rgb: 103, 232, 249; }
.reaction-pill[data-reaction="pause"] { --rx: #c4b5fd; --rx-rgb: 196, 181, 253; }
.reaction-pill[data-reaction="repeat"] { --rx: #60a5fa; --rx-rgb: 96, 165, 250; }
.reaction-pill[data-reaction="slower"] { --rx: #fdba74; --rx-rgb: 253, 186, 116; }
.reaction-pill[data-reaction="cantsee"] { --rx: #f87171; --rx-rgb: 248, 113, 113; }

.reaction-pill {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    min-width: 0;
    height: 44px;
    padding: 4px 1px 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 9.5px;
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    overflow: visible;
    isolation: isolate;
    user-select: none;
    touch-action: manipulation;
    transition: transform 140ms cubic-bezier(0.34, 1.56, 0.64, 1), background-color 150ms ease, color 150ms ease, border-color 150ms ease, box-shadow 200ms ease;
}

.reaction-pill span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.02em;
}

.reaction-pill svg {
    width: 17px;
    height: 17px;
    overflow: visible;
    transition: transform 160ms ease;
}

/* Ripple layer clips to the pill while the streak badge may overflow it */
.reaction-pill .ripple-clip {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
    z-index: -1;
}

.reaction-pill:active,
.reaction-pill.is-popped {
    background-color: rgba(var(--rx-rgb), 0.16);
    border-color: rgba(var(--rx-rgb), 0.55);
    color: var(--rx);
    box-shadow: 0 0 16px rgba(var(--rx-rgb), 0.35);
}

.reaction-pill:active {
    transform: scale(0.86);
}

.reaction-pill:active svg {
    transform: scale(0.85) rotate(-8deg);
}

/* Hover only on real pointers: prevents sticky highlight after a tap on phones */
@media (hover: hover) {
    .reaction-pill:hover {
        background-color: rgba(var(--rx-rgb), 0.12);
        border-color: rgba(var(--rx-rgb), 0.45);
        color: var(--rx);
    }
    .reaction-pill:hover svg {
        transform: translateY(-2px) scale(1.12);
    }
}

.reaction-pill:focus-visible {
    outline: 2px solid var(--rx);
    outline-offset: 2px;
}

.reaction-pill.is-popped {
    animation: pillPop 460ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pillPop {
    0% { transform: scale(0.86); }
    45% { transform: scale(1.12); }
    70% { transform: scale(0.97); }
    100% { transform: scale(1); }
}

/* G-continuity pills get a technical monospace caption */
.reaction-pill[data-reaction="g0"] span,
.reaction-pill[data-reaction="g1"] span,
.reaction-pill[data-reaction="g2"] span {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.reaction-ripple {
    position: absolute;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--rx-rgb), 0.55), rgba(var(--rx-rgb), 0) 70%);
    pointer-events: none;
    animation: rippleOut 560ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes rippleOut {
    from { transform: scale(0.4); opacity: 1; }
    to { transform: scale(11); opacity: 0; }
}

/* Streak badge: "x3" when tapping the same reaction repeatedly */
.reaction-pill[data-streak]::after {
    content: attr(data-streak);
    position: absolute;
    top: -8px;
    right: -6px;
    padding: 1px 5px;
    border-radius: 9px;
    background: var(--rx);
    color: #0b0812;
    font-size: 10px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 0 10px rgba(var(--rx-rgb), 0.6);
    animation: streakPop 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reaction-pill.is-streak-bump[data-streak]::after {
    animation: streakPopAlt 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes streakPop {
    from { transform: scale(1.8) rotate(-14deg); }
    to { transform: scale(1) rotate(0); }
}

/* Identical twin keyframes: switching the name restarts the animation without reflow hacks */
@keyframes streakPopAlt {
    from { transform: scale(1.8) rotate(14deg); }
    to { transform: scale(1) rotate(0); }
}

/* Combo chain hint: guides student to the next reaction in a secret sequence */
.reaction-pill.is-combo-next {
    border-color: var(--rx);
    background: rgba(var(--rx-rgb), 0.22);
    color: #fff;
    box-shadow: 0 0 16px rgba(var(--rx-rgb), 0.55), inset 0 0 10px rgba(var(--rx-rgb), 0.25);
    animation: comboNextPulse 900ms ease-in-out infinite alternate;
    z-index: 2;
}

.reaction-pill.is-combo-next svg {
    filter: drop-shadow(0 0 6px var(--rx));
}

.reaction-pill.is-combo-next::before {
    content: attr(data-combo-hint);
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1px 5px;
    border-radius: 7px;
    background: var(--rx);
    color: #0b0812;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.06em;
    line-height: 1.25;
    white-space: nowrap;
     pointer-events: none;
    box-shadow: 0 0 10px rgba(var(--rx-rgb), 0.75);
    animation: comboBadgeIn 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes comboNextPulse {
    from {
        transform: translateY(-1px) scale(1.03);
        box-shadow: 0 0 12px rgba(var(--rx-rgb), 0.45), inset 0 0 8px rgba(var(--rx-rgb), 0.2);
    }
    to {
        transform: translateY(-3px) scale(1.09);
        box-shadow: 0 0 22px rgba(var(--rx-rgb), 0.85), inset 0 0 14px rgba(var(--rx-rgb), 0.38);
    }
}

@keyframes comboBadgeIn {
    from { transform: translateX(-50%) scale(0.4); opacity: 0; }
    to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Per-reaction icon personality on tap */
.reaction-pill.is-popped[data-reaction="like"] svg { animation: iconThumb 520ms cubic-bezier(0.34, 1.56, 0.64, 1); transform-origin: 30% 90%; }
.reaction-pill.is-popped[data-reaction="fire"] svg { animation: iconFlicker 180ms ease-in-out 3 alternate; transform-origin: 50% 100%; }
.reaction-pill.is-popped[data-reaction="clap"] svg { animation: iconClap 150ms ease-in-out 3; transform-origin: 70% 80%; }
.reaction-pill.is-popped[data-reaction="heart"] svg { animation: iconBeat 520ms ease-in-out; }
.reaction-pill.is-popped[data-reaction="rocket"] svg { animation: iconLaunch 520ms cubic-bezier(0.5, 0, 0.3, 1.4); }
.reaction-pill.is-popped[data-reaction="idea"] svg { animation: iconGlow 520ms ease-out; }
.reaction-pill.is-popped[data-reaction="coffee"] svg { animation: iconTilt 520ms ease-in-out; transform-origin: 40% 90%; }
.reaction-pill.is-popped[data-reaction="shock"] svg { animation: iconShake 90ms linear 5; }
.reaction-pill.is-popped[data-reaction="sleep"] svg { animation: iconRock 620ms ease-in-out; transform-origin: 50% 60%; }
.reaction-pill.is-popped[data-reaction="g0"] svg { animation: iconSnap 420ms cubic-bezier(0.34, 1.56, 0.64, 1); }
.reaction-pill.is-popped[data-reaction="g1"] svg { animation: iconSlide 480ms cubic-bezier(0.34, 1.56, 0.64, 1); }
.reaction-pill.is-popped[data-reaction="g2"] svg { animation: iconWave 560ms ease-in-out; }
.reaction-pill.is-popped[data-reaction="lol"] svg { animation: iconLaugh 110ms ease-in-out 5 alternate; }
.reaction-pill.is-popped[data-reaction="gem"] svg { animation: iconGlow 560ms ease-out; }
.reaction-pill.is-popped[data-reaction="pause"] svg { animation: iconBeat 620ms ease-in-out; }
.reaction-pill.is-popped[data-reaction="repeat"] svg { animation: iconRewind 520ms cubic-bezier(0.34, 1.56, 0.64, 1); }
.reaction-pill.is-popped[data-reaction="slower"] svg { animation: iconFlip 620ms cubic-bezier(0.65, 0, 0.35, 1); }
.reaction-pill.is-popped[data-reaction="cantsee"] svg { animation: iconShake 90ms linear 5; }

.reaction-pill .fx-steam,
.reaction-pill .fx-z,
.reaction-pill .fx-dot,
.reaction-pill .fx-eye {
    transform-box: fill-box;
    transform-origin: center;
}

.reaction-pill.is-popped .fx-steam { animation: iconSteam 600ms ease-out; }
.reaction-pill.is-popped .fx-z { animation: iconZ 620ms ease-out; }
.reaction-pill.is-popped .fx-dot { animation: iconDot 420ms cubic-bezier(0.34, 1.56, 0.64, 1); }
.reaction-pill.is-popped .fx-eye { animation: iconEye 450ms ease-out; }
.reaction-pill.is-popped .fx-tangent { animation: iconDash 480ms linear; }
.reaction-pill .fx-tear { transform-box: fill-box; transform-origin: center top; }
.reaction-pill.is-popped .fx-tear { animation: iconTear 560ms ease-in; }
.reaction-pill.is-popped .fx-comb { stroke-dasharray: 1; animation: iconDraw 560ms ease-out; }

@keyframes iconThumb { 30% { transform: rotate(-24deg) translateY(-3px) scale(1.2); } 60% { transform: rotate(8deg); } }
@keyframes iconFlicker { to { transform: scale(0.9, 1.2) skewX(-6deg); } }
@keyframes iconClap { 50% { transform: rotate(-16deg) scale(0.88); } }
@keyframes iconBeat { 20% { transform: scale(1.35); } 40% { transform: scale(1.05); } 60% { transform: scale(1.25); } }
@keyframes iconLaunch { 45% { transform: translate(4px, -6px) rotate(-8deg); } 70% { transform: translate(-1px, 1px); } }
@keyframes iconGlow { 30% { filter: drop-shadow(0 0 8px currentColor) brightness(1.6); transform: scale(1.2); } }
@keyframes iconTilt { 25% { transform: rotate(-14deg); } 60% { transform: rotate(8deg); } }
@keyframes iconShake { 25% { transform: translate(1.5px, -1px); } 75% { transform: translate(-1.5px, 1px); } }
@keyframes iconRock { 30% { transform: rotate(-18deg); } 70% { transform: rotate(10deg); } }
@keyframes iconSnap { 40% { transform: scale(0.75); } 70% { transform: scale(1.2); } }
@keyframes iconSlide { 35% { transform: translateX(-3px); } 70% { transform: translateX(3px); } }
@keyframes iconWave { 25% { transform: scale(1.15, 0.9); } 50% { transform: scale(0.9, 1.15); } 75% { transform: scale(1.08, 0.95); } }
@keyframes iconLaugh { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-2px) rotate(6deg); } }
@keyframes iconRewind { from { transform: rotate(0); } to { transform: rotate(-360deg); } }
@keyframes iconFlip { from { transform: rotate(0); } to { transform: rotate(180deg); } }
@keyframes iconTear { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(5px) scale(1.3); opacity: 0; } }
@keyframes iconSteam { from { transform: translateY(3px); opacity: 0; } to { transform: translateY(-2px); opacity: 1; } }
@keyframes iconZ { from { transform: translate(-3px, 4px) scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes iconDot { 50% { transform: scale(2); } }
@keyframes iconEye { 30% { transform: scale(1.7); } }
@keyframes iconDash { to { stroke-dashoffset: -9; } }
@keyframes iconDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

/* Floating icon particle on button press */
.mini-reaction-particle {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    color: var(--particle-color, #c084fc);
    filter: drop-shadow(0 0 8px var(--particle-color, #c084fc));
    will-change: transform, opacity;
    animation: trycadMiniParticleFloat 900ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.mini-reaction-particle svg {
    width: 22px;
    height: 22px;
}

@keyframes trycadMiniParticleFloat {
    0% { opacity: 0; transform: translate3d(-50%, -50%, 0) scale(0.4) rotate(0); }
    18% { opacity: 1; transform: translate3d(-50%, calc(-50% - 14px), 0) scale(1.5) rotate(var(--spin, 0deg)); }
    100% { opacity: 0; transform: translate3d(calc(-50% + var(--drift-x, 0px)), calc(-50% - 80px), 0) scale(1.1) rotate(calc(var(--spin, 0deg) * -1)); }
}

/* Radial dots around the tap point */
.tap-dot {
    position: fixed;
    width: 5px;
    height: 5px;
    margin: -2.5px 0 0 -2.5px;
    border-radius: 50%;
    background: var(--particle-color, #c084fc);
    box-shadow: 0 0 8px var(--particle-color, #c084fc);
    pointer-events: none;
    z-index: 999;
    animation: tapDotBurst 520ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes tapDotBurst {
    from { opacity: 1; transform: translate(0, 0) scale(1); }
    to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

/* Steps Timeline */
.steps-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.steps-heading {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.steps-tree {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.group-title {
    font-size: 13px;
    font-weight: 600;
    padding: 10px 14px;
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.group-steps-list {
    display: flex;
    flex-direction: column;
}

.step-row {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 13px;
    transition: background-color 0.15s ease;
}

.step-row:last-child {
    border-bottom: none;
}

.step-row.is-current {
    background-color: rgba(168, 85, 247, 0.12);
    font-weight: 600;
    color: #ffffff;
    border-left: 3px solid var(--accent);
}

.step-label {
    flex: 1;
    min-width: 0;
    margin-right: 12px;
    word-break: break-word;
}

.step-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.step-action-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    padding: 0;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 120ms ease;
}

.step-action-btn:hover {
    transform: scale(1.12);
}

.step-action-btn:active {
    transform: scale(0.92);
}

.step-action-btn.btn-step-confirm:hover {
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.4);
    background-color: rgba(34, 197, 94, 0.1);
}

.step-action-btn.btn-step-confirm.active {
    background-color: var(--green-bg);
    border-color: var(--green-border);
    color: var(--green);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.25);
}

.step-action-btn.btn-step-question:hover {
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.4);
    background-color: rgba(245, 158, 11, 0.1);
}

.step-action-btn.btn-step-question.active {
    background-color: var(--amber-bg);
    border-color: var(--amber-border);
    color: var(--amber);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
}

.step-status-pill {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
}

.step-status-pill.confirmed {
    background-color: var(--green-bg);
    border-color: var(--green-border);
    color: var(--green);
}

.step-status-pill.question {
    background-color: var(--amber-bg);
    border-color: var(--amber-border);
    color: var(--amber);
}

/* Celebration Toast for COMBO WOW on Student Screens */
@property --combo-spin {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.combo-wow-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background:
        linear-gradient(135deg, rgba(35, 10, 30, 0.97), rgba(20, 10, 35, 0.97)) padding-box,
        conic-gradient(from var(--combo-spin), #ff0055, #ff7300, #facc15, #ff0055, #c084fc, #ff0055) border-box;
    border: 2px solid transparent;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8), 0 0 32px rgba(255, 0, 85, 0.7);
    border-radius: 28px;
    padding: 10px 22px;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    max-width: calc(100vw - 32px);
    z-index: 10050;
    pointer-events: none;
    animation: comboToastIn 620ms cubic-bezier(0.22, 1, 0.36, 1) both,
        comboSpin 1.4s linear infinite,
        comboToastOut 400ms ease 3.4s forwards;
}

.combo-wow-badge {
    background: linear-gradient(135deg, #ff0055, #ff5500, #facc15, #ff0055);
    background-size: 250% 100%;
    color: #ffffff;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    box-shadow: 0 0 12px rgba(255, 0, 85, 0.8);
    animation: comboBadgeShimmer 1.1s linear infinite, comboBadgeBeat 0.55s ease-in-out infinite alternate;
}

.combo-wow-text {
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* CLASS-A variant: iridescent border and zebra-striped badge */
.combo-wow-toast.is-class-a {
    background:
        linear-gradient(135deg, rgba(20, 16, 44, 0.97), rgba(14, 22, 40, 0.97)) padding-box,
        conic-gradient(from var(--combo-spin), #818cf8, #e879f9, #22d3ee, #a3e635, #f0abfc, #818cf8) border-box;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8), 0 0 32px rgba(129, 140, 248, 0.7);
}

.combo-wow-toast.is-class-a .combo-wow-badge {
    color: #1e1b4b;
    background: repeating-linear-gradient(115deg, #f5f3ff 0 6px, #c7d2fe 6px 12px);
    background-size: 200% 100%;
    box-shadow: 0 0 14px rgba(232, 121, 249, 0.8);
}

/* LASER variant: red-hot toast */
.combo-wow-toast.is-laser {
    background:
        linear-gradient(135deg, rgba(40, 6, 10, 0.97), rgba(28, 8, 14, 0.97)) padding-box,
        conic-gradient(from var(--combo-spin), #ff1f3d, #ff6b00, #ffffff, #ff1f3d, #ff6b00, #ff1f3d) border-box;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8), 0 0 36px rgba(255, 31, 61, 0.8);
}

.combo-wow-toast.is-laser .combo-wow-badge {
    background: linear-gradient(90deg, #ffffff, #ff1f3d 40%, #ff6b00, #ffffff);
    background-size: 250% 100%;
    box-shadow: 0 0 16px rgba(255, 31, 61, 0.9);
}

/* WARP variant: cyan-violet hyperspace toast */
.combo-wow-toast.is-warp {
    background:
        linear-gradient(135deg, rgba(10, 22, 42, 0.97), rgba(24, 12, 46, 0.97)) padding-box,
        conic-gradient(from var(--combo-spin), #22d3ee, #c084fc, #ffffff, #818cf8, #22d3ee) border-box;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8), 0 0 36px rgba(34, 211, 238, 0.75);
}

.combo-wow-toast.is-warp .combo-wow-badge {
    background: linear-gradient(90deg, #06b6d4, #c084fc 50%, #22d3ee, #06b6d4);
    background-size: 250% 100%;
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.85);
}

/* EUREKA variant: golden-electric neural toast */
.combo-wow-toast.is-eureka {
    background:
        linear-gradient(135deg, rgba(38, 28, 8, 0.97), rgba(26, 14, 42, 0.97)) padding-box,
        conic-gradient(from var(--combo-spin), #facc15, #38bdf8, #ffffff, #a855f7, #facc15) border-box;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8), 0 0 36px rgba(250, 204, 21, 0.8);
}

.combo-wow-toast.is-eureka .combo-wow-badge {
    color: #1c1917;
    background: linear-gradient(90deg, #fde047, #ffffff 45%, #38bdf8, #fde047);
    background-size: 250% 100%;
    box-shadow: 0 0 16px rgba(250, 204, 21, 0.9);
}

/* TURBO variant: amber espresso overdrive toast */
.combo-wow-toast.is-turbo {
    background:
        linear-gradient(135deg, rgba(42, 18, 6, 0.97), rgba(28, 12, 8, 0.97)) padding-box,
        conic-gradient(from var(--combo-spin), #f59e0b, #ef4444, #fde047, #fb923c, #f59e0b) border-box;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8), 0 0 36px rgba(245, 158, 11, 0.8);
}

.combo-wow-toast.is-turbo .combo-wow-badge {
    color: #1c1008;
    background: linear-gradient(90deg, #fde047, #f97316 50%, #ffffff, #fde047);
    background-size: 250% 100%;
    box-shadow: 0 0 16px rgba(249, 115, 22, 0.9);
}

/* Hyperspace warp overlay: radial starlight streaks zooming from screen center */
.warp-overlay {
    position: fixed;
    inset: 0;
    z-index: 10048;
    pointer-events: none;
    overflow: hidden;
    background: radial-gradient(circle at center, rgba(34, 211, 238, 0.16) 0%, transparent 55%, rgba(129, 140, 248, 0.28) 100%);
    animation: laserVignette 2.3s ease forwards;
}

.warp-ray {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 65vmax;
    height: 2.5px;
    transform-origin: 0 50%;
    transform: rotate(var(--ray-deg, 0deg)) translateX(12px) scaleX(0.05);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), #22d3ee 35%, #ffffff 85%, rgba(192, 132, 252, 0));
    box-shadow: 0 0 10px #22d3ee;
    opacity: 0;
    animation: warpRayStreak 1.3s cubic-bezier(0.22, 1, 0.36, 1) var(--ray-delay, 0ms) 2 forwards;
}

@keyframes warpRayStreak {
    0% { opacity: 0; transform: rotate(var(--ray-deg, 0deg)) translateX(8px) scaleX(0.04); }
    25% { opacity: 1; }
    100% { opacity: 0; transform: rotate(var(--ray-deg, 0deg)) translateX(55vmax) scaleX(0.75); }
}

/* Eureka overlay: expanding golden-cyan shockwave rings from center */
.eureka-overlay {
    position: fixed;
    inset: 0;
    z-index: 10048;
    pointer-events: none;
    overflow: hidden;
    background: radial-gradient(circle at center, rgba(250, 204, 21, 0.25) 0%, transparent 60%);
    animation: laserVignette 2.2s ease forwards;
}

.eureka-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border-radius: 50%;
    border: 2.5px solid #fde047;
    box-shadow: 0 0 18px #facc15, inset 0 0 12px #38bdf8;
    opacity: 0;
    animation: eurekaRingExpand 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes eurekaRingExpand {
    0% { opacity: 0.95; transform: scale(0.4); }
    100% { opacity: 0; transform: scale(36); }
}

/* Turbo overlay: rising golden espresso energy streaks */
.turbo-overlay {
    position: fixed;
    inset: 0;
    z-index: 10048;
    pointer-events: none;
    overflow: hidden;
    background: linear-gradient(0deg, rgba(245, 158, 11, 0.26) 0%, transparent 45%, rgba(249, 115, 22, 0.14) 100%);
    animation: laserVignette 2.1s ease forwards;
}

.turbo-line {
    position: absolute;
    bottom: -25vh;
    width: 3px;
    height: 24vh;
    border-radius: 3px;
    background: linear-gradient(180deg, #ffffff, #fde047 35%, #f97316 80%, transparent);
    box-shadow: 0 0 12px #f59e0b;
    opacity: 0;
    animation: turboStreakUp 950ms cubic-bezier(0.22, 1, 0.36, 1) 2 forwards;
}

@keyframes turboStreakUp {
    0% { opacity: 0; transform: translateY(0) scaleY(0.4); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-135vh) scaleY(1.3); }
}

/* Heat-vision overlay: two glowing eyes at the top, parallel beams sweeping down across the screen */
.laser-overlay {
    position: fixed;
    inset: 0;
    z-index: 10048;
    pointer-events: none;
    overflow: hidden;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 0, 30, 0.32) 100%);
    animation: laserVignette 2.5s ease forwards;
}

.laser-eye,
.laser-beam {
    position: absolute;
    top: 18%;
    left: calc(50% + var(--eye-x));
}

.laser-eye.is-left, .laser-beam.is-left { --eye-x: -16px; }
.laser-eye.is-right, .laser-beam.is-right { --eye-x: 16px; }

.laser-eye {
    width: 14px;
    height: 8px;
    margin: -4px 0 0 -7px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 10px 4px #ff1f3d, 0 0 28px 10px rgba(255, 31, 61, 0.7);
    animation: laserEyeCharge 2.4s ease forwards;
}

.laser-beam {
    width: 170vmax;
    height: 5px;
    margin-top: -2.5px;
    border-radius: 3px;
    transform-origin: 0 50%;
    background: linear-gradient(90deg, #ffffff 0%, #ffe4e6 4%, #ff1f3d 14%, rgba(255, 31, 61, 0.85) 60%, rgba(255, 31, 61, 0));
    box-shadow: 0 0 8px 2px rgba(255, 31, 61, 0.9), 0 0 24px 8px rgba(255, 60, 60, 0.45);
    opacity: 0;
    animation: laserSweep 1.7s cubic-bezier(0.45, 0, 0.55, 1) 0.35s forwards, laserFlicker 70ms linear 0.35s 24 alternate;
}

@keyframes laserVignette {
    0% { opacity: 0; }
    15%, 75% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes laserEyeCharge {
    0% { transform: scale(0.2); opacity: 0; }
    14% { transform: scale(1.4); opacity: 1; }
    85% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.4); opacity: 0; }
}

@keyframes laserSweep {
    0% { opacity: 1; transform: rotate(25deg); }
    50% { transform: rotate(110deg); }
    90% { opacity: 1; transform: rotate(65deg); }
    100% { opacity: 0; transform: rotate(60deg); }
}

@keyframes laserFlicker {
    from { filter: brightness(1); }
    to { filter: brightness(1.35); }
}

@keyframes comboToastIn {
    0% { opacity: 0; transform: translate3d(-50%, -40px, 0) scale(0.5); }
    55% { opacity: 1; transform: translate3d(-50%, 6px, 0) scale(1.08); }
    78% { transform: translate3d(-50%, -2px, 0) scale(0.98); }
    100% { opacity: 1; transform: translate3d(-50%, 0, 0) scale(1); }
}

@keyframes comboToastOut {
    to { opacity: 0; transform: translate3d(-50%, -24px, 0) scale(0.9); }
}

@keyframes comboSpin {
    to { --combo-spin: 360deg; }
}

@keyframes comboBadgeShimmer {
    to { background-position: -250% 0; }
}

@keyframes comboBadgeBeat {
    to { transform: scale(1.1); }
}

/* Firework pieces: dots, stars (clip-path) and rings */
.mini-celebration-sparkle {
    position: fixed;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    background-color: var(--sparkle-color, #ff0055);
    box-shadow: 0 0 12px var(--sparkle-color, #ff0055);
    pointer-events: none;
    z-index: 10049;
    animation: sparkleBurst 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.mini-celebration-sparkle.is-star {
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 0;
    clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.mini-celebration-sparkle.is-ring {
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    background: transparent;
    border: 2px solid var(--sparkle-color, #ff0055);
    animation: sparkleRing 700ms ease-out forwards;
}

@keyframes sparkleBurst {
    0% { opacity: 1; transform: translate(0, 0) scale(0.4) rotate(0); }
    20% { opacity: 1; transform: translate(calc(var(--dx, 0px) * 0.5), calc(var(--dy, 0px) * 0.5)) scale(1.4) rotate(90deg); }
    100% { opacity: 0; transform: translate(var(--dx, 0px), calc(var(--dy, 0px) + 40px)) scale(0.6) rotate(200deg); }
}

@keyframes sparkleRing {
    from { opacity: 1; transform: scale(0.3); }
    to { opacity: 0; transform: scale(6); }
}

@media (prefers-reduced-motion: reduce) {
    .reaction-pill,
    .reaction-pill svg,
    .reaction-pill svg *,
    .reaction-pill[data-streak]::after,
    .reaction-pill.is-combo-next::before,
    .combo-wow-toast,
    .combo-wow-badge {
        animation: none !important;
        transition: none !important;
    }
    .reaction-pill:active {
        transform: none;
    }
    .mini-reaction-particle,
    .laser-overlay,
    .warp-overlay,
    .eureka-overlay,
    .turbo-overlay,
    .tap-dot,
    .reaction-ripple,
    .mini-celebration-sparkle {
        display: none !important;
    }
}

/* ── 0.22: lecturer 3D scene ─────────────────────────────── */

.scene-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.scene-card.hidden {
    display: none;
}

/* Expanded view covers the screen; Fullscreen API is not available for divs on iOS Safari. */
.scene-card.is-expanded {
    position: fixed;
    inset: 0;
    z-index: 900;
    border-radius: 0;
}

.scene-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.scene-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: auto;
    letter-spacing: 0.02em;
}

.scene-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 32px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-main);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.scene-btn.is-on {
    border-color: var(--border-active);
    background: var(--accent-glow);
}

.scene-btn-icon {
    padding: 0 8px;
}

/* Height is set by scene3d.js from the lecturer's viewport aspect; this is the pre-layout fallback. */
.scene-viewport {
    position: relative;
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111015;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.scene-card.is-expanded .scene-viewport {
    flex: 1;
    height: auto;
}

/* Letterboxed area with the lecturer's aspect: same framing and fov as in Plasticity. */
.scene-frame {
    position: relative;
    width: 100%;
    height: 100%;
    background: #26262b;
    touch-action: none;
    overflow: hidden;
}

.scene-viewport canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.scene-pins {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.scene-status,
.scene-hint {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(12, 10, 19, 0.82);
    color: var(--text-main);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
}

.scene-status {
    top: 50%;
}

.scene-hint {
    top: 10px;
}

.scene-status.hidden,
.scene-hint.hidden {
    display: none;
}

.scene-pin {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
}

.scene-pin.is-hidden {
    display: none;
}

.scene-pin-dot {
    position: absolute;
    left: -5px;
    top: -5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #0c0a13;
}

.scene-pin.is-mine .scene-pin-dot {
    background: var(--amber);
}

.scene-pin-card {
    position: absolute;
    left: 8px;
    bottom: 6px;
    display: flex;
    align-items: baseline;
    gap: 4px;
    max-width: 180px;
    width: max-content;
    padding: 4px 7px;
    border-radius: var(--radius-sm);
    background: rgba(12, 10, 19, 0.88);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 11px;
    line-height: 1.3;
    pointer-events: auto;
}

.scene-pin-card b {
    color: #d8b4fe;
    font-weight: 600;
}

.scene-pin.is-mine .scene-pin-card {
    border-color: var(--amber-border);
}

.scene-pin.is-mine .scene-pin-card b {
    color: var(--amber);
}

.scene-pin-remove {
    border: none;
    background: none;
    color: var(--text-muted);
    font: inherit;
    padding: 0 2px;
    cursor: pointer;
}

.scene-pin-form {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
}

.scene-pin-form.hidden {
    display: none;
}

.scene-pin-form input {
    flex: 1;
    min-width: 0;
    min-height: 32px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-main);
    font: inherit;
    font-size: 16px;
}

/* ── 0.24: drone flight pad, look stick, FOV, muted notice ── */

.scene-fov {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.scene-fov input {
    width: 90px;
    accent-color: var(--accent);
}

.scene-fov input:disabled {
    opacity: 0.4;
}

.scene-fov b {
    min-width: 30px;
    color: var(--text-main);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.scene-pad {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.scene-pad > * {
    pointer-events: auto;
}

.scene-pad-move {
    display: grid;
    grid-template-columns: repeat(3, 34px);
    grid-template-rows: repeat(2, 34px);
    gap: 4px;
}

.pad-fwd { grid-column: 2; grid-row: 1; }
.pad-left { grid-column: 1; grid-row: 2; }
.pad-back { grid-column: 2; grid-row: 2; }
.pad-right { grid-column: 3; grid-row: 2; }

.scene-pad-alt {
    display: grid;
    grid-template-rows: repeat(2, 34px);
    gap: 4px;
}

.pad-btn {
    position: relative;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(12, 10, 19, 0.55);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    touch-action: none;
    transition: background-color 80ms ease, border-color 80ms ease;
}

.pad-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pad-btn i {
    position: absolute;
    right: 3px;
    bottom: 1px;
    font-style: normal;
    font-size: 8px;
    color: rgba(255, 255, 255, 0.45);
}

.pad-btn.is-active {
    background: var(--accent-glow);
    border-color: var(--border-active);
    color: #fff;
}

.scene-stick {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(12, 10, 19, 0.45);
    touch-action: none;
    cursor: grab;
}

.scene-stick.is-active {
    border-color: var(--border-active);
}

.scene-stick-knob {
    position: absolute;
    left: 25%;
    top: 25%;
    width: 50%;
    height: 50%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.scene-muted {
    display: none;
    padding: 18px 14px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.scene-card.is-muted .scene-muted {
    display: block;
}

.scene-card.is-muted .scene-viewport,
.scene-card.is-muted .scene-pin-form,
.scene-card.is-muted .scene-btn,
.scene-card.is-muted .scene-fov {
    display: none;
}

.scene-toolbar {
    flex-wrap: wrap;
}

.scene-title,
.scene-btn {
    white-space: nowrap;
}

/* Phones: FOV gets its own row so the buttons keep one line. */
@media (max-width: 560px) {
    .scene-fov {
        order: 10;
        width: 100%;
        margin: 2px 0 0;
    }

    .scene-fov input {
        flex: 1;
        width: auto;
    }
}

/* ── 0.24.2: focus lock crosshair ── */

.scene-focus-mark {
    position: absolute;
    left: -9px;
    top: -9px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 2px rgba(12, 10, 19, 0.6);
    pointer-events: none;
}

.scene-focus-mark::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 4px;
    margin: -2px 0 0 -2px;
    border-radius: 50%;
    background: var(--accent);
}

.scene-focus-mark.hidden {
    display: none;
}

/* ── 0.24.3: FOV reset to the lecturer's angle ── */

.scene-fov-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-main);
    cursor: pointer;
}

.scene-fov-reset.hidden {
    display: none;
}

/* ── 0.25: laser pointer ── */

.scene-pad-right {
    margin-left: auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.pad-btn.pad-pointer {
    width: 52px;
    height: 52px;
    border-radius: 50%;
}

.pad-btn.pad-pointer svg {
    width: 24px;
    height: 24px;
}

.pad-btn.pad-pointer i {
    right: 50%;
    bottom: 3px;
    transform: translateX(50%);
    white-space: nowrap;
    font-size: 8px;
}

.pad-btn.pad-pointer svg {
    margin-bottom: 6px;
}

/* Touch screens have no Space key: the hint would only confuse. */
@media (pointer: coarse) {
    .pad-btn.pad-pointer i {
        display: none;
    }

    .pad-btn.pad-pointer svg {
        margin-bottom: 0;
    }
}

.pad-btn.pad-pointer.is-active {
    background: rgba(255, 64, 96, 0.28);
    border-color: #ff4060;
    box-shadow: 0 0 12px rgba(255, 64, 96, 0.55);
}

.scene-pointer-dot {
    position: absolute;
    left: -6px;
    top: -6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff4060;
    box-shadow: 0 0 0 3px rgba(255, 64, 96, 0.35), 0 0 12px rgba(255, 64, 96, 0.9);
    pointer-events: none;
}

.scene-pointer-dot.hidden {
    display: none;
}
