@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

:root {
    --primary-color: #f43f5e;
    /* Cute Rose Pink */
    --primary-dark: #be123c;
    --primary-light: #ff758c;
    --secondary-color: #fb7185;
    /* Soft Blossom */
    --accent-color: #ff7eb3;
    /* Sweet Petal */
    --gold-accent: #f59e0b;
    /* Rose Gold */
    --background-color: #fff5f8;
    /* Dreamy Floral Backdrop */
    --card-bg: rgba(255, 255, 255, 0.94);
    /* Bright frosted glass */
    --text-main: #334155;
    --text-muted: #64748b;
    --success-color: #10b981;
    --error-color: #e11d48;
    --border-radius: 28px;
    --shadow: 0 15px 35px rgba(244, 63, 94, 0.15);
    --fairy-glow: 0 0 25px rgba(244, 63, 94, 0.35), 0 0 45px rgba(255, 117, 140, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', 'Cairo', sans-serif;
}

body {
    background-color: #fff5f8;
    background-image:
        radial-gradient(circle at 10% 15%, rgba(255, 117, 140, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 85%, rgba(255, 126, 179, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(254, 205, 211, 0.12) 0%, transparent 60%),
        linear-gradient(135deg, #fff5f7 0%, #fff0f5 50%, #fdf2f8 100%);
    color: var(--text-main);
    direction: rtl;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================================
   🌸 BACKGROUND FLOATING WATERMARKS & PETALS 🌸
   ======================================================== */
.bg-decorations {
    position: fixed !important;
    inset: 0 !important;
    pointer-events: none !important;
    z-index: 0 !important;
    overflow: hidden !important;
}

.floral-watermark {
    position: absolute !important;
    color: #fbcfe8 !important;
    opacity: 0.18 !important;
    font-size: 110px !important;
    user-select: none !important;
    filter: blur(1px) !important;
}

.floral-watermark.wm-1 {
    top: 40px !important;
    left: -20px !important;
    transform: rotate(-15deg) !important;
}

.floral-watermark.wm-2 {
    bottom: 60px !important;
    right: -20px !important;
    transform: rotate(20deg) !important;
    font-size: 130px !important;
}

.floral-watermark.wm-3 {
    top: 50% !important;
    left: -30px !important;
    transform: rotate(10deg) !important;
    font-size: 90px !important;
}

.floating-petal {
    position: absolute !important;
    font-size: 24px !important;
    opacity: 0.55 !important;
    user-select: none !important;
    animation: royalFloatPetal 12s infinite ease-in-out alternate !important;
}

.floating-petal.p-1 { top: 12%; right: 10%; animation-delay: 0s; }
.floating-petal.p-2 { top: 25%; left: 8%; animation-delay: 1.5s; font-size: 20px; }
.floating-petal.p-3 { top: 75%; left: 15%; animation-delay: 3s; }
.floating-petal.p-4 { top: 80%; right: 18%; animation-delay: 4.5s; }
.floating-petal.p-5 { top: 45%; right: 4%; animation-delay: 2s; font-size: 22px; }

@keyframes royalFloatPetal {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(15deg); }
    100% { transform: translateY(-8px) rotate(-10deg); }
}

/* Header & Gamification */
/* =========================================================
   🌸 UNIFIED COMPACT ROYAL HEADER FOR PRINCESS MALAK 🌸
========================================================= */
.main-header.compact-pro-header,
.fairy-header {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1.5px solid #fbcfe8 !important;
    border-radius: 20px !important;
    box-shadow: 0 4px 18px rgba(244, 63, 94, 0.08) !important;
    padding: 8px 22px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: sticky !important;
    top: 10px !important;
    z-index: 100 !important;
    min-height: 56px !important;
    box-sizing: border-box !important;
    max-width: 1200px !important;
    width: calc(100% - 32px) !important;
    margin: 10px auto 1.2rem auto !important;
}

.hero-profile-compact {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    flex-shrink: 0 !important;
}

.compact-avatar-wrap {
    position: relative !important;
    width: 44px !important;
    height: 44px !important;
    background: linear-gradient(135deg, #fff0f5, #ffe4e6) !important;
    border: 2px solid #fbcfe8 !important;
    box-shadow: 0 2px 10px rgba(244, 63, 94, 0.2) !important;
    border-radius: 50% !important;
    padding: 2px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: transform 0.2s ease !important;
    flex-shrink: 0 !important;
}

.compact-avatar-wrap:hover {
    transform: scale(1.08) !important;
}

.compact-avatar-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

.compact-crown {
    position: absolute !important;
    top: -8px !important;
    right: -5px !important;
    font-size: 15px !important;
    filter: drop-shadow(0 1px 3px rgba(245, 158, 11, 0.5)) !important;
}

.compact-title-wrap {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
}

.compact-name-row {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
}

.compact-student-name {
    font-family: 'Changa', 'Tajawal', sans-serif !important;
    font-size: 1.35rem !important;
    font-weight: 900 !important;
    color: #be123c !important;
    margin: 0 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
}

.compact-subject-badge {
    font-family: 'Tajawal', sans-serif !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    color: #9d174d !important;
    background: #fce7f3 !important;
    border: 1px solid #fbcfe8 !important;
    padding: 3px 12px !important;
    border-radius: 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
}

.header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
}

.stat-badge-link {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 14px !important;
    background: #ffffff !important;
    border: 1.5px solid #fbcfe8 !important;
    border-radius: 20px !important;
    color: #be123c !important;
    font-family: 'Tajawal', sans-serif !important;
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(236, 72, 153, 0.1) !important;
    transition: all 0.25s ease !important;
    cursor: pointer !important;
    outline: none !important;
    white-space: nowrap !important;
}

.stat-badge-link:hover {
    background: linear-gradient(135deg, #fdf2f8, #fce7f3) !important;
    border-color: #f43f5e !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.2) !important;
    color: #831843 !important;
}

.stat-badge-link.games-link {
    background: linear-gradient(135deg, #fffbeb, #fef3c7) !important;
    border-color: #fde68a !important;
    color: #b45309 !important;
}

.stat-badge-link.mult-link {
    background: linear-gradient(135deg, #eff6ff, #dbeafe) !important;
    border-color: #bfdbfe !important;
    color: #1d4ed8 !important;
}

.stat-badge-link.hidden,
.header-actions .hidden,
#headerBackToChaptersBtn.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    .main-header.compact-pro-header {
        padding: 6px 14px !important;
        gap: 8px !important;
    }
    .compact-student-name {
        font-size: 1.15rem !important;
    }
    .compact-subject-badge {
        font-size: 0.76rem !important;
        padding: 2px 8px !important;
    }
    .stat-badge-link {
        padding: 5px 11px !important;
        font-size: 0.82rem !important;
    }
}

@media (max-width: 600px) {
    .main-header.compact-pro-header {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        padding: 8px 10px !important;
        width: calc(100% - 16px) !important;
        margin: 6px auto 0.8rem auto !important;
    }
    .hero-profile-compact {
        width: 100% !important;
        justify-content: center !important;
        gap: 8px !important;
    }
    .compact-avatar-wrap {
        width: 38px !important;
        height: 38px !important;
    }
    .header-actions {
        width: 100% !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    .stat-badge-link {
        padding: 4px 10px !important;
        font-size: 0.78rem !important;
    }
}

/* Lesson Mode Header (Active inside Lessons: keeps only Profile, Return to Chapters, and Home) */
.fairy-header.lesson-mode-header,
.main-header.compact-pro-header.lesson-mode-header {
    padding: 0.5rem 1.8rem !important;
    justify-content: space-between !important;
}

.fairy-header.lesson-mode-header .fairy-header-center,
.main-header.compact-pro-header.lesson-mode-header .fairy-header-center {
    display: none !important;
}

.fairy-header.lesson-mode-header #multTableBtn,
.main-header.compact-pro-header.lesson-mode-header #multTableBtn,
.fairy-header.lesson-mode-header #playFairiesBtn,
.main-header.compact-pro-header.lesson-mode-header #playFairiesBtn {
    display: none !important;
}

.fairy-header.lesson-mode-header #headerBackToChaptersBtn,
.main-header.compact-pro-header.lesson-mode-header #headerBackToChaptersBtn {
    display: inline-flex !important;
}

.btn-header-back-chapters {
    background: linear-gradient(135deg, #fff0f5 0%, #ffe4e6 100%) !important;
    border: 1.5px solid #fbcfe8 !important;
    color: #be123c !important;
    padding: 7px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    font-weight: 900;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 10px rgba(244, 63, 94, 0.1);
    transition: all 0.25s ease;
    font-family: 'Alexandria', 'Cairo', sans-serif;
    text-decoration: none;
}

.btn-header-back-chapters:hover {
    background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%) !important;
    color: #831843 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(244, 63, 94, 0.2);
}

.back-btn {
    background: linear-gradient(135deg, #fff0f5 0%, #ffe4e6 100%) !important;
    border: 1.5px solid #fbcfe8 !important;
    color: #be123c !important;
    padding: 8px 22px !important;
    border-radius: 20px !important;
    font-size: 0.92rem !important;
    font-weight: 800 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    box-shadow: 0 3px 12px rgba(244, 63, 94, 0.1) !important;
    transition: all 0.25s ease !important;
    font-family: 'Cairo', 'Tajawal', sans-serif !important;
    text-decoration: none !important;
    margin-bottom: 1rem !important;
}

.back-btn:hover {
    background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%) !important;
    color: #831843 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 18px rgba(244, 63, 94, 0.2) !important;
}

/* 1. Student Profile (Right side in RTL) */
.user-profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-glow {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle, #ff007f 0%, #3c096c 100%);
    border: 2.5px solid #00f0ff;
    box-shadow: 0 0 20px rgba(255, 0, 127, 0.8), 0 0 30px rgba(0, 240, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}

.user-avatar-glow:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 30px rgba(255, 0, 127, 1), 0 0 45px rgba(0, 240, 255, 0.9);
}

.user-profile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.avatar-fairy-badge {
    position: absolute;
    bottom: -4px;
    left: -4px;
    background: linear-gradient(135deg, #ff007f, #00f0ff);
    border: 1.5px solid #ffd32a;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.user-info-text {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.student-name {
    font-size: 1.25rem;
    font-weight: 900;
    color: #FFFFFF;
    text-shadow: 0 0 12px rgba(255, 0, 127, 0.9);
    margin: 0;
    line-height: 1.2;
}

.student-grade-pill {
    display: inline-block;
    font-size: 0.74rem;
    font-weight: 800;
    color: #00f0ff;
    background: rgba(255, 0, 127, 0.25);
    border: 1px solid rgba(0, 240, 255, 0.5);
    border-radius: 20px;
    padding: 3px 10px;
    margin-top: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* 2. Center Magical Title */
.fairy-header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
}

.magical-title {
    font-size: clamp(1.25rem, 2.2vw, 1.8rem);
    margin: 0;
    background: linear-gradient(135deg, #ffffff 0%, #ffb3c6 45%, #fee440 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(247, 37, 133, 0.35);
    font-weight: 900;
    line-height: 1.2;
}

.magical-subtitle {
    font-size: 0.8rem;
    color: #e0aaff;
    margin: 3px 0 0 0;
    font-weight: 600;
}

/* 3. Actions / Buttons (Left side in RTL) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-play-fairies {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: linear-gradient(135deg, #f72585 0%, #7209b7 100%);
    color: #FFFFFF !important;
    text-decoration: none !important;
    border-radius: 50px;
    font-weight: 900;
    font-size: 0.95rem;
    box-shadow: 0 4px 18px rgba(247, 37, 133, 0.6), 0 0 16px rgba(254, 228, 64, 0.4);
    border: 2px solid #fee440;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.btn-play-fairies:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(247, 37, 133, 0.85), 0 0 25px rgba(254, 228, 64, 0.7);
    background: linear-gradient(135deg, #7209b7 0%, #f72585 100%);
}

.btn-play-fairies:active {
    transform: scale(0.95);
}

.fairy-btn-icon {
    font-size: 1.25rem;
    animation: gentleWiggle 2s infinite ease-in-out;
}

@keyframes gentleWiggle {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-10deg);
    }

    75% {
        transform: rotate(10deg);
    }
}

.fairy-sparkle-star {
    font-size: 0.85rem;
    animation: pulseStar 1.5s infinite alternate;
}

@keyframes pulseStar {
    0% {
        transform: scale(0.8);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.2);
        opacity: 1;
        filter: drop-shadow(0 0 6px #fee440);
    }
}

.btn-magical-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF !important;
    text-decoration: none !important;
    border-radius: 50px;
    font-weight: 800;
    font-size: 0.95rem;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
}

.btn-magical-back:hover {
    background: rgba(247, 37, 133, 0.3);
    border-color: #fee440;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(247, 37, 133, 0.4);
}

/* Header Responsive Breakpoints */
@media (max-width: 860px) {
    .fairy-header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 10px;
    }

    .fairy-header-center {
        order: 3;
        width: 100%;
        margin-top: 4px;
    }

    .user-profile-header {
        order: 1;
    }

    .header-actions {
        order: 2;
    }

    .user-avatar-glow {
        width: 52px;
        height: 52px;
    }

    .student-name {
        font-size: 1.1rem;
    }

    .btn-play-fairies {
        padding: 6px 12px;
        font-size: 0.82rem;
    }

    .btn-magical-back {
        padding: 6px 12px;
        font-size: 0.82rem;
    }
}

/* --- 7-Second Profile Magic Effects & Lighting --- */
.magic-glow-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    box-shadow: inset 0 0 100px rgba(247, 37, 133, 0.7), inset 0 0 160px rgba(254, 228, 64, 0.5), inset 0 0 200px rgba(76, 201, 240, 0.4);
    animation: magicalAuraPulse 1.2s ease-in-out infinite alternate;
    transition: opacity 0.8s ease;
}

@keyframes magicalAuraPulse {
    0% {
        box-shadow: inset 0 0 90px rgba(247, 37, 133, 0.8), inset 0 0 160px rgba(254, 228, 64, 0.6);
        background: radial-gradient(circle at 50% 10%, rgba(247, 37, 133, 0.18), transparent 70%);
    }

    50% {
        box-shadow: inset 0 0 130px rgba(76, 201, 240, 0.8), inset 0 0 190px rgba(254, 228, 64, 0.7);
        background: radial-gradient(circle at 50% 50%, rgba(76, 201, 240, 0.22), transparent 75%);
    }

    100% {
        box-shadow: inset 0 0 110px rgba(254, 228, 64, 0.8), inset 0 0 170px rgba(247, 37, 133, 0.7);
        background: radial-gradient(circle at 50% 90%, rgba(254, 228, 64, 0.2), transparent 70%);
    }
}

/* Avatar Royal Halo during Magic */
.user-avatar-glow.magic-active {
    animation: royalFairyGlow 1.2s ease-in-out infinite alternate !important;
}

@keyframes royalFairyGlow {
    0% {
        transform: scale(1.18) rotate(0deg);
        box-shadow: 0 0 35px #fee440, 0 0 60px #f72585, 0 0 90px #4cc9f0;
    }

    100% {
        transform: scale(1.26) rotate(6deg);
        box-shadow: 0 0 50px #f72585, 0 0 80px #fee440, 0 0 120px #ff70a6;
    }
}

/* Cute Platform Dancing & Bobbing (7 seconds) */
.magic-platform-dancing {
    animation: cutePlatformDance 1.4s ease-in-out infinite alternate;
}

@keyframes cutePlatformDance {
    0% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-6px) scale(1.008);
    }

    100% {
        transform: translateY(4px) scale(1);
    }
}

.magic-sparkle-card {
    animation: cardMagicSparkle 1.2s ease-in-out infinite alternate !important;
}

@keyframes cardMagicSparkle {
    0% {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 25px rgba(247, 37, 133, 0.6);
        transform: translateY(-4px);
    }

    100% {
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 0 45px rgba(254, 228, 64, 0.85);
        transform: translateY(-10px) scale(1.03);
    }
}

/* Floating Magical Visual Sprites (Pure visual magic, No text) */
.magic-floating-sprite {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    font-size: 2.2rem;
    filter: drop-shadow(0 0 15px rgba(254, 228, 64, 0.9));
    animation: floatSpriteUp 2.5s ease-out forwards;
}

@keyframes floatSpriteUp {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.5) rotate(0deg);
    }

    20% {
        opacity: 1;
        transform: translateY(0px) scale(1.35) rotate(-15deg);
    }

    80% {
        opacity: 0.9;
        transform: translateY(-90px) scale(1.1) rotate(20deg);
    }

    100% {
        opacity: 0;
        transform: translateY(-160px) scale(0.4) rotate(45deg);
    }
}

