:root {
    --primary: #064e3b; /* Very dark forest green */
    --primary-light: rgba(6, 78, 59, 0.4); /* Glass forest green */
    --secondary: #fbbf24; /* Gold */
    --accent: #38bdf8; /* Magical cyan */
    --background: #020617; /* Night sky/deep forest */
    --card-bg: rgba(15, 23, 42, 0.65); /* Glass slate */
    --text-main: #f8fafc; /* Light text for dark mode */
    --text-muted: #94a3b8;
    --glass: rgba(255, 255, 255, 0.05);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --neon-glow: 0 0 20px rgba(251, 191, 36, 0.5);
    --gold-gradient: linear-gradient(135deg, #bf953f 0%, #fcf6ba 25%, #b38728 50%, #fbf5b7 75%, #aa771c 100%);
    --radius: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Cairo', sans-serif;
}

body {
    background: radial-gradient(circle at top center, #064e3b 0%, #020617 100%);
    background-attachment: fixed;
    color: var(--text-main);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

.fairy-dust {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: -1;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, var(--secondary), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 50px 160px, var(--secondary), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 90px 40px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 130px 80px, var(--secondary), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 160px 120px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(3px 3px at 250px 250px, var(--accent), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 300px 100px, var(--accent), rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 400px 400px;
    animation: floatingDust 60s linear infinite;
    opacity: 0.6;
}

@keyframes floatingDust {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-400px) rotate(10deg); }
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.robot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    padding: 1.5rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow), var(--neon-glow);
    margin-bottom: 2rem;
    color: var(--text-main);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.header-user-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    background: var(--primary-light);
    padding: 2px 10px;
    border-radius: 12px;
}

.user-avatar {
    width: 60px;
    height: 60px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    border: 2px solid var(--secondary);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.header-content {
    flex-grow: 1;
}

.circuit-progress-container {
    width: 100%;
    margin-bottom: 3rem;
    padding: 0 1rem;
}

.circuit-progress-bar {
    width: 100%;
    height: 15px;
    background-color: var(--primary-light);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    background-image: linear-gradient(90deg, transparent 50%, rgba(255, 255, 255, 0.5) 50%);
    background-size: 20px 20px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}

.circuit-progress-fill {
    height: 100%;
    background-color: var(--accent);
    box-shadow: 0 0 15px var(--accent);
    transition: width 0.5s ease-in-out;
}

.home-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 4rem;
    color: var(--text-main);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.header-content h1 {
    font-size: 2.2rem;
    margin-bottom: 0.2rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.portal-btn {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    color: var(--text-main);
    border: 2px solid var(--secondary);
    padding: 1rem 1.5rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.portal-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-3px);
}

.achievements-btn {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.3rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.achievements-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 30px rgba(245, 158, 11, 0.4);
}

/* Tabs / Switcher */
.lesson-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    background: var(--glass);
    padding: 0.5rem;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: var(--shadow);
}

.tab-btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 25px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Content Area */
.content-wrapper {
    position: relative;
    min-height: 500px;
}

.pane {
    display: none;
    animation: slideUp 0.5s ease-out;
}

.pane.active {
    display: block;
}

/* Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--text-main);
}

.explanation-section h2, .exercise-section h2 {
    color: var(--primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.8rem;
}

.explanation-section p {
    font-size: 1.3rem;
    line-height: 1.8;
    margin-bottom: 1.2rem;
}

.ai-message {
    background: rgba(6, 78, 59, 0.6);
    backdrop-filter: blur(5px);
    color: var(--text-main);
    border-radius: 20px 20px 20px 5px;
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.concept {
    background: #eff6ff;
    padding: 1.5rem;
    border-radius: 15px;
    border-right: 5px solid var(--primary);
    color: #1e40af;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 1.5rem 0;
}

.cube {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #eab308, #facc15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.95rem;
    font-weight: 800;
    box-shadow: 4px 4px 0px #b45309;
    position: relative;
    transition: transform 0.3s;
}

.cube:hover {
    transform: translateY(-5px);
    box-shadow: 6px 6px 0px #b45309;
}

.cube-stack {
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
}

/* Exercise Items */
.exercise-item {
    background: rgba(15, 23, 42, 0.5);
    padding: 1.5rem;
    border-radius: 15px;
    margin-bottom: 1rem;
    border-right: 5px solid var(--primary);
    transition: all 0.3s;
}

.exercise-item:hover {
    transform: translateX(-5px);
    background: rgba(15, 23, 42, 0.8);
}

.input-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

input[type="number"], input[type="text"] {
    width: 80px;
    padding: 0.5rem;
    border: 2px solid rgba(251, 191, 36, 0.5);
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-main);
    border-radius: 10px;
    text-align: center;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.3s;
}

