body {
    margin: 0;
    padding: 0;
    font-family: 'Chewy', cursive; /* Fun, kid-friendly font */
    background: linear-gradient(135deg, #A8DCEC, #E0F2F7, #FFE0B2); /* Softer sky, light, and sand colors */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* Ensure it takes full viewport height */
    overflow: hidden; /* Prevent body scrollbar if content is too tall */
    max-height: 100vh;
    
    color: #333;
    text-align: center;
}

/* --- Back to Homepage Icon Button Styling --- */
.back-to-home-icon {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #777; /* Soft grey color for the icon */
    padding: 10px; /* Padding around the icon */
    border-radius: 50%; /* Make it circular */
    text-decoration: none;
    display: flex; /* Use flex to center the SVG inside */
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease-in-out;
    z-index: 101; /* Ensure it's above the game container and overlay */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Very subtle shadow */
    background-color: rgba(255, 255, 255, 0.7); /* Slightly transparent white background */
}

.back-to-home-icon:hover {
    color: #555; /* Darker grey on hover */
    transform: translateY(-2px); /* Slight lift */
    box-shadow: 0 4px 8px rgba(0,0,0,0.15); /* Slightly more prominent shadow on hover */
}

.back-to-home-icon:active {
    transform: translateY(1px); /* Press down effect */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.back-to-home-icon svg {
    width: 28px; /* Size of the SVG icon */
    height: 28px;
    fill: currentColor; /* Make SVG fill color inherit from parent 'color' property */
}
/* --- End Back to Homepage Icon Button Styling --- */


.game-container {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 25px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    padding: 20px; /* Reduced padding for more compact layout */
    max-width: 900px;
    width: 95%; /* Make it take 95% of screen width */
    box-sizing: border-box;
    border: 8px solid #FF8A80; /* Softer red border */
    position: relative;
    overflow: hidden; /* Keep game container itself from overflowing */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between; /* Distribute space */
    min-height: calc(100vh - 40px); /* Adjust based on new padding */
    max-height: 100vh; /* Prevent it from exceeding viewport height */
}

h1 {
    color: #FF8A80; /* Matching the border */
    font-size: clamp(2em, 4vw, 3em); /* More responsive for title */
    margin-bottom: 10px; /* Reduced margin */
    text-shadow: 3px 3px 0 #FFF, 5px 5px 0 #FFECB3; /* Softer gold outline */
    letter-spacing: 2px;
}

.instructions {
    font-family: 'Gochi Hand', cursive; /* Hand-written feel */
    font-size: clamp(1.2em, 2vw, 1.6em); /* Reduced font size */
    color: #81C784; /* Softer green for instructions */
    margin-bottom: 20px; /* Reduced margin */
    padding: 8px 15px; /* Reduced padding */
    background-color: rgba(255, 255, 255, 0.85);
    border-radius: 15px;
    border: 2px dashed #81C784;
    line-height: 1.2;
}

.current-problem-display {
    font-size: clamp(4em, 12vw, 7em); /* Slightly reduced max size */
    font-weight: bold;
    margin: 15px 0 25px; /* Reduced margins */
    color: #957DAD; /* Softer purple */
    text-shadow: 5px 5px 0 #FFF, 8px 8px 0 #FFCCBC; /* Softer peach outline */
    animation: bounce 2s infinite ease-in-out;
    line-height: 1; /* Prevent extra space around problem */
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); } /* Slightly less bounce */
}

.answer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); /* Use minmax for responsive columns */
    gap: clamp(8px, 1.5vw, 16px); /* Responsive gap */
    margin-top: 15px;
    width: 100%;
    padding-bottom: 10px;
    max-height: none;         
    overflow-y: visible;       
}

.answer-button {
    border: 4px solid;
    border-radius: 12px;
    font-size: clamp(1.8em, 3.5vw, 2.6em); /* Larger and responsive font size */
    font-weight: bold;
    color: #fff; /* Base color, overridden by specific button colors below */
    padding: 12px 0; /* Consistent vertical padding */
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 6px 0;
    user-select: none;
    font-family: 'Chewy', cursive;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center; /* Ensure text is horizontally centered too */
    min-height: 80px;         
    overflow: hidden;  
    line-height: 1;         
}

.answer-button:hover {
    transform: translateY(-3px);         
    box-shadow: 0 9px 0;         
}

.answer-button:active {
    transform: translateY(2px);         
    box-shadow: 0 4px 0;         
}