/* --- Fairy Multiplication Button & Table Section --- */
.btn-mult-fairy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #4cc9f0 0%, #7209b7 100%);
    color: #FFFFFF !important;
    border-radius: 50px;
    font-weight: 900;
    font-size: 0.95rem;
    box-shadow: 0 4px 18px rgba(76, 201, 240, 0.45), 0 0 15px rgba(254, 228, 64, 0.3);
    border: 2px solid #fee440;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-mult-fairy:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(76, 201, 240, 0.7), 0 0 25px rgba(254, 228, 64, 0.6);
    background: linear-gradient(135deg, #7209b7 0%, #4cc9f0 100%);
}

.btn-mult-fairy .mult-btn-icon {
    font-size: 1.15rem;
    animation: rotateIcon 4s linear infinite;
}

@keyframes rotateIcon {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.mult-nav-bar {
    margin-bottom: 2rem;
    overflow-x: auto;
    padding-bottom: 8px;
    width: 100%;
}

.mult-tabs-scroll {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.mult-tab-btn {
    background: #ffffff;
    border: 1.5px solid #fbcfe8;
    color: #be123c;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(244, 63, 94, 0.08);
    transition: all 0.25s ease;
}

.mult-tab-btn:hover {
    transform: translateY(-2px);
    border-color: #f43f5e;
    color: #831843;
    background: #fff5f8;
    box-shadow: 0 4px 14px rgba(244, 63, 94, 0.16);
}

.mult-tab-btn.active {
    background: linear-gradient(135deg, #f43f5e, #be123c) !important;
    color: #FFFFFF !important;
    border-color: #fda4af !important;
    box-shadow: 0 4px 16px rgba(244, 63, 94, 0.3) !important;
    transform: translateY(-2px) scale(1.05);
}

.mult-tab-btn.full-grid-tab.active {
    background: linear-gradient(135deg, #0284c7, #0369a1) !important;
    color: #FFFFFF !important;
    border-color: #7dd3fc !important;
    box-shadow: 0 4px 16px rgba(2, 132, 199, 0.3) !important;
}

.mult-tab-btn.quiz-tab.active {
    background: linear-gradient(135deg, #d97706, #b45309) !important;
    color: #FFFFFF !important;
    border-color: #fde68a !important;
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.3) !important;
}

.mult-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.4rem;
    margin-bottom: 2.5rem;
    width: 100%;
}

.mult-equation-card {
    background: linear-gradient(135deg, rgba(46, 0, 85, 0.9) 0%, rgba(20, 0, 48, 0.95) 100%);
    border-radius: 24px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 5px solid #ff70a6;
    padding: 1.4rem 1.2rem;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    cursor: pointer;
}

.mult-equation-card:hover {
    transform: translateY(-6px) scale(1.03);
    border-color: #fee440;
    box-shadow: 0 14px 30px rgba(247, 37, 133, 0.4);
}

.mult-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.mult-item-tag {
    font-size: 0.82rem;
    font-weight: 800;
    background: rgba(254, 228, 64, 0.18);
    color: #fee440;
    border: 1px solid rgba(254, 228, 64, 0.4);
    padding: 3px 12px;
    border-radius: 12px;
}

.mult-speaker-btn {
    background: rgba(36, 0, 70, 0.9);
    border: 1.5px solid #ff70a6;
    color: #FFFFFF;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.mult-speaker-btn:hover {
    background: #fee440;
    color: #12002b;
    transform: scale(1.15);
}

.mult-equation-text {
    font-size: 1.85rem;
    font-weight: 900;
    color: #FFFFFF;
    margin-bottom: 0.6rem;
    line-height: 1.2;
}

.mult-result-highlight {
    color: #fee440;
    background: rgba(254, 228, 64, 0.16);
    padding: 3px 12px;
    border-radius: 14px;
    border: 1.5px solid rgba(254, 228, 64, 0.4);
    display: inline-block;
    text-shadow: 0 0 12px rgba(254, 228, 64, 0.5);
}

.mult-visual-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    align-items: center;
    min-height: 36px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
    font-size: 1.1rem;
}

/* Full Grid Table */
.mult-full-grid-wrap {
    background: linear-gradient(135deg, rgba(36, 0, 70, 0.95), rgba(18, 0, 43, 0.98));
    border-radius: 25px;
    padding: 1.8rem;
    border: 2.5px solid #fee440;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.6), 0 0 30px rgba(247, 37, 133, 0.3);
    overflow-x: auto;
    width: 100%;
}

.mult-grid-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
}

.mult-grid-table th,
.mult-grid-table td {
    padding: 12px 10px;
    border: 2px solid rgba(114, 9, 183, 0.5);
    font-size: 1.15rem;
    font-weight: 800;
    transition: all 0.2s ease;
}

.mult-grid-table th {
    background: linear-gradient(135deg, #f72585, #7209b7);
    color: #FFFFFF;
    font-size: 1.25rem;
}

.mult-grid-table th.grid-corner {
    background: #12002b;
    color: #fee440;
    font-size: 1.5rem;
}

.mult-grid-table td {
    background: rgba(36, 0, 70, 0.6);
    color: #fce7f3;
    cursor: pointer;
}

.mult-grid-table td:hover,
.mult-grid-table td.active-cell {
    background: #fee440;
    color: #12002b;
    transform: scale(1.18);
    box-shadow: 0 0 18px rgba(254, 228, 64, 0.85);
    z-index: 2;
    border-radius: 8px;
    font-weight: 900;
}

/* Quiz Box */
.mult-quiz-box {
    background: linear-gradient(135deg, rgba(60, 9, 108, 0.95) 0%, rgba(26, 0, 56, 0.98) 100%);
    border-radius: 28px;
    border: 2.5px solid #fee440;
    padding: 2rem 1.8rem;
    text-align: center;
    max-width: 650px;
    margin: 0 auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7), 0 0 35px rgba(254, 228, 64, 0.4);
    width: 100%;
}

.quiz-fairy-avatar {
    font-size: 3.5rem;
    margin-bottom: 8px;
    animation: gentleFloat 2.5s infinite ease-in-out;
}

.gamification {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #FFF;
    padding: 0.5rem 1rem;
    border-radius: 30px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 2px solid var(--accent-color);
}

.star-icon {
    color: #FFD700;
    font-size: 1.5rem;
    animation: pulse 2s infinite;
}

.score-text {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-main);
}

