/* ═══════════════════════════════════════════════
   EQUATION QUEST — kid-friendly missing-number game
═══════════════════════════════════════════════ */
.eq-page {
    background: linear-gradient(160deg, #eef2ff 0%, #fef3c7 100%);
    min-height: calc(100vh - 250px);
    padding: 40px 0 60px;
}
.eq-shell {
    max-width: 640px;
    margin: 0 auto;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, .12);
    padding: 28px 24px 32px;
}
.eq-title {
    text-align: center;
    font-weight: 800;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    color: #1e293b;
    margin-bottom: 4px;
}
.eq-subtitle {
    text-align: center;
    color: #64748b;
    font-size: 1rem;
    margin-bottom: 24px;
}
.eq-screen { display: none; }
.eq-screen.active { display: block; animation: eq-fade .25s ease; }
@keyframes eq-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Setup screen ── */
.eq-step-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: #334155;
    margin: 18px 0 10px;
}
.eq-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.eq-choice-grid.eq-ops { grid-template-columns: repeat(3, 1fr); }
.eq-choice-grid.eq-classes { grid-template-columns: repeat(3, 1fr); }
.eq-choice-btn {
    border: 3px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 16px;
    padding: 18px 10px;
    font-weight: 800;
    font-size: 1.15rem;
    color: #334155;
    cursor: pointer;
    transition: transform .15s, border-color .15s, background .15s;
    text-align: center;
}
.eq-choice-btn .eq-choice-icon { display: block; font-size: 1.8rem; margin-bottom: 6px; }
.eq-choice-btn:hover { transform: translateY(-2px); border-color: #a5b4fc; }
.eq-choice-btn.selected {
    border-color: #6366f1;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: #4338ca;
    transform: translateY(-2px);
}
.eq-solve-x-note {
    display: none;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 4px;
}
.eq-solve-x-note.active { display: block; }
.eq-solve-x-note p { margin: 0; color: #475569; font-size: 0.92rem; line-height: 1.5; }
.eq-solve-x-note code {
    background: #e0e7ff;
    color: #4338ca;
    border-radius: 6px;
    padding: 1px 6px;
    font-weight: 700;
}

.eq-nickname {
    width: 100%;
    border: 3px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
}
.eq-nickname:focus { outline: none; border-color: #a5b4fc; }
.eq-btn-primary {
    width: 100%;
    margin-top: 24px;
    border: none;
    border-radius: 16px;
    padding: 16px;
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 8px 20px rgba(22,163,74,.3);
    cursor: pointer;
    transition: transform .15s, opacity .15s;
}
.eq-btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
.eq-btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.eq-btn-secondary {
    width: 100%;
    margin-top: 12px;
    border: 3px solid #e2e8f0;
    border-radius: 16px;
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #334155;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s, transform .15s;
}
.eq-btn-secondary:hover { border-color: #a5b4fc; transform: translateY(-2px); }

/* ── Play screen ── */
.eq-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.eq-stat { text-align: center; flex: 1; min-width: 70px; }
.eq-stat .eq-stat-num { font-weight: 800; font-size: 1.4rem; color: #1e293b; line-height: 1; }
.eq-stat .eq-stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; font-weight: 700; }
.eq-timer-wrap { flex: 1.2; min-width: 100px; }
.eq-timer-bar {
    height: 14px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    margin-bottom: 4px;
}
.eq-timer-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    transition: width 1s linear, background .3s;
    width: 100%;
}
.eq-timer-fill.eq-warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.eq-timer-fill.eq-danger { background: linear-gradient(90deg, #dc2626, #f87171); }
.eq-timer-num { text-align: center; font-weight: 800; font-size: 1rem; color: #334155; }

.eq-question-card {
    background: linear-gradient(135deg, #1e293b, #334155);
    border-radius: 20px;
    padding: 36px 20px;
    text-align: center;
    margin-bottom: 22px;
    position: relative;
    overflow: hidden;
}
.eq-question-card.eq-correct { animation: eq-flash-green .5s ease; }
.eq-question-card.eq-wrong { animation: eq-shake .4s ease; }
@keyframes eq-flash-green {
    0% { background: linear-gradient(135deg, #16a34a, #22c55e); }
    100% { background: linear-gradient(135deg, #1e293b, #334155); }
}
@keyframes eq-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); background: linear-gradient(135deg, #b91c1c, #dc2626); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}
.eq-question-parts {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}
.eq-part {
    font-size: clamp(1.8rem, 7vw, 2.6rem);
    font-weight: 800;
    color: #fff;
    letter-spacing: .02em;
}
.eq-part-op, .eq-part-eq { color: #94a3b8; font-size: clamp(1.4rem, 5vw, 2rem); }
.eq-part-var { color: #fbbf24; }
.eq-question-hint {
    display: none;
    margin-top: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.eq-question-hint.active { display: block; }
.eq-part-blank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4em;
    padding: 2px 12px;
    border: 3px dashed #fbbf24;
    border-radius: 12px;
    color: #fbbf24;
    background: rgba(251, 191, 36, .08);
    animation: eq-pulse 1.4s ease-in-out infinite;
}
@keyframes eq-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, .35); }
    50% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); }
}

.eq-options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.eq-option-btn {
    border: none;
    border-radius: 16px;
    padding: 22px 10px;
    font-size: 1.6rem;
    font-weight: 800;
    color: #1e293b;
    background: #f1f5f9;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s;
    box-shadow: 0 3px 0 #cbd5e1;
}
.eq-option-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 0 #cbd5e1; }
.eq-option-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #cbd5e1; }
.eq-option-btn:disabled { cursor: not-allowed; }
.eq-option-btn.eq-pick-correct { background: #bbf7d0; color: #166534; box-shadow: 0 3px 0 #4ade80; }
.eq-option-btn.eq-pick-wrong { background: #fecaca; color: #991b1b; box-shadow: 0 3px 0 #f87171; }

/* ── End screen ── */
.eq-stars {
    text-align: center;
    font-size: 2.6rem;
    letter-spacing: 6px;
    margin: 6px 0 18px;
    color: #e2e8f0;
}
.eq-stars .eq-star-on { color: #fbbf24; }
.eq-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 6px;
}
.eq-summary-item {
    text-align: center;
    background: #f8fafc;
    border-radius: 14px;
    padding: 16px 6px;
}
.eq-summary-item .eq-summary-num { font-weight: 800; font-size: 1.5rem; color: #1e293b; }
.eq-summary-item .eq-summary-label { font-size: .72rem; color: #94a3b8; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.eq-review-label {
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
    margin: 20px 0 8px;
}
.eq-review {
    max-height: 220px;
    overflow-y: auto;
    border: 2px solid #f1f5f9;
    border-radius: 14px;
    padding: 6px;
}
.eq-review-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .88rem;
    color: #334155;
}
.eq-review-row:nth-child(odd) { background: #f8fafc; }
.eq-review-eqn { flex: 1; }
.eq-review-answer { color: #64748b; font-weight: 700; white-space: nowrap; }
.eq-review-icon { font-weight: 800; width: 1.4em; text-align: center; flex-shrink: 0; }
.eq-review-row.eq-review-correct .eq-review-icon { color: #16a34a; }
.eq-review-row.eq-review-wrong .eq-review-icon { color: #dc2626; }

.eq-leaderboard-link { text-align: center; margin-top: 14px; }
.eq-leaderboard-link a { color: #4f46e5; font-weight: 700; text-decoration: none; }
.eq-leaderboard-link a:hover { text-decoration: underline; }

.eq-error-banner {
    background: #fef2f2;
    border: 2px solid #fecaca;
    color: #991b1b;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: 16px;
    display: none;
}
.eq-error-banner.active { display: block; }

/* ── Leaderboard page ── */
.eq-lb-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.eq-lb-filters select {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 600;
    color: #334155;
}
.eq-lb-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.eq-lb-table tr { background: #f8fafc; }
.eq-lb-table td { padding: 12px 14px; font-weight: 600; color: #334155; }
.eq-lb-table td:first-child { border-radius: 12px 0 0 12px; font-weight: 800; color: #6366f1; }
.eq-lb-table td:last-child { border-radius: 0 12px 12px 0; text-align: right; }
.eq-lb-empty { text-align: center; color: #94a3b8; padding: 30px 0; font-weight: 600; }

@media (max-width: 480px) {
    .eq-shell { padding: 22px 16px 26px; border-radius: 18px; }
    .eq-options-grid { gap: 10px; }
    .eq-option-btn { font-size: 1.35rem; padding: 18px 8px; }
    .eq-part { font-size: clamp(1.4rem, 8vw, 2rem); }
}

/* ── Fullscreen mobile play (see base.css body.game-page rules) ── */
@media (max-width: 991.98px) {
    body.game-page .eq-page { min-height: 100dvh; padding: 0; }
    body.game-page .eq-page .container { max-width: none; padding: 0; }
    body.game-page .eq-shell {
        max-width: none;
        min-height: 100dvh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 54px 16px 16px;
        display: flex;
        flex-direction: column;
    }
    body.game-page .eq-subtitle { display: none; }
    body.game-page .eq-screen.active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        justify-content: center;
    }
}
