/* =================================================================
   لعبة تسنيم للحساب — v4
   modes (direct/missing/problems), choices, equation builder
   ================================================================= */

:root {
    --bg-deep:        #07071a;
    --bg-mid:         #0d0d2b;
    --surface:        rgba(255, 255, 255, 0.05);
    --surface-2:      rgba(255, 255, 255, 0.08);
    --surface-hover:  rgba(255, 255, 255, 0.12);
    --border:         rgba(255, 255, 255, 0.10);
    --border-strong:  rgba(255, 255, 255, 0.18);
    --border-glow:    rgba(255, 214, 0, 0.45);

    --mul:        #FFD600;  --mul-glow:   rgba(255, 214, 0, 0.30);
    --add:        #00E676;  --add-glow:   rgba(0, 230, 118, 0.30);
    --sub:        #FF2D78;  --sub-glow:   rgba(255, 45, 120, 0.30);

    --lvl1:       #FFD600;  --lvl1-glow:  rgba(255, 214, 0, 0.30);
    --lvl2:       #FF2D78;  --lvl2-glow:  rgba(255, 45, 120, 0.30);
    --lvl3:       #00B0FF;  --lvl3-glow:  rgba(0, 176, 255, 0.30);

    --accent:      var(--mul);
    --accent-glow: var(--mul-glow);

    --success:     #00E676;  --success-glow: rgba(0, 230, 118, 0.30);
    --error:       #FF3D00;  --error-glow:   rgba(255, 61, 0, 0.30);
    --warn:        #FFA000;

    --text:        #FFFFFF;
    --text-soft:   rgba(255, 255, 255, 0.82);
    --text-muted:  rgba(255, 255, 255, 0.55);
    --text-dim:    rgba(255, 255, 255, 0.30);

    --radius-sm:   12px;
    --radius-md:   20px;
    --radius-lg:   28px;
    --radius-pill: 999px;
    --shadow-card: 0 8px 32px rgba(0,0,0,0.4);
    --transition:  all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body {
    height: 100%; width: 100%;
    overflow: hidden;
    background: var(--bg-deep);
    color: var(--text);
    font-family: 'Tajawal', 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
}

body { user-select: none; -webkit-user-select: none; direction: rtl; }
input, button { font-family: inherit; outline: none; border: none; background: none; color: inherit; }
button { cursor: pointer; }
input { user-select: text; -webkit-user-select: text; }

/* COSMIC BG */
.bg-stars { position: fixed; inset: 0; z-index: 0; background: radial-gradient(ellipse at top, var(--bg-mid) 0%, var(--bg-deep) 60%); overflow: hidden; pointer-events: none; }
.stars { position: absolute; inset: -100%; background-repeat: repeat;
    background-image: radial-gradient(1px 1px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 60px 100px, rgba(255,255,255,0.7), transparent), radial-gradient(2px 2px at 130px 60px, #fff, transparent), radial-gradient(1px 1px at 200px 200px, rgba(255,255,255,0.5), transparent), radial-gradient(1px 1px at 250px 80px, #fff, transparent);
    background-size: 300px 300px;
    animation: drift 80s linear infinite, twinkle 4s ease-in-out infinite;
    opacity: 0.6;
}
.stars-2 { background-image: radial-gradient(1.5px 1.5px at 50px 80px, rgba(255,214,0,0.6), transparent), radial-gradient(1px 1px at 150px 150px, #fff, transparent), radial-gradient(2px 2px at 280px 50px, rgba(255,45,120,0.4), transparent); background-size: 350px 350px; animation: drift 130s linear infinite, twinkle 6s ease-in-out infinite; animation-delay: 0s, 1s; opacity: 0.5; }
.stars-3 { background-image: radial-gradient(1px 1px at 30px 200px, rgba(255,255,255,0.8), transparent), radial-gradient(2.5px 2.5px at 220px 120px, rgba(255,214,0,0.3), transparent), radial-gradient(1px 1px at 320px 250px, #fff, transparent); background-size: 400px 400px; animation: drift 200s linear infinite, twinkle 8s ease-in-out infinite; animation-delay: 0s, 2s; opacity: 0.4; }
.nebula { position: absolute; inset: -50%; background: radial-gradient(ellipse at 30% 30%, rgba(255, 45, 120, 0.10) 0%, transparent 40%), radial-gradient(ellipse at 70% 70%, rgba(0, 176, 255, 0.10) 0%, transparent 40%), radial-gradient(ellipse at 50% 50%, rgba(255, 214, 0, 0.06) 0%, transparent 50%); filter: blur(20px); animation: nebula 60s linear infinite; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); pointer-events: none; opacity: 0.5; }
.orb-1 { width: 280px; height: 280px; background: var(--mul); top: -80px; left: -100px; animation: floatOrb1 18s ease-in-out infinite; }
.orb-2 { width: 220px; height: 220px; background: var(--sub); bottom: -60px; right: -80px; animation: floatOrb2 22s ease-in-out infinite; }
.orb-3 { width: 180px; height: 180px; background: var(--lvl3); top: 40%; right: -60px; animation: floatOrb3 26s ease-in-out infinite; }

/* APP / SCREENS */
#app { position: relative; z-index: 1; width: 100%; height: 100%; max-width: 480px; margin: 0 auto; overflow: hidden; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; padding: max(14px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); transform: translateX(-100%); opacity: 0; pointer-events: none; transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1); will-change: transform, opacity; }
.screen-active { transform: translateX(0); opacity: 1; pointer-events: auto; }

/* GLASS / BUTTONS */
.glass-card { background: var(--surface); backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 75%, #fff 25%));
    color: #000;
    font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 22px; letter-spacing: 0.5px;
    padding: 18px 32px; border-radius: var(--radius-pill);
    box-shadow: 0 0 24px var(--accent-glow), 0 4px 16px rgba(0,0,0,0.3);
    transition: var(--transition);
    width: 100%; min-height: 60px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    position: relative; overflow: hidden;
}
.btn-primary::before { content: ''; position: absolute; top: 0; right: -100%; width: 100%; height: 100%; background: linear-gradient(110deg, transparent, rgba(255,255,255,0.4), transparent); transition: right 0.6s ease; }
.btn-primary:hover::before { right: 100%; }
.btn-primary:active { transform: scale(0.94); box-shadow: 0 0 8px var(--accent-glow); }
.btn-primary:disabled { opacity: 0.45; pointer-events: none; filter: saturate(0.7); }

.btn-secondary { background: var(--surface); color: var(--text); font-family: 'Cairo', sans-serif; font-weight: 800; font-size: 17px; padding: 16px 28px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: var(--transition); min-height: 56px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-secondary:active { transform: scale(0.95); background: var(--surface-hover); }

.btn-danger { background: linear-gradient(135deg, var(--error), #FF6B3D); color: #fff; font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 16px; padding: 14px 24px; border-radius: var(--radius-pill); box-shadow: 0 0 16px var(--error-glow); transition: var(--transition); min-height: 50px; }
.btn-danger:active { transform: scale(0.95); }

.icon-btn { width: 48px; height: 48px; min-width: 48px; border-radius: 50%; background: var(--surface); color: var(--text); font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: var(--transition); }
.icon-btn:active { transform: scale(0.9); background: var(--surface-hover); }

.ghost-btn {
    background: linear-gradient(135deg, var(--surface-2), var(--surface));
    color: var(--text);
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 18px;
    padding: 16px 26px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--border-strong);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: var(--transition);
    min-height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: var(--shadow-card);
    flex: 1;
    max-width: 200px;
}
.ghost-btn span:first-child { font-size: 22px; }
.ghost-btn:active {
    transform: scale(0.95);
    color: var(--accent);
    border-color: var(--accent);
    background: var(--surface-hover);
    box-shadow: 0 0 18px var(--accent-glow), var(--shadow-card);
}

/* HOME */
.home-header { text-align: center; margin-top: 4px; margin-bottom: 12px; }

.game-title { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 26px; line-height: 1.2; letter-spacing: 0.5px; background: linear-gradient(90deg, var(--mul) 0%, #fff 25%, var(--sub) 50%, #fff 75%, var(--add) 100%); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; animation: shimmer 6s linear infinite, titlePulse 3s ease-in-out infinite; text-shadow: 0 0 30px rgba(255,214,0,0.3); }

.title-emoji { -webkit-text-fill-color: initial; color: var(--accent); background: none; display: inline-block; }

.home-subtitle { margin-top: 2px; color: var(--text-muted); font-size: 13px; letter-spacing: 2px; font-weight: 800; }

/* OPERATION TABS — bigger, kid-friendly */
.op-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--surface); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); padding: 6px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-pill); margin-bottom: 12px; box-shadow: var(--shadow-card); }
.op-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 10px 4px; border-radius: var(--radius-pill); color: var(--text); font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 14px; transition: var(--transition); position: relative; min-height: 64px; }
.op-tab-symbol { font-family: Arial, 'Helvetica Neue', sans-serif; font-size: 24px; font-weight: 900; line-height: 1; }
.op-tab[data-op="mul"] .op-tab-symbol { color: var(--mul); }
.op-tab[data-op="add"] .op-tab-symbol { color: var(--add); }
.op-tab[data-op="sub"] .op-tab-symbol { color: var(--sub); }
.op-tab[data-op="mix"] .op-tab-symbol {
    background: linear-gradient(90deg, var(--mul), var(--add), var(--sub));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    font-size: 20px;
}
.op-tab.op-tab-active { background: var(--surface-hover); color: var(--text); transform: scale(1.02); }
.op-tab.op-tab-active[data-op="mul"] { box-shadow: 0 0 20px var(--mul-glow), inset 0 0 0 1px rgba(255,214,0,0.4); }
.op-tab.op-tab-active[data-op="add"] { box-shadow: 0 0 20px var(--add-glow), inset 0 0 0 1px rgba(0,230,118,0.4); }
.op-tab.op-tab-active[data-op="sub"] { box-shadow: 0 0 20px var(--sub-glow), inset 0 0 0 1px rgba(255,45,120,0.4); }
.op-tab.op-tab-active[data-op="mix"] {
    box-shadow: 0 0 20px var(--accent3-glow), inset 0 0 0 1px rgba(0,176,255,0.5);
}
.op-tab:active { transform: scale(0.95); }

/* MODE TABS — bigger, kid-friendly */
.mode-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.mode-tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 14px 6px;
    background: var(--surface);
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-soft);
    font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 14px;
    transition: var(--transition);
    min-height: 86px;
    box-shadow: var(--shadow-card);
}
.mode-tab-icon { font-size: 30px; line-height: 1; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4)); }
.mode-tab.mode-tab-active {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 22px var(--accent-glow), inset 0 0 0 2px var(--accent);
    transform: translateY(-3px);
}
.mode-tab:active { transform: scale(0.96); }

