:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --background-color: #ecf0f1;
    --font-color: #2c3e50;
    --card-bg: #ffffff;
    --disabled-color: #95a5a6;
    --correct-color: #2ecc71;
    --incorrect-color: #e74c3c;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --border-radius: 15px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Lilita One', cursive;
    background-color: var(--background-color);
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
    color: var(--font-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    user-select: none;
}

#app {
    width: 100%;
    max-width: 500px;
    height: 100%;
    max-height: 900px;
    padding: 15px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Telas */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.5s ease;
    padding: 10px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

h1 {
    font-size: clamp(2.5rem, 10vw, 3.5rem);
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 30px;
}

h2 {
    font-size: clamp(1.8rem, 8vw, 2.5rem);
    color: var(--font-color);
    margin-bottom: 20px;
}

#total-score-display {
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: clamp(1.2rem, 5vw, 1.5rem);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.instructions {
    font-size: clamp(1rem, 4vw, 1.2rem);
    margin-bottom: 15px;
    color: #555;
}

/* Tela Inicial */
.game-selection {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.game-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    gap: 15px;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.game-card img {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
}

.game-card p {
    font-size: clamp(1.5rem, 6vw, 1.8rem);
    color: var(--primary-color);
    flex-grow: 1;
    text-align: left;
}

.game-card.disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    filter: grayscale(80%);
}

.game-card.disabled p {
    color: var(--disabled-color);
}

/* Jogo Base Styles */
.game-screen {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    justify-content: space-around;
    height: auto;
    max-height: 95vh;
    width: 100%;
    position: relative;
}

.score-display {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: var(--primary-color);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: clamp(1rem, 4vw, 1.2rem);
    box-shadow: var(--shadow);
    z-index: 10;
}

.home-btn, #home-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    z-index: 10;
}

.home-btn img, #home-btn img {
    width: 40px;
    height: 40px;
    transition: transform 0.2s;
}
.home-btn:hover img, #home-btn:hover img {
    transform: scale(1.1);
}

.feedback {
    font-size: clamp(1.5rem, 6vw, 2rem);
    padding: 10px 20px;
    border-radius: 10px;
    margin-top: 15px;
}
.feedback.correct {
    background-color: var(--correct-color);
    color: white;
}
.feedback.incorrect {
    background-color: var(--incorrect-color);
    color: white;
}

.next-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 15px 30px;
    font-size: clamp(1.2rem, 5vw, 1.5rem);
    cursor: pointer;
    margin-top: 15px;
    font-family: 'Lilita One', cursive;
    transition: background-color 0.2s;
}
.next-btn:hover {
    background-color: #27ae60;
}

/* Jogo 1 */
#game1-screen {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    padding: 20px;
    padding-top: 60px; /* Space for home button */
    box-shadow: var(--shadow);
    justify-content: space-between;
    height: auto;
    max-height: 95vh;
    width: 100%;
    position: relative;
}

#home-btn {
    position: absolute;
    top: 15px;
    left: 15px;
}

#game1-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#image-container {
    width: 100%;
    max-width: 180px;
    height: 180px;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#word-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

#drop-zones, #syllable-pool {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 65px;
    width: 100%;
    padding: 10px;
}

#drop-zones {
    background-color: #dde1e2;
    border-radius: 10px;
}

.drop-zone {
    width: 75px;
    height: 55px;
    border: 3px dashed var(--disabled-color);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.7rem;
    transition: background-color 0.2s;
}

.drop-zone .syllable {
    cursor: grab;
}

.drop-zone.over {
    background-color: #c8d6e5;
    border-style: solid;
}

.syllable {
    width: 75px;
    height: 55px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    border-radius: 10px;
    cursor: grab;
    transition: transform 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    touch-action: none; /* Important for touch drag */
}

.syllable.dragging {
    opacity: 0.5;
    cursor: grabbing;
    transform: scale(1.1);
}

.syllable.placeholder {
    background: transparent;
    box-shadow: none;
    border: 2px dashed #ccc;
}

