/* Estilos Globais */
:root {
    --primary-color: #2c2c54;
    --secondary-color: #f7d794;
    --accent-color: #706fd3;
    --text-color: #ffffff;
    --locked-color: #576574;
}

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

body {
    font-family: 'Lora', serif;
    background: var(--primary-color) url('background.png') no-repeat center center/cover;
    background-attachment: fixed;
    color: var(--text-color);
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

h1, h2 {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.screen {
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.hidden {
    display: none;
    opacity: 0;
}

button {
    font-family: 'Lora', serif;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: 2px solid var(--secondary-color);
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
}

button:hover {
    transform: scale(1.05);
    background-color: #8280e2;
}

.logo {
    max-width: 80%;
    height: auto;
    margin-bottom: 20px;
}

/* Tela de Carregamento */
#loading-screen {
    font-size: 1.5rem;
}

/* Tela Inicial */
#character-selection {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.character-card {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 15px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid transparent;
    text-align: center;
    position: relative;
}

.character-card:not(.locked):hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    border-color: var(--secondary-color);
}

.character-card img {
    width: 100px;
    height: 100px;
    object-fit: contain;
}

.character-card span {
    display: block;
    margin-top: 10px;
    font-size: 1.2rem;
}

.character-card.locked {
    background: var(--locked-color);
    cursor: not-allowed;
    filter: grayscale(80%);
}

.lock-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.7);
    opacity: 0;
    transition: opacity 0.3s;
}

.character-card.locked .lock-icon {
    opacity: 1;
}

/* Tela do Jogo */
#game-screen {
    justify-content: flex-start;
    padding: 10px;
}

#game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
}

#game-header button {
    padding: 5px 10px;
    font-size: 1rem;
}

#game-info {
    font-size: 1.2rem;
    font-weight: bold;
}

#game-area {
    width: 100%;
    height: 70vh; /* Ajustado para melhor visualização em mobile */
    position: relative;
    border: 2px solid var(--secondary-color);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Additions for Hermione's level scroll */
#game-area.memory-game {
    height: auto;
    max-height: 75vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0; /* Add some padding for better spacing */
}

#instructions {
    margin-top: 10px;
    font-size: 1.1rem;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
}

/* Nível Harry - Pomo */
#snitch {
    position: absolute;
    width: 60px;
    height: 60px;
    background: url('snitch.png') no-repeat center center/contain;
    cursor: pointer;
    transition: top 0.3s ease-out, left 0.3s ease-out;
}

/* Nível Hermione - Memória */
#memory-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 10px;
    width: 100%;
    max-width: 400px;
    margin: auto;
}

.memory-card {
    width: 100%;
    aspect-ratio: 1 / 1;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    cursor: pointer;
}

.memory-card.flipped {
    transform: rotateY(180deg);
}

.memory-card.matched {
    opacity: 0.5;
    pointer-events: none;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

.card-front {
    background-color: #eee;
    transform: rotateY(180deg);
}
.card-front img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.card-back {
    background: url('card_back.png') no-repeat center center/cover;
}

/* Nível Ron - Aranhas */
.spider {
    position: absolute;
    width: 70px;
    height: 70px;
    background: url('spider.png') no-repeat center center/contain;
    cursor: pointer;
    animation: fadeIn 0.3s;
}

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

/* Telas Modais (Nível/Jogo Completo) */
.modal {
    background: rgba(44, 44, 84, 0.9);
    padding: 30px;
    border-radius: 20px;
    border: 3px solid var(--secondary-color);
    box-shadow: 0 0 20px rgba(247, 215, 148, 0.5);
    max-width: 90%;
}

.modal h2 {
    color: var(--secondary-color);
    margin-bottom: 15px;
}

.modal p {
    margin-bottom: 25px;
    font-size: 1.2rem;
}

/* Responsividade */
@media (max-width: 600px) {
    #character-selection {
        gap: 10px;
    }
    .character-card img {
        width: 80px;
        height: 80px;
    }
    #memory-board {
        grid-template-columns: repeat(3, 1fr);
        max-width: 320px;
    }
}