/* LEVEL CARDS */
.level-cards { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 10px; max-height: 100%; }

.level-card {
    position: relative;
    background: linear-gradient(135deg, var(--surface-2), var(--surface));
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 14px 18px 12px;
    color: var(--text);
    text-align: right;
    overflow: hidden;
    transition: var(--transition);
    animation: float 6s ease-in-out infinite;
}
.level-card-2 { animation-delay: 1.5s; }
.level-card-3 { animation-delay: 3s; }
.level-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--lvl1); box-shadow: 0 0 12px var(--lvl1); }
.level-card-2::before { background: var(--lvl2); box-shadow: 0 0 12px var(--lvl2); }
.level-card-3::before { background: var(--lvl3); box-shadow: 0 0 12px var(--lvl3); }
.level-card-glow { position: absolute; inset: 0; border-radius: var(--radius-lg); pointer-events: none; background: radial-gradient(circle at 50% 0%, var(--lvl1-glow) 0%, transparent 60%); opacity: 0.6; }
.level-card-2 .level-card-glow { background: radial-gradient(circle at 50% 0%, var(--lvl2-glow) 0%, transparent 60%); }
.level-card-3 .level-card-glow { background: radial-gradient(circle at 50% 0%, var(--lvl3-glow) 0%, transparent 60%); }
.level-card:active { transform: scale(0.97); border-color: var(--border-glow); box-shadow: 0 0 30px var(--lvl1-glow), var(--shadow-card); }
.level-card-2:active { box-shadow: 0 0 30px var(--lvl2-glow), var(--shadow-card); }
.level-card-3:active { box-shadow: 0 0 30px var(--lvl3-glow), var(--shadow-card); }

.level-row { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.level-icon { font-size: 38px; line-height: 1; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4)); flex-shrink: 0; }
.level-info { flex: 1; min-width: 0; }
.level-name { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 20px; color: var(--text); margin-bottom: 2px; }
.level-desc { color: var(--text-soft); font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.level-example { font-family: Arial, 'Helvetica Neue', sans-serif; font-size: 17px; color: var(--lvl1); font-weight: 800; letter-spacing: 1px; direction: ltr; }
.level-card-2 .level-example { color: var(--lvl2); }
.level-card-3 .level-example { color: var(--lvl3); }

.level-cta { border-top: 1px solid var(--border); padding-top: 8px; display: flex; justify-content: space-between; align-items: center; font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 13px; letter-spacing: 1px; color: var(--text); }
.level-cta .arrow { font-size: 22px; color: var(--lvl1); transition: transform 0.3s ease; }
.level-card-2 .level-cta .arrow { color: var(--lvl2); }
.level-card-3 .level-cta .arrow { color: var(--lvl3); }
.level-card:active .arrow { transform: translateX(-4px); }

#screen-home { overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
#screen-home::-webkit-scrollbar { width: 4px; }
#screen-home::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }
#screen-home .level-cards { flex: 0 0 auto; justify-content: flex-start; }

.home-footer { display: flex; justify-content: center; gap: 14px; margin-top: 14px; padding-bottom: 4px; }

/* ============================================================
   DEV CREDIT (developer dedication card under home buttons)
   ============================================================ */
.dev-credit {
    margin-top: 14px;
    padding: 0 2px 6px;
    perspective: 800px;
    animation: devCreditFadeIn 1.2s ease-out 0.2s both;
}
.dev-credit-inner {
    position: relative;
    background:
        linear-gradient(135deg, rgba(255, 214, 0, 0.10), rgba(255, 45, 120, 0.10) 45%, rgba(0, 176, 255, 0.10)),
        linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 22px;
    padding: 16px 16px 18px;
    text-align: center;
    overflow: hidden;
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255,255,255,0.18);
    isolation: isolate;
}
.dev-credit-inner::before {
    content: '';
    position: absolute; inset: -2px;
    border-radius: 22px;
    padding: 2px;
    background: conic-gradient(
        from 0deg,
        rgba(255, 214, 0, 0.0) 0deg,
        rgba(255, 214, 0, 0.85) 60deg,
        rgba(255, 45, 120, 0.85) 130deg,
        rgba(0, 176, 255, 0.85) 220deg,
        rgba(0, 230, 118, 0.85) 290deg,
        rgba(255, 214, 0, 0.0) 360deg
    );
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    animation: devCreditBorderSpin 7s linear infinite;
    pointer-events: none;
    z-index: 0;
}
.dev-credit-inner::after {
    content: '';
    position: absolute;
    top: -50%; left: -120%;
    width: 60%; height: 200%;
    background: linear-gradient(110deg, transparent, rgba(255,255,255,0.18), transparent);
    transform: rotate(18deg);
    animation: devCreditShine 5.5s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}
