/* ========== SPEED MATH ========== */

.speedmath-stage {
    display: grid;
    gap: 1rem;
    padding: 1.1rem;
    border-radius: 1.2rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(235, 241, 252, 0.92));
    border: 1px solid rgba(84, 122, 227, 0.25);
}

.speedmath-scoreboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.speedmath-score-card {
    display: grid;
    gap: 0.2rem;
    padding: 0.6rem 0.85rem;
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(84, 122, 227, 0.2);
}

.speedmath-score-name {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.speedmath-score-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2b4f86;
}

.speedmath-score-sub {
    font-size: 0.75rem;
    color: var(--muted);
}

/* Narrow-screen contract: nothing here is fixed-px on the inline axis. The scoreboard and the
   answer choices are auto-fit/minmax grids that collapse to fewer columns on their own (at 320px
   the choices sit 2-up at ~139px each, the scoreboard 1-up), and .speedmath-input's 180px
   min-width still clears the 288px available. So this board needs no query -- it was already
   fluid, and unlike Connect4 it has no px floor hiding behind the fluidity. */
.speedmath-lanes {
    display: grid;
    gap: 0.6rem;
}

.speedmath-lane {
    position: relative;
    /* Deliberately left on vw. This is the only viewport-keyed rule remaining in the boards, and
       it is height, not width -- it cannot overflow, and it is already floored at 90px. Keying it
       to the container instead only changes 768px (99.8 -> 120) and 600px (90 -> 102) and is
       identical everywhere else, so the conversion is churn against a decorative lane. */
    height: clamp(90px, 13vw, 120px);
    border-radius: 0.9rem;
    background: linear-gradient(180deg, rgba(84, 122, 227, 0.16), rgba(84, 122, 227, 0.05));
    border: 1px solid rgba(84, 122, 227, 0.18);
    overflow: hidden;
}

.speedmath-task {
    position: absolute;
    top: 0;
    left: 50%;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(27, 52, 108, 0.2);
    font-weight: 600;
    color: #1c2f55;
    box-shadow: 0 6px 14px rgba(28, 47, 85, 0.2);
    animation: speedmath-fall var(--fall-duration, 4500ms) linear;
    animation-delay: var(--fall-delay, 0ms);
    will-change: transform, opacity;
    pointer-events: none;
}

@keyframes speedmath-fall {
    0% {
        transform: translate(-50%, -35%);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, 150%);
        opacity: 0.15;
    }
}

.speedmath-input {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.speedmath-input input {
    flex: 1;
    min-width: 180px;
    padding: 0.6rem 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid var(--line);
    font-size: 0.95rem;
    font-family: inherit;
}

.speedmath-input input:focus {
    outline: none;
    border-color: rgba(84, 122, 227, 0.65);
    box-shadow: 0 0 0 3px rgba(84, 122, 227, 0.2);
}

.speedmath-choice-panel {
    display: grid;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.9rem;
    background: rgba(84, 122, 227, 0.08);
    border: 1px solid rgba(84, 122, 227, 0.2);
}

.speedmath-choice-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.speedmath-choice-expression {
    font-weight: 600;
    color: #1c2f55;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.2rem 0.5rem;
    border-radius: 0.5rem;
}

.speedmath-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.6rem;
}

.speedmath-choice-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
}

.choice-index {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.choice-value {
    font-size: 1rem;
}

.speedmath-hidden-input {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.speedmath-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.speedmath-stats span {
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(84, 122, 227, 0.12);
}

.speedmath-status {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(185, 52, 52, 0.12);
    color: #b03434;
    font-size: 0.85rem;
    text-align: center;
}
