/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap');

/* --- General & Root Styles --- */
:root {
    --primary-color: #14b8a6; /* Teal */
    --primary-hover: #0d9488;
    --dark-text: #1e293b; /* Slate 800 */
    --medium-text: #475569; /* Slate 600 */
    --light-text: #64748b; /* Slate 500 */
    --background-color: #f8fafc; /* Slate 50 */
    --card-background: #ffffff;
    --border-color: #e2e8f0; /* Slate 200 */
    --disabled-color: #94a3b8; /* Slate 400 */
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--medium-text);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box; /* Ensures padding doesn't add to width */
}

/* --- Typography --- */
h1, h2, h3 {
    color: var(--dark-text);
    font-weight: 700;
    margin: 10px 0 20px 0;
    text-align: center;
}

h1 { font-size: 2.2em; }
h2 { font-size: 1.6em; }
h3 { font-size: 1.3em; color: var(--primary-color); }
p { line-height: 1.7; margin: 15px 0; }
hr { border: none; border-top: 1px solid var(--border-color); margin: 30px 0; }

/* --- Card Layout --- */
.card {
    background-color: var(--card-background);
    border-radius: 12px;
    padding: 30px 40px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    max-width: 800px;
    width: 100%; /* Full width by default, max-width will constrain it */
    margin: 20px 0;
    text-align: center;
    box-sizing: border-box; /* Ensures padding is inside the width */
}

/* --- Forms & Buttons --- */
select, button, .exercise-button {
    font-family: 'Poppins', sans-serif;
    font-size: 1em;
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin: 10px 5px;
    transition: all 0.2s ease-in-out;
    width: 100%; /* Make them full width for mobile */
    box-sizing: border-box;
}

select {
    background-color: #fff;
    color: var(--medium-text);
    cursor: pointer;
}

button, .exercise-button {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button:hover, .exercise-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(20, 184, 166, 0.3);
}

button:disabled {
    background-color: var(--disabled-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- Specific Container Styles --- */
#language-selection label {
    font-weight: 500;
    color: var(--dark-text);
    margin-right: 10px;
    display: block; /* Stack on mobile */
    margin-bottom: 10px;
}

.selection-controls {
    display: flex;
    flex-direction: column; /* Stack controls vertically on mobile */
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.hub-header {
    display: flex;
    flex-direction: column; /* Stack vertically on mobile */
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}
.hub-header h2 {
    margin: 0;
    text-align: center; /* Center on mobile */
}

#back-to-menu-button {
    background-color: var(--light-text);
}
#back-to-menu-button:hover {
    background-color: var(--medium-text);
    box-shadow: 0 4px 8px rgba(100, 116, 139, 0.2);
}

/* --- Lecture Content Styles --- */
#lecture-container { text-align: left; }
#lecture-container ul { list-style-type: disc; padding-left: 25px; }
#lecture-container li { margin-bottom: 10px; }
#lecture-container code {
    background-color: #f1f5f9;
    color: var(--dark-text);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: "Courier New", Courier, monospace;
    font-size: 1.1em;
    border: 1px solid var(--border-color);
    word-break: break-all; /* Prevent long code from overflowing */
}
#lecture-container strong { color: var(--dark-text); font-weight: 700; }
.lecture-example-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px;
    margin: 20px auto;
    border-radius: 8px;
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
}
.ex-chunk {
    position: relative;
    padding: 18px 15px 8px 15px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    font-size: 1.1em; /* Slightly smaller for mobile */
    line-height: 1;
    font-weight: 500;
}
.ex-chunk-label {
    position: absolute;
    top: -1px;
    left: -1px;
    font-size: 0.7em;
    font-weight: bold;
    padding: 2px 5px;
    border-top-left-radius: 6px;
    border-bottom-right-radius: 6px;
    color: white;
}

