/* 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: 100%;
    height: 100%;
    padding: 0;
    box-sizing: border-box;
}

.scene.active {
    display: block;
}

.hidden {
    display: none !important;
}

/* UI Elements inside Scenes */
.title-card {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    margin: auto;
}

.title-card h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.title-card p {
    font-size: 1.2rem;
    color: var(--secondary);
    margin-bottom: 30px;
}

/* 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: absolute;
    left: 0;
    top: 0;
    width: 240px;
    height: 100%;
    background: rgba(255, 255, 255, 0.93);
    border: none;
    border-right: 4px solid var(--accent);
    padding: 40px 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    text-align: left;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1);
    z-index: 20;
}

.dialogue-box p {
    font-size: 1.3rem;
    line-height: 1.5;
    margin: 0;
    font-weight: 700;
}

/* 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 {
    position: absolute;
    bottom: 30px;
    left: 270px;
    right: 30px;
    display: flex;
    gap: 20px;
    justify-content: center;
    z-index: 10;
    transition: left 0.4s;
}

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

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

/* Placeholder for Images (until Generated) */
.rabbit-sprite, .lion-sprite, .deer-sprite, .fox-sprite, .boar-sprite, .jackal-sprite {
    width: 150px;
    height: 150px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
    mix-blend-mode: multiply;
}

.rabbit-sprite.small {
    width: 100px;
    height: 100px;
}

.water-reflection {
    position: absolute;
    bottom: 25%;
    right: 40%;
    transform: scaleY(-1);
    opacity: 0.6;
    filter: blur(2px);
    z-index: 2;
    pointer-events: none;
}

/* Default Placeholders */
.rabbit-sprite { background-image: url('assets/images/rabbit.webp'); background-color: transparent;}
.lion-sprite { background-image: url('assets/images/lion.webp'); background-color: transparent; }
.deer-sprite { background-image: url('assets/images/deer.webp'); background-color: transparent; }
.fox-sprite { background-image: url('assets/images/fox.webp'); background-color: transparent; }
.boar-sprite { background-image: url('assets/images/boar.webp'); background-color: transparent; }
.jackal-sprite { background-image: url('assets/images/jackal.webp'); background-color: transparent; }

/* Backgrounds */
#scene-player.bg-start { background-image: url('assets/images/start_screen_bg.webp'); }
#scene-player.bg-forest { background-image: url('assets/images/forest_bg.webp'); }
#scene-player.bg-well { background-image: url('assets/images/well_bg.webp'); }
#scene-player.bg-banyan { background-image: url('assets/images/banyan_tree_bg.webp'); }
#scene-player.bg-cave { background-image: url('assets/images/lion_cave_bg.webp'); }
#scene-player.bg-path { background-image: url('assets/images/rabbit_walking_bg.webp'); }
#scene-player.bg-scary { background-image: url('assets/images/scary_forest_bg.webp'); }
#scene-player.bg-lion-hunt { background-image: url('assets/images/lion_hunting_bg.webp'); }
#scene-player.bg-bushes { background-image: url('assets/images/bushes_bg.webp'); }
#scene-player.bg-party { background-image: url('assets/images/party_forest_bg.webp'); }
#scene-player.bg-river { background-image: url('assets/images/river_bg.webp'); }
#scene-player.bg-pond { background-image: url('assets/images/pond_bg.webp'); }
#scene-player.bg-rabbit-well { background-image: url('assets/images/rabbit_well_reflection.webp'); }
#scene-player.bg-animals-talking { background-image: url('assets/images/animals_lion_cave.webp'); }
#scene-player.bg-animals-meeting { background-image: url('assets/images/animals_meeting_bg.webp'); }
#scene-player.bg-lion-peeping { background-image: url('assets/images/lion_peeping_well_bg.webp'); }
#scene-player.bg-fierce-lion { 
    background-image: url('assets/images/fierce_lion_bg.webp'); 
    background-position: calc(50% + 120px) top;
}
#scene-player.bg-lion-roaring { 
    background-image: url('assets/images/lion_roaring_well_bg.webp'); 
    background-position: calc(50% + 120px) top;
}
#scene-player.bg-lion-splash { background-image: url('assets/images/lion_splash_bg.webp'); }

