/* ================================================================
   Math Activity — Styles
   Calm, object-focused, zero-failure design for neurodivergent learners
   ================================================================ */

/* ── Wrapper ── */
.math-wrapper {
    min-height: 100vh;
    background: var(--act-bg);
    color: var(--act-text);
    display: flex;
    flex-direction: column;
    transition: color 0.3s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Top Bar ── */
.math-topbar {
    background: var(--act-topbar-bg) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--act-topbar-border) !important;
}

.math-topbar .speech-topbar-back {
    color: var(--act-topbar-back);
}

.math-topbar .speech-topbar-back:hover {
    background: var(--act-bg-subtle);
}

.math-topbar .speech-topbar-module {
    color: var(--act-topbar-text);
}

.math-topbar .speech-topbar-progress {
    color: var(--act-text-muted);
}

.math-topbar .speech-topbar-btn {
    color: var(--act-topbar-back);
}

.math-topbar .speech-topbar-btn:hover {
    background: var(--act-bg-subtle);
}

/* ── Activity Area ── */
.math-activity-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

/* ── Loading ── */
.math-loading {
    text-align: center;
    color: #7c8a96;
    padding: 60px 0;
}

.math-loading__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #1d9a8a;
    border-radius: 50%;
    animation: mathSpin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes mathSpin {
    to { transform: rotate(360deg); }
}

/* ── Views ── */
.math-view {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: mathViewEnter 0.35s ease-out;
}

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

/* ── Prompt ── */
.math-prompt {
    font-size: 1.4rem;
    color: var(--act-text);
    text-align: center;
    margin-bottom: 24px;
    font-weight: 600;
    line-height: 1.5;
    min-height: 1.6em;
}

/* ── Objects Grid ── */
.math-objects {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    align-items: center;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    min-height: 140px;
}

/* ── Single Object ── */
.math-object {
    position: relative;
    width: 90px;
    height: 90px;
    font-size: 3.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: var(--act-object-bg);
    border: 2px solid var(--act-object-border);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.math-object:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.math-object:active {
    transform: scale(0.95);
}

.math-object.counted {
    transform: scale(1.15);
    border-color: #fbbf24;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.4), 0 0 40px rgba(251, 191, 36, 0.15);
    background: rgba(251, 191, 36, 0.15);
    animation: mathObjectPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Floating number badge on each counted object */
.math-object.counted::after {
    content: attr(data-count);
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a2e;
    font-size: 0.85rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: mathBadgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.4);
}

.math-object.removing {
    animation: mathObjectRemove 0.4s ease-out forwards;
}

.math-object.removed {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

@keyframes mathObjectPop {
    0% { transform: scale(0.85); }
    40% { transform: scale(1.3); }
    60% { transform: scale(1.05); }
    80% { transform: scale(1.2); }
    100% { transform: scale(1.15); }
}

@keyframes mathBadgePop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.4); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Number display pulse when updating */
.math-number-display.pop {
    animation: mathNumberPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes mathNumberPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.4); color: #fbbf24; }
    100% { transform: scale(1); }
}

@keyframes mathObjectRemove {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

/* ── Number Display ── */
.math-number-display {
    font-size: 4rem;
    font-weight: 800;
    color: var(--act-number-color);
    text-align: center;
    margin: 16px 0;
    min-height: 4.5rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

/* ── Choices ── */
.math-choices {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* When choices contain an input (number_recognition/addition), stack vertically */
.math-choices--input-mode,
.math-choices:has(.math-input-wrap) {
    flex-direction: column;
    align-items: center;
}

.math-choice {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--act-bg-card);
    border: 2px solid var(--act-border);
    color: var(--act-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 6px var(--act-shadow);
}

.math-choice:hover {
    background: var(--act-bg-card-hover);
    border-color: var(--act-border-hover);
    transform: scale(1.05);
}

.math-choice:active {
    transform: scale(0.95);
}

.math-choice.correct {
    background: rgba(76, 175, 80, 0.25) !important;
    border-color: #4CAF50 !important;
    color: #4CAF50 !important;
    box-shadow: 0 0 16px rgba(76, 175, 80, 0.3);
    transform: scale(1.1);
    animation: mathChoiceCorrect 0.4s ease-out;
}

.math-choice--hint {
    animation: mathChoiceShake 0.4s ease-out;
    border-color: rgba(251, 191, 36, 0.5) !important;
}

@keyframes mathChoiceShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

.math-choice.hint-pulse {
    border-color: rgba(251, 191, 36, 0.5);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.2);
    animation: mathHintPulse 0.8s ease-in-out 2;
}

@keyframes mathChoiceCorrect {
    0% { transform: scale(1.3); }
    100% { transform: scale(1.1); }
}

@keyframes mathHintPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(251, 191, 36, 0.15); }
    50% { box-shadow: 0 0 20px rgba(251, 191, 36, 0.4); }
}