.dev-credit-stars {
    position: absolute; inset: 0;
    pointer-events: none;
    z-index: 0;
}
.dev-credit-stars span {
    position: absolute;
    color: rgba(255, 214, 0, 0.85);
    font-size: 10px;
    text-shadow: 0 0 6px rgba(255, 214, 0, 0.85);
    animation: devCreditTwinkle 3s ease-in-out infinite;
}
.dev-credit-stars span:nth-child(1) { top: 8%;  left: 6%;  animation-delay: 0s;   font-size: 9px;  }
.dev-credit-stars span:nth-child(2) { top: 18%; right: 9%; animation-delay: 0.5s; color: rgba(0, 176, 255, 0.85); text-shadow: 0 0 6px rgba(0,176,255,0.85); }
.dev-credit-stars span:nth-child(3) { bottom: 14%; left: 8%; animation-delay: 1.1s; color: rgba(255, 45, 120, 0.85); text-shadow: 0 0 6px rgba(255,45,120,0.85); }
.dev-credit-stars span:nth-child(4) { bottom: 22%; right: 12%; animation-delay: 1.6s; color: rgba(0, 230, 118, 0.85); text-shadow: 0 0 6px rgba(0,230,118,0.85); font-size: 8px; }
.dev-credit-stars span:nth-child(5) { top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 7px; opacity: 0.5; animation-delay: 0.8s; }

.dev-credit-line {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.92);
    line-height: 1.55;
    margin: 2px 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.dev-credit-line-1 { font-size: 12.5px; }
.dev-credit-line-2 { font-size: 13px; }
.dev-credit-line-3 { font-size: 11.5px; color: rgba(255, 255, 255, 0.82); }
.dev-credit-line-4 { font-size: 11.5px; color: rgba(255, 255, 255, 0.92); margin-top: 4px; }

.dev-credit-icon {
    font-size: 14px;
    filter: drop-shadow(0 0 4px rgba(255,255,255,0.4));
    animation: devCreditIconBob 2.6s ease-in-out infinite;
    display: inline-block;
}
.dev-credit-line-2 .dev-credit-icon { animation-delay: 0.4s; }
.dev-credit-line-3 .dev-credit-icon { animation-delay: 0.8s; }
.dev-credit-line-4 .dev-credit-icon { animation-delay: 1.2s; }

.dev-credit-author {
    font-family: 'Amiri', 'Cairo', serif;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, #FFD600, #FFA000, #FFD600);
    background-size: 200% 100%;
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: devCreditGradient 4s linear infinite;
    text-shadow: 0 0 18px rgba(255, 214, 0, 0.45);
}
.dev-credit-author-pink {
    background: linear-gradient(90deg, #FF2D78, #FF80B5, #FF2D78);
    background-size: 200% 100%;
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-shadow: 0 0 18px rgba(255, 45, 120, 0.45);
    animation: devCreditGradient 4s linear infinite reverse;
    font-size: 16px;
}

.dev-credit-divider {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 6px 0 4px;
    height: 14px;
}
.dev-credit-divider::before,
.dev-credit-divider::after {
    content: '';
    flex: 0 1 70px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,214,0,0.55), transparent);
}
.dev-credit-heart {
    margin: 0 10px;
    color: #FF2D78;
    font-size: 14px;
    text-shadow: 0 0 10px rgba(255, 45, 120, 0.7);
    animation: devCreditHeartBeat 1.4s ease-in-out infinite;
    display: inline-block;
}

.dev-credit-blessing {
    background: linear-gradient(90deg, rgba(0, 176, 255, 0.10), rgba(0, 230, 118, 0.10), rgba(0, 176, 255, 0.10));
    background-size: 200% 100%;
    border-radius: 12px;
    padding: 6px 8px;
    margin-top: 6px !important;
    animation: devCreditBlessingShift 6s linear infinite;
}