/* === Game Styles General === */
.shake-animation { animation: shake 0.3s ease-in-out; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* === Boxing Game Styles === */
#progress-bar-container { width: 100%; max-width: 800px; background-color: #e0e0e0; border-radius: 10px; margin: 20px auto; overflow: hidden; }
#progress-bar { height: 20px; width: 0%; background-color: #28a745; border-radius: 10px; transition: width 0.5s ease-in-out; }
#game-area { position: relative; padding: 20px; border: 1px solid #ddd; background-color: #fff; border-radius: 8px; }
#sentence-container { font-size: 1.5em; line-height: 2.2; user-select: none; }
.word { cursor: pointer; padding: 2px 0; }
.word.selecting { background-color: #d4eaff; }
.box { position: absolute; border-width: 2px; border-style: solid; border-radius: 6px; z-index: 10; pointer-events: none; }
.box-label { position: absolute; top: -22px; left: 2px; font-size: 0.8em; font-weight: bold; padding: 2px 4px; border-radius: 4px; color: white; pointer-events: all; cursor: pointer; }
.box.is-part .box-label { display: none; }

/* === Scramble Game Styles === */
#scramble-game-container { max-width: 800px; margin: 20px auto; width: 100%; box-sizing: border-box; }
#drop-zones-container { display: flex; flex-direction: column; gap: 15px; margin: 20px auto; }
#options-container { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; min-height: 50px; padding: 10px; border-radius: 8px; background-color: #fff; border: 1px solid #ddd; }
.drop-zone { border: 2px dashed #ccc; border-radius: 8px; min-height: 50px; padding: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background-color: #f8f9fa; transition: background-color .2s; }
.drop-zone.hover { background-color: #e9f5ff; }
.drop-zone.correct { border-color: #28a745; border-style: solid; background-color: #e9fde9; }
.drop-zone.incorrect { border-color: #dc3545; border-style: solid; background-color: #fde9e9; animation: shake .3s ease-in-out; }
.chunk { position: relative; padding: 16px 12px 8px 12px; border-radius: 6px; background-color: #f8f9fa; border: 1px solid #dee2e6; cursor: grab; user-select: none; transition: transform .2s, opacity .2s; font-size: 1.2em; line-height: 1; }
.chunk.dragging { opacity: .4; cursor: grabbing; }
.chunk-label { position: absolute; top: -1px; left: -1px; font-size: 0.7em; font-weight: bold; padding: 2px 5px; border-top-left-radius: 6px; border-bottom-right-radius: 6px; color: white; }

/* === Color Labels (Shared by all) === */
.label-S, .label-S-NC, .box-S, .box-S-NC { background-color: #007bff; border-color: #007bff; }
.label-V, .box-V { background-color: #dc3545; border-color: #dc3545; }
.label-O, .label-O-NC, .box-O, .box-O-NC { background-color: #28a745; border-color: #28a745; }
.label-O2, .box-O2 { background-color: #17a2b8; border-color: #17a2b8; }
.label-C, .label-C-NC, .box-C, .box-C-NC { background-color: #ffc107; border-color: #ffc107; }
.label-PL, .label-TM, .label-CS, .label-PP, .label-MN, .label-AC, .box-PL, .box-TM, .box-CS, .box-PP, .box-MN, .box-AC { background-color: #fd7e14; border-color: #fd7e14; }
.label-RC, .label-AP, .box-RC, .box-AP { background-color: #e83e8c; border-color: #e83e8c; }
.label-NC, .box-NC { background-color: #6610f2; border-color: #6610f2; }
.label-CJ, .box-CJ { background-color: #6c757d; border-color: #6c757d; }

/* === Gap-Fill Game Styles === */
#gap-fill-container { max-width: 800px; margin: 20px auto; width: 100%; box-sizing: border-box; }
#sentences-container { display: flex; flex-direction: column; gap: 15px; margin: 30px auto; padding: 20px; background-color: #fff; border: 1px solid #ddd; border-radius: 8px; max-width: 800px; }
.sentence-row { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; font-size: 1.2em; }
.sentence-row .drop-zone { min-width: 150px; height: 45px; margin: 0; font-weight: 700; width: 100%; }
.option-box { padding: 10px 15px; border-radius: 6px; background-color: #f8f9fa; border: 1px solid #dee2e6; cursor: grab; user-select: none; transition: transform .2s, opacity .2s; }
.option-box:hover { transform: scale(1.05); }
.option-box.dragging { opacity: .4; cursor: grabbing; }
.option-box.placed { opacity: .3; cursor: not-allowed; background-color: #e9ecef; }

/* === Picture Description Game Styles === */
#image-container { width: 100%; height: auto; aspect-ratio: 1 / 1; max-width: 500px; margin: 20px auto; border-radius: 8px; overflow: hidden; border: 1px solid #ddd; background-color: #e0e0e0; }
#exercise-image { width: 100%; height: 100%; object-fit: cover; }
#picture-game-container #sentence-container { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin: 30px auto; padding: 20px; background-color: #fff; border: 1px solid #ddd; border-radius: 8px; max-width: 800px; min-height: 60px; font-size: 1.2em; width: 100%; box-sizing: border-box; }
.sentence-part { font-weight: 700; }
#picture-game-container .option-box { font-size: 1em; }


/* --- Responsive Design --- */
/* Media Query for tablets and desktops */
@media (min-width: 768px) {
    body {
        padding: 40px;
    }

    h1 { font-size: 2.5em; }
    h2 { font-size: 1.8em; }
    h3 { font-size: 1.4em; }

    .card {
        width: 90%;
    }

    select, button, .exercise-button {
        width: auto; /* Allow buttons to size to their content */
    }

    #language-selection label {
        display: inline; /* Side-by-side on larger screens */
        margin-bottom: 0;
    }

    .selection-controls {
        flex-direction: row; /* Horizontal layout for controls */
    }
    
    .hub-header {
        flex-direction: row; /* Horizontal layout for hub header */
        align-items: center;
    }

    .hub-header h2 {
        text-align: left;
    }

    .ex-chunk {
        font-size: 1.2em;
    }

    #sentence-container {
        font-size: 1.8em;
    }
    
    .chunk {
        font-size: 1.4em;
    }

    .sentence-row {
        flex-direction: row;
        align-items: center;
        font-size: 1.6em;
    }

    .sentence-row .drop-zone {
        min-width: 200px;
        margin: 0 10px;
        width: auto;
    }

    #picture-game-container #sentence-container {
        font-size: 1.6em;
    }
    #picture-game-container .option-box {
        font-size: 1.2em;
    }
}