/* Softer Color classes for buttons (Ensuring good contrast for text) */
.color-1 { background-color: #FFECB3; border-color: #FFDDAA; box-shadow: 0 6px 0 #FFDDAA; color: #6A5ACD;}         
.color-1:hover { box-shadow: 0 9px 0 #FFDDAA; }
.color-1:active { box-shadow: 0 4px 0 #FFDDAA; }

.color-2 { background-color: #FFC0CB; border-color: #FFB6C1; box-shadow: 0 6px 0 #FFB6C1; color: #C71585;}         
.color-2:hover { box-shadow: 0 9px 0 #FFB6C1; }
.color-2:active { box-shadow: 0 4px 0 #FFB6C1; }

.color-3 { background-color: #D4EDDA; border-color: #B3E0B7; box-shadow: 0 6px 0 #B3E0B7; color: #4CAF50;}         
.color-3:hover { box-shadow: 0 9px 0 #B3E0B7; }
.color-3:active { box-shadow: 0 4px 0 #B3E0B7; }

.color-4 { background-color: #B2EBF2; border-color: #80DEEA; box-shadow: 0 6px 0 #80DEEA; color: #1E90FF;}         
.color-4:hover { box-shadow: 0 9px 0 #80DEEA; }
.color-4:active { box-shadow: 0 4px 0 #80DEEA; }

.color-5 { background-color: #E1BEE7; border-color: #CE93D8; box-shadow: 0 6px 0 #CE93D8; color: #8A2BE2;}         
.color-5:hover { box-shadow: 0 9px 0 #CE93D8; }
.color-5:active { box-shadow: 0 4px 0 #CE93D8; }

.color-6 { background-color: #FFAB91; border-color: #FF8A65; box-shadow: 0 6px 0 #FF8A65; color: #B22222;}         
.color-6:hover { box-shadow: 0 9px 0 #FF8A65; }
.color-6:active { box-shadow: 0 4px 0 #FF8A65; }

.message {
    font-size: clamp(1.6em, 2.5vw, 2.2em);         
    font-weight: bold;
    margin-top: 20px;         
    min-height: 1.2em;         
    text-shadow: 2px 2px 0 #fff;
}

.correct {
    color: #28a745;         
}

.wrong {
    color: #dc3545;         
    animation: shake 0.5s;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    50% { transform: translateX(10px); }
    75% { transform: translateX(-10px); }
    100% { transform: translateX(0); }
}

.score-board {
    font-size: clamp(1.1em, 1.8vw, 1.4em);         
    margin-top: 15px;         
    color: #555;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 8px 15px;         
    border-radius: 8px;         
    border: 2px solid #FFD700;
    font-family: 'Gochi Hand', cursive;
}

.control-buttons {
    display: flex;
    gap: 15px;         
    margin-top: 20px;         
}

.control-buttons button {
    background-color: #FFB300;         
    color: #fff;
    border: none;
    padding: clamp(8px, 2vw, 12px) clamp(15px, 4vw, 25px);         
    font-size: clamp(1.1em, 2vw, 1.4em);         
    border-radius: 12px;         
    cursor: pointer;
    transition: background-color 0.3s ease;
    box-shadow: 0 4px 0 #E6A000;         
    font-family: 'Chewy', cursive;
}

.control-buttons button:hover {
    background-color: #E6A000;
}

.control-buttons button:active {
    transform: translateY(2px);         
    box-shadow: 0 2px 0 #E6A000;
}

/* Start Game Overlay */
.start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(173, 216, 230, 0.95);         
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;         
    border-radius: 25px;         
}

.start-overlay h2 {
    font-size: clamp(2em, 5vw, 4em);
    color: #FF8A80;
    text-shadow: 3px 3px 0 #FFF, 5px 5px 0 #FFECB3;
    margin-bottom: 40px;
}

.start-button {
    background-color: #81C780;         
    color: white;
    padding: clamp(15px, 4vw, 25px) clamp(30px, 8vw, 50px);
    font-size: clamp(2em, 5vw, 3em);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 10px 0 #5CB85C;         
    transition: all 0.2s ease-in-out;
    font-family: 'Chewy', cursive;
}

.start-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 0 #5CB85C;
}

.start-button:active {
    transform: translateY(5px);
    box-shadow: 0 5px 0 #5CB85C;
}

.hidden {
    display: none;
}

.game-over-message {
    font-size: clamp(1.8em, 3vw, 2.5em);         
    color: #4CAF50;
    font-weight: bold;
    text-shadow: 2px 2px 0 #FFF;
    margin-bottom: 15px;         
}