/* Disabled choices after correct answer */
.math-choice--disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
}
.math-choice--disabled.correct {
    opacity: 1;
}

/* ── Number Input (Desktop keyboard entry) ── */
.math-input-wrap {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
}

.math-number-input {
    width: 120px;
    padding: 14px 18px;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    background: var(--act-input-bg);
    border: 2px solid var(--act-input-border);
    border-radius: 14px;
    color: var(--act-input-text);
    outline: none;
    transition: border-color 0.2s, background 0.3s;
    -moz-appearance: textfield;
}

.math-number-input::-webkit-outer-spin-button,
.math-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.math-number-input:focus {
    border-color: var(--act-input-focus);
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.2);
}

.math-number-input::placeholder {
    color: var(--act-input-placeholder);
    font-size: 0.9rem;
    font-weight: 400;
}

.math-input--shake {
    animation: mathChoiceShake 0.4s ease-out;
    border-color: rgba(251, 191, 36, 0.6) !important;
}

.math-input--correct {
    border-color: #4CAF50 !important;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.35) !important;
    background: rgba(76, 175, 80, 0.1) !important;
}

.math-input--try-again {
    animation: mathInputGentleShake 0.5s ease-out;
    border-color: rgba(251, 191, 36, 0.5) !important;
}

@keyframes mathInputGentleShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.math-input-hint {
    text-align: center;
    color: var(--act-text-muted);
    font-size: 0.88rem;
    margin-top: 10px;
    min-height: 24px;
    transition: color 0.3s;
    line-height: 1.5;
}

/* ── Virtual Number Pad (Mobile/Tablet) ── */
.math-numpad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-width: 320px;
    margin: 16px auto 0;
}

.math-numpad-key {
    width: 100%;
    aspect-ratio: 1;
    max-width: 56px;
    border-radius: 12px;
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--act-object-bg);
    border: 2px solid var(--act-object-border);
    color: var(--act-text);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.math-numpad-key:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    transform: scale(1.05);
}

.math-numpad-key:active {
    transform: scale(0.95);
}

.math-numpad-key.correct {
    background: rgba(76, 175, 80, 0.25) !important;
    border-color: #4CAF50 !important;
    color: #4CAF50 !important;
    box-shadow: 0 0 16px rgba(76, 175, 80, 0.3);
}

.math-numpad-toggle {
    display: block;
    margin: 14px auto 0;
    padding: 8px 20px;
    border-radius: 8px;
    border: 1px solid var(--act-border);
    background: var(--act-bg-subtle);
    color: var(--act-text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.math-numpad-toggle:hover {
    border-color: var(--act-border-hover);
    color: #1d9a8a;
}

.math-numpad-clear {
    background: rgba(239, 68, 68, 0.08) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
}

.math-numpad-enter {
    background: rgba(76, 175, 80, 0.12) !important;
    border-color: rgba(76, 175, 80, 0.3) !important;
    color: #4CAF50 !important;
}

.math-numpad-enter:hover {
    background: rgba(76, 175, 80, 0.25) !important;
}

@media (min-width: 769px) {
    .math-number-input {
        width: 180px;
        padding: 18px 28px;
        font-size: 2.2rem;
    }
    .math-number-input::placeholder {
        font-size: 1rem;
    }
    .math-input-hint {
        font-size: 1rem;
    }
    .math-numpad {
        max-width: 480px;
    }
    .math-numpad-key {
        max-width: 60px;
        font-size: 1.4rem;
    }
}

/* ── Groups (Compare mode) ── */
.math-groups {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
}

.math-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 32px;
    border-radius: 20px;
    border: 2px dashed var(--act-group-border);
    min-width: 180px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--act-group-bg);
    box-shadow: 0 2px 8px var(--act-shadow);
}

