:root {
    /* --- Masha and the Bear Theme Colors (From reading platform) --- */
    --masha-pink: #E91E63;
    --masha-pink-dark: #C2185B;
    --masha-pink-light: #FF4081;
    --masha-fuchsia: #D81B60;
    
    --bear-brown: #5D4037;
    --bear-brown-dark: #3E2723;
    --bear-brown-light: #8D6E63;
    --wood-bark: #4E342E;
    
    --forest-green: #2E7D32;
    --forest-green-light: #4CAF50;
    --forest-mint: #E8F5E9;
    
    --honey-gold: #FFB300;
    --honey-amber: #FFA000;
    --honey-light: #FFF8E1;
    --sunflower-yellow: #FFD54F;
    
    --card-bg: #FFFFFF;
    --text-main: #3E2723;
    --text-muted: #6D4C41;
    --text-dim: #795548;
    
    --border-radius: 20px;
    --radius-xl: 28px;
    --radius-lg: 18px;
}

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

body {
    font-family: 'Tajawal', 'Changa', 'Marhey', sans-serif;
    background-color: #F8F5EE;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(233, 30, 99, 0.05), transparent 30%),
        radial-gradient(circle at 90% 40%, rgba(255, 179, 0, 0.07), transparent 35%),
        linear-gradient(180deg, #FFFDF9 0%, #F5EFE6 100%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    direction: rtl;
    position: relative;
}

body.locked {
    overflow: hidden;
    height: 100vh;
}

/* Floating subtle forest background elements */
.floating-forest-bg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.forest-leaf {
    position: absolute;
    font-size: 2.2rem;
    opacity: 0.16;
    animation: gentleFloat 12s infinite ease-in-out;
}

.leaf-1 { top: 12%; left: 6%; }
.leaf-2 { top: 35%; right: 4%; }
.leaf-3 { top: 65%; left: 8%; }
.leaf-4 { top: 82%; right: 7%; }
.leaf-5 { top: 48%; left: 50%; }

@keyframes gentleFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

/* --- Masha & Bear Premium Header --- */
.masha-premium-header {
    background: linear-gradient(135deg, #4E342E 0%, #5D4037 45%, #3E2723 100%);
    color: #FFFDF9;
    border-radius: 0 0 35px 35px;
    box-shadow: 0 10px 30px rgba(62, 39, 35, 0.25);
    border-bottom: 5px solid var(--honey-gold);
    position: relative;
    overflow: hidden;
    margin-bottom: 2.5rem;
}

.masha-premium-header.simple-profile-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.6rem 2rem;
}

.profile-header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    position: relative;
    z-index: 2;
}

.header-avatar-wrap {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #FFF;
    border: 3.5px solid var(--honey-gold);
    box-shadow: 0 0 16px rgba(255, 179, 0, 0.5);
    flex-shrink: 0;
    overflow: hidden;
}

.header-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.header-student-name {
    font-size: 2.3rem;
    font-weight: 800;
    color: #FFFFFF;
    font-family: 'Marhey', 'Changa', sans-serif;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 0 var(--masha-pink-dark), 0 0 20px rgba(233, 30, 99, 0.4);
    margin: 0;
    line-height: 1;
}

.masha-premium-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}

.header-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 2.5rem;
    position: relative;
    z-index: 2;
    gap: 1.5rem;
}

.nav-right-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-user-badge, .play-masha-btn {
    height: 62px;
    min-width: 215px;
    box-sizing: border-box;
    border-radius: 50px;
    border: 2px solid rgba(255, 215, 79, 0.45);
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.nav-user-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    padding: 0 1.2rem 0 0.55rem;
    cursor: default;
}

.nav-user-badge:hover {
    transform: translateY(-2px);
    border-color: var(--honey-gold);
    box-shadow: 0 6px 20px rgba(255, 179, 0, 0.25);
}

.nav-avatar-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #FFF;
    border: 3px solid var(--honey-gold);
    box-shadow: 0 0 12px rgba(255, 179, 0, 0.5);
    flex-shrink: 0;
}