input:focus {
    border-color: var(--primary);
}

.check-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s;
}

.check-btn:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Lesson Selector */
.lesson-selector {
    margin-bottom: 1.5rem;
    background: var(--glass);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.lesson-selector select {
    padding: 0.5rem;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: rgba(15, 23, 42, 0.8);
    color: var(--secondary);
    cursor: pointer;
    outline: none;
}

/* Place Value Table */
.place-value-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.place-value-table th {
    background: var(--primary);
    color: white;
    padding: 1rem;
    font-size: 1.1rem;
}

.place-value-table td {
    border: 1px solid #e2e8f0;
    padding: 1rem;
    text-align: center;
    vertical-align: top;
}

.visual-repr {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    min-height: 80px;
}

.mini-cube { width: 15px; height: 15px; background: #6366f1; border-radius: 2px; }
.mini-rod { width: 6px; height: 40px; background: #f43f5e; border-radius: 2px; }
.mini-square { width: 30px; height: 30px; background: #10b981; border-radius: 2px; border: 1px solid #059669; }
.mini-thousand { width: 40px; height: 40px; background: #8b5cf6; border-radius: 4px; box-shadow: 2px 2px 0 #6d28d9; }

/* Lesson 3 Specifics */
.underlined {
    text-decoration: underline;
    text-decoration-color: var(--secondary);
    text-decoration-thickness: 3px;
    font-weight: 800;
    color: var(--secondary);
}

.expanded-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.expanded-form input {
    width: 70px !important;
}

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

/* Responsive */
@media (max-width: 768px) {
    .app-container { padding: 1rem; }
    header h1 { font-size: 1.8rem; }
    .card { 
        padding: 1.5rem; 
        overflow-x: auto; 
    }
    
    #teacher-scene {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
        text-align: center;
    }
    .teacher-emoji, .student-emoji { 
        font-size: 3rem; 
    }
    .speech-bubble {
        margin: 10px 0;
        font-size: 1.1rem;
        padding: 15px;
        width: 100%;
    }
    .speech-bubble::before, .speech-bubble::after {
        display: none; 
    }
    
    /* Target the correct wrappers for explanations and exercises on mobile */
    .interactive-explanation,
    .example-box,
    .exercise-item {
        padding: 15px !important;
    }
    
    /* Scale down large inline font sizes globally on mobile */
    .pane [style*="font-size: 4rem"] { font-size: 2.5rem !important; }
    .pane [style*="font-size: 3.5rem"] { font-size: 2.2rem !important; }
    .pane [style*="font-size: 3rem"] { font-size: 2rem !important; }
    .pane [style*="font-size: 2.5rem"] { font-size: 1.5rem !important; }
    .pane [style*="font-size: 2.2rem"] { font-size: 1.3rem !important; }
    
    /* Reduce huge paddings and gaps in inline styles */
    .pane [style*="padding: 25px"] { padding: 10px !important; }
    .pane [style*="padding: 20px"] { padding: 10px !important; }
    .pane [style*="padding: 15px 30px"] { padding: 10px 15px !important; }
    .pane [style*="padding: 15px 25px"] { padding: 10px 15px !important; }
    .pane [style*="gap: 40px"] { gap: 15px !important; }
    .pane [style*="gap: 20px"] { gap: 10px !important; }
    .pane [style*="gap: 15px"] { gap: 10px !important; }

    /* Fix Place Value Table overlapping on mobile */
    .pv-table-container {
        gap: 5px !important;
        padding: 10px !important;
    }
    .pv-col {
        padding: 5px !important;
        gap: 5px !important;
        border-width: 2px !important;
    }
    .pv-title {
        font-size: 0.85rem !important;
    }
    .pv-val {
        font-size: 1.2rem !important;
        padding: 2px 5px !important;
    }
    .pv-icon {
        width: 16px !important;
        height: 16px !important;
    }
}

/* Decorative Background */
.bg-blob {
    position: fixed;
    z-index: -1;
    filter: blur(80px);
    opacity: 0.4;
    border-radius: 50%;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-light);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--secondary);
    bottom: -50px;
    right: -50px;
}

/* Curriculum Map & Views */
.view { animation: fadeIn 0.5s ease-out; position: relative; }
.view.hidden { display: none; }

/* The Giant Tree */
.books-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4rem;
    padding: 10rem 2rem 5rem; /* Extra top padding for canopy */
    position: relative;
    border: none;
    min-height: 80vh;
    background: 
        radial-gradient(circle at 30% 10%, rgba(22, 101, 52, 0.95) 15%, transparent 25%),
        radial-gradient(circle at 70% 15%, rgba(21, 128, 61, 0.9) 18%, transparent 28%),
        radial-gradient(circle at 50% 5%, rgba(20, 83, 45, 1) 22%, transparent 35%),
        radial-gradient(circle at 20% 25%, rgba(22, 101, 52, 0.8) 12%, transparent 22%),
        radial-gradient(circle at 80% 25%, rgba(20, 83, 45, 0.85) 15%, transparent 25%);
    background-repeat: no-repeat;
    background-size: 100% 400px; /* Limit canopy to top */
}

/* Tree Trunk */
.books-grid::before {
    content: '';
    position: absolute;
    top: 30px;
    bottom: -2rem;
    left: 50%;
    width: 140px;
    background-color: #5c3a21; /* Rich wood base color */
    background-image: 
        /* Vertical bark texture */
        repeating-linear-gradient(
            90deg,
            transparent 0px,
            transparent 10px,
            rgba(0, 0, 0, 0.15) 10px,
            rgba(0, 0, 0, 0.15) 15px,
            transparent 15px,
            transparent 25px,
            rgba(38, 20, 10, 0.4) 25px,
            rgba(38, 20, 10, 0.4) 30px
        ),
        /* 3D Cylinder shadow */
        linear-gradient(
            90deg, 
            rgba(0,0,0,0.8) 0%, 
            rgba(0,0,0,0.1) 20%, 
            rgba(255,255,255,0.05) 50%,
            rgba(0,0,0,0.1) 80%, 
            rgba(0,0,0,0.8) 100%
        );
    border: none;
    z-index: 0;
    transform: translateX(-50%);
    border-radius: 70px 70px 0 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* Apple Button Wrapper */
.apple-btn {
    background: transparent;
    border-radius: 0; 
    position: relative;
    cursor: pointer;
    box-shadow: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    outline: none;
    z-index: 1;
    animation: sway 4s ease-in-out infinite alternate;
    transform-origin: top center;
    width: 250px;
}

@keyframes sway {
    0% { transform: rotate(-5deg); }
    100% { transform: rotate(5deg); }
}

/* Curved Branch connecting Apple to Trunk */
.apple-btn::before {
    content: '';
    position: absolute;
    top: -10px;
    width: 150px;
    height: 60px;
    border-bottom: 15px solid #3e2715;
    z-index: -1;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5));
}

