:root {
    --primary-color: #0f172a; /* Slate 900 */
    --secondary-color: #1e293b; /* Slate 800 */
    --bg-color-top: #0a192f; /* Modern deep slate blue */
    --bg-color-bottom: #112240; /* Lighter navy slate */
    --card-bg: rgba(30, 41, 59, 0.85); /* Slate 800 glass */
    --card-border: rgba(255, 255, 255, 0.1);
    --text-color: #f8fafc;
    --text-light: #e2e8f0;
    --accent-color: #38bdf8; /* Sky Blue */
    --correct-color: #10b981;
    --wrong-color: #ef4444;
    --sky-color: #38bdf8;
    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.4);
    
    /* Car Colors */
    --car-red: #ef4444;
    --car-blue: #38bdf8;
    --car-green: #10b981;
    --car-purple: #8b5cf6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Baloo Bhaijaan 2', 'Tajawal', Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(180deg, var(--bg-color-top), var(--bg-color-bottom));
    background-attachment: fixed;
    color: var(--text-color);
    font-size: 24px;
    overflow-x: hidden;
    min-height: 100vh;
}

.view {
    display: none;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}
.active-view {
    display: block;
    animation: fadeIn 0.5s;
}

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

/* Home button racing */
.home-btn-racing {
    background: var(--primary-color);
    color: var(--accent-color);
    padding: 10px 20px;
    border: 3px solid var(--accent-color);
    border-radius: 15px;
    text-decoration: none;
    font-weight: 800;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 1.2rem;
    margin-bottom: 15px;
}
.home-btn-racing:hover {
    transform: scale(1.10);
    background: var(--accent-color);
    color: var(--primary-color);
}

/* Top Header Banner */
.top-header-banner {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(2, 6, 23, 0.98));
    backdrop-filter: blur(10px);
    border-bottom: 3px solid var(--accent-color);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-soft);
    margin-bottom: 20px;
}

.banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 20px;
}

.banner-text {
    flex: 1;
    text-align: right;
    color: white;
}

.banner-title-small {
    font-size: 1.2rem;
    color: var(--text-light);
    display: block;
}

.banner-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-color);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin: 5px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.banner-subtitle {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 10px;
}

.speaker-icon {
    background: rgba(0,0,0,0.2);
    border-radius: 50%;
    padding: 5px 10px;
    cursor: pointer;
    transition: transform 0.2s;
}
.speaker-icon:hover {
    transform: scale(1.2);
    background: rgba(0,0,0,0.4);
}

.banner-avatar {
    width: 100px;
    height: 100px;
    background: white;
    border-radius: 50%;
    border: 5px solid var(--accent-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    overflow: hidden;
}
.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    color: var(--text-light);
    border-radius: 20px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-soft);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.header p {
    font-size: 1.4rem;
}

.header-car-img {
    width: 150px;
    height: auto;
    border-radius: 15px;
    box-shadow: var(--shadow-glow);
    border: 2px solid var(--accent-color);
    animation: float 3s ease-in-out infinite;
}

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

/* Grid Layout */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
    padding: 10px;
}

/* Racing Unit/Chapter Cards */
.lesson-card {
    background: var(--card-bg);
    backdrop-filter: blur(5px);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 0 15px rgba(255, 235, 59, 0.5); /* Permanent Yellow Neon Glow */
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s, border-color 0.3s;
    border: 1px solid var(--card-border);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lesson-card:hover, .lesson-card:active {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 0 25px rgba(255, 235, 59, 0.9);
    border-color: #facc15;
}

.lesson-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    transition: transform 0.3s ease-in-out;
}

.lesson-card:hover .lesson-icon {
    transform: scale(1.15) rotate(5deg);
}

.lesson-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-light);
    line-height: 1.3;
}

/* Map Track View Container */
.map-view-container {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
    border: 2px solid var(--card-border);
    position: relative;
    overflow: hidden;
}

.track-header {
    display: flex;
    justify-content: space-between;
    font-size: 3rem;
    margin-bottom: 20px;
}

/* Map Container */
.map-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    /* Drawing an SVG background or we draw SVG in JS */
}