/* 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);
}

/* Responsive Base Classes (Extracted from UI Inline Styles) */
.next-continue-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    font-weight: bold;
    padding: 5px 15px;
    margin-left: 10px;
    border-radius: 15px;
}
.text-toggle-btn {
    margin-left: 10px;
}
.nav-story-btn {
    background-color: var(--secondary);
    color: white;
    border: none;
    margin-left: auto; /* push to right on desktop */
    font-weight: bold;
    width: auto;
    padding: 7px 15px;
    text-decoration: none;
    border-radius: 15px;
}
.nav-quiz-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    margin-left: 10px;
    font-weight: bold;
    width: auto;
    padding: 7px 15px;
    text-decoration: none;
    border-radius: 15px;
}
.nav-close-btn {
    background-color: #ff5252;
    color: white;
    border: 2px solid #b71c1c;
    margin-left: 10px;
    font-weight: bold;
    width: auto;
    padding: 5px 15px;
    border-radius: 15px;
}
.interactive-zone {
    position: absolute;
    left: 240px;
    right: 0;
    top: 0;
    bottom: 0;
    cursor: pointer;
    z-index: 15;
}
.reward-actions-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}
.reward-btn {
    font-size: 1.5rem;
    padding: 15px 30px;
    display: inline-block;
    text-decoration: none;
}
.action-read-story {
    background-color: var(--secondary);
    box-shadow: 0 6px 0 #27ae60;
}
.action-take-quiz {
    background-color: var(--primary);
    box-shadow: 0 6px 0 #2980b9;
}
.action-close {
    background-color: #ff5252;
    box-shadow: 0 6px 0 #b71c1c;
}

/* ========================================================= */
/* Responsive Media Queries (Mobile & Small Tablets)         */
/* ========================================================= */
@media (max-width: 768px) {
    /* Header Adjustments */
    #ui-header {
        padding: 10px;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
    }
    .media-controls {
        margin-right: 0;
        justify-content: center;
        flex-wrap: wrap;
    }
    .progress-bar {
        width: 100%;
        margin-bottom: 5px;
    }
    .nav-story-btn {
        margin-left: 0;
    }
    .next-continue-btn, .text-toggle-btn, .nav-story-btn, .nav-quiz-btn, .nav-close-btn {
        margin-left: 0;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    .stars {
        font-size: 1.2rem;
    }
    
    /* Scene UI - Top Overlay Dialogue Box */
    .dialogue-box {
        width: 100%;
        height: auto;
        max-height: 40%;
        top: 0;
        left: 0;
        border-right: none;
        border-bottom: 4px solid var(--accent);
        padding: 20px 15px;
        background: rgba(255, 255, 255, 0.95);
        z-index: 30;
    }
    .dialogue-box p {
        font-size: 1.1rem;
    }
    .hide-text-pane .dialogue-box {
        transform: translateY(-100%);
    }
    
    /* Character Stage Constraints */
    .character-stage {
        left: 0;
        bottom: 5%; /* Shift to bottom */
        padding: 0 20px;
        justify-content: center;
        gap: 15px;
        flex-wrap: wrap;
        /* z-index removed to restore mix-blend-mode multiply */
    }
    
    /* Choices Stacked Bottom */
    .choices-container {
        left: 20px;
        right: 20px;
        bottom: 20px;
        flex-direction: column;
        gap: 10px;
        z-index: 35;
    }
    .hide-text-pane .choices-container {
        left: 20px;
    }
    .choice-btn {
        padding: 12px;
        font-size: 1rem;
    }
    .primary-btn {
        padding: 12px 20px;
        font-size: 1.2rem;
    }
    
    /* Focus the Lion properly without stretching */
    #scene-player.bg-fierce-lion,
    #scene-player.bg-lion-roaring {
        background-size: cover !important;
        background-position: center bottom !important;
    }
    
    /* Interactive Zones Adjusted */
    .interactive-zone {
        left: 0;
        top: 40%; /* Right beneath dialougue */
    }
    
    /* Title and Reward Pages */
    .title-card h1 { font-size: 2rem; }
    .title-card p { font-size: 1rem; }
    
    .reward-card { padding: 20px; }
    .reward-card h2 { font-size: 2.5rem; }
    #s14-moral { font-size: 1.5rem; margin-bottom: 20px; }
    .reward-btn { font-size: 1.1rem; padding: 10px 20px; }
    
    /* Sprites Shrink */
    .rabbit-sprite, .lion-sprite, .deer-sprite, .fox-sprite, .boar-sprite, .jackal-sprite {
        width: 100px;
        height: 100px;
    }
    .rabbit-sprite.small, .fox-sprite.small, .boar-sprite.small, .jackal-sprite.small, .deer-sprite.small {
        width: 70px;
        height: 70px;
    }
    .happy-rabbit-sprite {
        width: 100px;
        height: 100px;
    }
    .floating-rabbit {
        bottom: 180px;
        right: 20px;
    }
    .water-reflection {
        right: 20%;
    }
}
