@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&display=swap');

:root {
    --primary-color: #F9A825;
    --secondary-color: #F57F17;
    --accent-color: #E65100;
    --bg-color: #212121;
    --card-bg: #333333;
    --text-color: #EEEEEE;
    --success-color: #4CAF50;
    --font-main: 'Cairo', sans-serif;
    --font-num: 'Orbitron', 'Black Ops One', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    direction: rtl;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Fix text colors inside light backgrounds */
[style*="background:#fff"], 
[style*="background: #fff"], 
[style*="background:#e1"], 
[style*="background: #e1"], 
[style*="background:#e8"], 
[style*="background: #e8"], 
[style*="background:#f3"], 
[style*="background: #f3"], 
[style*="background:#fa"], 
[style*="background: #fa"], 
[style*="background:#00cec9"], 
[style*="background:#ff7675"],
.path-step,
.shifter-container, 
.shifter-container .digit-box,
.mountain-container,
.strategy-container,
.pair-container .lonely-ball,
.pair-container .pair {
    color: #1a1a1a !important;
}

[style*="background:#fff"] *, 
[style*="background: #fff"] *, 
[style*="background:#e1"] *, 
[style*="background: #e1"] *, 
[style*="background:#e8"] *, 
[style*="background: #e8"] *, 
[style*="background:#f3"] *, 
[style*="background: #f3"] *,
[style*="background:#fa"] *,
[style*="background:#00cec9"] *,
[style*="background:#ff7675"] * {
    color: #1a1a1a !important;
}

header {
    background: repeating-linear-gradient(
        45deg,
        #000000,
        #000000 20px,
        #F9A825 20px,
        #F9A825 40px
    );
    color: white;
    padding: 2rem 0;
    text-align: center;
    border-bottom: 5px solid var(--accent-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.8rem;
    font-weight: 900;
    color: #FFFFFF;
    text-shadow: 3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    background: rgba(0,0,0,0.7);
    display: inline-block;
    padding: 10px 20px;
    border-radius: 10px;
}

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-text {
    text-align: right;
    flex: 1;
}

.home-btn {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.home-btn:hover {
    background: white;
    color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.home-btn i {
    font-size: 1.2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* TABS STYLES */
.lesson-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    border: 2px solid #555;
    border-radius: 5px;
    background: linear-gradient(to bottom, #444, #222);
    color: #ccc;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    text-transform: uppercase;
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.1), 0 5px 10px rgba(0,0,0,0.5);
}

.tab-btn.active {
    background: var(--primary-color);
    color: #000;
    border-color: var(--accent-color);
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.5), 0 0 15px var(--primary-color);
    text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
}

/* PRACTICE SECTION STYLES */
.practice-container {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 2px solid #555;
}

.exercise-card {
    background: #444;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    border: 2px solid #555;
    transition: all 0.3s ease;
}

.exercise-card.correct {
    border-color: #2ecc71;
    background: #1e3a2b;
}

.exercise-card.wrong {
    border-color: #ff4757;
    background: #3b1e1e;
}

.exercise-question {
    font-size: 1.8rem;
    font-family: var(--font-num);
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--primary-color);
    text-align: center;
}

.exercise-input {
    width: 100%;
    padding: 12px;
    font-size: 1.5rem;
    font-family: var(--font-num);
    background: #222;
    color: #0f0;
    border: 2px solid #555;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 10px;
    outline: none;
}

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

.check-btn {
    width: 100%;
    padding: 10px;
    background: #2f3542;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
}

.practice-stats {
    display: flex;
    justify-content: space-between;
    background: #f1f2f6;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    font-weight: bold;
    color: #2c3e50;
}

/* CLICKABLE TEXT FOR TTS */
.intro-box, .step-text, .rule-box, .examples-section div {
    cursor: pointer;
    position: relative;
    transition: background 0.3s ease;
}

.intro-box:hover, .step-text:hover, .rule-box:hover {
    background-color: rgba(108, 99, 255, 0.05);
    border-radius: 10px;
}

.intro-box::after, .step-text::after, .rule-box::after {
    content: '🔊';
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 0.8rem;
    opacity: 0.3;
}

/* Home Page - Chapters Grid */
.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(250px, 45%, 300px), 1fr));
    gap: 1.5rem;
    padding-bottom: 3rem;
}

