/**
 * Kids Math Game CSS
 */
:root {
    --primary: #FF6B6B;
    --secondary: #4ECDC4;
    --accent: #FFE66D;
    --accent-alt: #9D4EDD;
    --bg-color: #F7FFF7;
    --text-dark: #2F3542;
    --shadow: rgba(47, 53, 66, 0.15);
}

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

body {
    font-family: 'Fredoka One', cursive;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* Background elements reused from previous games */
.background-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    z-index: -1;
    opacity: 0.6;
    animation: floatBg 20s infinite alternate cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

.shape-1 {
    width: 300px;
    height: 300px;
    background: var(--secondary);
    top: -50px;
    left: -50px;
}

.shape-2 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    bottom: -100px;
    right: -50px;
    animation-delay: -5s;
}

.shape-3 {
    width: 250px;
    height: 250px;
    background: var(--accent-alt);
    top: 40%;
    left: 20%;
    animation-delay: -10s;
}

@keyframes floatBg {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(50px, -50px) scale(1.1); }
    100% { transform: translate(-30px, 60px) scale(0.9); }
}

/* Header & Back Button */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    z-index: 10;
}

.back-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 1.2rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    backdrop-filter: blur(5px);
    transition: all 0.3s;
}

.back-button:active {
    transform: scale(0.95);
}

.back-button.disabled {
    opacity: 0.8;
    background: rgba(220, 220, 220, 0.4);
    color: #747d8c;
    box-shadow: none;
}

.score-container {
    display: flex;
    gap: 5px;
    font-size: 2rem;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

.star {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Main Container */
.game-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    gap: 2rem;
    z-index: 10;
}

/* Equation Display */
.equation-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.85);
    padding: 20px 40px;
    border-radius: 30px;
    box-shadow: 0 15px 35px var(--shadow), inset 0 0 0 4px rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    font-size: 5rem;
    color: var(--text-dark);
}

.equation-term, .equation-op, .equation-eq {
    display: flex;
    justify-content: center;
    align-items: center;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1);
}

.equation-term {
    min-width: 80px;
    color: var(--primary);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hidden-answer {
    color: #ced6e0;
    border-bottom: 5px dashed #ced6e0;
    min-width: 80px;
    text-align: center;
}

.equation-op, .equation-eq {
    color: var(--secondary);
}

.revealed {
    color: var(--accent-alt);
    border-bottom: none;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Blocks Display Area */
.blocks-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    min-height: 180px;
    margin-top: -10px;
}

.block-group {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 5px;
    min-width: 120px;
}

.block-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
    transform-origin: bottom;
}

.block-number {
    font-size: 2.2rem;
    color: #1e272e;
    font-weight: 800;
    text-shadow: 2px 2px 0px rgba(255,255,255,0.7), -1px -1px 0px rgba(255,255,255,0.7);
    z-index: 2;
}

.block-group-op {
    font-size: 3rem;
    color: rgba(255,255,255,0.7);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
    margin-bottom: 25px; /* line it up with the images, above the numbers */
}

.number-block {
    width: 120px;
    height: auto;
    max-height: 180px;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.15));
}

/* Delays for block entrances */
.delay-0 { animation-delay: 0.1s; }
.delay-1 { animation-delay: 0.3s; }

/* Options Container */
.options-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    min-height: 120px; /* Reserve space so the screen ignores DOM shifts */
}

.option-card {
    background: #FFF;
    border-radius: 20px;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    color: var(--accent-alt);
    box-shadow: 0 10px 25px var(--shadow), inset 0 -6px 0 rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.option-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.2), inset 0 -6px 0 rgba(0,0,0,0.1);
}

.option-card.pressing {
    transform: translateY(4px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2), inset 0 -2px 0 rgba(0,0,0,0.1);
}

/* States */
.correct-flash {
    background-color: #4ade80 !important;
    color: white !important;
    transform: scale(1.1);
}

.wrong-flash {
    background-color: #f87171 !important;
    color: white !important;
    animation: shake 0.4s ease-in-out;
}

.penalty-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: transparent;
}
.penalty-backdrop.hidden {
    display: none;
}

.penalty {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
    border: 3px solid #ff4757;
}
.penalty::after {
    content: attr(data-penalty);
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #ff4757;
    text-shadow: 1px 1px 0px #fff, -1px -1px 0px #fff;
    font-weight: 800;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px) rotate(-5deg); }
    40%, 80% { transform: translateX(10px) rotate(5deg); }
}

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

@keyframes slideUp {
    0% { transform: translateY(50px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Confetti */
.confetti {
    position: fixed;
    top: -10px;
    width: 15px;
    height: 15px;
    pointer-events: none;
    z-index: 1000;
    animation: fall linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(110vh) rotate(720deg);
    }
}

/* Sequential Reveal Animations */
.hide-initially {
    opacity: 0;
    transform: scale(0.5);
}

.reveal-anim {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.anim-bounce-mark {
    animation: floatMark 2s ease-in-out infinite alternate;
}

@keyframes floatMark {
    0% { transform: translateY(0px) scale(1); }
    100% { transform: translateY(-10px) scale(1.1); }
}

.floating-icon {
    animation: floatItem 3s ease-in-out infinite alternate;
}
@keyframes floatItem {
    0% { transform: translateY(0px) rotate(-5deg); }
    100% { transform: translateY(-15px) rotate(10deg); }
}

@keyframes popInResult {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.4); }
    100% { transform: scale(1.3); opacity: 1; }
}

.result-block-wrapper {
    animation: popInResult 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* ============================
   RESPONSIVE - MOVILES VERTICALES
   ============================ */
@media (max-width: 480px) {
    .game-header {
        padding: 0.8rem 1rem;
    }
    
    .back-button {
        font-size: 1rem;
        padding: 0.4rem 0.8rem;
    }
    
    .score-container {
        font-size: 1.5rem;
    }
    
    .game-container {
        padding: 10px;
        gap: 1.5rem;
        justify-content: flex-start;
        margin-top: 2rem;
    }
    
    .equation-container {
        font-size: 3.5rem;
        padding: 15px 20px;
        gap: 10px;
        border-radius: 20px;
    }
    
    .hidden-answer {
        min-width: 55px;
    }
    
    .blocks-container {
        min-height: 120px;
        gap: 10px;
        margin-top: 0;
    }
    
    .number-block {
        width: 70px;
        max-height: 110px;
    }
    
    .block-group {
        min-width: 70px;
    }
    
    .block-number {
        font-size: 1.6rem;
    }
    
    .block-group-op {
        font-size: 2rem;
        margin-bottom: 15px;
    }
    
    .options-container {
        gap: 15px;
        min-height: 90px;
    }
    
    .option-card {
        width: 75px;
        height: 75px;
        font-size: 2.8rem;
    }
}
