/* Math Express - Kid-Friendly Game Styles */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One:wght@400&family=Nunito:wght@400;600;700&display=swap');

:root {
    --primary-blue: #4A90E2;
    --bright-green: #7ED321;
    --sunshine-yellow: #F5A623;
    --warm-orange: #FF8C42;
    --soft-red: #FF6B6B;
    --purple-fun: #9013FE;
    --sky-blue: #87CEEB;
    --grass-green: #90EE90;
    --cloud-white: #F8F9FA;
    --train-gray: #606060;
}

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

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, var(--sky-blue) 0%, var(--sunshine-yellow) 100%);
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

#gameContainer {
    width: 100%;
    height: 100vh;
    position: relative;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Start Screen */
#startScreen {
    background: linear-gradient(135deg, var(--sky-blue) 0%, var(--grass-green) 100%);
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.3) 20px, transparent 20px),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.2) 15px, transparent 15px),
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.1) 25px, transparent 25px);
}

.title-container {
    text-align: center;
    animation: bounceIn 1s ease-out;
}

.game-title {
    font-family: 'Fredoka One', cursive;
    font-size: 4rem;
    color: var(--primary-blue);
    text-shadow: 3px 3px 0px var(--sunshine-yellow), 6px 6px 10px rgba(0,0,0,0.2);
    margin-bottom: 1rem;
    animation: pulse 2s infinite alternate;
}

.subtitle {
    font-size: 1.5rem;
    color: var(--train-gray);
    font-weight: 600;
    margin-bottom: 2rem;
}

.instructions {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 2rem;
    margin: 2rem 0;
    border: 3px solid var(--warm-orange);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.instructions p {
    font-size: 1.2rem;
    margin: 0.5rem 0;
    color: var(--train-gray);
    font-weight: 600;
}

/* Buttons */
.big-button {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(45deg, var(--bright-green), var(--grass-green));
    color: white;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.big-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.big-button:active {
    transform: translateY(-1px);
}

/* Math Screen */
#mathScreen {
    background: linear-gradient(135deg, var(--cloud-white) 0%, var(--sky-blue) 100%);
    flex-direction: column;
}

.math-container {
    width: 90%;
    max-width: 800px;
    text-align: center;
}

.hud {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.timer, .score, .math-score {
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--train-gray);
    border: 3px solid var(--warm-orange);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    min-width: 150px;
}

.problem-container {
    margin: 3rem 0;
}

.math-problem {
    font-family: 'Fredoka One', cursive;
    font-size: 4rem;
    color: var(--primary-blue);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.answer-box {
    display: inline-block;
    min-width: 1.5em;
    padding: 0.1em 0.3em;
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid var(--sunshine-yellow);
    border-radius: 10px;
    color: var(--train-gray);
    font-weight: 700;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.feedback {
    font-size: 2rem;
    font-weight: 700;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback.correct {
    color: var(--bright-green);
    animation: correctPulse 0.6s ease-out;
}

.feedback.incorrect {
    color: var(--soft-red);
    animation: shake 0.6s ease-out;
}

.answer-display {
    font-size: 2rem;
    font-weight: 700;
    color: var(--train-gray);
    margin: 2rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    border: 2px solid var(--sunshine-yellow);
}

/* Number Pad */
.number-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    max-width: 300px;
    margin: 0 auto;
}

.num-btn {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    padding: 1rem;
    border: none;
    border-radius: 20px;
    background: linear-gradient(45deg, var(--sunshine-yellow), var(--warm-orange));
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.1s, box-shadow 0.1s;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    min-height: 70px;
}

.num-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.num-btn:active {
    transform: translateY(0);
}

.num-btn.submit {
    background: linear-gradient(45deg, var(--bright-green), var(--grass-green));
}

.num-btn.clear {
    background: linear-gradient(45deg, var(--soft-red), #FF8A80);
}

/* Train Screen */
#trainScreen {
    background: linear-gradient(135deg, var(--sky-blue) 0%, var(--grass-green) 100%);
    flex-direction: column;
    padding: 1rem;
}

.train-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.train-info {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.steam-counter, .distance-counter, .speed-meter {
    background: rgba(255, 255, 255, 0.9);
    padding: 0.8rem 1.2rem;
    border-radius: 15px;
    font-weight: 700;
    color: var(--train-gray);
    border: 2px solid var(--warm-orange);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-btn {
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.1s, box-shadow 0.1s;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

#boostBtn {
    background: linear-gradient(45deg, var(--warm-orange), var(--sunshine-yellow));
}

#brakeBtn {
    background: linear-gradient(45deg, var(--soft-red), #FF8A80);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#trainCanvas {
    border: 4px solid var(--primary-blue);
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    background: linear-gradient(to bottom, var(--sky-blue) 0%, var(--grass-green) 100%);
    max-width: 100%;
    height: auto;
}

/* Game Over Screen */
#gameOverScreen {
    background: linear-gradient(135deg, var(--purple-fun) 0%, var(--primary-blue) 100%);
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.2) 30px, transparent 30px),
        radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.1) 20px, transparent 20px);
}

.game-over-container {
    text-align: center;
    color: white;
    animation: bounceIn 1s ease-out;
}

.game-over-title {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
}

.stats {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 2rem;
    margin: 2rem 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.stat {
    font-size: 1.5rem;
    margin: 1rem 0;
    font-weight: 700;
}

.game-over-buttons {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Mute Button */
.mute-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s;
    z-index: 1000;
}

.mute-btn:hover {
    transform: scale(1.1);
}

/* Animations */
@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

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

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 3rem;
    }
    
    .math-problem {
        font-size: 3rem;
    }
    
    .hud {
        justify-content: center;
    }
    
    .timer, .score, .math-score {
        min-width: 120px;
        font-size: 1rem;
        padding: 0.8rem;
    }
    
    .train-hud {
        flex-direction: column;
        align-items: center;
    }
    
    .train-info {
        justify-content: center;
    }
    
    .game-over-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .big-button {
        font-size: 1.5rem;
        padding: 0.8rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 2.5rem;
    }
    
    .math-problem {
        font-size: 2.5rem;
    }
    
    .number-pad {
        max-width: 250px;
        gap: 0.5rem;
    }
    
    .num-btn {
        font-size: 1.5rem;
        padding: 0.8rem;
        min-height: 60px;
    }
    
    .instructions {
        padding: 1rem;
    }
    
    .instructions p {
        font-size: 1rem;
    }
}