@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700;900&display=swap');

:root {
    --font-heading: 'Fredoka One', cursive;
    --font-body: 'Nunito', sans-serif;

    /* Common Colors */
    --color-green: #2ecc71;
    --color-green-dark: #27ae60;
    --color-blue: #3498db;
    --color-blue-dark: #2980b9;
    --color-red: #e74c3c;
    --color-red-dark: #c0392b;
    --color-yellow: #f1c40f;
    --color-yellow-dark: #f39c12;
    --color-purple: #9b59b6;
    --color-purple-dark: #8e44ad;
    --color-orange: #e67e22;
    --color-orange-dark: #d35400;

    --color-text: #2c3e50;
    --border-radius: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    /* Disable text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Disable blue tap highlight */
}

body {
    font-family: var(--font-body);
    background: linear-gradient(180deg, #A1C4FD 0%, #C2E9FB 100%);
    /* Sky Blue Gradient */
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    color: var(--color-text);
    /* overscroll-behavior: none; -- Moved to html, body */
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling for iOS inner elements */
}

/* LOCK VIEWPORT GLOBALLY */
html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Fix body */
    position: fixed;
    /* Fix rubber band */
    overscroll-behavior: none;
}

/* Clouds Animation */
.cloud {
    position: absolute;
    font-size: 5rem;
    opacity: 0.8;
    animation: drift 20s linear infinite;
    z-index: 0;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.cloud-1 {
    top: 10%;
    left: -10%;
    animation-duration: 25s;
}

.cloud-2 {
    top: 20%;
    left: -20%;
    animation-duration: 35s;
    animation-delay: 5s;
}

.cloud-3 {
    top: 15%;
    left: -15%;
    animation-duration: 45s;
    animation-delay: 2s;
}

@keyframes drift {
    from {
        transform: translateX(-10vw);
    }

    to {
        transform: translateX(110vw);
    }
}

/* Containers */
/* Updated to be scrollable within fixed body */
/* Updated to be scrollable within fixed body */
.container {
    width: 100%;
    /* Take full screen width */
    height: 100%;
    /* Take full height */
    max-width: none;
    /* Removed limit so scrollbar is at edge */
    margin: 0;
    padding: 20px;
    position: relative;
    z-index: 10;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;

    /* Center content internally */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Constrain direct children to keep the app look */
.container>* {
    width: 100%;
    max-width: 500px;
}

.container::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar Chrome/Safari */
}

.game-title {
    font-family: var(--font-heading);
    color: white;
    /* White text */
    font-size: 2.2rem;
    margin: 20px 0;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1),
        -1px -1px 0 #3498db,
        1px -1px 0 #3498db,
        -1px 1px 0 #3498db,
        1px 1px 0 #3498db;
    /* Stroke effect simulation */
    -webkit-text-stroke: 1.5px #3498db;
}

/* Profile Input */
.profile-section {
    background: white;
    padding: 10px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    border: 3px solid #fff;
    max-width: 350px;
    margin: 20px auto;
}

.avatar-circle {
    font-size: 1.5rem;
    margin-right: 10px;
}

.profile-section input {
    border: none;
    outline: none;
    font-size: 1.2rem;
    font-family: var(--font-heading);
    color: #555;
    background: transparent;
    width: 100%;
}

/* Voice Indicator */
#voice-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    display: none;
    /* Hidden by default */
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: pulseMic 1.5s infinite;
}

@keyframes pulseMic {
    0% {
        transform: translateX(-50%) scale(1);
        box-shadow: 0 0 0 rgba(255, 255, 255, 0.7);
    }

    70% {
        transform: translateX(-50%) scale(1.05);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0);
    }

    100% {
        transform: translateX(-50%) scale(1);
    }
}

/* Age Toggle */
.age-toggle-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.age-btn {
    background: #fff;
    border: 2px solid #ddd;
    color: #aaa;
    padding: 10px 20px;
    border-radius: 50px;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    box-shadow: 0 4px 0 #ccc;
}

.age-btn.active {
    background: var(--color-yellow);
    color: white;
    border-color: var(--color-yellow-dark);
    box-shadow: 0 4px 0 var(--color-yellow-dark);
    transform: translateY(-2px);
}

