:root {
    --primary-blue: #008CCE;
    --text-black: #000000;
    --text-grey: #666666;
    --bg-white: #FFFFFF;
    --primary-green: #669933;
    --primary-orange-yellow: #FBB03B;
    --font-outfit: 'Outfit', sans-serif;
    --font-opensans: 'Open Sans', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-white);
    font-family: var(--font-outfit);
    user-select: none;
    -webkit-user-select: none;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 2s ease;
    padding-bottom: 110px; /* Leave space for persistent footer */
    overflow-y: auto;
    box-sizing: border-box;
}

#splash-screen {
    z-index: 10;
    cursor: pointer;
}

#main-screen {
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.5s ease;
    justify-content: flex-start;
}

#main-screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* Splash Content */
.splash-content {
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#main-logo {
    width: 250px;
    height: auto;
    margin-bottom: 20px;
    transition: transform 0.8s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 2s ease-in-out;
    will-change: transform, opacity;
}

#tap-text {
    font-size: 1.5rem;
    color: var(--primary-blue);
    font-weight: 700;
    letter-spacing: 1px;
}

/* Main Header */
.main-header {
    text-align: center;
    transition: transform 1s ease-in-out, top 1s ease-in-out;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
}

.main-header.at-top {
    top: 60px;
    transform: translate(-50%, 0);
}

.unit-title {
    font-family: var(--font-opensans);
    color: var(--text-black);
    font-weight: 700;
    font-size: 2.2rem;
    margin-bottom: -5px;
}

.subtheme-title {
    font-family: var(--font-opensans);
    color: var(--text-grey);
    font-weight: 400;
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 145px; /* Pegado justo debajo del subtema */
    opacity: 0;
    transition: opacity 1.5s ease;
    width: 100%;
}

.main-content.visible {
    opacity: 1;
}

.medium-logo {
    width: 200px;
    height: auto;
}

.game-button {
    background-color: var(--primary-blue);
    color: white;
    border: none;
    padding: 10px 40px; /* Reduced from 15px to 10px to reduce height */
    border-radius: 50px;
    font-family: var(--font-opensans);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 140, 206, 0.3);
}

.content-text {
    font-family: var(--font-opensans);
    color: var(--text-black);
    font-size: 0.95rem;
    margin-top: 20px;
}

.instruction-label {
    font-family: var(--font-opensans);
    color: var(--text-black);
    font-size: 0.95rem;
    font-weight: 700;
}

.instructions-container {
    text-align: center;
    width: 100%;
    max-width: 450px;
    padding: 0 25px;
    margin: 10px auto 0 auto;
    box-sizing: border-box;
}

.instruction-body {
    font-family: var(--font-opensans);
    color: var(--text-grey);
    font-size: 0.95rem;
    line-height: 1.4;
}

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

@keyframes pulse-animation {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.fade-out {
    opacity: 0 !important;
}

.hidden {
    display: none !important;
}

/* Footer - Persistent */
.persistent-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    padding-bottom: 15px;
    padding-top: 10px;
    text-align: center;
    width: 100%;
    background-color: transparent;
    z-index: 100;
    pointer-events: none;
    transition: background-color 0.3s ease, border-radius 0.3s ease, box-shadow 0.3s ease;
}

.persistent-footer.scrolled {
    background-color: #FFFFFF;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08);
    pointer-events: auto; /* Enable clicks if needed when it has background */
}

.powered-by {
    font-family: var(--font-opensans);
    color: var(--text-black);
    font-size: 0.8rem;
    margin-bottom: -5px;
    font-weight: 700;
}

.footer-brand {
    position: relative;
    display: inline-block;
}

