:root {
    --bg-color: #e0e0e0;
    --card-bg-color: #303030;
    --header-card-bg-color: #f7f7f7;
    --text-color: #000000;
    --text-color-2: #ffffff;
    --accent-color: #008653;
    --accent-color-2: #00b46f;
    --medium-gray: #757575;
    --button-gray: #505050;
    --font-logo: 'knewave', cursive;
    --font-body: 'Roboto', sans-serif;
    --underline-color: #ffffff;

    /* GAME VARIABLES */
    --game-bg-color: #3a3a3a;
    --drop-zone-bg: #dddddd;
    --drop-zone-border: #000000;
    --drop-zone-text: #000000;
    --drop-zone-occupied-bg: #d0e0ff;
    --drop-zone-occupied-text: #1a3c68;
    --ordbank-bg: #ffffff;
    --ordbank-title-color: #f7b731;
    --draggable-word-bg: #f7b731;
    --draggable-word-text: #333333;
    --sentence-success-bg: #4CAF50;
}



/* ----------------------------- Navbar and Title Card ----------------------------- */



body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    max-width: 100%;
    overflow-x: hidden;
}

.font-container {
    font-size: 16px;
}

.page-container {
    max-width: clamp(320px, 1200px, 90vw);
    margin: 0 auto;
    box-sizing: border-box;
}

header {
    height: auto;
    min-height: 70px;
    background-color: var(--card-bg-color);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5vw;
    margin-bottom: 3em;
}

.logo {
    font-family: var(--font-logo);
    font-size: clamp(1.8em, 4vw, 2.5em);
    color: var(--accent-color-2);
    margin-right: 20px;
}

nav a {
    color: white;
    text-decoration: none;
    margin-left: clamp(15px, 3vw, 30px);
    font-size: clamp(1em, 2.5vw, 1.5em);
    transition: color 0.3s ease;
}

nav a:hover {
    color: var(--accent-color);
}

.chapter-title-card {
    background-color: var(--card-bg-color);
    padding: clamp(1em, 3vw, 2em) clamp(1.5em, 4vw, 2.6em);
    border-radius: 1.5em;
    margin-bottom: 3em;
    text-align: center;
}

.chapter-title-card h2 {
    margin: 0;
    font-size: clamp(1.5em, 4vw, 2.5em);
    color: var(--accent-color-2);
    font-weight: 500;
}



/* ----------------------------- Read & Listen Card ----------------------------- */



.collapsible-card {
    background-color: var(--header-card-bg-color);
    border-radius: 1.5em;
    margin-bottom: 25px;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(1em, 3vw, 1.8em) clamp(1.5em, 4vw, 2.6em);
    cursor: pointer;
    background-color: var(--card-bg-color);
}

.collapsible-header h3 {
    margin: 0;
    font-size: clamp(1.8em, 4.5vw, 2.8em);
    font-weight: 500;
    color: var(--text-color-2);
}

.toggle-button {
    background-color: #4a4a4a;
    border: 1px solid #666;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.toggle-button:hover {
    background-color: #5a5a5a;
}

.collapsible-content-wrapper {
    max-height: 10000px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.7s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease-out 0.1s;
}

.collapsible-content-wrapper.collapsed {
    max-height: 0;
    opacity: 0;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease-in;
}

.collapsible-content-inner {
    padding: 2em clamp(1.5em, 5vw, 4em);
}

.story-image {
    display: block;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    height: auto;
    border-radius: 1em;
    margin-bottom: 25px;
}

.content-block {
    border-radius: 1em;
    background-color: #ffffff;
    padding: clamp(1em, 3vw, 2em);
    margin-bottom: 25px;
    position: relative;
}
.content-block:last-child {
    margin-bottom: 0;
}

.content-block h4 {
    font-size: clamp(1.5em, 3.5vw, 2.2em);
    color: var(--text-color);
    margin-top: 0;
    margin-bottom: 0.75em;
    font-weight: 500;
    position: relative;
    padding-bottom: 0.5em;
}


.content-block h4::after {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    background-color: var(--underline-color);
    position: absolute;
    bottom: 0;
    left: 0;
}

.story-text-section p {
    margin-bottom: 10px;
    font-size: clamp(1em, 2vw, 1.3em);
}