/* Main Layout */
.container {
    display: flex;
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 2rem;
    gap: 2rem;
}

/* Sidebar */
.sidebar-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.mascot-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Curriculum Nav */
.curriculum-nav {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

.nav-title {
    color: var(--secondary-color);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    border-bottom: 2px dashed rgba(46, 196, 182, 0.3);
    padding-bottom: 0.8rem;
}

.nav-chapter {
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 1rem;
    margin-top: 1.5rem;
    /* Space between chapters */
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-chapter:first-child {
    margin-top: 0;
}

.nav-lessons-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.nav-lesson-item {
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    /* Rounded box feel */
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
    color: var(--text-main);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.nav-lesson-item::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    right: -50%;
    bottom: -50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent);
    opacity: 0;
    transition: opacity 0.4s;
    transform: rotate(45deg);
}

.nav-lesson-item:hover {
    border-color: var(--accent-color);
    color: var(--primary-color);
    transform: translateX(-5px) scale(1.02);
    box-shadow: var(--fairy-glow);
}

.nav-lesson-item:hover::before {
    opacity: 1;
}

.nav-lesson-item.active {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    border-color: transparent;
    box-shadow: var(--fairy-glow);
}

.nav-lesson-item.active i {
    color: #FFF;
}

.emoji-mascot {
    width: 150px;
    height: 150px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.5));
    box-shadow: var(--fairy-glow);
    border: 5px solid var(--accent-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 5rem;
    animation: floatMascot 4s ease-in-out infinite, magicGlow 2s infinite alternate;
    backdrop-filter: blur(10px);
}