.footer-logo {
    height: 16px;
    width: auto;
    position: absolute;
    right: 100%;
    margin-right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.footer-brand span {
    font-family: var(--font-opensans);
    font-size: 0.85rem;
    color: var(--text-grey);
    font-weight: 400;
}

/* --- GAME SCREEN --- */
#game-screen {
    z-index: 20;
    justify-content: flex-start;
    padding: 0 20px 20px 20px;
    padding-top: 65px; /* Leave space for absolute header */
    background-color: var(--bg-white);
    transition: opacity 2.5s ease-in-out;
    opacity: 1;
}

#game-screen.fade-out {
    opacity: 0 !important;
}

.game-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin: 0;
    background-color: var(--bg-white);
    z-index: 100;
    box-sizing: border-box;
}

.round-counter {
    color: var(--text-grey);
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
}

/* Help Container & Circle Icon (Grey) */
.help-container {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-grey);
    cursor: pointer;
    user-select: none;
}

.help-label {
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-opensans);
}

.help-icon-circle {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--text-grey);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
}

/* Effects Container & Speaker Icon (Blue) */
.effects-container {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--primary-blue);
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s ease;
}

.effects-container.muted {
    opacity: 0.4;
}

.effects-container.muted .volume-wave,
.effects-container.muted .volume-wave-outer {
    display: none !important;
}

.effects-container.muted .mute-cross {
    display: block !important;
}

.effects-label {
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-opensans);
}

.speaker-icon {
    width: 18px;
    height: 18px;
    display: block;
}

/* Exit Button Top (Grey with white text and icon) */
.exit-btn-top {
    background-color: var(--text-grey);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    font-family: var(--font-opensans);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: transform 0.1s, background-color 0.2s;
}

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

.exit-icon {
    width: 14px;
    height: 14px;
    display: block;
}

/* Modal Overlay & Help Card Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    display: none !important;
}

.help-card {
    background-color: var(--bg-white);
    padding: 30px 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 320px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    text-align: center;
    border: 1px solid #eaeaea;
}

.help-close-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.6rem;
    color: var(--text-grey);
    cursor: pointer;
    line-height: 1;
}

.help-text {
    font-family: var(--font-opensans);
    font-size: 1.1rem;
    color: var(--text-grey);
    font-weight: 400;
    margin-top: 10px;
}

.animate-zoom {
    animation: animatezoom 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes animatezoom {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Image Container */
.game-image-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-placeholder {
    width: 100%;
    height: 200px;
    border: 2px dashed #cccccc;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
}

.image-placeholder p {
    color: var(--text-grey);
    font-size: 1rem;
}

.game-image {
    max-width: 100%;
    max-height: 250px;
    border-radius: 10px;
}

/* Flags UI for Game Time 2 */
.flags-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: 20px;
    gap: 20px;
}

.spell-country-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    font-size: 1.2rem;
    font-family: var(--font-opensans);
    font-weight: 700;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.1s;
    background-color: var(--primary-blue);
    width: 100%;
    max-width: 300px;
}

.spell-country-btn:active {
    transform: scale(0.98);
}

.flags-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    max-width: 400px;
}

.flag-option {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background-color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.flag-option:active {
    transform: scale(0.95);
}

.flag-image {
    width: 100%;
    height: 100px;
    object-fit: contain;
    display: block;
}

#game-over-screen {
    z-index: 25;
    justify-content: flex-start;
    padding: 20px 20px 110px 20px;
    background-color: var(--bg-white);
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.5s ease-in-out;
}

#game-over-screen.active {
    opacity: 1;
    pointer-events: auto;
}

.game-over-header {
    text-align: center;
    margin-top: 15px; /* Reduced from 40px */
    margin-bottom: 5px; /* Reduced from 20px */
}