/* ----------------------------- Listen Part ----------------------------- */



.audio-player-section {
    margin-bottom: 2em !important;
}

.audio-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.audio-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 25px;
    font-size: clamp(0.9em, 2vw, 1em);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.audio-btn:active {
    transform: scale(0.95);
}

.play-pause-btn {
    background-color: var(--accent-color);
    color: white;
    padding: 12px;
    min-width: 50px;
    height: 50px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.play-pause-btn:hover {
    background-color: #cc8e11;
}

.play-pause-btn svg.icon {
    width: 24px;
    height: 24px;
}

.play-pause-btn .icon-play {
    display: inline-block;
}
.play-pause-btn .icon-pause {
    display: none;
}

.play-pause-btn.playing .icon-play {
    display: none;
}
.play-pause-btn.playing .icon-pause {
    display: inline-block;
}

.stop-btn {
    background-color: var(--button-gray);
    color: var(--text-color-2);
    padding: 10px 20px;
    height: 50px;
}
.stop-btn:hover {
    background-color: #505050;
}

.audio-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.time-display {
    font-size: clamp(0.85em, 1.8vw, 1em);
    color: var(--light-gray);
    min-width: 40px;
    text-align: center;
}

.progress-bar-container {
    flex-grow: 1;
    height: 10px;
    border-radius: 5px;
    position: relative;
}

#progressBar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    border-radius: 5px;
    cursor: pointer;
    margin: 0;
    padding: 0;
    outline: none;
    background: var(--medium-gray);
    border: none;
    display: block;
}

#progressBar::-webkit-slider-runnable-track {
    width: 100%;
    height: 10px;
    background: transparent;
    border: none;
    border-radius: 5px;
}

#progressBar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    border: 2px solid var(--card-bg-color);
    cursor: pointer;
    margin-top: -5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#progressBar::-moz-range-track {
    width: 100%;
    height: 10px;
    background: var(--medium-gray);
    border: none;
    border-radius: 5px;
}

#progressBar::-moz-range-progress {
    background-color: var(--accent-color);
    height: 10px;
    border-radius: 5px;
}

#progressBar::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    border: 2px solid var(--card-bg-color);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.audio-status {
    font-size: clamp(0.8em, 1.6vw, 0.9em);
    color: #bebebe;
    margin: 0;
}


/* ----------------------------- Learn Rules Card ----------------------------- */

#learn-rules-section .collapsible-content-inner {
    background-color: white;
    padding: 2em clamp(1.5em, 5vw, 4em);
    color: #000;
}

.rules-section {
    margin-bottom: 2em;
}
.rules-section:last-child {
    margin-bottom: 0;
}

.top-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 30px;
}

.rules-text {
    flex: 2 1 400px;
}

.rules-text ul {
    list-style: disc;
    padding-left: 25px;
    margin: 0;
}

.rules-text li {
    margin-bottom: 1em;
    font-size: clamp(1em, 2vw, 1.2em);
    line-height: 1.5;
}
.rules-text li:last-child {
    margin-bottom: 0;
}

.book-image {
    flex: 1 1 180px;
    text-align: center;
}

.book-image img {
    width: 300px;
    height: auto;
}