@keyframes floatMascot {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-15px) rotate(5deg);
    }

    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

@keyframes magicGlow {
    0% {
        box-shadow: 0 0 20px rgba(247, 37, 133, 0.4);
    }

    100% {
        box-shadow: 0 0 40px rgba(76, 201, 240, 0.8);
    }
}

.mascot-message {
    background: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    font-weight: 600;
    color: var(--secondary-color);
}

.mascot-message::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 10px 10px 10px;
    border-style: solid;
    border-color: transparent transparent white transparent;
}

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Navigation Tabs */
.tabs {
    display: flex;
    gap: 1rem;
    background: var(--card-bg);
    padding: 0.5rem;
    border-radius: 50px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: 50px;
    background: transparent;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    box-shadow: var(--fairy-glow);
}

.tab-btn:hover:not(.active) {
    background: rgba(206, 147, 216, 0.15);
    color: var(--text-main);
}

/* Cards */
.card {
    background: var(--card-bg);
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 10 Q 25 25 10 40' stroke='%23ce93d8' stroke-width='1' fill='none' opacity='0.3'/%3E%3Ccircle cx='50' cy='50' r='2' fill='%23f48fb1' opacity='0.3'/%3E%3C/svg%3E");
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease;
    border: 2px solid rgba(244, 143, 177, 0.3);
    display: none;
    animation: fadeIn 0.5s ease forwards;
}

.card.active {
    display: block;
}

.card-title {
    color: var(--secondary-color);
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    border-bottom: 3px dashed rgba(46, 196, 182, 0.3);
    padding-bottom: 0.5rem;
    display: inline-block;
}

/* Explanation Section */
.explanation-block {
    background: white;
    padding: 1.5rem;
    border-radius: 15px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
    border-right: 5px solid var(--primary-color);
    font-size: 1.2rem;
    line-height: 1.8;
}

.highlight-block {
    background: #FFF9E6;
    border-right-color: #FFD700;
    font-weight: bold;
}

/* Vocabulary */
.vocab-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.vocab-tag {
    background: var(--secondary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(46, 196, 182, 0.3);
}

/* Exercises */
.exercise {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 2px solid #E2E8F0;
    transition: border-color 0.3s;
}

.exercise:hover {
    border-color: var(--primary-color);
}

.exercise-prompt {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
}

/* Pattern Sequence */
.pattern-sequence {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    direction: ltr;
    /* Render LTR visually, but logical right-to-left in data */
    justify-content: center;
}

.pattern-item {
    padding: clamp(0.5rem, 1.5vw, 1rem);
    background: #F8FAFC;
    border-radius: 10px;
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: bold;
    color: var(--secondary-color);
    min-width: 0;
    flex: 1 1 0;
    text-align: center;
    border: 2px solid #E2E8F0;
    white-space: nowrap;
}

.pattern-input {
    width: 100%;
    max-width: 120px;
    min-width: 60px;
    padding: clamp(0.5rem, 1.5vw, 1rem);
    font-size: clamp(1rem, 3vw, 1.5rem);
    text-align: center;
    border: 3px dashed var(--primary-color);
    border-radius: 10px;
    outline: none;
    transition: all 0.3s;
    background: #FFF;
    color: var(--primary-color);
    font-weight: bold;
}

.pattern-input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(46, 196, 182, 0.2);
}

.pattern-input.correct {
    border-color: var(--success-color);
    border-style: solid;
    color: var(--success-color);
    background: #F0FDF4;
}

.pattern-input.incorrect {
    border-color: var(--error-color);
    background: #FEF2F2;
    animation: shake 0.5s;
}

.rule-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    background: #F8FAFC;
    padding: 1rem;
    border-radius: 10px;
}

.rule-input {
    width: 100px;
    padding: 0.5rem;
    font-size: 1.2rem;
    text-align: center;
    border: 2px solid #CBD5E1;
    border-radius: 8px;
    outline: none;
}

/* Fill Blanks & Word Problems */
.fill-blanks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.fill-item {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    white-space: nowrap;
}

.fill-input {
    flex: 1;
    padding: 0.8rem;
    font-size: 1.2rem;
    border: 2px solid #CBD5E1;
    border-radius: 8px;
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

/* Vertical Math Layout */
.vertical-math {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1.2;
    margin: 0 1rem;
    direction: ltr;
    /* Numbers should align right/LTR */
}

.math-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.2rem;
}