.nav-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.avatar-star-badge {
    position: absolute;
    bottom: -4px;
    left: -4px;
    font-size: 1rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.nav-user-details {
    display: flex;
    align-items: center;
}

.nav-user-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: #FFFFFF;
    font-family: 'Marhey', 'Tajawal', sans-serif;
    letter-spacing: 0.3px;
    line-height: 1;
}

.play-masha-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #FFFFFF;
    padding: 0 1.4rem;
    font-family: 'Marhey', 'Tajawal', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
}

.play-masha-btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 215, 79, 0.2);
    border-color: var(--honey-gold);
    color: var(--sunflower-yellow);
    box-shadow: 0 6px 20px rgba(255, 179, 0, 0.35);
}

.play-masha-btn .btn-icon {
    font-size: 1.35rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.play-masha-btn .btn-badge {
    font-size: 1.15rem;
    line-height: 1;
}

.nav-title-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.nav-title-capsule {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.nav-emoji-cluster {
    font-size: 1.3rem;
    margin-bottom: 2px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    animation: gentleBob 3s infinite ease-in-out;
}

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

.nav-title-capsule h1 {
    font-family: 'Marhey', 'Changa', sans-serif;
    font-size: 2.1rem;
    font-weight: 700;
    color: #FFFFFF;
    text-shadow: 0 2px 0 var(--masha-pink-dark), 0 0 20px rgba(233, 30, 99, 0.4);
    margin: 0;
    line-height: 1.2;
}

.nav-subject-tag {
    font-size: 0.85rem;
    font-weight: 800;
    color: #3E2723;
    background: linear-gradient(135deg, var(--honey-gold), var(--sunflower-yellow));
    padding: 2px 14px;
    border-radius: 20px;
    margin-top: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-family: 'Changa', sans-serif;
}

.header-hero-strip {
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.65rem 1.5rem;
    position: relative;
    z-index: 2;
}

.hero-strip-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.98rem;
    font-family: 'Tajawal', sans-serif;
}

.hero-bear-greeting {
    color: var(--sunflower-yellow);
    font-weight: 800;
}

.hero-divider {
    color: rgba(255, 255, 255, 0.4);
}

.hero-subtitle {
    color: #F5EBE6;
    font-weight: 600;
}

/* --- Portal Main Wrapper --- */
.portal-main-wrap {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1.5rem 3rem;
    position: relative;
    z-index: 1;
}

.section-head-masha {
    text-align: center;
    margin-bottom: 2.2rem;
}

.section-head-masha h2 {
    font-family: 'Marhey', 'Changa', sans-serif;
    font-size: 2rem;
    color: var(--bear-brown-dark);
    margin-bottom: 6px;
}

.section-head-masha p {
    color: var(--text-muted);
    font-size: 1.05rem;
    font-weight: 600;
}

/* --- Masha & Bear Platform Cards --- */
.masha-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.masha-platform-card {
    background: #FFFFFF;
    border-radius: var(--border-radius);
    padding: 2rem 1.6rem 1.6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    text-decoration: none;
    color: var(--text-main);
    box-shadow: 0 8px 22px rgba(93, 64, 55, 0.08);
    border: 2px solid #F0EAE4;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.masha-platform-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 32px rgba(233, 30, 99, 0.18);
}

/* Specific Card Top Borders & Stages */
.card-reading-theme {
    border-top: 6px solid #FFB300;
}
.card-reading-theme:hover {
    border-color: #FFD54F;
}
.card-reading-theme .card-stage-bubble {
    background: linear-gradient(135deg, #FFF8E1, #FFECB3);
    border-color: #FFD54F;
    color: #FF8F00;
}
.card-reading-theme .card-masha-btn {
    background: linear-gradient(135deg, #FFB300, #FF8F00);
    color: #3E2723;
    box-shadow: 0 4px 14px rgba(255, 179, 0, 0.4);
}

.card-science-theme {
    border-top: 6px solid #4CAF50;
}
.card-science-theme:hover {
    border-color: #81C784;
}
.card-science-theme .card-stage-bubble {
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
    border-color: #81C784;
    color: #2E7D32;
}
.card-science-theme .card-masha-btn {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(76, 175, 80, 0.4);
}

.card-math-theme {
    border-top: 6px solid #AB47BC;
}
.card-math-theme:hover {
    border-color: #CE93D8;
}
.card-math-theme .card-stage-bubble {
    background: linear-gradient(135deg, #F3E5F5, #E1BEE7);
    border-color: #CE93D8;
    color: #7B1FA2;
}
.card-math-theme .card-masha-btn {
    background: linear-gradient(135deg, #AB47BC, #6A1B9A);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(171, 71, 188, 0.4);
}

/* Card Badge Pill */
.card-header-pill {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 0.8rem;
}

.lesson-status-pill {
    font-size: 0.82rem;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: 20px;
    font-family: 'Changa', sans-serif;
    background: #FFF8E1;
    color: #795548;
    border: 1px solid #FFE082;
}

/* Center Stage Bubble */
.card-stage-bubble {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.4rem 0 1rem 0;
    position: relative;
    border: 3px solid #FFFFFF;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-stage-bubble i {
    width: 44px;
    height: 44px;
    stroke-width: 2.2;
}

.masha-platform-card:hover .card-stage-bubble {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.card-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--bear-brown-dark);
    margin-bottom: 0.4rem;
    font-family: 'Marhey', 'Changa', sans-serif;
    line-height: 1.3;
}

.card-desc {
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    min-height: 46px;
    font-family: 'Tajawal', sans-serif;
}

/* Action Button Inside Card - Exactly Matching Reading Buttons */
.card-masha-btn {
    width: 100%;
    padding: 0.75rem 1.2rem;
    border-radius: 50px;
    font-weight: 800;
    font-family: 'Changa', 'Tajawal', sans-serif;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s ease;
    border: 2px solid rgba(255, 255, 255, 0.6);
    margin-top: auto;
}

.card-masha-btn i {
    width: 20px;
    height: 20px;
    transition: transform 0.25s ease;
}

.masha-platform-card:hover .card-masha-btn {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.masha-platform-card:hover .card-masha-btn i {
    transform: translateX(-5px);
}

/* --- Masha & Bear Login Overlay (Cottage Theme) --- */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(62, 39, 35, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease, visibility 0.4s;
    padding: 20px;
}

.login-overlay.hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-cottage-card {
    background: #FFFFFF;
    border-radius: 30px;
    border: 4px solid var(--honey-gold);
    max-width: 470px;
    width: 100%;
    box-shadow: 
        0 25px 50px rgba(62, 39, 35, 0.35),
        0 0 30px rgba(255, 179, 0, 0.3);
    animation: cottagePop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    position: relative;
    text-align: center;
}

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

.login-cottage-header {
    background: linear-gradient(135deg, #4E342E 0%, #5D4037 45%, #3E2723 100%);
    padding: 25px 20px 20px;
    position: relative;
    border-bottom: 4px solid var(--honey-gold);
}

.login-cottage-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 18px 18px;
    pointer-events: none;
}

.login-avatar-outer {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: #FFFFFF;
    border: 4px solid var(--honey-gold);
    box-shadow: 0 0 20px rgba(255, 179, 0, 0.6);
    margin: 0 auto 12px;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.login-avatar-outer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.login-cottage-header h2 {
    font-family: 'Marhey', 'Changa', sans-serif;
    font-size: 1.85rem;
    color: #FFFFFF;
    text-shadow: 0 2px 0 var(--masha-pink-dark), 0 0 15px rgba(233, 30, 99, 0.5);
    margin: 0 0 6px 0;
    position: relative;
    z-index: 1;
}

.login-cottage-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--honey-gold), var(--sunflower-yellow));
    color: #3E2723;
    font-family: 'Changa', sans-serif;
    font-weight: 800;
    font-size: 0.85rem;
    padding: 2px 14px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1;
}

.login-cottage-body {
    padding: 25px 25px 20px;
}

.login-cottage-body p {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 20px;
    font-weight: 600;
    font-family: 'Tajawal', sans-serif;
}

.input-wrap-masha {
    margin-bottom: 16px;
}

#access-code {
    width: 100%;
    background: var(--honey-light);
    border: 3px solid var(--honey-amber);
    padding: 14px 18px;
    border-radius: 50px;
    color: var(--bear-brown-dark);
    font-size: 1.7rem;
    text-align: center;
    letter-spacing: 6px;
    font-family: 'Changa', monospace;
    font-weight: 800;
    outline: none;
    transition: all 0.25s ease;
    box-shadow: inset 0 2px 6px rgba(93, 64, 55, 0.08);
}

#access-code:focus {
    background: #FFFFFF;
    border-color: var(--masha-pink);
    box-shadow: 0 0 16px rgba(233, 30, 99, 0.3), inset 0 2px 6px rgba(0,0,0,0.05);
}

#access-code::placeholder {
    color: #BCAAA4;
    font-size: 1.05rem;
    letter-spacing: normal;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
}

