:root {
    --azul-ceu: #87CEEB;
    --azul-escuro: #4682B4;
    --azul-vibrante: #1E90FF;
    --amarelo-sol: #FFD700;
    --amarelo-escuro: #DAA520;
    --laranja-divertido: #FF8C00;
    --verde-grama: #4CAF50;
    --verde-escuro: #2E8B57;
    --branco: #FFFFFF;
    --texto-principal: #333333;
    --erro-vermelho: #FF4757;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Baloo 2', cursive, sans-serif;
}

body {
    background-color: var(--azul-ceu);
    background-image: radial-gradient(circle, #ffffff33 2px, transparent 2px);
    background-size: 30px 30px;
    color: var(--texto-principal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- TELA DE CARREGAMENTO --- */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--azul-ceu);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

#loading-screen img {
    width: 80vw;
    max-width: 600px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

.loading-text {
    font-size: 24px;
    font-weight: 800;
    color: var(--branco);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    animation: pulse 1.5s infinite;
}

/* --- PLACAR (SCOREBOARD) --- */
.scoreboard {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 700px;
}

.score-box {
    background-color: var(--branco);
    border: 4px solid var(--branco);
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s;
}

.score-j1 {
    border-color: var(--amarelo-sol);
    color: var(--amarelo-escuro);
}

.score-j2 {
    border-color: var(--azul-vibrante);
    color: var(--azul-escuro);
}

.score-box.ativo {
    transform: scale(1.1);
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.2);
}

/* --- TELA DO JOGO --- */
#game-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.8s ease-in;
    overflow-y: auto;
}

.header img {
    height: 80px;
    max-width: 90vw;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 0px rgba(0, 0, 0, 0.1));
}

/* CARD PRINCIPAL */
.game-card {
    background-color: var(--branco);
    border: 4px solid var(--azul-escuro);
    border-radius: 30px;
    padding: 30px;
    width: 100%;
    max-width: 700px;
    text-align: center;
    box-shadow: 0 10px 0 var(--azul-escuro);
    margin-bottom: 30px;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* BOTÃO MÁGICO DINÂMICO */
#btn-sortear {
    color: var(--texto-principal);
    padding: 15px 40px;
    font-size: 26px;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    margin: auto;
}

.btn-amarelo {
    background-color: var(--amarelo-sol);
    border: 4px solid var(--amarelo-escuro);
    box-shadow: 0 8px 0 var(--amarelo-escuro), 0 15px 20px rgba(0, 0, 0, 0.2);
}

.btn-amarelo:active {
    transform: translateY(8px);
    box-shadow: 0 0px 0 var(--amarelo-escuro);
}

.btn-azul {
    background-color: var(--azul-vibrante);
    color: var(--branco) !important;
    border: 4px solid var(--azul-escuro);
    box-shadow: 0 8px 0 var(--azul-escuro), 0 15px 20px rgba(0, 0, 0, 0.2);
}

.btn-azul:active {
    transform: translateY(8px);
    box-shadow: 0 0px 0 var(--azul-escuro);
}

/* TEXTOS DA PERGUNTA */
#pergunta-display {
    display: none;
    width: 100%;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tag-desafio {
    display: inline-block;
    background-color: var(--laranja-divertido);
    color: var(--branco);
    padding: 5px 20px;
    border-radius: 20px;
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 15px;
    box-shadow: 0 4px 0 #CC7000;
    text-transform: uppercase;
}

.texto-pergunta {
    font-size: 26px;
    font-weight: 800;
    color: var(--azul-escuro);
    line-height: 1.3;
    margin-bottom: 15px;
}

.feedback-msg {
    font-size: 22px;
    font-weight: 800;
    margin-top: 10px;
    min-height: 35px;
}

/* --- GRID DE ESTADOS --- */
.states-container {
    width: 100%;
    max-width: 900px;
    display: none;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.4s ease;
    background-color: var(--branco);
    padding: 20px;
    border-radius: 25px;
    border: 4px solid var(--azul-escuro);
    box-shadow: 0 8px 0 var(--azul-escuro);
}

.states-container.visible {
    display: block;
    opacity: 1;
    transform: scale(1);
}

.states-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 12px;
    pointer-events: none;
}

.states-grid.active {
    pointer-events: auto;
}

.state-btn {
    background-color: var(--azul-ceu);
    color: var(--azul-escuro);
    border: 3px solid var(--azul-escuro);
    padding: 12px 0;
    font-size: 20px;
    font-weight: 800;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--azul-escuro);
    transition: all 0.1s ease;
}

.state-btn:hover {
    background-color: var(--amarelo-sol);
    transform: translateY(-2px);
    box-shadow: 0 7px 0 var(--azul-escuro);
}

.state-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0px 0 var(--azul-escuro);
}

.state-btn.correct {
    background-color: var(--verde-grama) !important;
    border-color: var(--verde-escuro) !important;
    color: var(--branco) !important;
    box-shadow: 0 0 0 var(--verde-escuro) !important;
    transform: scale(1.1) rotate(5deg);
    z-index: 10;
}

.state-btn.wrong {
    background-color: var(--erro-vermelho) !important;
    border-color: #C23616 !important;
    color: var(--branco) !important;
    animation: shake 0.4s ease-in-out;
}

.state-btn.disabled {
    background-color: #E0E0E0 !important;
    border-color: #BDBDBD !important;
    color: #9E9E9E !important;
    box-shadow: none !important;
    pointer-events: none;
    transform: scale(0.95);
}