.math-row span {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 1.5rem;
    height: 1.5rem;
}

.carry-row {
    font-size: 1rem;
    min-height: 1.5rem;
    margin-bottom: 0.2rem;
    align-items: center;
}

.carry-digit {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 1.5rem;
    height: 1.5rem;
    background-color: #3B82F6;
    /* Blue circle */
    color: white;
    border-radius: 50%;
    font-size: 0.9rem;
    margin: 0;
}

/* Long Division Layout */
.long-division {
    display: inline-table;
    vertical-align: middle;
    text-align: center;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.5rem;
    font-weight: bold;
    direction: ltr;
    /* Math is LTR */
    margin: 0 10px;
}

.ld-row {
    display: table-row;
}

.ld-quotient {
    display: table-cell;
    padding-bottom: 2px;
}

.ld-dividend {
    display: table-cell;
    border-top: 2px solid var(--text-main);
    border-right: 2px solid var(--text-main);
    padding: 2px 8px 0 8px;
    letter-spacing: 2px;
}

.ld-divisor {
    display: table-cell;
    vertical-align: top;
    padding: 2px 8px 0 8px;
}

/* Fraction Layout */
.fraction {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    margin: 0 5px;
    line-height: 1.2;
}

.fraction .num {
    border-bottom: 2px solid var(--text-main);
    padding: 0 5px;
}

.fraction .den {
    padding: 0 5px;
}

/* Mixed Number Layout */
.mixed-number {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    direction: rtl;
    vertical-align: middle;
    margin: 0 5px;
}

.mixed-number .whole {
    font-size: 1.4em;
    font-weight: bold;
    color: var(--secondary-color);
}

.op-row {
    position: relative;
}

.op-row .op {
    position: absolute;
    left: -2rem;
    /* Place operator to the left */
    color: var(--primary-color);
}

.math-divider {
    width: 100%;
    height: 3px;
    background-color: var(--text-main);
    margin: 0.5rem 0;
}

.fill-input.vertical-input {
    width: 100%;
    margin-top: 0;
}

.btn-check {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(46, 196, 182, 0.3);
    transition: all 0.3s;
    display: block;
    margin: 2rem auto 0;
    width: fit-content;
}

.btn-check:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 196, 182, 0.4);
}

/* Animations */
@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-15px);
    }

    100% {
        transform: translateY(0px);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Fairy Garden Custom Elements */
.lesson-fairy-btn {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cdefs%3E%3CradialGradient id='g2' cx='50%25' cy='50%25' r='50%25'%3E%3Cstop offset='0%25' stop-color='%23ffffff' /%3E%3Cstop offset='40%25' stop-color='%2380deea' /%3E%3Cstop offset='100%25' stop-color='%23b39ddb' /%3E%3C/radialGradient%3E%3CradialGradient id='c1' cx='50%25' cy='50%25' r='50%25'%3E%3Cstop offset='0%25' stop-color='%23fff59d' /%3E%3Cstop offset='100%25' stop-color='%23ffb300' /%3E%3C/radialGradient%3E%3C/defs%3E%3Cg fill='url(%23g2)'%3E%3Ccircle cx='100' cy='55' r='45' /%3E%3Ccircle cx='142.7' cy='86' r='45' /%3E%3Ccircle cx='126.1' cy='136.4' r='45' /%3E%3Ccircle cx='73.9' cy='136.4' r='45' /%3E%3Ccircle cx='57.3' cy='86' r='45' /%3E%3C/g%3E%3Ccircle cx='100' cy='100' r='30' fill='url(%23c1)' /%3E%3C/svg%3E") center/contain no-repeat;
    border: none;
    border-radius: 0;
    width: 150px;
    height: 150px;
    min-width: unset;
    padding: 0;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    font-family: var(--font-main);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: visible;
    filter: drop-shadow(0 0 15px rgba(76, 201, 240, 0.6));
    margin: 15px;
}

.lesson-fairy-btn::before {
    display: none;
}

.lesson-fairy-btn:hover {
    transform: scale(1.15) translateY(-5px) rotate(-10deg);
    filter: drop-shadow(0 0 35px rgba(76, 201, 240, 0.9));
}

.lesson-fairy-btn:hover::before {
    display: none;
}

.lesson-icon {
    font-size: 2.2rem;
    position: relative;
    color: var(--primary-color);
    filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s;
}

.lesson-fairy-btn:hover .lesson-icon {
    transform: rotate(10deg) scale(1.1);
}

.lesson-icon .audio-icon {
    position: absolute;
    bottom: -5px;
    right: -10px;
    font-size: 1.5rem;
    color: #fff;
    background: var(--primary-color);
    border-radius: 50%;
    padding: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.lesson-info {
    text-align: right;
    z-index: 1;
}

.lesson-num {
    font-size: 1.2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.lesson-title {
    font-size: 1rem;
    color: #fff;
    font-weight: bold;
    opacity: 0.95;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.stardust-trail {
    position: absolute;
    top: 50px;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 15px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 100' preserveAspectRatio='none'%3E%3Cpath d='M10,0 C20,25 0,75 10,100' stroke='%23fee440' stroke-width='4' fill='none' stroke-dasharray='10 5'/%3E%3C/svg%3E");
    background-size: 100% 200px;
    filter: drop-shadow(0 0 10px var(--gold-accent));
    z-index: 1;
    opacity: 0.9;
    animation: stardustFlow 3s linear infinite;
}

@keyframes stardustFlow {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 0 200px;
    }
}

/* Chapter fairy gate */
.chapter-fairy-btn {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cdefs%3E%3CradialGradient id='g1' cx='50%25' cy='50%25' r='50%25'%3E%3Cstop offset='0%25' stop-color='%23ffffff' /%3E%3Cstop offset='40%25' stop-color='%23f48fb1' /%3E%3Cstop offset='100%25' stop-color='%23ce93d8' /%3E%3C/radialGradient%3E%3CradialGradient id='c1' cx='50%25' cy='50%25' r='50%25'%3E%3Cstop offset='0%25' stop-color='%23fff59d' /%3E%3Cstop offset='100%25' stop-color='%23ffb300' /%3E%3C/radialGradient%3E%3C/defs%3E%3Cg fill='url(%23g1)'%3E%3Ccircle cx='100' cy='55' r='45' /%3E%3Ccircle cx='142.7' cy='86' r='45' /%3E%3Ccircle cx='126.1' cy='136.4' r='45' /%3E%3Ccircle cx='73.9' cy='136.4' r='45' /%3E%3Ccircle cx='57.3' cy='86' r='45' /%3E%3C/g%3E%3Ccircle cx='100' cy='100' r='30' fill='url(%23c1)' /%3E%3C/svg%3E") center/contain no-repeat;
    border: none;
    border-radius: 0;
    width: 160px;
    height: 160px;
    min-width: unset;
    padding: 0;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: visible;
    filter: drop-shadow(0 0 20px rgba(247, 37, 133, 0.6));
    margin: 15px;
}

.chapter-fairy-btn::before {
    display: none;
}

.chapter-fairy-btn:hover {
    transform: translateY(-15px) scale(1.1) rotate(15deg);
    filter: drop-shadow(0 0 40px rgba(254, 228, 64, 0.9));
}

.chapter-fairy-btn:hover .fairy-gate-icon {
    transform: scale(1.1) rotate(-15deg);
}

.fairy-gate-icon {
    font-size: 3.5rem;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3));
    z-index: 1;
    transition: all 0.4s;
}

.fairy-gate-title {
    font-size: 1.2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.8);
    z-index: 1;
    max-width: 180px;
    text-align: center;
    line-height: 1.3;
}