/* Alternating sides for Apples */
.apple-btn:nth-child(odd) {
    align-self: flex-start;
    margin-right: 15%;
}
.apple-btn:nth-child(odd)::before {
    right: -100px;
    border-right: 15px solid #3e2715;
    border-bottom-right-radius: 40px;
    border-bottom-left-radius: 80px;
}

.apple-btn:nth-child(even) {
    align-self: flex-end;
    margin-left: 15%;
}
.apple-btn:nth-child(even)::before {
    left: -100px;
    border-left: 15px solid #3e2715;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 80px;
}

.apple-btn:hover {
    animation: none;
    transform: scale(1.1) rotate(0deg);
}

.apple-btn:hover .apple-svg {
    filter: drop-shadow(0 0 25px rgba(251, 191, 36, 0.9));
}

.apple-svg {
    width: 130px;
    height: 130px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5));
    position: relative;
    z-index: 2;
}

/* Wood Sign for Title */
.wood-sign {
    margin-top: -15px;
    background: linear-gradient(to bottom, #8b5a2b, #6b4226);
    border: 3px solid #3e2715;
    border-radius: 10px;
    padding: 0.8rem 1.5rem;
    box-shadow: 0 10px 20px rgba(0,0,0,0.6), inset 0 0 10px rgba(0,0,0,0.5);
    color: #fdfbf7;
    font-size: 1.2rem;
    font-weight: 800;
    text-align: center;
    font-family: 'Cairo', sans-serif;
    position: relative;
    z-index: 3;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    width: 90%;
}
.wood-sign::before, .wood-sign::after {
    content: '•';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #2c1a0c;
    font-size: 1.5rem;
}
.wood-sign::before { right: 5px; }
.wood-sign::after { left: 5px; }

/* Subtitle inside Wood Sign */
.wood-subtitle {
    display: block;
    font-size: 0.9rem;
    color: #fbbf24;
    margin-top: 5px;
    font-weight: 700;
}

/* Checkmark badge on the Apple */
.apple-check {
    position: absolute;
    top: 10px;
    right: 30px;
    width: 35px;
    height: 35px;
    background: var(--accent);
    border: 3px solid white;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 5;
}

/* Speaker on the Apple */
.apple-speaker {
    position: absolute;
    top: 15px;
    left: 30px;
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    transition: all 0.3s;
    z-index: 5;
}
.apple-btn:hover .apple-speaker {
    transform: scale(1.2);
    color: var(--secondary);
}

/* Achievements Grid */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.badge-card {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(251, 191, 36, 0.2);
    padding: 2rem;
    border-radius: 30px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    opacity: 0.5;
    filter: grayscale(1);
}

.badge-card.unlocked {
    opacity: 1;
    filter: grayscale(0);
    transform: scale(1.05);
    border: 3px solid #fcd34d;
}

.badge-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

.badge-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.badge-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.back-btn {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--secondary);
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 800;
    color: var(--text-main);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    cursor: pointer;
    transition: all 0.3s;
}