/* The Masha Pink Login Button */
#login-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--masha-pink) 0%, var(--masha-pink-dark) 100%);
    color: #FFFFFF;
    border: 2px solid #FF80AB;
    padding: 14px 22px;
    border-radius: 50px;
    font-size: 1.25rem;
    font-weight: 800;
    font-family: 'Changa', 'Tajawal', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 8px 20px rgba(233, 30, 99, 0.35);
}

#login-btn:hover {
    transform: translateY(-3px) scale(1.02);
    background: linear-gradient(135deg, var(--masha-pink-light) 0%, var(--masha-pink) 100%);
    box-shadow: 0 12px 25px rgba(233, 30, 99, 0.5), 0 0 15px rgba(255, 179, 0, 0.35);
    border-color: var(--honey-gold);
}

#login-btn:active {
    transform: translateY(0);
}

.error-msg {
    color: #E53935 !important;
    margin-top: 10px;
    min-height: 22px;
    font-weight: 700;
    font-size: 0.95rem;
}

.login-cottage-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 2px dashed #EFEBE9;
    font-size: 0.88rem;
    color: #8D6E63;
    font-weight: 600;
}

/* Expired Alert Box */
.expired-alert-box {
    background: rgba(229, 57, 53, 0.08);
    border: 2px solid #E53935;
    border-radius: 20px;
    padding: 18px;
    margin-top: 10px;
    text-align: center;
}

