:root {
    --primary-color: #0F2042; /* Deep Sea Blue */
    --secondary-color: #00A896; /* Turquoise */
    --bg-color-top: #5dade2; /* Lighter sea blue */
    --bg-color-bottom: #0F2042;
    --card-bg: #ffffff;
    --text-color: #2f3640; /* Dark text for cards */
    --text-light: #F8F9FA; /* Light text for headers */
    --accent-color: #FAB800; /* Amber/Yellow */
    --correct-color: #2ed573;
    --wrong-color: #ff4757;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Baloo Bhaijaan 2', 'Tajawal', 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 buoy */
.home-btn-buoy {
    position: fixed;
    top: 15px;
    left: 15px; /* تم تغييره لليسار لتجنب التداخل مع شريط التقدم */
    background: #ff4757;
    color: white;
    padding: 10px 20px;
    border: 4px solid white;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 800;
    box-shadow: 0 4px 0 #c0392b, inset 0 0 10px rgba(0,0,0,0.2);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.3s;
    font-size: 1.2rem;
}
.home-btn-buoy::before, .home-btn-buoy::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 100%;
    background: white;
    top: 0;
    opacity: 0.5;
}
.home-btn-buoy::before { left: 20%; }
.home-btn-buoy::after { right: 20%; }

/* Captain Avatar */
.captain-avatar {
    position: fixed;
    bottom: 20px;
    left: 20px;
    font-size: 5rem;
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.3));
    animation: floatCaptain 4s infinite alternate ease-in-out;
}
@keyframes floatCaptain {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

/* Progress Bar (Ship) */
.progress-container {
    max-width: 800px;
    margin: 20px auto 0;
    padding: 0 20px;
    position: relative;
    z-index: 3;
}
.progress-track {
    width: 100%;
    height: 25px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    border: 3px solid rgba(255,255,255,0.5);
    position: relative;
}
.progress-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 20px;
    position: relative;
    transition: width 0.5s ease-in-out;
}
.ship-icon {
    position: absolute;
    right: -15px; /* RTL */
    top: -25px;
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    animation: waveAnim 2s infinite alternate ease-in-out;
}
.island-icon {
    position: absolute;
    left: -10px;
    top: -25px;
    font-size: 2.5rem;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(15, 32, 66, 0.8);
    color: var(--text-light);
    border-radius: 25px;
    border: 3px solid var(--accent-color);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

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

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

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

/* Lesson Cards (Porthole / Wooden style) */
.lesson-card {
    background: var(--card-bg);
    border-radius: 50%; /* Porthole shape */
    aspect-ratio: 1; /* Make it a circle */
    padding: 20px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3), inset 0 0 20px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 10px solid #8b5a2b; /* Wooden border */
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: 0 auto;
    width: 100%;
    max-width: 250px;
}

.lesson-card::after {
    content: '';
    position: absolute;
    top: 5%;
    left: 5%;
    width: 20%;
    height: 20%;
    background: rgba(255,255,255,0.4);
    border-radius: 50%;
    pointer-events: none;
}

.lesson-card:hover, .lesson-card:active {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 15px 30px rgba(0,0,0,0.4);
    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.1);
    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-color);
    line-height: 1.3;
}

/* Top Bar in Lesson View */
.top-bar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    background: rgba(255,255,255,0.9);
    padding: 10px;
    border-radius: 20px;
    border: 3px solid var(--secondary-color);
}

.back-btn {
    background: var(--accent-color);
    border: none;
    color: var(--primary-color);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 0 #d35400;
}
.back-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #d35400;
}

#unit-title, #chapter-title, #lesson-title {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 800;
    cursor: pointer;
}

/* 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(255,255,255,0.8);
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--accent-color);
    color: var(--primary-color);
    border-color: white;
    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(255,255,255,0.95);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    border: 4px solid var(--secondary-color);
}

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

.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: #f4f6f9;
    border-radius: 20px;
}
.game-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--primary-color);
    cursor: pointer;
}

/* Sorting Game */
.sort-item {
    font-size: 4rem;
    margin: 10px;
    cursor: grab;
    display: inline-block;
    background: white;
    padding: 10px;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    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(0, 168, 150, 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(0, 168, 150, 0.3);
}
.drop-zone-title {
    width: 100%;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    cursor: pointer;
    color: var(--primary-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: white;
    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.1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.mcq-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    border-color: var(--accent-color);
}
.mcq-btn.correct {
    border-color: var(--correct-color);
    background: #e8f9f0;
}
.mcq-btn.wrong {
    border-color: var(--wrong-color);
    background: #ffe9eb;
    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;
}

/* Sea Background Decorations */
.sea-decor {
    position: fixed;
    z-index: 1;
    pointer-events: none;
    opacity: 0.6;
}

.bubble {
    font-size: 2rem;
    bottom: -50px;
    animation: floatUp infinite ease-in;
}
.bubble1 { left: 10%; animation-duration: 8s; font-size: 1.5rem; }
.bubble2 { left: 50%; animation-duration: 12s; font-size: 3rem; }
.bubble3 { right: 20%; animation-duration: 10s; font-size: 2rem; }

@keyframes floatUp {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { transform: translateY(-120vh) translateX(20px); opacity: 0; }
}

.fish-silhouette {
    font-size: 4rem;
    filter: brightness(0) invert(1) opacity(0.1);
    animation: swimAcross infinite linear;
}
.fish1 { top: 20%; animation-duration: 20s; }
.fish2 { top: 60%; font-size: 6rem; animation-duration: 30s; animation-delay: 5s; }

@keyframes swimAcross {
    0% { transform: translateX(-10vw) scaleX(-1); }
    100% { transform: translateX(110vw) scaleX(-1); }
}

.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(15, 32, 66, 0.6);
    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(--secondary-color);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 168, 150, 0.4);
}

/* Audio Hint */
.audio-hint {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    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: #fff8e1;
    transform: scale(1.02);
}
