@import url('https://fonts.googleapis.com/css2?family=Chewy&family=Gochi+Hand&display=swap');

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;
    cursor: pointer; /* Indicate it's clickable */
    user-select: none; /* Prevent text selection */
}

.problem-display-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Flexible columns for items */
    gap: clamp(10px, 2vw, 20px); /* Responsive gap */
    margin: 15px 0 25px;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
}

.logic-item-button {
    background-color: #fce4ec; /* Light pink background for items */
    border: 4px solid #f06292; /* Stronger pink border */
    border-radius: 15px;
    padding: 15px; /* Padding inside the button */
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 6px 0 #d81b60; /* Deep pink shadow */
    user-select: none;
    display: flex; /* Use flexbox for centering content */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
    min-height: 120px; /* Larger touch target */
}

.logic-item-button:hover {
    transform: translateY(-5px);    
    box-shadow: 0 10px 0 #c2185b; /* More pronounced hover shadow */
}

.logic-item-button:active {
    transform: translateY(2px);    
    box-shadow: 0 4px 0 #ad1457; /* Pressed in effect */
}

.logic-item-button svg,
.logic-item-button .emoji {
    width: 80px; /* Size of SVG/Emoji inside buttons */
    height: 80px;
    /* Removed display: block and text-align: center from here */
    /* Relying on parent flexbox for centering */
}
.logic-item-button .emoji {
    font-size: 70px; /* Larger emoji size */
    line-height: 1; /* Prevent extra space */
    /* Removed display: block and text-align: center from here */
    /* Relying on parent flexbox for centering */
}


.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;
}

.level-display {
    font-size: clamp(1.1em, 1.8vw, 1.4em);    
    margin-top: 10px;    
    color: #555;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 8px 15px;    
    border-radius: 8px;    
    border: 2px solid #64B5F6; /* Blue border for level */
    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;    
}