/* Confetti */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background-color: var(--primary-color);
    z-index: 1000;
    pointer-events: none;
    animation: fall 3s linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 1100px) {
    .container {
        gap: 1.5rem;
        padding: 1.5rem;
    }

    .sidebar-panel {
        width: 280px;
    }
}

@media (max-width: 850px) {
    .container {
        flex-direction: column;
    }

    .sidebar-panel {
        width: 100%;
    }

    .mascot-section {
        flex-direction: row;
        gap: 1.5rem;
        align-items: center;
        background: var(--card-bg);
        padding: 1rem;
        border-radius: var(--border-radius);
        box-shadow: var(--shadow);
    }

    .emoji-mascot {
        width: 90px;
        height: 90px;
        font-size: 3rem;
        flex-shrink: 0;
    }

    .mascot-message {
        margin-top: 0;
        text-align: right;
        flex: 1;
    }

    .mascot-message::before {
        display: none;
    }

    .curriculum-nav {
        margin-top: 0;
    }

    .nav-lessons-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 0.5rem;
    }

    .nav-lesson-item {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }


    .tabs {
        flex-direction: column;
        border-radius: 20px;
    }

    .tab-btn {
        padding: 0.8rem;
        font-size: 1rem;
    }

    .card-title {
        font-size: 1.4rem;
    }

    .nav-lessons-list {
        grid-template-columns: 1fr;
    }
}

/* Visual Fraction Models Container Fix */
div[style*="justify-content:center"] {
    flex-wrap: wrap !important;
    gap: 10px !important;
}

/* Visual Fraction Models */
.fraction-model {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    border: 2px solid var(--text-main);
    height: 40px;
    margin: 10px 5px;
    background-color: white;
    direction: ltr;
    width: fit-content;
    min-width: 100px;
    max-width: 100%;
}

.fraction-model .part {
    border-right: 1px solid var(--text-main);
    height: 100%;
}

.fraction-model .part:last-child {
    border-right: none;
}

.fraction-model .part.shaded {
    background-color: var(--primary-color);
    opacity: 0.8;
}

.models-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    width: 100%;
    margin-bottom: 10px;
}

/* 100-Grid Model for Decimals */
.grid-100 {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    width: 180px;
    height: 180px;
    border: 2px solid var(--text-main);
    background-color: var(--text-main);
    gap: 1px;
    margin: 10px auto;
    direction: ltr;
}

.grid-100 .cell {
    background-color: white;
}

.grid-100 .cell.shaded {
    background-color: var(--primary-color);
    opacity: 0.8;
}

.grid-100 .cell.shaded-secondary {
    background-color: var(--secondary-color);
    opacity: 0.8;
}

/* Number Line */
.number-line-container {
    padding: 20px 40px;
    margin: 10px 0;
    position: relative;
    direction: ltr;
}

.number-line {
    height: 4px;
    background-color: var(--text-main);
    position: relative;
    display: flex;
    justify-content: space-between;
}

.number-line::before,
.number-line::after {
    content: '';
    position: absolute;
    top: -4px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.number-line::before {
    left: -10px;
    border-right: 10px solid var(--text-main);
}

.number-line::after {
    right: -10px;
    border-left: 10px solid var(--text-main);
}

.tick {
    position: relative;
    width: 2px;
    height: 15px;
    background-color: var(--text-main);
    top: -5px;
}

.tick.point::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -6px;
    width: 14px;
    height: 14px;
    background-color: var(--secondary-color);
    border-radius: 50%;
    z-index: 2;
}

.tick-label {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1rem;
    font-weight: bold;
    white-space: nowrap;
}

.tick-letter {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--secondary-color);
    font-weight: bold;
    font-size: 1.2rem;
}

/* Place Value Table for Comparison */
.place-value-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 1rem;
}

.place-value-table th {
    background-color: var(--primary-color);
    color: white;
    padding: 10px;
    border: 1px solid var(--text-main);
}

.place-value-table td {
    padding: 10px;
    border: 1px solid var(--text-main);
    text-align: center;
    font-weight: bold;
}

.place-value-table .comma-col {
    background-color: #f8f9fa;
    color: var(--secondary-color);
    font-size: 1.4rem;
}

/* Grid Map for Location and Direction */
.grid-map-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
}

.grid-map {
    display: grid;
    grid-template-columns: repeat(11, 30px);
    grid-template-rows: repeat(11, 30px);
    border: 2px solid #64748b;
    background-image:
        linear-gradient(#cbd5e1 1px, transparent 1px),
        linear-gradient(90deg, #cbd5e1 1px, transparent 1px);
    background-size: 30px 30px;
    background-color: white;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    border-radius: 4px;
    direction: ltr;
}

.grid-map .item {
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
}

.grid-map .label {
    font-size: 10px;
    color: #64748b;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
}

.grid-map .path-h {
    border-bottom: 3px solid #ef4444;
    z-index: 1;
}

.grid-map .path-v {
    border-left: 3px solid #ef4444;
    z-index: 1;
}

.grid-map .point-marker {
    width: 10px;
    height: 10px;
    background-color: #ef4444;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 3;
    margin: auto;
}

/* Fractions and Mixed Numbers Styling */
.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 5px;
    direction: ltr;
    /* Ensure numbers and fractions are always LTR */
}

.fraction .num {
    padding: 2px 5px;
    line-height: 1.2;
    font-weight: bold;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 25px;
    border-bottom: none !important;
}

.fraction .den {
    padding: 2px 5px;
    border-top: 2px solid var(--text-main);
    line-height: 1.2;
    font-weight: bold;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 25px;
}

.mixed-number {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    direction: ltr;
}

.mixed-number .whole {
    margin-right: 5px;
    /* LTR margin */
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text-main);
}

/* Ensure input boxes inside fractions are properly sized and aligned */
.fraction input {
    width: 40px !important;
    height: 30px !important;
    font-size: 1.2rem !important;
    text-align: center !important;
    padding: 0 !important;
    margin: 2px 0 !important;
    border: 2px solid #2EC4B6 !important;
    /* Secondary color for input borders */
    border-radius: 4px !important;
    color: var(--secondary-color) !important;
}

/* Chapters View (Cakes) Styles */
.chapters-grid {
    padding: 3rem;
    gap: 3rem;
}

.chapter-cake-btn {
    background: #FDF1E7;
    /* Sponge cake color */
    border: none;
    border-radius: 15px;
    /* Base of the cake */
    padding: 3.5rem 1.5rem 1.5rem 1.5rem;
    min-width: 200px;
    height: 220px;
    cursor: pointer;
    box-shadow: 0 8px 0 #DABBA6, 0 15px 35px rgba(255, 133, 161, 0.2);
    /* Cake 3D base */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

/* The main frosting at the top */
.chapter-cake-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: var(--primary-color);
    /* Strawberry frosting */
    border-radius: 15px 15px 0 0;
}