.main-illustration img {
    margin-left: 10%;
    max-width: 80%;
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.bottom-section .important-question {
    font-size: clamp(1.1em, 2.3vw, 1.4em);
    text-align: center;
    margin-bottom: 2em;
    line-height: 1.5;
}

.example-box {
    font-size: clamp(1.1em, 2.3vw, 1.3em);
    line-height: 1.8;
}

.example-box h4 {
    font-size: 1.2em;
    font-weight: 700;
    margin: 0 0 0.5em 0;
}

.example-box p {
    margin: 0.3em 0;
}

.example-sentence {
    font-style: italic;
    margin-bottom: 1em !important;
}

.question-hint {
    color: #555;
    font-size: 0.9em;
    font-style: normal;
}


/* ----------------------------- Game Card ----------------------------- */

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.shake {
    animation: shake 0.7s cubic-bezier(.36,.07,.19,.97) both;
}

.drop-zone.wrong-drop {
    border-color: #e53935 !important;
    border-style: dashed !important;
    background-color: #ffebee !important;
}


.game-container {
    text-align: center;
    padding-bottom: 2em;
}

.game-title {
    font-size: clamp(2em, 5vw, 3em);
    color: var(--accent-color);
    margin-bottom: 0.4em;
}

.game-instructions {
    font-size: clamp(1em, 2.2vw, 1.2em);
    color: black;
    margin-bottom: 2em;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

.sentence-image-container {
    margin: 0 auto 2em auto;
    width: clamp(250px, 60vw, 450px);
    height: auto;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    padding: 15px;
    overflow: hidden;
}
#sentenceImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.sentence-builder {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center; /* Changed from baseline to center for more stability */
    gap: 10px;
    margin-bottom: 3em;
    font-size: clamp(1.4em, 3.5vw, 2em);
    font-weight: 500;
    line-height: 1.5;
}

.drop-zone {
    background-color: var(--drop-zone-bg);
    color: var(--drop-zone-text);
    border: 2px dashed var(--drop-zone-border);
    border-radius: 12px;
    /* Use the 'occupied' padding as the default to prevent size change */
    padding: 12px 20px; 
    min-width: 200px;
    /* Adjust min-height to comfortably fit the new padding and bold text */
    min-height: 60px; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    transition: all 0.3s ease;
    vertical-align: middle;
}
.drop-zone.drag-over {
    border-color: #354675;
    background-color: #f0f4ff;
    transform: scale(1.03);
}
.drop-zone.occupied {
    background-color: var(--accent-color-2);
    border-style: solid;
    border-color: var(--accent-color);
    color: white;
    font-weight: bold;
}

.drop-zone .dropped-word {
    animation: dropInPlace 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes dropInPlace {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.ordbank-container {
    background-color: var(--ordbank-bg);
    border-radius: 20px;
    padding: 25px clamp(15px, 3vw, 35px);
    margin-top: 1em;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 5em;
}

.ordbank-title {
    font-size: clamp(1.8em, 4vw, 2.8em);
    color: black;
    margin-top: 0;
    margin-bottom: 1em;
}

.ordbank-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
}

.draggable-word {
    background-color: #3a3a3a;
    color: white;
    border: 1px solid #000000;
    padding: 12px 22px;
    font-size: clamp(1em, 2.2vw, 1.3em);
    border-radius: 22px;
    font-weight: 500;
    cursor: grab;
    text-align: center;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.draggable-word:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 5px 10px rgba(0,0,0,0.2);
}
.draggable-word.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* ----------------------------- Mobile Layout Adjustments ----------------------------- */

@media (max-width: 768px) {
    /* No longer needed for the old rules layout */
}

/* Adjusts Game Layout on Mobile */
@media (max-width: 550px) {
    .game-title {
        font-size: 1.8em;
    }
    .game-instructions {
        font-size: 0.9em;
        margin-bottom: 2em;
    }

    .sentence-builder {
        gap: 5px;
    }
    .drop-zone {
        padding: 15px;
        min-width: 90px;
        min-height: 50px;
        font-size: 1em;
    }
    .plus-sign {
        font-size: 1.5em;
    }

    .ordbank-title {
        font-size: 1.6em;
    }
    .ordbank-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    .draggable-word {
        font-size: 0.9em;
        padding: 10px 12px;
    }
}

/* NEW: Adjusts Header/Navbar Layout on Mobile */
@media (max-width: 600px) {
    header {
        flex-direction: column;
        gap: 15px;
        padding-top: 20px;
        padding-bottom: 20px;
    }
    .logo {
        margin-right: 0;
    }
    nav {
        display: flex;
        justify-content: center;
        gap: 25px;
        width: 100%;
    }
    nav a {
        margin-left: 0;
    }
}

/* ===================== NEXT CHAPTER BUTTON STYLES ===================== */
.next-chapter-container {
    text-align: center;
    margin: 4em 0 6em 0; /* Adds space above and below the button */
    padding: 0 20px; /* Prevents button from touching screen edges on mobile */
}

.next-chapter-btn {
    display: inline-block;
    background-color: var(--accent-color);
    color: white;
    padding: 16px 35px;
    font-size: clamp(1.1em, 3vw, 1.4em);
    font-weight: 700;
    text-decoration: none;
    border-radius: 50px; /* A pill shape to match other buttons */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.next-chapter-btn:hover {
    background-color: var(--accent-color-2);
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.25);
}