.track-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.track-path {
    fill: none;
    stroke: #424242; /* Asphalt */
    stroke-width: 30px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.track-path-dash {
    fill: none;
    stroke: #ffffff; /* White dashes */
    stroke-width: 4px;
    stroke-dasharray: 20, 20;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.car-node {
    position: absolute;
    z-index: 10;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.car-node:hover {
    transform: translate(-50%, -50%) scale(1.15);
    filter: drop-shadow(0 0 20px rgba(255, 235, 59, 0.9));
}

.car-svg {
    width: 120px;
    height: 60px;
    filter: drop-shadow(0 8px 10px rgba(0,0,0,0.4));
}

.car-label {
    background: var(--primary-color);
    color: var(--accent-color);
    padding: 5px 15px;
    border-radius: 15px;
    font-weight: 800;
    font-size: 1rem;
    margin-top: 10px;
    border: 2px solid var(--accent-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    text-align: center;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}
.car-label .speaker-icon {
    font-size: 0.8rem;
    padding: 2px 5px;
}

/* Top Bar in Lesson View */
.top-bar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    background: var(--card-bg);
    padding: 10px;
    border-radius: 15px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-soft);
}

.back-btn {
    background: var(--card-bg);
    border: 3px solid var(--accent-color);
    color: var(--text-light);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.back-btn:hover {
    transform: scale(1.05);
    background: var(--accent-color);
    color: var(--primary-color);
}

#unit-title, #chapter-title, #lesson-title {
    font-size: 1.5rem;
    color: var(--accent-color);
    font-weight: 800;
    cursor: pointer;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    font-size: 1.4rem;
    font-weight: 800;
    border: 1px solid var(--card-border);
    border-radius: 15px;
    background: var(--card-bg);
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
    box-shadow: var(--shadow-glow);
}

.tab-content {
    display: none;
}
.active-tab {
    display: block;
    animation: fadeIn 0.4s;
}

.content-box {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--card-border);
    color: var(--text-color);
}

/* Text Highlighting Feature */
.highlight-word {
    background-color: var(--accent-color);
    color: #333;
    border-radius: 5px;
    padding: 0 5px;
    transition: all 0.2s;
}

/* Learn Elements */
.learn-item {
    display: flex;
    align-items: center;
    padding: 20px;
    margin-bottom: 15px;
    background: var(--card-bg);
    border-radius: 20px;
    border: 3px dashed var(--secondary-color);
    cursor: pointer;
    transition: transform 0.2s;
}
.learn-item:hover {
    transform: scale(1.02);
    background: var(--secondary-color);
}
.learn-item.playing {
    border-style: solid;
    border-color: var(--accent-color);
    background: rgba(255, 193, 7, 0.2);
}

.learn-icon {
    font-size: 3.5rem;
    margin-left: 20px;
}
.learn-text {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.5;
}

/* Games Elements */
.game-container {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-color-bottom);
    border-radius: 20px;
    border: 2px solid var(--secondary-color);
}
.game-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--accent-color);
    cursor: pointer;
}

/* Sorting Game */
.sort-item {
    font-size: 4rem;
    margin: 10px;
    cursor: grab;
    display: inline-block;
    background: var(--secondary-color);
    padding: 10px;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border: 3px solid var(--accent-color);
}
.sort-item:active { cursor: grabbing; }

.drop-zones {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.drop-zone {
    flex: 1;
    min-width: 150px;
    min-height: 150px;
    border: 4px dashed var(--secondary-color);
    border-radius: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    gap: 10px;
    transition: background 0.3s;
}
.drop-zone.hovered {
    background: rgba(255, 255, 255, 0.2);
}
.drop-zone-title {
    width: 100%;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    cursor: pointer;
    color: var(--accent-color);
}

/* Multiple Choice Game */
.mcq-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}
.mcq-btn {
    padding: 15px 30px;
    font-size: 2.5rem;
    background: var(--card-bg);
    border: 4px solid var(--secondary-color);
    border-radius: 50%;
    width: 100px;
    height: 100px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}
.mcq-btn:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    border-color: var(--accent-color);
}
.mcq-btn.correct {
    border-color: var(--correct-color);
    background: #1b5e20;
}
.mcq-btn.wrong {
    border-color: var(--wrong-color);
    background: #b71c1c;
    animation: shake 0.4s;
}

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

.clickable-text {
    cursor: pointer;
}
.clickable-text:active {
    opacity: 0.7;
}

.view.active-view, .tab-content.active-tab {
    animation: flyIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* Footer Copyright */
.footer-copyright {
    text-align: center;
    padding: 20px 10px;
    margin-top: 40px;
    position: relative;
    z-index: 5;
}

.footer-copyright a {
    color: var(--text-light);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    background: rgba(13, 71, 161, 0.8);
    padding: 8px 15px;
    border-radius: 20px;
    border: 2px solid var(--secondary-color);
    transition: all 0.3s ease;
    display: inline-block;
}

.footer-copyright a:hover {
    background: var(--accent-color);
    color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(250, 184, 0, 0.4);
}

/* Audio Hint */
.audio-hint {
    background: rgba(13, 71, 161, 0.9);
    color: var(--text-light);
    text-align: center;
    padding: 10px 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: 700;
    border: 2px dashed var(--accent-color);
    display: inline-block;
    width: 100%;
    transition: transform 0.2s, background 0.2s;
}

.audio-hint:hover {
    background: var(--card-bg);
    transform: scale(1.02);
}

/* Responsive Scaling for Map Elements */
@media (max-width: 800px) {
    .car-svg {
        width: 80px;
        height: 40px;
    }
    .car-label {
        font-size: 0.8rem;
        padding: 4px 10px;
        white-space: normal;
        max-width: 140px;
    }
    .track-header {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .car-svg {
        width: 60px;
        height: 30px;
    }
    .car-label {
        font-size: 0.65rem;
        padding: 3px 8px;
        max-width: 100px;
    }
    .track-header {
        font-size: 1.5rem;
    }
}

/* Racing Lights Overlay Effect */
.racing-lights-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        -45deg,
        rgba(56, 189, 248, 0.4),
        rgba(56, 189, 248, 0.4) 50px,
        rgba(255, 235, 59, 0.4) 50px,
        rgba(255, 235, 59, 0.4) 100px,
        rgba(239, 68, 68, 0.4) 100px,
        rgba(239, 68, 68, 0.4) 150px
    );
    background-size: 200% 200%;
    animation: speedMotion 0.15s linear infinite;
    mix-blend-mode: color-dodge;
}

@keyframes speedMotion {
    0% { background-position: 0 0; }
    100% { background-position: 100% 100%; }
}