/* Frosting drips using box-shadows on pseudo-element */
.chapter-cake-btn::after {
    content: '';
    position: absolute;
    top: 30px;
    left: 15px;
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow:
        45px 5px 0 5px var(--primary-color),
        90px -5px 0 5px var(--primary-color),
        135px 10px 0 5px var(--primary-color);
}

.chapter-cake-btn:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 12px 0 #DABBA6, 0 25px 45px rgba(255, 133, 161, 0.3);
}

.chapter-cake-btn .cake-icon {
    font-size: 4.5rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.1));
    z-index: 2;
    /* To appear above frosting drips if overlapping */
}

.chapter-cake-btn .cake-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    text-align: center;
    z-index: 2;
}

.btn-back-chapters {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-back-chapters:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* ===================================================================== */
/* BOT UI STYLES                                                         */
/* ===================================================================== */
.bot-floating-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color), #20c997);
    color: white;
    border: 4px solid white;
    box-shadow: 0 10px 25px rgba(32, 201, 151, 0.4);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bot-floating-btn:hover {
    transform: scale(1.1) rotate(10deg);
}

.bot-emoji {
    font-size: 2.5rem;
}

.bot-tooltip {
    position: absolute;
    left: 80px;
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--secondary-color);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    white-space: nowrap;
}

.bot-floating-btn:hover .bot-tooltip {
    opacity: 1;
    visibility: visible;
    left: 90px;
}

.bot-chat-window {
    position: fixed;
    bottom: 110px;
    left: 30px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 25px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom left;
}

.bot-chat-window.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.bot-chat-header {
    background: linear-gradient(135deg, var(--secondary-color), #20c997);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.bot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bot-header-emoji {
    font-size: 1.8rem;
}

.bot-chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
}

#bot-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
}

#bot-close-btn:hover {
    transform: scale(1.2);
}

.bot-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f8f9fa;
}

.bot-message,
.user-message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 1rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

.bot-message {
    align-self: flex-start;
    background: white;
    color: var(--text-main);
    border-bottom-right-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.user-message {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-left-radius: 5px;
    box-shadow: 0 4px 10px rgba(255, 133, 161, 0.2);
}

.bot-quick-prompts {
    display: flex;
    gap: 8px;
    padding: 10px 15px;
    overflow-x: auto;
    background: #fdfdfd;
    border-top: 1px solid #f1f5f9;
}

.bot-quick-prompts::-webkit-scrollbar {
    height: 6px;
}

.bot-quick-prompts::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.quick-prompt-btn {
    background: white;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.quick-prompt-btn:hover {
    background: var(--secondary-color);
    color: white;
}

.bot-chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

#bot-input-field {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 30px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}

#bot-input-field:focus {
    border-color: var(--secondary-color);
}

#bot-send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--secondary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    transition: transform 0.2s, background 0.3s;
}

#bot-send-btn:hover {
    transform: scale(1.1);
    background: #20c997;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-typing {
    align-self: flex-start;
    background: white;
    padding: 10px 15px;
    border-radius: 20px;
    border-bottom-right-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 5px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Force Flex Row Layout for Chapters */
.chapters-grid {
    display: flex;
    flex-wrap: wrap !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: stretch !important;
    gap: 26px !important;
    width: 100% !important;
    margin: 1.5rem auto !important;
    max-width: 1200px !important;
    padding: 0 1rem;
}

/* --- Princess Malak Royal Chapter Cards --- */
.chapter-fairy-btn {
    background: #ffffff !important;
    border: 2px solid #fbcfe8 !important;
    border-radius: 26px !important;
    padding: 1.4rem 1.2rem !important;
    width: 270px !important;
    min-height: 310px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: space-between !important;
    text-align: center !important;
    cursor: pointer !important;
    box-shadow: 0 10px 28px rgba(244, 63, 94, 0.08) !important;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    position: relative !important;
    overflow: hidden !important;
    color: #1f2937 !important;
}

.chapter-fairy-btn:hover {
    transform: translateY(-8px) scale(1.03) !important;
    border-color: #f43f5e !important;
    box-shadow: 0 16px 36px rgba(244, 63, 94, 0.2) !important;
    background: #ffffff !important;
}

.chapter-top-tag {
    background: #fff0f5;
    color: #be123c;
    border: 1px solid #fbcfe8;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.chapter-hero-thumb {
    position: relative;
    width: 140px;
    height: 140px;
    border-radius: 22px;
    overflow: hidden;
    margin: 0 auto 10px auto;
    padding: 3px;
    background: linear-gradient(135deg, #fff0f5, #fce7f3);
    border: 2px solid #fbcfe8;
    box-shadow: 0 4px 14px rgba(244, 63, 94, 0.12);
}

.chapter-hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 18px;
    display: block;
    transition: transform 0.4s ease;
}

.chapter-fairy-btn:hover .chapter-hero-img {
    transform: scale(1.08);
}

.chapter-thumb-badge {
    position: absolute;
    bottom: 3px;
    right: 3px;
    background: #ffffff;
    border: 1.5px solid #fbcfe8;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(244, 63, 94, 0.15);
}

.fairy-gate-title {
    font-family: 'Cairo', 'Tajawal', sans-serif !important;
    font-size: 1.25rem !important;
    font-weight: 900 !important;
    color: #831843 !important;
    text-shadow: none !important;
    line-height: 1.35 !important;
    margin: 6px 0 !important;
}

.chapter-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #fbcfe8;
}

.chapter-lessons-count {
    color: #be123c;
    font-size: 0.82rem;
    font-weight: 800;
}

.chapter-btn-badge {
    background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%) !important;
    border: 1.5px solid #fda4af !important;
    border-radius: 14px !important;
    padding: 5px 14px !important;
    font-size: 0.8rem !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    box-shadow: 0 3px 10px rgba(244, 63, 94, 0.25) !important;
    transition: all 0.25s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
}

.chapter-fairy-btn:hover .chapter-btn-badge {
    background: linear-gradient(135deg, #fb7185 0%, #e11d48 100%) !important;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(244, 63, 94, 0.38) !important;
}

/* =========================================================
   Princess Malak Royal Lessons Deck Grid
========================================================= */
.math-lessons-deck-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 22px !important;
    width: 100% !important;
    max-width: 1100px !important;
    margin: 0 auto !important;
    padding: 0.5rem 1rem !important;
}

.math-lesson-track-card {
    background: #ffffff !important;
    border: 2px solid #fbcfe8 !important;
    border-radius: 22px !important;
    padding: 1.3rem !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    gap: 14px !important;
    cursor: pointer !important;
    box-shadow: 0 8px 24px rgba(244, 63, 94, 0.08) !important;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    position: relative !important;
    overflow: hidden !important;
}

.math-lesson-track-card:hover {
    transform: translateY(-6px) scale(1.02) !important;
    border-color: #f43f5e !important;
    box-shadow: 0 14px 32px rgba(244, 63, 94, 0.2) !important;
    background: #ffffff !important;
}

.track-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.track-number-badge {
    background: #fff0f5 !important;
    border: 1px solid #fbcfe8 !important;
    color: #be123c !important;
    padding: 3px 12px !important;
    border-radius: 12px !important;
    font-size: 0.75rem !important;
    font-weight: 800 !important;
}