.expired-icon {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.expired-alert-box h3 {
    color: #D32F2F;
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 6px;
    font-family: 'Changa', sans-serif;
}

.expired-alert-box p {
    color: #C62828 !important;
    font-size: 0.95rem !important;
    margin-bottom: 15px !important;
    line-height: 1.5;
}

.contact-us-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #1877F2, #0D5CB6);
    color: #FFFFFF !important;
    text-decoration: none;
    padding: 10px 22px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(24, 119, 242, 0.35);
    transition: all 0.25s ease;
    border: 2px solid rgba(255, 255, 255, 0.4);
    font-family: 'Changa', sans-serif;
}

.contact-us-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 20px rgba(24, 119, 242, 0.5);
}

.contact-us-btn i {
    width: 18px;
    height: 18px;
}

/* Footer */
.masha-footer {
    margin-top: 3rem;
    text-align: center;
    padding-bottom: 2rem;
}

.masha-footer-line {
    width: 120px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--honey-gold), transparent);
    margin: 0 auto 12px;
}

.masha-footer p {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 850px) {
    .header-nav-bar {
        flex-direction: column;
        padding: 1.2rem 1rem;
        gap: 1rem;
    }
    .nav-right-group {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    .nav-user-badge, .play-masha-btn {
        min-width: 170px;
        height: 52px;
        font-size: 1rem;
    }
    .nav-title-capsule h1 {
        font-size: 1.8rem;
    }
    .masha-cards-grid {
        grid-template-columns: 1fr;
    }
}