.age-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding: 10px;
}

.theme-card {
    background: white;
    border-radius: 20px;
    padding: 5px;
    /* Inner border gap */
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1);
    /* Base shadow */
}

.theme-card:hover {
    transform: translateY(-5px);
}

.theme-card:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.card-inner {
    border-radius: 15px;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: white;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

.theme-card .icon {
    font-size: 3rem;
    margin-bottom: 5px;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.2));
}

.theme-card .stars {
    font-size: 0.8rem;
    margin-bottom: 10px;
    color: #FFD700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.theme-card h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    text-transform: uppercase;
    margin: 0;
}

/* Card Colors */
.color-red .card-inner {
    background: linear-gradient(135deg, #ff7675, #d63031);
    border: 2px solid white;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.color-blue .card-inner {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    border: 2px solid white;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.color-green .card-inner {
    background: linear-gradient(135deg, #55efc4, #00b894);
    border: 2px solid white;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.color-purple .card-inner {
    background: linear-gradient(135deg, #a29bfe, #6c5ce7);
    border: 2px solid white;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Teacher Link */
.teacher-link {
    color: white;
    font-weight: bold;
    text-decoration: none;
    opacity: 0.7;
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.1);
}

/* Mascot Decoration */
.mascot-decoration {
    position: fixed;
    bottom: -10px;
    right: 20px;
    font-size: 6rem;
    z-index: 5;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.3));
    pointer-events: none;
}

.game-mascot {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 150px;
    z-index: 20;
    pointer-events: none;
}

.game-mascot img {
    width: 100%;
    display: block;
}

/* ---------------- GAME INTERFACE ---------------- */
.game-mode {
    background: linear-gradient(135deg, #fce38a 0%, #f38181 100%);
    /* Warm animated gradient */
}

/* Top Bar */
.top-bar {
    width: 100%;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
}

.home-btn {
    background: #fff;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 0 #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.progress-container {
    flex-grow: 1;
    margin: 0 15px;
    background: rgba(0, 0, 0, 0.3);
    height: 20px;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    overflow: hidden;
    position: relative;
}

.progress-bar {
    background: #2ecc71;
    height: 100%;
    width: 50%;
    border-radius: 20px;
    transition: width 0.5s;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.score-pill {
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    padding: 5px 15px;
    border-radius: 20px;
    font-family: var(--font-heading);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Question Area */
.game-wrapper {
    width: 100%;
    max-width: none;
    /* Full width for scrolling */
    height: calc(100% - 80px);
    margin-top: 80px;
    padding: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center content */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* TOP BAR (Shared by Quiz and Menu) */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: none !important;
    /* Override container limit */
    height: 70px;
    padding: 0 15px;
    z-index: 100;

    /* Purple Gradient Background */
    background: linear-gradient(135deg, #a29bfe, #6c5ce7);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);

    /* Flex layout for buttons */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Centre Title Absolute */
.menu-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-heading);
    color: white;
    font-size: 1.2rem;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    /* Let clicks pass through if overlapping */
}

@media (max-width: 480px) {
    .menu-title {
        font-size: 0.9rem;
        /* Smaller font on mobile */
        max-width: 50%;
        /* Strict limit to avoid button overlap */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Restoring button styles which were accidentally removed */
.top-bar-btn {
    background: white;
    border: 2px solid #ccc;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #999;
    transition: transform 0.1s, box-shadow 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-bar-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #999;
}

.game-wrapper>* {
    width: 100%;
    max-width: 500px;
}

.question-header {
    text-align: center;
    color: #2c3e50;
    /* Fallback */
    font-family: var(--font-heading);
    opacity: 1;
    /* Make it solid */
    margin-bottom: 15px;
    font-size: 1.2rem;
    text-shadow: none;
    /* Remove shadow for cleaner look on colors */
}

#theme-title {
    color: #8e44ad;
    /* Purple */
    text-shadow: 2px 2px 0px white;
    /* Outline effect */
    font-size: 1.8rem !important;
}

#question-number {
    color: #d35400;
    /* Dark Orange */
    font-weight: bold;
    font-size: 1.3rem;
    background: rgba(255, 255, 255, 0.8);
    padding: 5px 15px;
    border-radius: 15px;
}

.question-card {
    background: white;
    border-radius: 30px;
    padding: 30px 20px;
    border: 5px solid #a3cbff;
    /* Light blue border */
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.05), inset 0 -5px 0 rgba(0, 0, 0, 0.05);
    /* Inner shadow for depth */
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
}

.question-card h2 {
    font-family: var(--font-heading);
    color: #2c3e50;
    font-size: 1.6rem;
    /* Increased size */
    line-height: 1.3;
    text-align: center;
    overflow-wrap: break-word;
    /* Ensure wrapping */
    word-wrap: break-word;
    margin: 0;
}

/* Options Grid */
.options-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* GLOSSY BUTTONS */
.glossy-btn {
    width: 100%;
    border: none;
    padding: 15px 20px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: white;
    border-radius: 50px;
    /* Pill shape */
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    text-shadow: 2px 2px 0 #000;
    /* Strong black outline */
    position: relative;
    outline: none;
    transition: transform 0.1s;
}

.glossy-btn .letter {
    font-size: 1.3rem;
    margin-right: 15px;
    opacity: 0.8;
}

.glossy-btn:active {
    transform: translateY(4px) !important;
}

/* Color Variants */
.glossy-btn.yellow {
    background: linear-gradient(to bottom, #f1c40f 0%, #f39c12 100%);
    box-shadow: 0 5px 0 #d35400;
}

.glossy-btn.orange {
    background: linear-gradient(to bottom, #e67e22 0%, #d35400 100%);
    box-shadow: 0 5px 0 #a04000;
}

.glossy-btn.pink {
    background: linear-gradient(to bottom, #fd79a8 0%, #e84393 100%);
    box-shadow: 0 5px 0 #c44569;
}

.glossy-btn.cyan {
    background: linear-gradient(to bottom, #81ecec 0%, #00cec9 100%);
    box-shadow: 0 5px 0 #00b894;
}

.glossy-btn.green {
    /* Correct */
    background: linear-gradient(to bottom, #55efc4 0%, #00b894 100%);
    box-shadow: 0 5px 0 #006266;
}

.glossy-btn.blue {
    /* Menu */
    background: linear-gradient(to bottom, #74b9ff 0%, #0984e3 100%);
    box-shadow: 0 5px 0 #2c3e50;
}

.glossy-btn.red {
    /* Wrong */
    background: linear-gradient(to bottom, #ff7675 0%, #d63031 100%);
    box-shadow: 0 5px 0 #b33939;
}

.glossy-btn.purple {
    background: linear-gradient(to bottom, #a29bfe 0%, #6c5ce7 100%);
    box-shadow: 0 5px 0 #8e44ad;
}


/* Final Score Box */
.final-score-box {
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 20px;
    margin: 20px 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Speech Bubble */
.speech-bubble {
    position: absolute;
    bottom: 130px;
    /* Adjusted to sit nicely above */
    right: 0;
    left: -180px;
    /* Extend to left */
    background: #fff;
    border: 3px solid #333;
    border-radius: 20px;
    padding: 15px;
    width: 220px;
    text-align: center;
    font-family: var(--font-heading);
    color: #333;
    font-size: 1.1rem;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
    z-index: 25;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Bubble Tail */
.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -13px;
    right: 40px;
    border-width: 13px 13px 0;
    border-style: solid;
    border-color: #333 transparent;
    display: block;
    width: 0;
}

/* Inner white tail */
.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 43px;
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: #fff transparent;
    display: block;
    width: 0;

    z-index: 1;
}

/* Ranking Page Styling */
.ranking-card {
    background: white;
    border-radius: 20px;
    padding: 10px;
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.1);
    border: 4px solid white;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-heading);
    color: #444;
    table-layout: fixed;
    /* Force fixed width */
}

.ranking-table th {
    background: #f1f2f6;
    padding: 10px;
    text-align: left;
    border-bottom: 2px solid #ddd;
    color: #7f8fa6;
    text-transform: uppercase;
    font-size: 0.8rem;
    white-space: nowrap;
    /* Prevent headers from breaking poorly */
}

/* Specific Column Widths */
.ranking-table th:nth-child(1) {
    width: 40%;
}

/* Jogador */
.ranking-table th:nth-child(2) {
    width: 25%;
}

/* Missão */
.ranking-table th:nth-child(3) {
    width: 15%;
}

/* Pontos */
.ranking-table th:nth-child(4) {
    width: 20%;
}

/* Data */

.ranking-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    font-size: 1rem;

    /* Ellipsis for overflow */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-table tr:last-child td {
    border-bottom: none;
}

.ranking-table tr:hover {
    background-color: #f8f9fa;
}

/* Medal Colors for Top 3 */
.ranking-table tr:nth-child(1) td:first-child::before {
    content: '🥇 ';
}

.ranking-table tr:nth-child(2) td:first-child::before {
    content: '🥈 ';
}

.ranking-table tr:nth-child(3) td:first-child::before {
    content: '🥉 ';
}

/* Ranking Button Specifics */
.glossy-btn.gold {
    background: linear-gradient(to bottom, #f1c40f 0%, #f39c12 100%);
    box-shadow: 0 5px 0 #d35400;
    border: 2px solid #fff;
    justify-content: center;
    color: white;
}

.ranking-btn {
    height: 80px;
    margin-bottom: 20px;
    transition: transform 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    display: flex;
    align-items: center;
}

.ranking-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #d35400;
}

/* Settings Page Styling */
.settings-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.1);
    border: 4px solid white;
    width: 100%;
}

.setting-item {
    margin-bottom: 25px;
    text-align: left;
}

.setting-label {
    font-family: var(--font-heading);
    color: #444;
    font-size: 1.2rem;
    margin-bottom: 10px;
    display: block;
}

/* Custom Range Slider */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 30px;
    width: 30px;
    border-radius: 50%;
    background: var(--color-blue);
    cursor: pointer;
    margin-top: -12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 3px solid white;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: #dde6f0;
    border-radius: 5px;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f1f2f6;
    padding: 15px;
    border-radius: 15px;
    cursor: pointer;
}

.toggle-status {
    font-weight: bold;
    color: var(--color-green);
}

.toggle-status.off {
    color: var(--color-red);
}

/* ------------------------------------------- */
/*               END SCREEN STYLES             */
/* ------------------------------------------- */

#end-container {
    /* Override defaults for better centering */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding-top: 20px;
    text-align: center;
    /* Ensure internal text is centered */
}

/* Constrain content width */
#end-container>* {
    width: 100%;
    max-width: 400px;
    /* Limit width */
}

.mascot-container {
    width: 180px;
    margin: 10px auto;
}

.mascot-container img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.2));
}

#end-container .final-score-box {
    margin: 15px auto 25px auto;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#end-container h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: white;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    line-height: 1.2;
    text-align: center;
    width: 100%;
}

#end-container button {
    margin-bottom: 15px;
    justify-content: center;
    /* Center button content */
}

/* End Screen Speech Bubble Override */
#end-mascot-speech {
    left: auto;
    bottom: auto;
    /* Positioned via inline styles in HTML, but reset generic class props */
    width: 250px;
    z-index: 101;
    /* Above modal/other elements */
    font-size: 1rem;
    padding: 10px;
}

#end-mascot-speech::before {
    /* Adjust tail */
    bottom: -8px;
    right: 50%;
    /* Center tail roughly or adjust */
    transform: translateX(50%);
    border-color: #fff transparent;
}

#end-mascot-speech::after {
    /* Border tail */
    content: '';
    position: absolute;
    bottom: -13px;
    right: 50%;
    transform: translateX(50%);
    border-width: 13px 13px 0;
    border-style: solid;
    border-color: #333 transparent;
    display: block;
    width: 0;
    z-index: 0;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    font-family: var(--font-heading);
}

.modal-content h2 {
    color: #8e44ad;
    margin-bottom: 15px;
}