.track-rating-badge {
    color: #d97706 !important;
    font-size: 0.75rem !important;
    font-weight: 900 !important;
    letter-spacing: 0.5px !important;
}

.track-card-body {
    display: flex;
    align-items: center;
    gap: 14px;
}

.track-hero-avatar {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 18px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #fff0f5, #ffe4e6);
    border: 2px solid #fbcfe8;
    padding: 2px;
    box-shadow: 0 4px 10px rgba(244, 63, 94, 0.1);
}

.track-hero-avatar .track-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
    display: block;
    transition: transform 0.3s ease;
}

.math-lesson-track-card:hover .track-hero-avatar .track-img {
    transform: scale(1.08);
}

.track-stage-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: #ffffff;
    border: 1.5px solid #fbcfe8;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    box-shadow: 0 2px 6px rgba(244, 63, 94, 0.15);
}

.track-title-info {
    flex: 1;
    text-align: right;
}

.track-title {
    font-size: 1.15rem !important;
    font-weight: 900 !important;
    color: #831843 !important;
    line-height: 1.35 !important;
    margin: 0 0 4px 0 !important;
    font-family: 'Cairo', 'Tajawal', sans-serif !important;
    text-shadow: none !important;
}

.track-subtitle {
    font-size: 0.78rem !important;
    color: #9d174d !important;
    font-weight: 700 !important;
}

.track-card-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    padding-top: 8px;
    border-top: 1px dashed #fbcfe8;
}

.track-launch-btn {
    background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%) !important;
    border: 1.5px solid #fda4af !important;
    color: #ffffff !important;
    padding: 6px 18px !important;
    border-radius: 16px !important;
    font-size: 0.85rem !important;
    font-weight: 800 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.25) !important;
    transition: all 0.25s ease !important;
    font-family: 'Cairo', 'Tajawal', sans-serif !important;
}

.math-lesson-track-card:hover .track-launch-btn {
    background: linear-gradient(135deg, #fb7185 0%, #e11d48 100%) !important;
    color: #ffffff !important;
    transform: scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.35) !important;
}

/* ==========================================================================
   SPIDER-MAN STARK-TECH LAB & NANO SUIT ARMORY (مختبر تقنيات سبايدرمان)
   ========================================================================== */
.spider-tech-lab-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 30%, rgba(20, 5, 40, 0.98) 0%, rgba(5, 2, 12, 0.99) 70%, #020005 100%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 2rem;
    box-sizing: border-box;
    overflow: hidden;
    animation: stageFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    backdrop-filter: blur(14px);
    font-family: 'Alexandria', 'Cairo', sans-serif;
    user-select: none;
    --laser-c1: #e60026;
    --laser-c2: #0066ff;
    --laser-c3: #00d2ff;
}

.spider-tech-lab-overlay.lab-closing {
    animation: stageFadeOut 0.4s forwards ease-in;
}

.tech-grid-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.lab-top-hud {
    position: relative;
    z-index: 10;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.hud-badges-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.hud-live-pill {
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 900;
    padding: 4px 14px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 0 15px rgba(230, 0, 38, 0.8);
    letter-spacing: 0.5px;
}

.hud-blink-dot {
    width: 8px;
    height: 8px;
    background: #00d2ff;
    border-radius: 50%;
    animation: liveBlink 0.8s infinite alternate;
    box-shadow: 0 0 8px #00d2ff;
}

.hud-defense-tag {
    background: rgba(0, 240, 255, 0.15);
    border: 1px solid #00f0ff;
    color: #00f0ff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: 20px;
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
}

.lab-main-title {
    font-size: 2.2rem;
    font-weight: 900;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.2;
}

.lab-sub-slogan {
    color: #cbd5e1;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.lab-chamber-arena {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    width: 100%;
    max-width: 900px;
    margin: auto 0;
}

.spider-bot-card {
    position: relative;
    width: 140px;
    height: 180px;
    border-radius: 24px;
    background: rgba(15, 23, 42, 0.75);
    border: 2px solid rgba(0, 210, 255, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-shadow: 0 0 25px rgba(0, 210, 255, 0.3);
    backdrop-filter: blur(8px);
}

.bot-img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 18px;
    filter: drop-shadow(0 0 12px rgba(0, 210, 255, 0.6));
}

.bot-label {
    font-size: 0.75rem;
    font-weight: 900;
    color: #ffd700;
    margin-top: 10px;
    letter-spacing: 1px;
    font-family: 'Orbitron', monospace;
}

.lab-hero-center {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-avatar-frame {
    position: relative;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    padding: 6px;
    background: linear-gradient(135deg, #e60026, #0066ff, #00d2ff);
    box-shadow: 0 0 40px rgba(230, 0, 38, 0.7), 0 0 60px rgba(0, 210, 255, 0.5);
}

.hero-main-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #ffffff;
    display: block;
}

.hero-nano-badge {
    position: absolute;
    bottom: 0;
    right: 8px;
    width: 44px;
    height: 44px;
    background: #070a14;
    border: 2px solid #00d2ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 0 15px #00d2ff;
}

.hero-energy-sparks {
    position: absolute;
    top: 0;
    left: 8px;
    font-size: 1.5rem;
    animation: liveBlink 1s infinite alternate;
    filter: drop-shadow(0 0 10px #ffd700);
}

.hero-nameplate {
    text-align: center;
    margin-top: 12px;
}

.hero-arabic-name {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

.hero-suit-rank {
    font-size: 0.8rem;
    font-weight: 800;
    color: #ffd700;
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
    display: block;
    margin: 4px 0 6px 0;
}

.hero-tech-status {
    display: inline-block;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 900;
    color: #ffffff;
    box-shadow: 0 0 15px rgba(230, 0, 38, 0.5);
}

.lab-telemetry-row {
    position: relative;
    z-index: 10;
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 750px;
    justify-content: center;
    margin-bottom: 15px;
}

.telemetry-box {
    flex: 1;
    background: rgba(15, 23, 42, 0.7);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 8px 14px;
    text-align: center;
    backdrop-filter: blur(8px);
}

.tel-label {
    display: block;
    font-size: 0.72rem;
    color: #cbd5e1;
    font-weight: 700;
    margin-bottom: 4px;
}

.tel-bar-wrap {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 4px;
}

.tel-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #e60026, #0066ff);
    border-radius: 6px;
}

.tel-val {
    font-size: 0.82rem;
    font-weight: 900;
    color: #00f0ff;
}

.lab-controls-bar {
    position: relative;
    z-index: 10;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
}

.lab-ctrl-btn {
    padding: 10px 22px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
    border: none;
    outline: none;
}

.btn-power {
    background: linear-gradient(135deg, #e60026, #0066ff);
    color: #ffffff;
    border: 1.5px solid #00d2ff;
    box-shadow: 0 0 20px rgba(230, 0, 38, 0.6);
}

.btn-power:hover {
    transform: scale(1.06) translateY(-2px);
    box-shadow: 0 0 30px rgba(0, 210, 255, 0.8);
}

.btn-close-lab {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(8px);
}

.btn-close-lab:hover {
    background: rgba(230, 0, 38, 0.8);
    border-color: #e60026;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(230, 0, 38, 0.7);
}