/* --- TELA DE FIM DE JOGO --- */
#end-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(135, 206, 235, 0.95);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.5s ease;
    text-align: center;
    padding: 20px;
}

.end-card {
    background-color: var(--branco);
    border: 6px solid var(--amarelo-sol);
    border-radius: 40px;
    padding: 40px;
    max-width: 600px;
    box-shadow: 0 15px 0 var(--amarelo-escuro), 0 20px 30px rgba(0, 0, 0, 0.3);
    animation: popIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.end-title {
    font-size: 40px;
    font-weight: 800;
    color: var(--verde-escuro);
    margin-bottom: 20px;
    text-transform: uppercase;
}

.final-scores {
    display: flex;
    justify-content: space-around;
    margin: 30px 0;
    font-size: 28px;
    font-weight: 800;
}

.btn-reiniciar {
    background-color: var(--verde-grama);
    color: var(--branco);
    border: 4px solid var(--verde-escuro);
    padding: 20px 50px;
    font-size: 28px;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 0 var(--verde-escuro);
    transition: all 0.2s ease;
    text-transform: uppercase;
    margin-top: 20px;
}

.btn-reiniciar:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

.btn-reiniciar:active {
    transform: translateY(8px);
    box-shadow: 0 0px 0 var(--verde-escuro);
}

/* --- ANIMAÇÕES --- */
@keyframes bounce {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

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

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

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

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-8px) rotate(-5deg);
    }
    50% {
        transform: translateX(8px) rotate(5deg);
    }
    75% {
        transform: translateX(-8px) rotate(-5deg);
    }
}

/* --- RESPONSIVIDADE --- */
@media (max-width: 1024px) {
    #game-screen {
        padding: 18px 16px;
    }

    .game-card {
        max-width: 92vw;
        padding: 24px;
    }

    .states-container {
        max-width: 92vw;
        padding: 18px;
    }

    .texto-pergunta {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    #game-screen {
        height: auto;
        min-height: 100vh;
        justify-content: flex-start;
        padding: 16px 12px 24px;
    }

    .header img {
        height: 64px;
        margin-bottom: 12px;
    }

    .scoreboard {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        max-width: 100%;
    }

    .score-box {
        width: 100%;
        justify-content: center;
        font-size: 20px;
        padding: 10px 14px;
    }

    .game-card {
        width: 100%;
        max-width: 100%;
        padding: 20px 14px;
        border-radius: 22px;
        min-height: 210px;
        margin-bottom: 18px;
    }

    #btn-sortear {
        width: 100%;
        padding: 14px 18px;
        font-size: 22px;
    }

    .tag-desafio {
        font-size: 16px;
    }

    .texto-pergunta {
        font-size: 22px;
    }

    .feedback-msg {
        font-size: 20px;
    }

    .states-container {
        width: 100%;
        max-width: 100%;
        padding: 14px;
        border-radius: 20px;
    }

    .states-grid {
        grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
        gap: 10px;
    }

    .state-btn {
        font-size: 18px;
        padding: 10px 0;
        border-radius: 12px;
    }

    .end-card {
        width: min(94vw, 600px);
        padding: 28px 20px;
        border-radius: 28px;
    }

    .end-title {
        font-size: 32px;
    }

    .final-scores {
        margin: 22px 0;
        font-size: 24px;
        gap: 14px;
    }

    .btn-reiniciar {
        width: 100%;
        padding: 16px 20px;
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    #loading-screen img {
        width: 88vw;
        margin-bottom: 14px;
    }

    .loading-text {
        font-size: 20px;
        text-align: center;
        padding: 0 12px;
    }

    .header img {
        height: 52px;
    }

    .score-box {
        font-size: 17px;
        border-width: 3px;
    }

    .score-box.ativo {
        transform: scale(1.03);
    }

    .game-card {
        padding: 16px 10px;
        border-width: 3px;
        box-shadow: 0 7px 0 var(--azul-escuro);
    }

    #btn-sortear {
        font-size: 18px;
        border-width: 3px;
        padding: 12px 14px;
    }

    .btn-amarelo,
    .btn-azul {
        box-shadow: 0 6px 0 var(--amarelo-escuro), 0 10px 14px rgba(0, 0, 0, 0.18);
    }

    .btn-azul {
        box-shadow: 0 6px 0 var(--azul-escuro), 0 10px 14px rgba(0, 0, 0, 0.18);
    }

    .tag-desafio {
        font-size: 14px;
        padding: 5px 14px;
    }

    .texto-pergunta {
        font-size: 19px;
    }

    .feedback-msg {
        font-size: 18px;
        min-height: 28px;
    }

    .states-container {
        padding: 10px;
        border-width: 3px;
    }

    .states-grid {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 8px;
    }

    .state-btn {
        font-size: 16px;
        border-width: 2px;
        box-shadow: 0 4px 0 var(--azul-escuro);
    }

    #end-screen {
        padding: 12px;
    }

    .end-card {
        padding: 22px 14px;
        border-width: 4px;
        border-radius: 22px;
    }

    .end-title {
        font-size: 26px;
    }

    .final-scores {
        font-size: 20px;
    }

    .btn-reiniciar {
        font-size: 20px;
        border-width: 3px;
        box-shadow: 0 6px 0 var(--verde-escuro);
    }
}