.unit-subtitle {
    color: var(--text-black);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.unit-title-grey {
    color: var(--text-grey);
    font-size: 1.1rem;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px; /* Reduced from 10px */
    margin: 5px 0; /* Reduced from 20px */
    padding: 10px; /* Reduced from 20px */
}

.large-logo {
    width: 230px;
    height: auto;
    margin-top: 0px;
    margin-bottom: 5px;
}

.game-time-label {
    color: var(--primary-blue);
    font-size: 1.3rem;
    font-weight: 700;
}

.final-score-label {
    color: var(--text-grey);
    font-weight: 700;
    font-size: 1.2rem;
}

.score-result {
    color: var(--primary-blue);
    font-size: 2.5rem;
    font-weight: 700;
}

/* Pulse animation helper for score container */
.score-card.pulse {
    will-change: transform;
}

#game-over-screen.active .score-card.pulse {
    animation: pulse-animation-light 2s infinite ease-in-out;
}

@keyframes pulse-animation-light {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.game-over-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 320px;
    margin-top: 0px; /* Reduced from 5px */
}

.whatsapp-instruction {
    color: var(--text-grey);
    font-size: 0.95rem;
    text-align: center;
    margin-bottom: 5px; /* Reduced margin */
}

.action-btn {
    width: 100%;
    padding: 12px 20px; /* Slightly reduced padding */
    border: none;
    border-radius: 50px;
    color: white;
    font-family: var(--font-opensans);
    font-size: 1.1rem; /* Slightly reduced font size */
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    text-decoration: none; /* In case of anchor tags */
    box-sizing: border-box;
}

.btn-green { background-color: var(--primary-green); }
.btn-yellow { background-color: var(--primary-orange-yellow); }
.btn-blue { background-color: var(--primary-blue); }
.btn-grey { background-color: var(--text-grey); }

/* --- REVIEW MISTAKES SCREEN --- */
#review-screen {
    z-index: 30;
    justify-content: flex-start;
    padding: 40px 20px;
    background-color: var(--bg-white);
}

.review-title {
    color: var(--text-black);
    margin-bottom: 30px;
    font-size: 1.8rem;
}

.mistakes-list {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    flex-grow: 1;
    margin-bottom: 20px;
}

.mistake-item {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.mistake-number {
    font-weight: 700;
    color: var(--text-grey);
    margin-bottom: 5px;
}

.mistake-user-answer {
    color: #dc3545; /* Red */
    font-weight: 700;
    font-size: 0.95rem;
}

.mistake-correct-answer {
    color: #28a745; /* Green */
    font-weight: 700;
    font-size: 0.95rem;
}

/* --- SPELLING UI (Game Time 1) --- */
.spelling-ui-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 350px;
    margin-top: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.spelling-audio-btns {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.spelling-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 50px;
    font-family: var(--font-opensans);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

.spelling-btn:active {
    transform: scale(0.98);
}

.spelling-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.spelling-btn .speaker-icon {
    width: 18px;
    height: 18px;
    stroke: white; /* Ensure speaker is white on blue button */
}

.spelling-input {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--primary-blue);
    border-radius: 25px;
    font-family: var(--font-opensans);
    font-size: 1.2rem;
    text-align: center;
    outline: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s;
}

.spelling-input:focus {
    border-color: var(--primary-orange-yellow);
}

.submit-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 50px;
    color: white;
    font-family: var(--font-opensans);
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
    background-color: var(--primary-green);
    box-shadow: 0 4px 15px rgba(102, 153, 51, 0.3);
}

.submit-btn:active {
    transform: scale(0.98);
}

.feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    font-size: 2.2rem;
    font-weight: 700;
    color: white;
    z-index: 10;
    animation: fadeInOverlay 0.25s ease-in-out;
}

.feedback-overlay.correct {
    background-color: rgba(102, 153, 51, 0.75); /* Green transparent overlay */
}

.feedback-overlay.incorrect {
    background-color: rgba(220, 53, 69, 0.75); /* Red transparent overlay */
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.spelling-correction {
    font-family: var(--font-opensans);
    color: var(--text-grey);
    font-size: 0.95rem;
    margin-top: 5px;
    margin-bottom: 5px;
    text-align: center;
}

.spelling-correction strong {
    color: var(--primary-orange-yellow);
    font-weight: 800;
}

