/* Global Variables for Child-Friendly Active Aesthetics */
:root {
    --primary: #FF9800; /* Vibrant Orange */
    --primary-hover: #F57C00;
    --secondary: #8BC34A; /* Nature Green */
    --accent: #29B6F6; /* Sky Blue */
    --bg-light: #FFFDE7; /* Soft Sunny Yellow */
    --text-dark: #4E342E; /* Warm Brown (softer than black) */
    --white: #FFFFFF;
    --error: #EF5350; /* Soft Red */
    --font-main: 'Nunito', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none; /* Prevent accidental text selection by kids tapping */
}

body {
    font-family: var(--font-main);
    background-image: url('assets/images/start_screen_bg.webp'); /* fallback or border glow */
    background-size: cover;
    background-position: center;
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    margin: 0;
}

/* Main Container */
#game-container {
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    max-height: 100%;
    background-color: var(--white);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border-radius: 0;
}

/* Header UI */
#ui-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background-color: var(--secondary);
    color: var(--white);
    border-bottom: 4px solid rgba(0,0,0,0.1);
    z-index: 10;
    flex-wrap: wrap;
    gap: 10px;
}

#ui-header.hidden {
    display: none;
}

.progress-bar {
    width: 60%;
    height: 15px;
    background: rgba(255,255,255,0.4);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background-color: var(--primary);
    transition: width 0.5s ease-out;
}

.stars {
    font-size: 1.5rem;
    font-weight: 800;
}

/* Media Controls */
.media-controls {
    display: flex;
    flex-direction: row !important;
    gap: 12px;
    align-items: center;
    margin-right: 15px;
}

.icon-btn {
    background-color: var(--white);
    color: var(--primary);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-btn:hover {
    transform: scale(1.1);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn:disabled {
    background-color: rgba(255,255,255,0.5);
    color: #aaa;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Scene System */
#scene-player {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0; 
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center center;
    transition: background-image 0.5s ease;
}

.scene {
    position: relative;
    width: 100vw;
    height: 100vh;
    padding: 0;
    box-sizing: border-box;
    display: none;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}

.scene.active {
    display: flex;
}

@media (max-width: 900px) {
    body, #game-container, #scene-player {
        height: auto !important;
        min-height: 100vh;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
    .scene.active {
        flex-direction: column-reverse;
        justify-content: flex-end;
        padding-bottom: 40px;
        height: auto !important;
        min-height: 100vh;
        overflow-y: visible !important;
    }
    .title-card, .dialogue-box {
        width: 95% !important;
        max-width: none !important;
        margin: 5px auto !important;
        padding: 12px 15px !important;
    }
    .title-card h1 {
        font-size: 1.5rem !important;
        margin-bottom: 5px;
    }
    .dialogue-box p, .title-card p {
        font-size: 0.95rem !important;
        margin-bottom: 8px;
    }
    .primary-btn, .choice-btn {
        padding: 8px 15px !important;
        font-size: 1.2rem !important;
        margin-top: 5px !important;
    }
    .planet-stage {
        width: 100% !important;
        height: 35vh !important;
        margin-top: 5px;
    }
    .planet-sprite, .moon-sprite, .orbital-system {
        max-width: 80vw !important;
        max-height: 35vh !important;
        width: auto !important;
        height: auto !important;
    }
    #ui-header {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 8px;
        gap: 8px;
    }
    .progress-bar {
        width: 90% !important;
        order: 10;
        margin-top: 2px;
    }
    .media-controls {
        margin-right: 0;
        margin-bottom: 0;
        justify-content: center;
        flex-wrap: wrap;
    }
    .nav-btn, a.nav-btn, button.nav-btn {
        margin-left: 2px !important;
        margin-right: 2px !important;
        padding: 6px 10px !important;
        font-size: 0.85rem !important;
    }
    .reading-container {
        padding: 20px !important;
        margin: 10px !important;
    }
    .story-title {
        font-size: 2rem !important;
    }
}

.hidden {
    display: none !important;
}

/* UI Elements inside Scenes */
.title-card {
    text-align: left;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 35px 45px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6), inset 0 2px 0 rgba(255,255,255,0.05);
    max-width: 550px;
    position: relative;
    margin-left: 5%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.title-card h1 {
    font-size: 3.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #FFD700, #FF8C00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 10px rgba(255, 140, 0, 0.3));
}

.title-card p {
    font-size: 1.3rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 0;
}

/* End Screen Reward Card */
.reward-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
    padding: 40px;
    box-sizing: border-box;
}