.math-group:hover {
    border-style: solid;
    border-color: var(--act-border-hover);
    background: var(--act-bg-card-hover);
}

.math-group.selected,
.math-group.correct {
    border-style: solid;
    border-color: #4CAF50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.25);
    background: rgba(76, 175, 80, 0.08);
}

.math-group .math-objects {
    padding: 8px;
    gap: 10px;
    max-width: 280px;
    min-height: auto;
}

.math-group .math-object {
    width: 48px;
    height: 48px;
    font-size: 1.8rem;
    cursor: default;
    border: none;
    background: transparent;
}

/* Desktop: much bigger objects for visibility */
@media (min-width: 769px) {
    .math-activity-area {
        max-width: 900px;
    }
    .math-object {
        width: 100px;
        height: 100px;
        font-size: 3.6rem;
        border-radius: 20px;
    }
    .math-objects {
        gap: 22px;
        max-width: 680px;
    }
    .math-group {
        padding: 36px 48px;
        min-width: 280px;
        border-radius: 24px;
    }
    .math-group .math-objects {
        gap: 16px;
        max-width: 420px;
    }
    .math-group .math-object {
        width: 80px;
        height: 80px;
        font-size: 3rem;
    }
    .math-group__label {
        font-size: 1.5rem;
        margin-top: 16px;
    }
    .math-groups {
        gap: 40px;
    }
    .math-vs {
        font-size: 2.2rem;
        font-weight: 700;
        padding: 0 16px;
    }
    .math-prompt {
        font-size: 1.8rem;
        margin-bottom: 32px;
    }
    .math-number-display {
        font-size: 5rem;
    }
    .math-choice {
        width: 80px;
        height: 80px;
        font-size: 2rem;
        border-radius: 16px;
    }
    .math-combine-plus,
    .math-combine-equals {
        font-size: 2.5rem;
    }
    .math-combine-result {
        font-size: 3rem;
        min-width: 80px;
        min-height: 80px;
    }
}

.math-group .math-object:hover {
    transform: none;
}

.math-group__label {
    font-size: 1.2rem;
    color: var(--act-text-secondary, #4b5563);
    margin-top: 12px;
    font-weight: 700;
}

.math-group.math-hint-pulse {
    animation: mathGroupHint 0.6s ease-in-out 3;
}

@keyframes mathGroupHint {
    0%, 100% { border-color: var(--act-border); }
    50% { border-color: #fbbf24; box-shadow: 0 0 16px rgba(251, 191, 36, 0.25); }
}

.math-vs {
    font-size: 1.6rem;
    color: var(--act-text-muted);
    font-weight: 700;
    padding: 0 8px;
}

/* ── Equation display (numbers first) ── */
.math-equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.math-equation__num {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--act-text);
    min-width: 60px;
    text-align: center;
}

.math-equation__op {
    font-size: 2.5rem;
    font-weight: 700;
    color: #7c8a96;
}

.math-equation__answer {
    color: #fbbf24;
    min-width: 70px;
    padding: 8px 16px;
    border-radius: 14px;
    border: 2px dashed rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.06);
}

.math-equation__answer--correct {
    color: #4CAF50;
    border-color: #4CAF50;
    border-style: solid;
    background: rgba(76, 175, 80, 0.1);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.2);
    animation: mathNumberPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Show Objects button */