.dev-credit-flag {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px; height: 18px;
    background: linear-gradient(90deg, #C1272D 0%, #C1272D 100%);
    border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 8px rgba(193, 39, 45, 0.55);
    opacity: 0.55;
    z-index: 1;
}
.dev-credit-flag-star {
    color: #006233;
    font-size: 14px;
    text-shadow: 0 0 4px rgba(0, 98, 51, 0.8);
    animation: devCreditTwinkle 2.4s ease-in-out infinite;
}

@keyframes devCreditFadeIn {
    from { opacity: 0; transform: translateY(14px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes devCreditBorderSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes devCreditShine {
    0%   { left: -120%; opacity: 0; }
    20%  { opacity: 0.9; }
    60%  { left: 140%; opacity: 0; }
    100% { left: 140%; opacity: 0; }
}
@keyframes devCreditTwinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50%      { opacity: 1;   transform: scale(1.2); }
}
@keyframes devCreditIconBob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-3px) rotate(-6deg); }
}
@keyframes devCreditGradient {
    0%   { background-position:   0% 50%; }
    100% { background-position: 200% 50%; }
}
@keyframes devCreditHeartBeat {
    0%, 100% { transform: scale(1);    text-shadow: 0 0 10px rgba(255,45,120,0.7); }
    25%      { transform: scale(1.25); text-shadow: 0 0 18px rgba(255,45,120,1); }
    50%      { transform: scale(1);    text-shadow: 0 0 10px rgba(255,45,120,0.7); }
    75%      { transform: scale(1.18); text-shadow: 0 0 16px rgba(255,45,120,0.9); }
}
@keyframes devCreditBlessingShift {
    0%   { background-position:   0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Compact mode for short screens */
@media (max-height: 760px) {
    .dev-credit { margin-top: 8px; }
    .dev-credit-inner { padding: 11px 12px 14px; border-radius: 18px; }
    .dev-credit-line-1, .dev-credit-line-2 { font-size: 11.5px; }
    .dev-credit-line-3, .dev-credit-line-4 { font-size: 10.5px; }
    .dev-credit-author { font-size: 13.5px; }
    .dev-credit-author-pink { font-size: 14px; }
    .dev-credit-divider { margin: 3px 0 2px; }
}
@media (max-height: 640px) {
    .dev-credit-line-3 { display: none; }
    .dev-credit-flag { display: none; }
    .dev-credit-inner { padding: 9px 10px 11px; }
}

/* QUIZ */
.quiz-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.quiz-counter { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 16px; color: var(--text); }
.quiz-level-badge { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 13px; padding: 7px 14px; border-radius: var(--radius-pill); background: var(--accent); color: #000; box-shadow: 0 0 12px var(--accent-glow); }
.quiz-level-badge.lvl-2 { background: var(--lvl2); color: #fff; box-shadow: 0 0 12px var(--lvl2-glow); }
.quiz-level-badge.lvl-3 { background: var(--lvl3); color: #fff; box-shadow: 0 0 12px var(--lvl3-glow); }

.timer-wrap { margin-bottom: 14px; text-align: center; }
.timer-bar { width: 100%; height: 10px; background: rgba(255,255,255,0.1); border-radius: var(--radius-pill); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
.timer-fill { height: 100%; width: 100%; background: var(--accent); border-radius: var(--radius-pill); box-shadow: 0 0 8px var(--accent); transition: width 0.1s linear, background-color 0.4s ease, box-shadow 0.4s ease; will-change: width; }
.timer-fill.warn { background: var(--warn); box-shadow: 0 0 12px var(--warn); }
.timer-fill.danger { background: var(--error); box-shadow: 0 0 16px var(--error); animation: barPulse 0.6s ease-in-out infinite; }
.timer-text { margin-top: 6px; font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 20px; color: var(--accent); transition: color 0.3s ease; }
.timer-text.warn { color: var(--warn); }
.timer-text.danger { color: var(--error); }

.quiz-body { flex: 1; display: flex; flex-direction: column; justify-content: flex-start; gap: 14px; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 40px; scroll-padding-bottom: 40px; }

/* QUESTION (direct / missing) */
.question-box { position: relative; text-align: center; padding: 14px 8px; }
.question-glow { position: absolute; inset: 0; background: radial-gradient(circle at center, var(--accent-glow) 0%, transparent 70%); animation: pulse-glow 2.5s ease-in-out infinite; pointer-events: none; z-index: 0; }
.question-text { position: relative; z-index: 1; font-family: Arial, 'Helvetica Neue', sans-serif; font-weight: 900; font-size: 56px; line-height: 1; color: var(--text); text-shadow: 0 0 24px var(--accent-glow), 0 4px 8px rgba(0,0,0,0.4); letter-spacing: 1px; animation: slideInUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; direction: ltr; }
.question-text .q-x { color: var(--accent); font-size: 1.05em; text-shadow: 0 0 20px var(--accent); }
.question-text .q-eq { color: var(--text-muted); font-size: 0.6em; margin-right: 8px; }
.question-text .q-missing {
    display: inline-block;
    min-width: 1.2em;
    padding: 0 0.18em;
    border-radius: 14px;
    border: 3px dashed var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
    box-shadow: 0 0 24px var(--accent-glow);
    animation: pulseSoft 1.6s ease-in-out infinite;
}

/* PROBLEM CARD (book-style purple band) */
.problem-card {
    position: relative;
    background: linear-gradient(180deg, rgba(180, 150, 220, 0.18), rgba(150, 130, 200, 0.10));
    border: 2px solid rgba(180, 150, 220, 0.45);
    border-radius: var(--radius-lg);
    padding: 22px 18px 18px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.10);
    animation: slideInUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.problem-card-badge {
    position: absolute;
    top: -14px;
    right: 18px;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff 30%));
    color: #000;
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 14px;
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    box-shadow: 0 4px 16px var(--accent-glow);
    letter-spacing: 0.5px;
}

.problem-card-text {
    font-family: 'Amiri', 'Cairo', serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 2.0;
    text-align: right;
    margin-bottom: 12px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.problem-card-text .num {
    display: inline-block;
    color: var(--accent);
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-weight: 900;
    font-size: 1.15em;
    margin: 0 3px;
    direction: ltr;
    text-shadow: 0 0 8px var(--accent-glow);
}

.problem-card-question {
    font-family: 'Cairo', sans-serif;
    font-size: 21px;
    font-weight: 900;
    color: var(--accent);
    text-align: right;
    padding-top: 12px;
    border-top: 2px dashed rgba(180, 150, 220, 0.40);
    text-shadow: 0 0 8px var(--accent-glow);
    line-height: 1.5;
}

/* ANSWER INPUT (used in direct/missing) */
.answer-wrap { display: flex; justify-content: center; }
.answer-wrap[hidden] { display: none !important; }

.answer-input {
    width: 80%; max-width: 320px; height: 84px;
    background: var(--surface);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 46px; font-weight: 800;
    text-align: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
    -moz-appearance: textfield; appearance: textfield;
    direction: ltr;
}
.answer-input::-webkit-outer-spin-button, .answer-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.answer-input::placeholder { color: var(--text-dim); font-weight: 800; }
.answer-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); background: rgba(255,255,255,0.07); }
.answer-input.correct { border-color: var(--success); box-shadow: 0 0 0 4px var(--success-glow); animation: bounceIn 0.5s ease; }
.answer-input.wrong { border-color: var(--error); box-shadow: 0 0 0 4px var(--error-glow); animation: shake 0.45s ease; }

/* EQUATION BUILDER (problems mode) */
.eq-builder {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 14px 14px 16px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: relative;
}
.eq-builder-label {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 14px;
    color: var(--text-soft);
    text-align: right;
    margin-bottom: 12px;
}
.eq-builder-row {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    direction: ltr;
}
.eq-input {
    width: 80px; height: 64px;
    background: rgba(255,255,255,0.04);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 30px; font-weight: 900;
    text-align: center;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    -moz-appearance: textfield; appearance: textfield;
    direction: ltr;
}
.eq-input::-webkit-outer-spin-button, .eq-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.eq-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.eq-input::placeholder { color: var(--text-dim); font-weight: 800; font-size: 22px; }

.eq-input.eq-result {
    width: 140px; height: 70px;
    font-size: 32px;
    border: 2px solid var(--accent);
    box-shadow: 0 0 16px var(--accent-glow);
    background: rgba(255,214,0,0.08);
}

.eq-op-btn {
    width: 64px; height: 64px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff 30%));
    color: #000;
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 36px; font-weight: 900;
    box-shadow: 0 0 16px var(--accent-glow), 0 4px 12px rgba(0,0,0,0.3);
    transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    border: 2px solid transparent;
}
.eq-op-btn:active { transform: scale(0.93); }

/* Empty (unchosen) operator: placeholder look — invites the kid to tap */
.eq-op-btn.eq-op-empty {
    background: rgba(255,255,255,0.04) !important;
    color: var(--text-dim) !important;
    border: 2px dashed var(--accent) !important;
    box-shadow: 0 0 14px var(--accent-glow), inset 0 0 0 1px rgba(255,255,255,0.04) !important;
    font-size: 32px;
    animation: opPulse 1.6s ease-in-out infinite;
}
.eq-op-btn.eq-op-empty::after {
    content: '';
    position: absolute;
}
@keyframes opPulse {
    0%, 100% { box-shadow: 0 0 12px var(--accent-glow); transform: scale(1); }
    50%      { box-shadow: 0 0 22px var(--accent-glow); transform: scale(1.04); }
}

.eq-builder-equals {
    text-align: center;
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 30px;
    font-weight: 900;
    color: var(--accent);
    margin: 10px 0 8px;
    text-shadow: 0 0 12px var(--accent-glow);
}

.eq-result-row {
    display: flex; justify-content: center;
}

.eq-builder.correct .eq-input { border-color: var(--success); box-shadow: 0 0 0 3px var(--success-glow); }
.eq-builder.correct .eq-op-btn { background: linear-gradient(135deg, var(--success), #4dffa4); box-shadow: 0 0 16px var(--success-glow); }
.eq-builder.correct .eq-builder-equals { color: var(--success); text-shadow: 0 0 12px var(--success-glow); }
.eq-builder.wrong .eq-input { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-glow); animation: shake 0.45s ease; }

/* Op picker popup */
.eq-op-picker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    background: rgba(13,13,43,0.98);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 2px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 26px var(--accent-glow);
    z-index: 50;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}
.eq-op-picker.show { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.eq-op-picker-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 17px;
    color: var(--text);
    text-align: center;
    direction: rtl;
}
.eq-op-picker-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.eq-op-choice {
    width: 64px; height: 64px;
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    color: var(--text);
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 36px; font-weight: 900;
    border: 2px solid var(--border-strong);
    transition: var(--transition);
    line-height: 1;
}
.eq-op-choice[data-op="add"] { color: var(--add); border-color: rgba(0,230,118,0.4); }
.eq-op-choice[data-op="sub"] { color: var(--sub); border-color: rgba(255,45,120,0.4); }
.eq-op-choice[data-op="mul"] { color: var(--mul); border-color: rgba(255,214,0,0.4); }
.eq-op-choice:active { transform: scale(0.92); }

/* MULTIPLE CHOICE BUTTONS */
.choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    direction: ltr;
}