.syllable:active {
    cursor: grabbing;
    transform: scale(1.1);
    opacity: 0.8;
}

#feedback {
    font-size: 2rem;
    padding: 10px 20px;
    border-radius: 10px;
    margin-top: 15px;
}
#feedback.correct {
    background-color: var(--secondary-color);
    color: white;
}
#feedback.incorrect {
    background-color: #e74c3c;
    color: white;
}

#next-word-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 15px 30px;
    font-size: 1.5rem;
    cursor: pointer;
    margin-top: 15px;
    font-family: 'Lilita One', cursive;
    transition: background-color 0.2s;
}
#next-word-btn:hover {
    background-color: #27ae60;
}

/* Jogo 2 */
#game2-screen {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    padding: 20px;
    padding-top: 60px; /* Space for home button */
    box-shadow: var(--shadow);
    justify-content: space-around;
    gap: 20px;
}

.syllable-display {
    background-color: var(--primary-color);
    color: white;
    font-size: clamp(3rem, 15vw, 5rem);
    padding: 15px 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

#game2-choices {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    width: 100%;
}

#game2-choices.disabled {
    pointer-events: none;
}

.choice-card {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 10px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 4px solid transparent;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.choice-card:hover {
    transform: translateY(-5px);
}

.choice-card img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.choice-card.correct {
    border-color: var(--correct-color);
    animation: bounce 0.5s;
}
.choice-card.incorrect {
    border-color: var(--incorrect-color);
    animation: shake 0.5s;
}

/* Jogo 3 */
#game3-screen {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    padding: 20px;
    padding-top: 60px; /* Space for home button */
    box-shadow: var(--shadow);
    justify-content: space-around;
    gap: 15px;
}

#game3-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 260px;
}

#game3-grid.disabled {
    pointer-events: none;
}

.game3-card {
    width: auto;
    height: auto;
    aspect-ratio: 1/1;
}
.game3-card.selected {
    border-color: var(--primary-color);
}

/* Modal Pop-up */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    text-align: center;
    width: 100%;
    max-width: 350px;
    animation: zoomIn 0.3s ease;
}

#popup-message {
    font-size: clamp(1.8rem, 7vw, 2.2rem);
    color: var(--font-color);
    margin-bottom: 25px;
}

#popup-next-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 15px 30px;
    font-size: clamp(1.2rem, 5vw, 1.5rem);
    cursor: pointer;
    font-family: 'Lilita One', cursive;
    transition: background-color 0.2s;
    width: 100%;
}

#popup-next-btn:hover {
    background-color: #27ae60;
}

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

/* Animações */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
  40% {transform: translateY(-20px);}
  60% {transform: translateY(-10px);}
}

@keyframes shake {
  0%, 100% {transform: translateX(0);}
  10%, 30%, 50%, 70%, 90% {transform: translateX(-5px);}
  20%, 40%, 60%, 80% {transform: translateX(5px);}
}

/* Responsividade para Desktop */
@media (min-width: 768px) {
    #app {
        max-width: 800px;
        padding: 40px;
    }

    h1 {
        font-size: 4.5rem;
    }
    h2 {
        font-size: 3rem;
    }

    .game-selection {
        flex-direction: row;
        justify-content: center;
        gap: 30px;
    }

    .game-card {
        flex-direction: column;
        width: 200px;
    }

    .game-card img {
        width: 150px;
        height: 150px;
    }
    
    .game-card p {
        text-align: center;
        font-size: 2rem;
    }

    #game1-screen, #game2-screen, #game3-screen {
        padding: 40px;
        padding-top: 80px;
    }

    #home-btn img, .home-btn img {
        width: 50px;
        height: 50px;
    }

    .drop-zone, .syllable {
        width: 100px;
        height: 80px;
        font-size: 2.5rem;
    }

    .choice-card {
        width: 150px;
        height: 150px;
    }

    #game3-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 450px;
    }
}

.hidden {
    display: none !important;
}