.reward-card h2 {
    font-size: 4rem;
    color: var(--primary);
    text-shadow: 3px 3px 6px rgba(0,0,0,0.15);
    margin-bottom: 20px;
}

#s14-moral {
    font-size: 2.8rem;
    font-weight: 900;
    line-height: 1.3;
    color: var(--accent);
    max-width: 900px;
    margin-bottom: 50px;
    text-shadow: 2px 2px 4px rgba(255,255,255,0.8);
}

.dialogue-box {
    position: relative;
    width: 45%;
    max-width: 500px;
    line-height: normal;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 30px 40px;
    margin-left: 5%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6), inset 0 2px 0 rgba(255,255,255,0.05);
    z-index: 20;
}

.dialogue-box p {
    font-size: 1.3rem;
    line-height: 1.6;
    margin: 0;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
}

/* Inline Quizzes */
.inline-quiz {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 25px;
    border-radius: 16px;
    margin-top: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 600px;
}

.inline-quiz p {
    font-size: 1.25rem !important;
    font-weight: 900 !important;
    color: #FFD700 !important; /* Gold text */
    margin-bottom: 15px !important;
    text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.inline-quiz .btn-group {
    display: flex;
    gap: 15px;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.quiz-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    border: 2px solid transparent;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.quiz-btn:hover {
    background: #FFD700;
    color: #000;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0,0,0,0.3);
}

.quiz-btn.correct {
    background: #2ed573;
    color: white;
    box-shadow: 0 4px 0 #209950;
}

.quiz-btn.wrong {
    background: #ff4757;
    color: white;
    box-shadow: 0 4px 0 #be3541;
}

/* Buttons */
.primary-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: 900;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--primary-hover);
    transition: transform 0.1s, box-shadow 0.1s;
    font-family: var(--font-main);
}

.primary-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 var(--primary-hover);
}

.choices-container {
    margin-top: 30px;
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    z-index: 30;
}

/* Hide Text Pane Modifier */
.hide-text-pane .dialogue-box {
    transform: translateX(-50%) translateY(200%);
}

.hide-text-pane .choices-container {
    left: 30px;
}

.choice-btn {
    background-color: var(--white);
    border: 3px solid var(--primary);
    color: var(--primary);
    padding: 15px 20px;
    flex: 1;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
    box-shadow: 0 4px 0 rgba(255,152,0,0.3);
}

.choice-btn:hover {
    background-color: #FFF3E0;
    transform: translateY(-2px);
}

.choice-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 transparent;
}

.happy-rabbit-sprite {
    width: 140px;
    height: 140px;
    background-image: url('assets/images/happy_rabbit.webp');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
    mix-blend-mode: multiply; /* Removes white generator background */
}

.floating-rabbit {
    position: absolute;
    bottom: 30px;
    right: 50px;
    z-index: 5;
    animation: bouncePop 2s infinite;
}

/* Character Staging Area */
.character-stage {
    position: absolute;
    bottom: 10px;
    right: 0;
    left: 240px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 40px;
    pointer-events: none;
}

/* Interactive Search Area */
#well-search {
    flex: 1;
    position: relative;
    border-radius: 20px;
    margin-top: 20px;
    border: 3px dashed var(--accent);
    background-color: rgba(41, 182, 246, 0.1);
}

.hidden-object {
    position: absolute;
    width: 60px;
    height: 60px;
    background-color: rgba(255,255,255,0.5); /* Placeholder, will be an image */
    border-radius: 50%;
    cursor: pointer;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid var(--accent);
}

/* Feedback Overlay */
#feedback-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#feedback-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

#feedback-message {
    font-size: 4rem;
    color: var(--secondary);
    text-align: center;
    animation: bouncePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.moral-box {
    background-color: var(--bg-light);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border-left: 5px solid var(--secondary);
}