.choice-btn {
    padding: 16px 8px;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-weight: 900;
    font-size: 26px;
    transition: var(--transition);
    min-height: 60px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.choice-btn:active {
    transform: scale(0.95);
    background: var(--surface-hover);
    border-color: var(--accent);
    box-shadow: 0 0 18px var(--accent-glow);
}
.choice-btn.choice-correct {
    border-color: var(--success);
    background: rgba(0,230,118,0.18);
    color: var(--success);
    box-shadow: 0 0 24px var(--success-glow);
    animation: bounceIn 0.5s ease;
}
.choice-btn.choice-wrong {
    border-color: var(--error);
    background: rgba(255,61,0,0.15);
    color: var(--error);
    box-shadow: 0 0 18px var(--error-glow);
    animation: shake 0.4s ease;
}
.choice-btn:disabled { opacity: 0.55; pointer-events: none; }

/* FEEDBACK — large, kid-friendly */
.feedback {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 3px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 22px 22px 24px;
    text-align: center;
    animation: bounceIn 0.45s ease;
    margin: 0 auto;
    max-width: 440px;
    width: 100%;
}
.feedback.correct { border-color: var(--success); box-shadow: 0 0 40px var(--success-glow), 0 0 80px rgba(0,230,118,0.15); background: linear-gradient(180deg, rgba(0,230,118,0.14), rgba(255,255,255,0.04)); }
.feedback.wrong   { border-color: var(--error);   box-shadow: 0 0 40px var(--error-glow), 0 0 80px rgba(255,61,0,0.15);   background: linear-gradient(180deg, rgba(255,61,0,0.14), rgba(255,255,255,0.04)); }

.feedback-icon {
    font-size: 64px;
    margin-bottom: 6px;
    line-height: 1;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
    animation: iconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feedback-text {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 34px;
    margin-bottom: 14px;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.feedback.correct .feedback-text { color: var(--success); }
.feedback.wrong   .feedback-text { color: var(--error); }

.feedback-correct {
    font-family: 'Cairo', sans-serif;
    font-size: 22px;
    color: var(--text-soft);
    font-weight: 900;
    line-height: 1.5;
}

.feedback-correct .right-answer {
    display: inline-block;
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 44px;
    font-weight: 900;
    color: var(--accent);
    margin: 6px 6px;
    padding: 8px 22px;
    border-radius: var(--radius-md);
    background: rgba(255,214,0,0.16);
    border: 3px solid var(--accent);
    box-shadow: 0 0 26px var(--accent-glow), 0 4px 14px rgba(0,0,0,0.3);
    letter-spacing: 1.5px;
    direction: ltr;
    line-height: 1;
}
.feedback.correct .feedback-correct .right-answer {
    color: var(--success);
    border-color: var(--success);
    background: rgba(0,230,118,0.16);
    box-shadow: 0 0 26px var(--success-glow), 0 4px 14px rgba(0,0,0,0.3);
}

.feedback-correct .your-answer {
    display: inline-block;
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 32px;
    font-weight: 900;
    color: var(--error);
    margin: 4px 4px;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    background: rgba(255,61,0,0.14);
    border: 2.5px solid rgba(255,61,0,0.65);
    text-decoration: line-through;
    text-decoration-thickness: 3px;
    direction: ltr;
    line-height: 1;
}

.feedback-correct .arrow-to {
    display: inline-block;
    margin: 0 10px;
    color: var(--text-soft);
    font-weight: 900;
    font-size: 36px;
    line-height: 1;
    vertical-align: middle;
}

.feedback-correct-line {
    margin-top: 14px;
    font-size: 26px;
    font-weight: 900;
    color: var(--text);
    direction: ltr;
    font-family: Arial, 'Helvetica Neue', sans-serif;
    background: rgba(255,255,255,0.06);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-strong);
    letter-spacing: 1px;
}

.quiz-bottom { padding-top: 12px; transition: padding-bottom 0.2s ease; }

.dots { display: flex; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--border); transition: var(--transition); }
.dot.dot-correct { background: var(--success); box-shadow: 0 0 8px var(--success-glow); }
.dot.dot-wrong   { background: var(--error);   box-shadow: 0 0 8px var(--error-glow); }
.dot.dot-current { background: var(--accent);  box-shadow: 0 0 10px var(--accent); animation: pulse-glow 1.2s ease-in-out infinite; transform: scale(1.3); }

/* RESULTS */
.results-header { text-align: center; margin-bottom: 12px; margin-top: 4px; }
.results-title { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 28px; letter-spacing: 1px; color: var(--text); text-shadow: 0 0 20px var(--accent-glow); }
.results-score-card { background: linear-gradient(135deg, var(--surface-2), var(--surface)); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 20px 18px 16px; text-align: center; margin-bottom: 12px; animation: bounceIn 0.6s ease; }
.score-display { font-family: Arial, 'Helvetica Neue', sans-serif; font-weight: 900; font-size: 64px; line-height: 1; color: var(--text); text-shadow: 0 0 30px var(--accent-glow); margin-bottom: 10px; display: inline-flex; align-items: baseline; gap: 6px; direction: ltr; }
.score-num { color: var(--accent); font-size: 1.2em; animation: countUp 0.6s ease; }
.score-sep, .score-total { color: var(--text-muted); }
.stars { display: flex; justify-content: center; gap: 6px; font-size: 30px; margin: 8px 0 6px; }
.star { display: inline-block; transform: scale(0); opacity: 0; }
.star.star-on { color: var(--accent); text-shadow: 0 0 10px var(--accent); animation: starPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.star.star-off { color: var(--text-dim); animation: starPop 0.5s ease forwards; }
.results-message { margin-top: 6px; font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 19px; color: var(--text); }

.review-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--surface); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 6px; min-height: 80px; max-height: 35vh; }
.review-row { padding: 12px 14px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; border-right: 4px solid transparent; border-radius: 10px; margin-bottom: 4px; background: rgba(255,255,255,0.03); opacity: 0; animation: fadeIn 0.4s ease forwards; }
.review-row:last-child { border-bottom: none; }
.review-row.correct { border-right-color: var(--success); background: rgba(0,230,118,0.06); }
.review-row.wrong   { border-right-color: var(--error);   background: rgba(255,61,0,0.06); }
.review-q { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 14px; color: var(--text-muted); text-align: center; }
.review-eq { font-family: Arial, 'Helvetica Neue', sans-serif; font-weight: 800; color: var(--text); font-size: 16px; word-break: break-word; direction: ltr; text-align: left; }
.review-eq .eq-result-num { color: var(--accent); font-weight: 900; }
.review-ans { font-family: Arial, 'Helvetica Neue', sans-serif; font-weight: 900; font-size: 15px; text-align: left; line-height: 1.2; white-space: nowrap; direction: ltr; }
.review-row.correct .review-ans { color: var(--success); }
.review-row.wrong .review-ans { color: var(--error); }
.review-row .review-ans .ans-icon { font-size: 19px; margin-left: 2px; }

