:root {
    --primary-color: #222222; /* Dark Asphalt */
    --secondary-color: #424242; /* Lighter Asphalt */
    --bg-color-top: #1a1a1a;
    --bg-color-bottom: #333333;
    --card-bg: #444444;
    --text-color: #ffffff;
    --text-light: #F8F9FA;
    --accent-color: #FFCA28; /* Gold/Yellow */
    --correct-color: #4CAF50;
    --wrong-color: #FF3D00;
    --sky-color: #81D4FA; /* Sky/Glass */
    
    /* Car Colors */
    --car-red: #FF3D00;
    --car-blue: #1E88E5;
    --car-green: #4CAF50;
    --car-purple: #9C27B0;
}

* {
    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, #1E88E5, #0D47A1);
    border-bottom: 5px solid var(--accent-color);
    padding: 20px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    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: rgba(34, 34, 34, 0.8);
    color: var(--text-light);
    border-radius: 25px;
    border: 3px solid var(--secondary-color);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.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;
}

/* 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);
    border-radius: 25px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    border: 4px solid var(--secondary-color);
    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 15px 30px rgba(0,0,0,0.7);
    border-color: var(--accent-color);
}

.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: #fff;
    border-radius: 30px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 5px solid var(--accent-color);
    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);
}

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

.car-label {
    background: #222;
    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: rgba(34,34,34,0.9);
    padding: 10px;
    border-radius: 20px;
    border: 3px solid var(--secondary-color);
}

.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: #222;
}

#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: 3px solid transparent;
    border-radius: 25px;
    background: rgba(68,68,68,0.8);
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--accent-color);
    color: #222;
    border-color: #fff;
    box-shadow: 0 5px 15px rgba(250, 184, 0, 0.4);
}

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

.content-box {
    background: rgba(34,34,34,0.95);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    border: 4px solid var(--secondary-color);
    color: var(--text-light);
}

/* 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: #444;
    border-radius: 20px;
    border: 3px dashed var(--secondary-color);
    cursor: pointer;
    transition: transform 0.2s;
}
.learn-item:hover {
    transform: scale(1.02);
    background: #555;
}
.learn-item.playing {
    border-style: solid;
    border-color: var(--accent-color);
    background: #665533;
}

.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: #333;
    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: #555;
    padding: 10px;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border: 3px solid var(--secondary-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: #444;
    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(34, 34, 34, 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: #222;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(250, 184, 0, 0.4);
}

/* Audio Hint */
.audio-hint {
    background: rgba(34, 34, 34, 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: #444;
    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;
    }
}