.math-show-objects-btn {
    display: block;
    margin: 0 auto 16px;
    padding: 10px 24px;
    border-radius: 10px;
    border: 1px solid var(--act-show-btn-border);
    background: var(--act-show-btn-bg);
    color: var(--act-show-btn-text);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.math-show-objects-btn:hover {
    background: rgba(29, 154, 138, 0.15);
    border-color: rgba(29, 154, 138, 0.5);
    color: #1d9a8a;
}

/* Objects area (hidden by default in addition) */
.math-combine-objects {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 14px;
    background: var(--act-bg-subtle);
    border: 1px solid var(--act-border);
    animation: mathFadeIn 0.4s ease-out;
}

@keyframes mathFadeIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ── Combine mode ── */
.math-combine-area {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 16px;
    width: 100%;
}

@media (min-width: 769px) {
    .math-equation__num { font-size: 5rem; min-width: 80px; }
    .math-equation__op { font-size: 3.5rem; }
    .math-equation__answer { min-width: 90px; padding: 10px 20px; }
    .math-equation { gap: 24px; margin-bottom: 28px; }
    .math-show-objects-btn { font-size: 1rem; padding: 12px 28px; }
    .math-combine-objects { padding: 24px; }
    .math-combine-group .math-object { width: 56px; height: 56px; font-size: 2rem; }
}

.math-combine-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
    padding: 12px;
    border-radius: 14px;
    background: var(--act-bg-subtle);
    border: 1px solid var(--act-border);
    min-width: 80px;
    min-height: 60px;
}

.math-combine-group .math-object {
    width: 44px;
    height: 44px;
    font-size: 1.6rem;
    cursor: default;
    border: none;
    background: transparent;
}

.math-combine-group .math-object:hover {
    transform: none;
}

.math-combine-plus,
.math-combine-equals {
    font-size: 1.8rem;
    font-weight: 700;
    color: #7c8a96;
    flex-shrink: 0;
}

.math-combine-result {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fbbf24;
    min-width: 50px;
    text-align: center;
    transition: all 0.3s ease;
}

.math-combine-result.revealed {
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
    animation: mathResultReveal 0.4s ease-out;
}

@keyframes mathResultReveal {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Action Buttons ── */
.math-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 16px 20px;
    flex-wrap: wrap;
}

.math-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.math-btn--next {
    background: linear-gradient(135deg, #1d9a8a, #6a60f0);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(29, 154, 138, 0.25);
}

.math-btn--next:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(29, 154, 138, 0.35);
}

.math-btn--replay {
    background: var(--act-bg-card);
    border: 1px solid var(--act-border);
    color: var(--act-text-secondary);
    box-shadow: 0 2px 6px var(--act-shadow);
}

.math-btn--replay:hover {
    background: var(--act-bg-card-hover);
    border-color: var(--act-border-hover);
}

.math-btn--prev {
    background: var(--act-bg-card);
    border: 1px solid var(--act-border);
    color: var(--act-text-secondary);
    box-shadow: 0 2px 6px var(--act-shadow);
}

.math-btn--prev:hover {
    background: var(--act-bg-card-hover);
    border-color: var(--act-border-hover);
}

.math-btn--reset {
    background: var(--act-bg-card);
    border: 1px solid var(--act-border);
    color: var(--act-text-secondary);
    box-shadow: 0 2px 6px var(--act-shadow);
}

.math-btn--reset:hover {
    background: var(--act-bg-card-hover);
    border-color: var(--act-border-hover);
}

/* ── Celebration Overlay ── */
.math-celebration {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: mathCelebFadeIn 0.2s ease-out;
}

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

.math-celebration__emoji {
    font-size: 5rem;
    animation: mathCelebPulse 0.6s ease-out;
    line-height: 1;
    margin-bottom: 16px;
}