.results-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.btn-yellow { background: linear-gradient(135deg, var(--mul), #FFE657); color: #000; }

.congrats-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; padding: 22px 16px; text-align: center; font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 26px; letter-spacing: 0.5px; background: rgba(7,7,26,0.9); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border-bottom: 2px solid var(--accent); box-shadow: 0 8px 30px var(--accent-glow); animation: congrats-banner 4s ease forwards, textRainbow 2s linear infinite; }

/* SCORES */
.scores-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.scores-title { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 22px; color: var(--text); }
.scores-spacer { width: 48px; }
.scores-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 10px; }
.scores-empty { text-align: center; color: var(--text-muted); padding: 40px 12px; font-weight: 800; font-size: 16px; }
.score-row { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 10px; padding: 14px 16px; background: var(--surface); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--border-strong); border-radius: var(--radius-md); opacity: 0; animation: slideInUp 0.35s ease forwards; }
.score-row.perfect { border-color: var(--accent); box-shadow: 0 0 20px var(--accent-glow); background: linear-gradient(135deg, rgba(255,214,0,0.10), rgba(255,255,255,0.04)); }
.score-row-op { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: Arial, 'Helvetica Neue', sans-serif; font-size: 22px; font-weight: 900; background: var(--surface-hover); border: 1.5px solid var(--border-strong); color: var(--text); }
.score-row-op.op-mul { color: var(--mul); border-color: rgba(255,214,0,0.4); box-shadow: 0 0 8px var(--mul-glow); }
.score-row-op.op-add { color: var(--add); border-color: rgba(0,230,118,0.4); box-shadow: 0 0 8px var(--add-glow); }
.score-row-op.op-sub { color: var(--sub); border-color: rgba(255,45,120,0.4); box-shadow: 0 0 8px var(--sub-glow); }
.score-row-mode {
    font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 11px;
    padding: 3px 8px; border-radius: var(--radius-pill);
    background: rgba(255,255,255,0.07);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.score-row-lvl { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 13px; padding: 5px 10px; border-radius: var(--radius-pill); background: var(--surface-hover); text-align: center; color: var(--accent); border: 1px solid var(--border); white-space: nowrap; }
.score-row-score { font-family: Arial, 'Helvetica Neue', sans-serif; font-weight: 900; font-size: 20px; color: var(--text); direction: ltr; text-align: left; }
.score-row-stars { color: var(--accent); font-size: 15px; letter-spacing: 1px; text-shadow: 0 0 8px var(--accent-glow); white-space: nowrap; grid-column: 1 / -1; text-align: left; margin-top: -4px; }
.score-row-date { grid-column: 1 / -1; font-size: 11px; color: var(--text-muted); margin-top: 0; text-align: left; font-weight: 700; direction: ltr; }
.best-score { text-align: center; margin-top: 12px; padding: 14px; color: var(--text); font-weight: 900; font-size: 17px; }
.best-score #best-score-val { color: var(--accent); font-family: Arial, 'Helvetica Neue', sans-serif; font-size: 20px; margin: 0 6px; direction: ltr; display: inline-block; }

/* SHEET */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 100; opacity: 0; transition: opacity 0.3s ease; }
.modal-backdrop.show { opacity: 1; }
.bottom-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 101; background: linear-gradient(180deg, rgba(13,13,43,0.97), rgba(7,7,26,0.99)); backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%); border-top: 1px solid var(--border-strong); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 14px 22px max(28px, env(safe-area-inset-bottom)); box-shadow: 0 -8px 40px rgba(0,0,0,0.6), 0 0 0 1px var(--border-strong); transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); max-height: 90vh; overflow-y: auto; }
.bottom-sheet.show { transform: translateY(0); }
.sheet-handle { width: 48px; height: 5px; background: var(--border-strong); border-radius: var(--radius-pill); margin: 0 auto 14px; }
.sheet-title { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 24px; color: var(--text); text-align: center; margin-bottom: 22px; }
.sheet-body { margin-bottom: 22px; }
.sheet-label { display: block; font-weight: 800; color: var(--text-soft); font-size: 15px; margin-bottom: 14px; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; direction: ltr; background: linear-gradient(to right, var(--mul) 0%, var(--mul) var(--val, 50%), rgba(255,255,255,0.15) var(--val, 50%), rgba(255,255,255,0.15) 100%); box-shadow: 0 0 8px rgba(255,214,0,0.15); margin-bottom: 8px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 30px; height: 30px; border-radius: 50%; background: var(--mul); box-shadow: 0 0 12px var(--mul-glow), 0 2px 8px rgba(0,0,0,0.4); cursor: pointer; border: 3px solid #0d0d2b; transition: transform 0.15s ease; }
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb { width: 30px; height: 30px; border-radius: 50%; background: var(--mul); box-shadow: 0 0 12px var(--mul-glow); border: 3px solid #0d0d2b; cursor: pointer; }
.slider-scale { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 13px; font-weight: 800; margin-bottom: 12px; padding: 0 4px; direction: ltr; font-family: Arial, 'Helvetica Neue', sans-serif; }
.slider-current { text-align: center; color: var(--text-soft); font-size: 16px; font-weight: 800; margin-bottom: 16px; }
.slider-current #slider-value-box { display: inline-block; min-width: 56px; padding: 6px 14px; margin: 0 6px; background: var(--surface-hover); border-radius: var(--radius-sm); color: var(--mul); font-family: Arial, 'Helvetica Neue', sans-serif; font-size: 22px; font-weight: 900; border: 2px solid var(--border-glow); direction: ltr; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md); margin-top: 8px; }
.setting-row-info { flex: 1; min-width: 0; }
.setting-row-title { display: flex; align-items: center; gap: 8px; font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 16px; color: var(--text); margin-bottom: 2px; }
.setting-row-title span:first-child { font-size: 22px; }
.setting-row-desc { font-size: 12px; color: var(--text-muted); font-weight: 700; }

.toggle-switch { position: relative; display: inline-block; width: 56px; height: 32px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: rgba(255,255,255,0.15); border: 1px solid var(--border-strong); border-radius: 999px; transition: var(--transition); }
.toggle-slider::before { content: ''; position: absolute; width: 24px; height: 24px; right: 3px; top: 3px; background: #fff; border-radius: 50%; transition: var(--transition); box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
.toggle-switch input:checked + .toggle-slider { background: var(--mul); box-shadow: 0 0 12px var(--mul-glow); border-color: var(--mul); }
.toggle-switch input:checked + .toggle-slider::before { right: calc(100% - 27px); background: #07071a; }

/* QUIT */
.confirm-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.9); z-index: 102; width: calc(100% - 40px); max-width: 360px; padding: 28px 22px; text-align: center; opacity: 0; transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.confirm-modal.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.confirm-icon { font-size: 48px; margin-bottom: 8px; }
.confirm-title { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 22px; margin-bottom: 6px; color: var(--text); }
.confirm-text { color: var(--text-soft); font-size: 15px; margin-bottom: 20px; font-weight: 700; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions button { flex: 1; }

/* TOAST */
.toast { position: fixed; bottom: max(28px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(20px); z-index: 200; background: rgba(0,230,118,0.95); color: #001b09; padding: 14px 24px; border-radius: var(--radius-pill); font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 16px var(--success-glow); opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease; pointer-events: none; max-width: calc(100% - 40px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: rgba(255,61,0,0.95); color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 16px var(--error-glow); }

#confetti-canvas { position: fixed; inset: 0; z-index: 999; pointer-events: none; width: 100vw; height: 100vh; }
audio { display: none; }

/* =================================================================
   EXAM (الروائز)
   ================================================================= */
.exam-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 4px 4px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}

.exam-item {
    background: linear-gradient(135deg, var(--surface-2), var(--surface));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 14px 14px 14px;
    box-shadow: var(--shadow-card);
    position: relative;
    animation: slideInUp 0.4s ease both;
}

.exam-item-num {
    position: absolute;
    top: -12px;
    right: 14px;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff 30%));
    color: #000;
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    box-shadow: 0 4px 12px var(--accent-glow);
    letter-spacing: 0.5px;
}

.exam-item-kind {
    position: absolute;
    top: -12px;
    left: 14px;
    background: var(--surface-hover);
    color: var(--text-soft);
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
}

/* Direct/missing equation row inside exam */
.exam-eq {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    direction: ltr;
    margin-top: 6px;
    flex-wrap: wrap;
}

.exam-eq .num,
.exam-eq .op,
.exam-eq .eq {
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-weight: 900;
    font-size: 28px;
    color: var(--text);
    line-height: 1;
}

.exam-eq .op { color: var(--accent); }
.exam-eq .eq { color: var(--text-muted); }

.exam-input {
    width: 80px;
    height: 50px;
    background: rgba(255,255,255,0.04);
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 26px;
    font-weight: 900;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
    direction: ltr;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 0 12px var(--accent-glow);
}
.exam-input::-webkit-outer-spin-button,
.exam-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.exam-input::placeholder { color: var(--text-dim); font-weight: 800; font-size: 22px; }
.exam-input:focus { box-shadow: 0 0 0 3px var(--accent-glow); }
.exam-input.exam-correct { border-color: var(--success); box-shadow: 0 0 0 3px var(--success-glow); background: rgba(0,230,118,0.08); }
.exam-input.exam-wrong   { border-color: var(--error);   box-shadow: 0 0 0 3px var(--error-glow);   background: rgba(255,61,0,0.08); }

/* Problem inside exam */
.exam-problem-text {
    font-family: 'Amiri', 'Cairo', serif;
    font-size: 21px;
    font-weight: 700;
    color: var(--text);
    line-height: 2.0;
    text-align: right;
    margin: 10px 0 12px;
}
.exam-problem-text .num {
    display: inline-block;
    color: var(--accent);
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-weight: 900;
    font-size: 1.15em;
    margin: 0 4px;
    direction: ltr;
    text-shadow: 0 0 8px var(--accent-glow);
}
.exam-problem-q {
    font-family: 'Cairo', sans-serif;
    font-size: 19px;
    font-weight: 900;
    color: var(--accent);
    margin-bottom: 14px;
    text-align: right;
    border-top: 2px dashed var(--border-strong);
    padding-top: 12px;
    line-height: 1.6;
    text-shadow: 0 0 8px var(--accent-glow);
}

/* Compact equation builder for exam */
.exam-eq-builder {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}
.exam-eq-builder .row {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    direction: ltr;
}
.exam-eq-mini-input {
    width: 64px; height: 46px;
    background: rgba(255,255,255,0.04);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 22px; font-weight: 900;
    text-align: center;
    -moz-appearance: textfield; appearance: textfield;
    direction: ltr;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.exam-eq-mini-input::-webkit-outer-spin-button,
.exam-eq-mini-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.exam-eq-mini-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.exam-eq-mini-input::placeholder { color: var(--text-dim); font-size: 18px; }
.exam-eq-mini-input.exam-correct { border-color: var(--success); box-shadow: 0 0 0 2px var(--success-glow); background: rgba(0,230,118,0.08); }
.exam-eq-mini-input.exam-wrong { border-color: var(--error); box-shadow: 0 0 0 2px var(--error-glow); background: rgba(255,61,0,0.08); }

.exam-eq-result {
    width: 110px;
    border-color: var(--accent);
    background: rgba(255,214,0,0.08);
    box-shadow: 0 0 10px var(--accent-glow);
}

.exam-eq-op-btn {
    width: 50px; height: 46px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff 30%));
    color: #000;
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 26px; font-weight: 900;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: var(--transition);
    border: 2px solid transparent;
}
.exam-eq-op-btn:active { transform: scale(0.92); }
.exam-eq-op-btn.exam-correct { background: linear-gradient(135deg, var(--success), #4dffa4); }
.exam-eq-op-btn.exam-wrong   { background: linear-gradient(135deg, var(--error), #ff7a4a); color: #fff; }
.exam-eq-op-btn.eq-op-empty {
    background: rgba(255,255,255,0.04) !important;
    color: var(--text-dim) !important;
    border: 2px dashed var(--accent) !important;
    box-shadow: 0 0 10px var(--accent-glow) !important;
    font-size: 24px;
    animation: opPulse 1.6s ease-in-out infinite;
}

.exam-eq-equals {
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 22px;
    font-weight: 900;
    color: var(--accent);
    margin: 4px 0;
}

/* Mini op picker for exam */
.exam-op-picker {
    position: absolute;
    z-index: 50;
    background: rgba(13,13,43,0.98);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 2px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: none;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 18px var(--accent-glow);
    flex-direction: column;
}
.exam-op-picker.show { display: flex; animation: bounceIn 0.25s ease; }
.exam-op-picker-title {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 15px;
    color: var(--text);
    text-align: center;
    direction: rtl;
}
.exam-op-picker-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.exam-op-picker .ch {
    width: 50px; height: 50px;
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    color: var(--text);
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-size: 26px; font-weight: 900;
    border: 2px solid var(--border-strong);
    transition: var(--transition);
}
.exam-op-picker .ch[data-op="add"] { color: var(--add); border-color: rgba(0,230,118,0.4); }
.exam-op-picker .ch[data-op="sub"] { color: var(--sub); border-color: rgba(255,45,120,0.4); }
.exam-op-picker .ch[data-op="mul"] { color: var(--mul); border-color: rgba(255,214,0,0.4); }
.exam-op-picker .ch:active { transform: scale(0.92); }

.exam-bottom {
    padding-top: 12px;
    transition: padding-bottom 0.2s ease;
}

/* Exam results */
.exam-pct-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.exam-pct {
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-weight: 900;
    font-size: 28px;
    color: var(--accent);
    text-shadow: 0 0 12px var(--accent-glow);
    direction: ltr;
}
.exam-time-spent {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    font-size: 14px;
    color: var(--text-soft);
}

.exam-review {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px;
    min-height: 80px;
    max-height: 38vh;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.exam-review-row {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border-right: 4px solid transparent;
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.exam-review-row.correct { border-right-color: var(--success); background: rgba(0,230,118,0.06); }
.exam-review-row.wrong   { border-right-color: var(--error);   background: rgba(255,61,0,0.06); }

.exam-review-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.exam-review-num {
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 13px;
    color: var(--text-muted);
}
.exam-review-icon { font-size: 18px; }

.exam-review-eq {
    font-family: Arial, 'Helvetica Neue', sans-serif;
    font-weight: 800;
    font-size: 16px;
    color: var(--text);
    direction: ltr;
    text-align: left;
}
.exam-review-eq .eq-result-num { color: var(--accent); font-weight: 900; }
.exam-review-eq .your { color: var(--error); text-decoration: line-through; }
.exam-review-row.correct .exam-review-eq .your { color: var(--success); text-decoration: none; }
.exam-review-note {
    font-family: 'Cairo', sans-serif;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
    text-align: right;
    margin-top: 2px;
}
.exam-review-problem {
    font-family: 'Amiri', 'Cairo', serif;
    font-size: 14px;
    color: var(--text-soft);
    font-weight: 700;
    line-height: 1.6;
    text-align: justify;
    direction: rtl;
}
.exam-review-problem .num { color: var(--accent); font-family: Arial, 'Helvetica Neue', sans-serif; font-weight: 900; }

/* Setting groups */
.setting-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 10px;
}
.setting-group .sheet-label { margin-bottom: 8px; }
.setting-group .slider-current { margin-bottom: 0; }

/* Mobile adjustments */
@media (max-width: 360px) {
    .mode-tab-label { font-size: 9px; }
    .mode-tab-icon { font-size: 18px; }
    .mode-tab { padding: 8px 2px; min-height: 56px; }
    .exam-eq .num, .exam-eq .op, .exam-eq .eq { font-size: 24px; }
    .exam-input { width: 70px; height: 46px; font-size: 22px; }
    .exam-eq-mini-input { width: 56px; height: 42px; font-size: 20px; }
    .exam-eq-result { width: 95px; }
}

/* ANIMATIONS */
@keyframes shimmer { 0% { background-position: -200% center; } 100% { background-position: 200% center; } }
@keyframes titlePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pulse-glow { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.7; } }
@keyframes pulseSoft { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.7; transform: scale(1.05); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes bounceIn { 0% { transform: scale(0.3); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 80% { transform: scale(0.95); } 100% { transform: scale(1); opacity: 1; } }
@keyframes slideInUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes starPop { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 60% { transform: scale(1.3) rotate(0deg); opacity: 1; } 100% { transform: scale(1) rotate(0deg); opacity: 1; } }
@keyframes countUp { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }
@keyframes textRainbow { 0% { color: #FFD600; } 25% { color: #FF2D78; } 50% { color: #00E676; } 75% { color: #00B0FF; } 100% { color: #FFD600; } }
@keyframes twinkle { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
@keyframes drift { 0% { transform: translateY(0); } 100% { transform: translateY(-100vh); } }
@keyframes nebula { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }
@keyframes barPulse { 0%, 100% { box-shadow: 0 0 8px var(--error); } 50% { box-shadow: 0 0 20px var(--error); } }
@keyframes congrats-banner { 0% { transform: translateY(-100%); opacity: 0; } 15% { transform: translateY(0); opacity: 1; } 85% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-100%); opacity: 0; } }
@keyframes iconPop {
    0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
    60%  { transform: scale(1.4) rotate(0deg); opacity: 1; }
    80%  { transform: scale(0.92); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes floatOrb1 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(40px, 60px); } }
@keyframes floatOrb2 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-50px, -30px); } }
@keyframes floatOrb3 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-30px, 50px); } }

/* RESPONSIVE */
@media (max-height: 740px) {
    .level-card { padding: 11px 14px; }
    .level-icon { font-size: 34px; }
    .level-name { font-size: 19px; }
    .level-desc { font-size: 12px; }
    .level-example { font-size: 15px; }
    .level-cta { padding-top: 7px; font-size: 12px; }
    .game-title { font-size: 22px; }
    .level-cards { gap: 8px; }
    .home-header { margin-bottom: 8px; }
    .op-tabs { margin-bottom: 10px; padding: 6px; gap: 6px; }
    .op-tab { padding: 13px 6px; font-size: 16px; min-height: 50px; }
    .op-tab-symbol { font-size: 24px; }
    .mode-tabs { margin-bottom: 10px; gap: 6px; }
    .mode-tab { padding: 11px 4px; font-size: 12px; min-height: 74px; gap: 4px; }
    .mode-tab-icon { font-size: 26px; }
    .ghost-btn { font-size: 16px; padding: 13px 20px; min-height: 50px; }
    .ghost-btn span:first-child { font-size: 19px; }
    .home-footer { margin-top: 10px; gap: 10px; }
    .question-text { font-size: 50px; }
    .answer-input { height: 76px; font-size: 42px; }
    .problem-card-text { font-size: 17px; line-height: 1.8; }
    .eq-input { height: 56px; font-size: 26px; width: 70px; }
    .eq-op-btn { height: 56px; width: 56px; font-size: 30px; }
    .eq-input.eq-result { height: 60px; font-size: 28px; width: 130px; }
}

@media (max-height: 640px) {
    .question-text { font-size: 44px; }
    .answer-input { height: 66px; font-size: 36px; }
    .score-display { font-size: 50px; }
    .stars { font-size: 24px; }
    .level-card { padding: 9px 12px; }
    .level-icon { font-size: 30px; }
    .level-name { font-size: 17px; }
    .level-row { gap: 10px; margin-bottom: 6px; }
    .game-title { font-size: 20px; }
    .problem-card { padding: 16px 14px 14px; }
    .problem-card-text { font-size: 16px; line-height: 1.7; }
    .problem-card-question { font-size: 14px; }
    .eq-input { height: 50px; font-size: 24px; width: 64px; }
    .eq-op-btn { height: 50px; width: 50px; font-size: 26px; }
    .eq-input.eq-result { height: 56px; font-size: 26px; width: 120px; }
    .choice-btn { font-size: 22px; padding: 12px 8px; min-height: 52px; }
}

@media (max-width: 360px) {
    .game-title { font-size: 20px; }
    .question-text { font-size: 42px; }
    .answer-input { font-size: 36px; height: 70px; }
    .score-display { font-size: 50px; }
    .feedback { padding: 18px 16px 20px; }
    .feedback-icon { font-size: 54px; }
    .feedback-text { font-size: 28px; }
    .feedback-correct { font-size: 19px; }
    .feedback-correct .right-answer { font-size: 36px; padding: 6px 18px; }
    .feedback-correct .your-answer { font-size: 26px; padding: 4px 12px; }
    .feedback-correct .arrow-to { font-size: 30px; }
    .feedback-correct-line { font-size: 22px; }
    .review-eq { font-size: 15px; }
    .review-ans { font-size: 14px; }
    .op-tab-label { display: inline; font-size: 14px; }
    .op-tab { padding: 14px 4px; gap: 4px; }
    .op-tab-symbol { font-size: 24px; }
    .mode-tab { padding: 12px 4px; min-height: 80px; }
    .mode-tab-label { font-size: 12px; }
    .mode-tab-icon { font-size: 26px; }
    .ghost-btn { font-size: 16px; padding: 14px 18px; }
    .ghost-btn span:first-child { font-size: 20px; }
    .eq-input { width: 60px; font-size: 22px; }
    .eq-input.eq-result { width: 110px; font-size: 24px; }
    .choice-btn { font-size: 20px; }
    .problem-card-text { font-size: 16px; }
}

@media (min-width: 480px) {
    .screen { padding: 24px 22px; }
}