.chapter-card {
    background: linear-gradient(135deg, #333 0%, #222 100%);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.1), 0 8px 15px rgba(0,0,0,0.5);
    border: 4px solid #555;
    border-bottom: 8px solid #111 !important; /* To give a 3D button effect */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.chapter-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 10px;
    pointer-events: none;
    background: repeating-linear-gradient(
        45deg,
        #F9A825,
        #F9A825 10px,
        #000000 10px,
        #000000 20px
    );
}

.chapter-card:hover {
    transform: translateY(4px);
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.1), 0 4px 5px rgba(0,0,0,0.5);
    border-color: var(--primary-color);
    border-bottom-width: 4px !important;
    margin-top: 4px;
}

.chapter-card h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.chapter-card .lesson-count {
    font-size: 0.9rem;
    color: #eee;
    background: #555;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    display: inline-block;
}

/* Lessons List View */
.back-btn {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(to bottom, #d32f2f, #b71c1c);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
    cursor: pointer;
    font-weight: 900;
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.2), 0 5px 10px rgba(0,0,0,0.5);
    border: 2px solid #ff5252;
    transition: 0.3s;
    text-transform: uppercase;
}

.back-btn:hover {
    background: linear-gradient(to bottom, #b71c1c, #7f0000);
    transform: translateY(2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lesson-item {
    background: linear-gradient(to right, #333, #222);
    padding: 1.2rem 2rem;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    border: 2px solid #555;
    border-right: 15px solid var(--primary-color);
    position: relative;
    overflow: hidden;
}

.lesson-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0,0,0,0.2) 10px,
        rgba(0,0,0,0.2) 20px
    );
    opacity: 0.5;
}

.lesson-item:hover {
    background: linear-gradient(to right, #444, #333);
    transform: scale(1.02);
    border-color: var(--primary-color);
    border-right-color: var(--accent-color);
}

.lesson-item h4 {
    font-size: 1.2rem;
}

.lesson-item .arrow {
    font-size: 1.5rem;
    color: var(--primary-color);
}

/* Lesson Explanation View */
.explanation-container {
    background: var(--card-bg);
    border-radius: 30px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    margin-bottom: 3rem;
    border: 1px solid #555;
}

.highlight-active {
    box-shadow: 0 0 20px var(--accent-color) !important;
    border-color: var(--accent-color) !important;
    transform: scale(1.02) !important;
    transition: all 0.5s ease-in-out !important;
    z-index: 10;
    position: relative;
}

.intro-box {
    background: #332d16;
    padding: 1.5rem;
    border-radius: 20px;
    border-right: 8px solid var(--primary-color);
    margin-bottom: 2rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.step-card {
    margin-bottom: 2.5rem;
    animation: fadeIn 0.8s ease;
}

/* Animations */
.anim-fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes pop {
    0% { transform: scale(0); }
    80% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.anim-pop { animation: pop 0.5s ease-out backwards; }

@keyframes slideUp {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}
.anim-slide-up { animation: slideUp 0.5s ease-out backwards; }

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
.anim-pulse { animation: pulse 2s infinite ease-in-out; }

@keyframes dropIn {
    0% { transform: translateY(-50px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}
.anim-drop { animation: dropIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards; }

/* Dashboard */
.step-card h3 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-content {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: center;
}

.step-text {
    flex: 1 1 350px;
    font-size: clamp(1.1rem, 4vw, 1.3rem);
    line-height: 1.8;
}

.step-visual {
    flex: 1 1 300px;
    background: #222;
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    overflow-x: auto;
    max-width: 100%;
    border: 2px solid #444;
}

.rule-box {
    background: linear-gradient(135deg, #55efc4, #00b894);
    color: white;
    padding: 2rem;
    border-radius: 25px;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 900;
    margin: 3rem 0;
    box-shadow: 0 10px 20px rgba(85, 239, 196, 0.3);
}

.visual-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.hundred-block {
    width: 150px;
    height: 150px;
    background: #fab005;
    border: 2px solid #e67e22;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 1px;
}

.hundred-block div {
    background: rgba(255,255,255,0.3);
    border: 0.1px solid rgba(0,0,0,0.1);
}

.ten-stick {
    width: 20px;
    height: 150px;
    background: #ff7675;
    border: 2px solid #d63031;
    display: grid;
    grid-template-rows: repeat(10, 1fr);
    gap: 1px;
}

.ten-stick div {
    background: rgba(255,255,255,0.3);
    border: 0.1px solid rgba(0,0,0,0.1);
}

.one-cube {
    width: 20px;
    height: 20px;
    background: #00cec9;
    border: 1px solid #008080;
}

/* Place Value Table */
.pv-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

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

.pv-table td {
    padding: 1.5rem;
    text-align: center;
    border: 1px solid #eee;
    color: #2c3e50;
}

.pv-result {
    margin-top: 2rem;
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    color: #2c3e50;
}

.number-display {
    font-size: 4rem;
    font-weight: 900;
    color: var(--primary-color);
    letter-spacing: 10px;
}

.number-label {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 0.5rem;
    font-weight: bold;
}

.label-h { color: #fab005; }
.label-t { color: #ff7675; }
.label-o { color: #00cec9; }

/* Expanded Form Visuals */
.explosion-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    background: #f1f2f6;
    border-radius: 20px;
    font-size: 2rem;
    font-weight: 900;
    color: #2c3e50;
}

.box-h, .box-t, .box-o {
    padding: 1rem 2rem;
    border-radius: 15px;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.box-h { background: #fab005; }
.box-t { background: #ff7675; }
.box-o { background: #00cec9; }

.digit-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Reading Order & Words */
.reading-path {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.5rem;
    font-weight: bold;
    justify-content: center;
}

.path-step {
    padding: 1rem;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.word-badge {
    background: white;
    border: 2px solid var(--secondary-color);
    padding: 0.8rem;
    border-radius: 15px;
    text-align: center;
    font-weight: bold;
    color: #2c3e50;
}

/* Odd/Even Pairing */
.pair-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    padding: 1rem;
}

.pair {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: #e3f2fd;
    padding: 10px;
    border-radius: 10px;
    border: 2px dashed #2196f3;
}

.friend-ball {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #FF7675;
}

.lonely-ball {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #FF7675;
    border: 3px solid #d63031;
    animation: shake 0.5s infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Neighbor Shifter */
.shifter-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 2rem;
    background: #e0f7fa;
    border-radius: 20px;
    color: #2c3e50;
}

.digit-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #2c3e50;
}

.digit-val {
    font-size: 3rem;
    font-weight: 900;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    background: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    transition: 0.3s;
}

.digit-val.highlight {
    background: #ffeb3b;
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(255, 235, 59, 0.5);
}

.shift-arrow {
    font-size: 2rem;
    color: var(--primary-color);
    animation: bounceX 1s infinite;
}

@keyframes bounceX {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-10px); }
}

/* Comparison */
.comparison-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    padding: 2rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    color: #2c3e50;
}

.num-card {
    background: var(--bg-color);
    padding: 1rem 2rem;
    border-radius: 15px;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary-color);
}

.symbol-circle {
    width: 80px;
    height: 80px;
    background: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(255, 118, 117, 0.4);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Sorting Train */
.train-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    padding: 2rem;
    overflow-x: auto;
}

.carriage {
    background: #FF7675;
    color: white;
    padding: 1.5rem;
    border-radius: 15px;
    min-width: 120px;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 900;
    position: relative;
    box-shadow: 0 4px 0 #d63031;
    animation: bounceY 1.5s infinite;
}

.carriage:nth-child(even) { background: #4ECDC4; box-shadow: 0 4px 0 #45b7d1; }
.carriage:nth-child(3n) { background: #fab005; box-shadow: 0 4px 0 #e67e22; }

.carriage::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 10px;
    width: 20px;
    height: 20px;
    background: #2d3436;
    border-radius: 50%;
}

.carriage::before {
    content: '';
    position: absolute;
    bottom: -15px;
    right: 10px;
    width: 20px;
    height: 20px;
    background: #2d3436;
    border-radius: 50%;
}

@keyframes bounceY {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Rounding Mountain */
.mountain-container {
    height: 150px;
    width: 100%;
    background: #f1f3f5;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    margin: 2rem 0;
}

.mountain-peak {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 200px solid transparent;
    border-right: 200px solid transparent;
    border-bottom: 120px solid #adb5bd;
}

.mountain-label {
    position: absolute;
    bottom: 10px;
    font-weight: bold;
    font-size: 1.2rem;
}

.label-left { left: 10%; color: #d63031; }
.label-right { right: 10%; color: #2ecc71; }

.rounding-ball {
    width: 40px;
    height: 40px;
    background: var(--accent-color);
    border-radius: 50%;
    position: absolute;
    bottom: 20px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    transition: all 1s ease-in-out;
}

.magnet-line {
    height: 10px;
    background: linear-gradient(to right, #d63031 50%, #2ecc71 50%);
    border-radius: 10px;
    margin: 2rem 0;
    position: relative;
}

/* Addition Strategies */
.strategy-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background: #fdf2f2;
    border-radius: 20px;
    border: 2px dashed #ff7675;
    color: #2c3e50;
}

.addition-row {
    display: flex;
    gap: 1rem;
    font-size: 2.5rem;
    font-weight: 900;
}

.num-circle {
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--secondary-color);
}

.num-circle.active {
    background: var(--primary-color);
    color: white;
    border-color: white;
    box-shadow: 0 0 15px rgba(108, 92, 231, 0.5);
    animation: bounceY 1s infinite;
}

.result-bubble {
    background: var(--success-color);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    font-size: 1.5rem;
    font-weight: bold;
}

/* Vertical Math */
.vertical-math {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 3rem 2rem 2rem 2rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    position: relative;
    font-size: 2.5rem;
    font-family: 'Inter', 'Tajawal', sans-serif;
    color: #2c3e50;
}

.carry-circle {
    width: 35px;
    height: 35px;
    border: 2px dashed var(--accent-color);
    border-radius: 50%;
    position: absolute;
    top: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--accent-color);
    background: #fff8f8;
}

.math-line {
    width: 110%;
    height: 3px;
    background: #333;
    margin: 10px 0;
    align-self: center;
}

.math-row {
    display: flex;
    flex-direction: row-reverse; /* تضمن وجود الآحاد في اليمين دائماً */
    gap: 10px;
    margin-bottom: 5px;
}

.math-row span {
    width: 35px;
    text-align: center;
    display: inline-block;
}

/* Zero Magic */
.magic-number {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 3.5rem;
    font-weight: 900;
}

.magic-digit {
    color: var(--primary-color);
}

.magic-zeros {
    color: var(--secondary-color);
    opacity: 0.3;
    animation: glow 2s infinite alternate;
}

@keyframes glow {
    from { opacity: 0.3; transform: scale(1); }
    to { opacity: 1; transform: scale(1.1); }
}

/* Mental Math Bubbles */
.mental-container {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding: 3rem;
    background: #eef2f7;
    border-radius: 30px;
    position: relative;
    color: #2c3e50;
}

.mental-bubble {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 50% 50% 50% 0;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    font-weight: bold;
    color: var(--primary-color);
    animation: float 3s infinite ease-in-out;
}

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

.triple-column-math {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 2.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: 10px;
    color: #2c3e50;
}

.triple-column-math .math-row {
    width: 150px;
}

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

@media (max-width: 768px) {
    header h1 { font-size: 2rem; }
    .explanation-container { padding: 1.5rem; }
    .rule-box { font-size: 1.5rem; padding: 1.5rem; }
    .step-card h3 { font-size: 1.5rem; }
    .number-display { font-size: 3rem; }
    .magic-number { font-size: 2.5rem; }
}

@media (max-width: 480px) {
    header h1 { font-size: 1.6rem; }
    header p { font-size: 0.9rem; }
    .intro-box { font-size: 1.1rem; padding: 1rem; }
    .step-text { font-size: 1.1rem; flex-basis: 100%; }
    .step-visual { flex-basis: 100%; padding: 1rem; }
    .rule-box { font-size: 1.2rem; margin: 2rem 0; }
    .chapter-card { padding: 1.2rem; }
    .lesson-tabs { flex-direction: column; }
    .back-btn { width: 100%; justify-content: center; }
    .number-display { font-size: 2.5rem; }
}

/* CHAPTER 8 - GEOMETRY STYLES */
.shape-box {
    width: 60px;
    height: 60px;
    transition: transform 0.3s ease;
}
.shape-box:hover { transform: scale(1.2) rotate(10deg); }

.cube-3d {
    width: 80px;
    height: 80px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-20deg) rotateY(30deg);
    animation: rotate3d 10s infinite linear;
}
@keyframes rotate3d {
    from { transform: rotateX(-20deg) rotateY(0deg); }
    to { transform: rotateX(-20deg) rotateY(360deg); }
}
.face {
    position: absolute;
    width: 80px;
    height: 80px;
    background: rgba(108, 92, 231, 0.7);
    border: 2px solid white;
}
.front  { transform: translateZ(40px); }
.back   { transform: rotateY(180deg) translateZ(40px); }
.right  { transform: rotateY(90deg) translateZ(40px); }
.left   { transform: rotateY(-90deg) translateZ(40px); }
.top    { transform: rotateX(90deg) translateZ(40px); }
.bottom { transform: rotateX(-90deg) translateZ(40px); }

.cylinder-3d {
    width: 60px;
    height: 100px;
    background: linear-gradient(to right, #74b9ff, #0984e3, #74b9ff);
    border-radius: 30px / 15px;
    position: relative;
}
.cylinder-3d::before {
    content: '';
    position: absolute;
    top: 0;
    width: 100%;
    height: 30px;
    background: #74b9ff;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
}

.shape-small {
    width: 30px;
    height: 30px;
}
.shape-small.square { background: var(--primary-color); }
.shape-small.circle { background: var(--accent-color); border-radius: 50%; }

/* CHAPTER 9 - FRACTION STYLES */
.pizza-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 10px auto;
    border: 3px solid #2d3436;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.fraction-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 10px;
}
.fraction-line {
    width: 40px;
    height: 3px;
    background: #333;
    margin: 2px 0;
}

.toy-ball {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #dfe6e9;
}
.toy-ball.highlight {
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

.fraction-card {
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
    font-weight: bold;
    font-size: 1.5rem;
}

/* CHAPTER 10 - MULTIPLICATION STYLES */
.group-box {
    background: white;
    padding: 10px;
    border-radius: 15px;
    border: 2px solid #ddd;
    font-size: 2rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.pattern-row {
    background: #f8f9fa;
    padding: 5px 15px;
    border-radius: 20px;
    margin-bottom: 5px;
    width: 100%;
    text-align: center;
}

/* Animations for Visuals */
.anim-pop {
    animation: animPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
.anim-slide-up {
    animation: animSlideUp 0.5s ease both;
}
.anim-drop {
    animation: animDrop 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.anim-pulse {
    animation: animPulse 1s infinite;
}

@keyframes animPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes animSlideUp {
    0% { transform: translateY(30px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes animDrop {
    0% { transform: translateY(-50px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes animPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Global Fix for Light Containers */
.shifter-container, 
.digit-box, 
.comparison-box, 
.train-container, 
.strategy-container, 
.vertical-math, 
.mountain-container, 
.pv-table, 
.example-visual {
    color: #2c3e50;
}

.shifter-container p, 
.digit-box p, 
.comparison-box p, 
.train-container p, 
.strategy-container p, 
.vertical-math p, 
.mountain-container p, 
.example-visual p,
.digit-val,
.result-bubble,
.mountain-label {
    color: #2c3e50;
}

.hide-anim {
    opacity: 0;
}

.fraction-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    font-weight: bold;
    margin: 0 4px;
    font-size: 0.9em;
}

.fraction-box .numerator {
    border-bottom: 2px solid currentColor;
    padding: 0 4px;
    line-height: 1.2;
}

.fraction-box .denominator {
    padding: 0 4px;
    line-height: 1.2;
}