@keyframes mathCelebPulse {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.math-celebration__text {
    font-size: 1.5rem;
    color: #ffffff;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ── Overlays ── */
.math-overlay {
    background: rgba(0, 0, 0, 0.45) !important;
}

.math-overlay-panel {
    background: var(--act-bg-card) !important;
    border: 1px solid var(--act-border);
    box-shadow: 0 20px 60px var(--act-shadow);
}

.math-overlay-panel .speech-overlay-header h3 {
    color: var(--act-text) !important;
}

.math-overlay-panel .speech-overlay-close {
    background: var(--act-bg-subtle) !important;
    color: var(--act-text-muted) !important;
}

.math-overlay-panel .speech-setting {
    border-bottom-color: var(--act-border) !important;
}

.math-overlay-panel .speech-setting span {
    color: var(--act-text-secondary) !important;
}

.math-overlay-panel .speech-setting select {
    background: var(--act-bg-input);
    border: 1px solid var(--act-border);
    color: var(--act-text);
}

.math-overlay-panel .speech-setting input[type="checkbox"] {
    accent-color: #1d9a8a;
}

.math-overlay-panel .speech-setting-tip {
    background: rgba(29, 154, 138, 0.08);
    color: #1d9a8a;
}

/* Summary overlay */
.math-overlay .speech-overlay-panel--summary {
    background: var(--act-bg-card) !important;
    border: 1px solid var(--act-border);
    box-shadow: 0 20px 60px var(--act-shadow);
}

.math-overlay .speech-summary-title {
    color: var(--act-text) !important;
}

.math-overlay .speech-summary-player {
    color: var(--act-text-muted) !important;
}

.math-overlay .speech-summary-stat {
    background: var(--act-bg-subtle) !important;
}

.math-overlay .speech-summary-num {
    color: #1d9a8a !important;
}

.math-overlay .speech-summary-label {
    color: var(--act-text-muted) !important;
}

.math-overlay .speech-summary-icon {
    background: rgba(29, 154, 138, 0.1) !important;
    color: #1d9a8a !important;
}

.math-overlay .speech-summary-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid var(--act-border);
    transition: all 0.15s;
    background: var(--act-bg-card);
    color: var(--act-text-secondary);
}

.math-overlay .speech-summary-btn:hover {
    background: var(--act-bg-card-hover);
    border-color: var(--act-border-hover);
}

.math-overlay .speech-summary-btn--primary {
    background: linear-gradient(135deg, #1d9a8a, #6a60f0);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(29, 154, 138, 0.25);
}

.math-overlay .speech-summary-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(29, 154, 138, 0.3);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .math-activity-area {
        padding: 16px 12px;
    }

    .math-object {
        width: 72px;
        height: 72px;
        font-size: 2.6rem;
        border-radius: 14px;
    }

    .math-objects {
        gap: 16px;
        padding: 16px;
    }

    .math-number-display {
        font-size: 3rem;
    }

    .math-choice {
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
        border-radius: 12px;
    }

    .math-group {
        padding: 14px;
        min-width: 100px;
    }

    .math-group .math-object {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .math-groups {
        gap: 10px;
    }

    .math-combine-group .math-object {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }

    .math-combine-plus,
    .math-combine-equals {
        font-size: 1.4rem;
    }

    .math-combine-result {
        font-size: 2rem;
    }

    .math-prompt {
        font-size: 1rem;
        margin-bottom: 14px;
    }

    .math-celebration__emoji {
        font-size: 4rem;
    }

    .math-celebration__text {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .math-object {
        width: 64px;
        height: 64px;
        font-size: 2.2rem;
        border-radius: 12px;
    }

    .math-objects {
        gap: 12px;
        padding: 12px;
    }

    .math-groups {
        flex-direction: column;
        gap: 8px;
    }

    .math-vs {
        font-size: 1rem;
    }

    .math-group {
        width: 100%;
        max-width: 240px;
    }

    .math-combine-area {
        gap: 8px;
        padding: 8px;
    }

    .math-choice {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }

    .math-number-display {
        font-size: 2.5rem;
    }

    .math-btn {
        padding: 10px 18px;
        font-size: 0.85rem;
    }
}

/* ── Prefers reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .math-object.counted {
        animation: none;
    }

    .math-object.removing {
        animation: none;
        opacity: 0;
    }

    .math-view {
        animation: none;
    }

    .math-celebration__emoji {
        animation: none;
    }

    .math-celebration {
        animation: none;
    }

    .math-loading__spinner {
        animation: none;
        border-top-color: #1d9a8a;
    }

    .math-choice.correct {
        animation: none;
    }

    .math-combine-result.revealed {
        animation: none;
    }

    .math-choice.hint-pulse {
        animation: none;
    }

    .math-group.math-hint-pulse {
        animation: none;
    }
}
