:root {
    --primary-color: #6C5CE7;
    --accent-color: #00A3FF;
    --bg-color: #FFFBF0;
    --text-color: #2D3436;
    --white: #FFFFFF;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --border-radius: 16px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Fredoka', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Screen Management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    z-index: 10;
    background-color: var(--bg-color);
}

.screen.active {
    display: flex;
}

/* Splash Screen */
#splash-screen {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.splash-content {
    text-align: center;
    color: var(--white);
    animation: fadeInScale 0.8s ease-out;
}

.logo-container {
    width: 140px;
    height: 140px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.splash-logo {
    width: 100px;
    height: 100px;
}

#splash-screen h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Onboarding Screen */
#onboarding-screen {
    justify-content: space-between;
    padding: 40px 20px;
}

.onboarding-carousel {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.onboarding-slide {
    display: none;
    animation: slideIn 0.5s ease-out;
}

.onboarding-slide.active {
    display: block;
}

.slide-image {
    font-size: 80px;
    color: var(--primary-color);
    margin-bottom: 30px;
}

.onboarding-slide h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.onboarding-slide p {
    font-size: 1.2rem;
    color: #636e72;
    max-width: 300px;
    margin: 0 auto;
}

.onboarding-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.dots {
    display: flex;
    gap: 10px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #dfe6e9;
}

.dot.active {
    background-color: var(--primary-color);
    width: 25px;
    border-radius: 5px;
}

/* Buttons */
.btn {
    padding: 14px 40px;
    border-radius: 30px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--accent-color);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(0, 163, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 163, 255, 0.4);
}

.btn-link {
    background: none;
    color: #636e72;
    text-decoration: underline;
}

.btn-secondary {
    background-color: #dfe6e9;
    color: var(--text-color);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
}

.btn-icon-close {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 110;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
}

.btn-icon-lock {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 110;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.01);
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.lock-indicator {
    background: rgba(0, 0, 0, 0.6);
    padding: 20px;
    border-radius: 20px;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.lock-overlay.touched .lock-indicator {
    opacity: 1;
}

.lock-indicator i {
    font-size: 3rem;
    margin-bottom: 10px;
    color: var(--accent-color);
}

.unlock-btn {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.unlock-btn i {
    font-size: 1.5rem;
    z-index: 2;
}

.progress-ring {
    position: absolute;
    top: 10px;
    left: 10px;
    transform: rotate(-90deg);
}

.progress-ring__circle {
    stroke-dasharray: 163.36;
    stroke-dashoffset: 163.36;
    transition: stroke-dashoffset 0.1s linear;
}

.player-fallback {   align-items: center;
    cursor: pointer;
    z-index: 100;
}

/* Header */
.app-header {
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    display: flex;
    align-items: center;
    padding: 0 20px;
    color: var(--white);
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    flex: 1;
    text-align: center;
}

/* Main Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(to bottom, transparent, rgba(108, 92, 231, 0.05));
}

/* Series Grid */
.series-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.series-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.series-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.series-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background-color: #eee;
}

.series-info {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.series-info h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.series-info span {
    font-size: 0.9rem;
    color: #636e72;
}

/* Episodes List */
.episodes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
}

.episode-card {
    background: var(--white);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: var(--transition);
}

.episode-card:hover {
    background-color: #f8f9fa;
    transform: scale(1.02);
}

.episode-thumb {
    width: 100px;
    height: 70px;
    border-radius: 8px;
    object-fit: cover;
}

.episode-info {
    flex: 1;
}

.episode-info h4 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.episode-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-play-small {
    background-color: var(--accent-color);
    color: var(--white);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}



/* Player */
#player-screen {
    background: #000;
}

#youtube-player-container {
    width: 100%;
    height: 100%;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: var(--white);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
    border: none;
    cursor: pointer;
    z-index: 50;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: modalPop 0.3s ease-out;
}

.modal-content.large {
    max-width: 600px;
    text-align: left;
}

.modal-content header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-content header .btn-icon {
    color: var(--text-color);
}

.math-challenge {
    font-size: 2rem;
    font-weight: 700;
    margin: 20px 0;
    color: var(--primary-color);
}

#math-answer {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 2px solid #eee;
    font-size: 1.2rem;
    text-align: center;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.player-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #1a1a1a;
    color: white;
    padding: 20px;
    text-align: center;
    z-index: 50;
}

.player-fallback p {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.error-msg {
    grid-column: 1 / -1;
    text-align: center;
    background: rgba(255, 0, 0, 0.1);
    color: #d63031;
    padding: 20px;
    border-radius: 12px;
    margin: 20px;
}

.error-msg small {
    display: block;
    margin-top: 10px;
    color: #636e72;
}

/* Animations */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

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

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

.loading-spinner {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 2rem;
    color: var(--white);
    padding: 50px;
}

/* Responsive Grid Adjustments */
@media (max-width: 600px) {
    .series-grid {
        grid-template-columns: 1fr;
    }
    
    #splash-screen h1 {
        font-size: 2rem;
    }
}