.back-btn:hover {
    background: var(--secondary);
    color: var(--background);
}

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

/* Teacher Scene */
#teacher-scene {
    background: #1e293b;
    border-radius: 20px;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 5px solid #475569;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    position: relative;
}

.teacher-emoji {
    font-size: 5rem;
    transition: transform 0.2s;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.3));
}

.teacher-emoji.talking {
    animation: bounceTalk 0.4s infinite alternate;
}

.student-emoji {
    font-size: 4rem;
    transition: transform 0.3s;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.3));
}

.student-emoji.happy {
    animation: jump 0.5s infinite alternate;
}

.speech-bubble {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--secondary);
    padding: 20px 30px;
    border-radius: 20px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #1e293b;
    flex-grow: 1;
    margin: 0 30px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    text-align: center;
    border: 3px solid #fcd34d;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 15px 0 15px 20px;
    border-style: solid;
    border-color: transparent transparent transparent #fcd34d;
}
.speech-bubble::after {
    content: '';
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 12px 0 12px 16px;
    border-style: solid;
    border-color: transparent transparent transparent white;
}

@keyframes bounceTalk {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

@keyframes jump {
    0% { transform: translateY(0); }
    100% { transform: translateY(-20px); }
}

.site-footer {
    text-align: center;
    padding: 2rem;
    margin-top: 2rem;
    font-size: 1.2rem;
    font-weight: bold;
    border-top: 2px dashed rgba(0,0,0,0.1);
}

.site-footer a {
    color: #4a2511;
    text-decoration: none;
    transition: color 0.3s;
}

.site-footer a:hover {
    color: #d946ef;
}

.highlight-part {
    animation: highlightPulse 1.5s infinite alternate !important;
    position: relative;
    z-index: 10;
}

@keyframes highlightPulse {
    0% { 
        box-shadow: 0 0 0px #fcd34d; 
        border-color: #cbd5e1; 
        transform: scale(1);
    }
    100% { 
        box-shadow: 0 0 25px #f59e0b, inset 0 0 15px rgba(245,158,11,0.2); 
        border-color: #f59e0b !important; 
        transform: scale(1.05);
    }
}

/* AI Bot Styles */
.ai-bot-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    border: 4px solid white;
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(249, 115, 22, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.ai-bot-btn:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 15px 35px rgba(249, 115, 22, 0.6);
}

.ai-bot-modal {
    position: fixed;
    bottom: 120px;
    right: 30px;
    width: 350px;
    max-width: calc(100vw - 60px);
    height: 500px;
    background: white;
    border-radius: 25px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom right;
    border: 3px solid var(--primary-light);
}

.ai-bot-modal.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.1);
}

.ai-bot-header {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-bot-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
}

.close-bot-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.close-bot-btn:hover {
    transform: scale(1.2);
}

.ai-bot-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #faf5ff;
}

.bot-message, .user-message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 1.05rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-out;
}

.bot-message {
    background: white;
    color: #4b5563;
    align-self: flex-start;
    border-bottom-right-radius: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border: 1px solid #f3e8ff;
}

.user-message {
    background: #d946ef;
    color: white;
    align-self: flex-end;
    border-bottom-left-radius: 5px;
    box-shadow: 0 4px 10px rgba(217, 70, 239, 0.3);
}