.moral-box h3 {
    color: var(--secondary);
    margin-bottom: 5px;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse { animation: pulse 2s infinite ease-in-out; }

@keyframes bouncePop {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

.bounce-in {
    animation: bouncePop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* Celebration Particles */
.particle {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 2rem;
    animation: fallAndSpin 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 200;
}

@keyframes fallAndSpin {
    0% { transform: translateY(-50px) rotate(0deg); opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

/* Solar System Sprites / Overlays (Using Emoji / Shapes for now) */
.floating-planet {
    position: absolute;
    bottom: 40px;
    right: 50px;
    font-size: 8rem;
    animation: bouncePop 3s infinite;
    z-index: 5;
    filter: drop-shadow(0 0 20px rgba(255,255,255,0.4));
}
.floating-sun {
    position: absolute;
    top: 50px;
    right: 50px;
    font-size: 10rem;
    animation: pulse 4s infinite ease-in-out;
    z-index: 5;
    filter: drop-shadow(0 0 40px #FFC107);
}
.planet-stage {
    position: relative;
    width: 50%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 2;
}

.orbital-system {
    position: relative;
    width: 250px;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.planet-sprite {
    width: 220px;
    height: 220px;
    object-fit: contain;
    border-radius: 50%;
    filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.4));
}

.moon-orbit {
    position: absolute;
    width: 320px;
    height: 320px;
    border: 1px dashed rgba(255,255,255,0.2);
    border-radius: 50%;
    animation: simple-orbit 10s linear infinite;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.moon-sprite {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 50%;
    transform: translateX(-25px);
}

.moon-orbit.reverse {
    animation: simple-orbit-reverse 15s linear infinite;
}

@keyframes simple-orbit {
    100% { transform: rotate(360deg); }
}

@keyframes simple-orbit-reverse {
    100% { transform: rotate(-360deg); }
}

.spin-slow { animation: spin-slow 30s linear infinite; }
@keyframes spin-slow { 100% { transform: rotate(360deg); } }

/* Space Backgrounds using CSS Gradients */
#scene-player.bg-space { background: linear-gradient(135deg, #1A0B2E, #091236); }
#scene-player.bg-sun { background: linear-gradient(135deg, #FF6B00, #990000); }
#scene-player.bg-mercury { background: linear-gradient(135deg, #4A5568, #1A202C); }
#scene-player.bg-venus { background: linear-gradient(135deg, #F59E0B, #9D174D); }
#scene-player.bg-earth { background: linear-gradient(135deg, #1D4ED8, #065F46); }
#scene-player.bg-mars { background: linear-gradient(135deg, #EF4444, #7F1D1D); }
#scene-player.bg-belt { background: linear-gradient(135deg, #4C1D95, #111827); }
#scene-player.bg-jupiter { background: linear-gradient(135deg, #D97706, #78350F); }
#scene-player.bg-saturn { background: linear-gradient(135deg, #EAB308, #312E81); }
#scene-player.bg-uranus { background: linear-gradient(135deg, #06B6D4, #0F766E); }
#scene-player.bg-neptune { background: linear-gradient(135deg, #2563EB, #1E3A8A); }
#scene-player.bg-pluto { background: linear-gradient(135deg, #94A3B8, #1E1B4B); }
/* Sparkle stars overlay */
#scene-player::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: radial-gradient(rgba(255,255,255,0.8) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: 0 0, 25px 25px;
    opacity: 0.15;
    pointer-events: none;
    z-index: 1;
}
.dialogue-box, .choices-container, .reward-card, .title-card {
    z-index: 10 !important;
}

/* Reading Mode Styles for full_story.html & quiz.html */
#game-container.reading-mode {
    height: auto;
    min-height: 100vh;
    overflow-y: visible;
    overflow-x: hidden;
}
.reading-mode {
    background: url('assets/images/forest_bg.webp') no-repeat center center fixed;
    background-size: cover;
}
.reading-container {
    max-width: 800px;
    margin: 40px auto;
    background: rgba(255, 255, 255, 0.95);
    padding: 60px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    backdrop-filter: blur(5px);
}
.reading-container h1 {
    color: var(--primary);
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 20px;
}
.reading-container h2 {
    color: var(--secondary);
    font-size: 2rem;
    margin-bottom: 10px;
}
.story-text p {
    font-size: 1.3rem;
    line-height: 1.8;
    color: var(--text-dark);
    margin-bottom: 20px;
}
.quiz-card {
    background: rgba(240, 248, 245, 0.9);
    padding: 40px;
    border-radius: 15px;
    border: 2px solid var(--secondary);
    margin-top: 20px;
}
.question-block {
    margin-bottom: 25px;
    padding: 20px;
    border-radius: 10px;
    transition: background 0.3s;
}
.question-block.correct-answer {
    background: rgba(46, 204, 113, 0.2);
    border-left: 5px solid #2ecc71;
}
.question-block.wrong-answer {
    background: rgba(255, 0, 0, 0.1);
    border-left: 5px solid #ff5252;
}
.question-block h3 {
    margin-bottom: 15px;
    color: var(--primary);
    font-size: 1.4rem;
}
.option-label {
    display: block;
    margin-bottom: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    background: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    border: 1px solid #ccc;
    transition: all 0.2s;
}
.option-label:hover {
    background: #e8f5e9;
    border-color: var(--secondary);
}