.ai-bot-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #f3e8ff;
    display: flex;
    gap: 10px;
}

.ai-bot-input-area input {
    flex-grow: 1;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.ai-bot-input-area input:focus {
    border-color: #d946ef;
}

.send-bot-btn {
    background: #d946ef;
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.send-bot-btn:hover {
    background: #c026d3;
}

@media (max-width: 768px) {
    .ai-bot-btn {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
    
    .ai-bot-modal {
        bottom: 90px;
        right: 20px;
        width: calc(100vw - 40px);
        height: 60vh;
    }
}

/* ==========================================
   Games Section Styles
   ========================================== */
.games-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.game-card {
    background: white;
    border: 3px solid var(--primary-light);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.game-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 10px 15px rgba(249, 115, 22, 0.2);
}

.game-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.game-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
}

.game-area {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    padding: 20px;
    min-height: 400px;
    position: relative;
    overflow: hidden;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.game-question {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    color: var(--primary);
    margin: 20px 0;
}

/* Meteor Game */
.meteor-container {
    position: relative;
    height: 300px;
    background: #0f172a;
    border-radius: 10px;
    overflow: hidden;
}

.meteor {
    position: absolute;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 30% 30%, #fbbf24, #d97706);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
    transition: transform 0.1s;
}

.meteor::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 30px;
    background: linear-gradient(to top, rgba(245, 158, 11, 0.8), transparent);
    border-radius: 50%;
    filter: blur(2px);
}

.meteor:hover {
    transform: scale(1.1);
}

/* Energy Race Game */
.energy-track {
    height: 40px;
    background: #e2e8f0;
    border-radius: 20px;
    margin: 30px 0;
    position: relative;
    overflow: hidden;
    border: 3px solid #cbd5e1;
}

.energy-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    transition: width 0.5s ease-in-out;
}

.robot-runner {
    position: absolute;
    top: -10px;
    left: 0;
    font-size: 2.5rem;
    transition: left 0.5s ease-in-out;
    transform: translateX(-50%);
    z-index: 10;
}

.energy-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.energy-btn {
    padding: 10px 25px;
    font-size: 1.5rem;
    border: 2px solid var(--primary);
    border-radius: 10px;
    background: white;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.energy-btn:hover {
    background: var(--primary);
    color: white;
}

/* Circuit Match */
.circuit-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

.circuit-card {
    height: 100px;
    perspective: 1000px;
    cursor: pointer;
}

.circuit-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.circuit-card.flipped .circuit-inner {
    transform: rotateY(180deg);
}

.circuit-front, .circuit-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    border: 2px solid var(--primary-light);
}

.circuit-front {
    background: var(--primary);
    color: white;
    font-size: 2rem;
}

.circuit-back {
    background: white;
    color: var(--primary);
    transform: rotateY(180deg);
}

.circuit-card.matched .circuit-inner {
    transform: rotateY(180deg);
}

.circuit-card.matched .circuit-back {
    background: #10b981;
    color: white;
    border-color: #059669;
}

/* Processor Assembly */
.processor-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.robot-screen {
    width: 300px;
    height: 200px;
    background: #1e293b;
    border: 10px solid #cbd5e1;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #10b981;
    font-family: monospace;
    font-size: 1.5rem;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.robot-screen.error {
    color: #ef4444;
    animation: glitch 0.2s infinite;
}

@keyframes glitch {
    0% { transform: translate(0) }
    20% { transform: translate(-2px, 2px) }
    40% { transform: translate(-2px, -2px) }
    60% { transform: translate(2px, 2px) }
    80% { transform: translate(2px, -2px) }
    100% { transform: translate(0) }
}

.missing-slot {
    width: 60px;
    height: 40px;
    border: 2px dashed #475569;
    display: inline-block;
    vertical-align: middle;
    margin: 0 10px;
}

.processor-parts {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.part {
    padding: 10px 20px;
    background: #f59e0b;
    color: white;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid #b45309;
    box-shadow: 0 4px 0 #b45309;
    transition: all 0.1s;
}

.part:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #b45309;
}

.magic-note {
    position: absolute;
    font-size: 2rem;
    pointer-events: none;
    z-index: 50;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
    animation: floatNote 2s ease-in forwards;
}

@keyframes floatNote {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    20% { opacity: 1; transform: translateY(-20px) scale(1) translateX(10px); }
    80% { opacity: 1; transform: translateY(-80px) scale(1.2) translateX(-10px); }
    100% { transform: translateY(-120px) scale(0.5); opacity: 0; }
}
