@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap');

body {
    font-family: 'Poppins', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #87D47D;
    color: #333;
}

h1 {
    font-size: 3em;
    margin-bottom: 10px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}

/* Screen Management */
.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px; /* Adjust as needed */
    padding: 20px;
    box-sizing: border-box;
}

.screen.hidden {
    display: none;
}

/* Level Select Screen */
#level-select-screen h2 {
    font-size: 2.5em;
    color: #fff;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}

#level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    width: 100%;
    max-width: 400px;
}

.level-button {
    padding: 15px;
    font-size: 1.5em;
    font-weight: bold;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    border: 2px solid #2ECC71;
    border-radius: 10px;
    background: #F6F5F1;
    color: #2ECC71;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.level-button:hover:not(.locked) {
    background: #27AE60;
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

.level-button.locked {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
    border-color: #999;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

.level-button.completed {
    background: linear-gradient(45deg, #2ECC71, #27AE60);
    color: #fff;
    border-color: #1ABC9C;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Game Screen Controls */
#controls {
    display: flex; /* Changed to flex */
    flex-direction: column; /* Stack areas vertically */
    gap: 10px; /* Gap between areas */
    width: 480px; /* Keep original width for now, adjust later */
    margin-bottom: 20px;
    background: #F6F5F1;
    padding: 15px; /* Slightly more padding for the main container */
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

#info-display-area {
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 1em; /* Smaller font for info */
    color: #E67E22;
    font-weight: bold;
    padding-bottom: 5px; /* Small separator */
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

#objective-area {
    display: flex;
    flex-direction: column; /* Stack objective lines */
    align-items: center; /* Center text */
    font-size: 1em; /* Smaller font */
    color: #E67E22;
    font-weight: bold;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0,0,0,0.1); /* Small separator */
}

#objective-area > div {
    margin-bottom: 3px; /* Space between lines */
}

#objective-area > div:last-child {
    margin-bottom: 0;
}

#timer {
    color: #FF0000;
}

#action-buttons-area {
    display: flex;
    justify-content: center; /* Center buttons */
    gap: 15px; /* Space between buttons */
    padding-top: 10px;
}

.icon-btn {
    width: 40px; /* Fixed width for icon buttons */
    height: 40px; /* Fixed height for icon buttons */
    border-radius: 50%; /* Make them circular */
    background: #2ECC71;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em; /* Size of the emoji */
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: #27AE60;
    transform: translateY(-2px);
}

/* Adjust existing .btn for general buttons like Next Level, Retry */
.btn {
    padding: 8px 15px; /* Slightly smaller padding */
    font-size: 0.9em; /* Slightly smaller font */
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    background: #2ECC71;
    color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.btn:hover {
    background: #27AE60;
    transform: translateY(-2px);
}

#game-board {
    display: grid;
    grid-template-columns: repeat(8, 52px);
    grid-template-rows: repeat(8, 52px);
    padding: 10px;
    background: #A9EFAF;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3), inset 0 0 10px rgba(0,0,0,0.2);
}

.gem {
    width: 50px;
    height: 50px;
    box-sizing: border-box;
    cursor: pointer;
    position: relative;
    transition: transform 0.3s ease, filter 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    background: transparent;
    text-shadow: 2px 2px 3px rgba(0,0,0,0.3);
}

.gem:hover {
    transform: scale(1.1);
}

.gem.selected {
    transform: scale(1.2);
    filter: drop-shadow(0 0 8px #F1C40F);
    z-index: 10;
}

.gem.removed {
    animation: pop 0.4s ease forwards;
}

@keyframes pop {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.4);
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* --- Level Complete / Game Over Screens --- */
#level-complete-screen, #game-over-screen {
    background: #F6F5F1;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    padding: 30px;
    text-align: center;
}

#level-complete-screen h2, #game-over-screen h2 {
    font-size: 2.8em;
    color: #2ECC71;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

#game-over-screen h2 {
    color: #E74C3C;
}

#level-complete-screen p, #game-over-screen p {
    font-size: 1.5em;
    margin-bottom: 15px;
    color: #333;
}

#level-complete-screen .btn, #game-over-screen .btn {
    margin: 10px;
    width: 180px;
}

#level-complete-screen .fruit-display {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

#level-complete-screen .fruit-item {
    display: flex;
    align-items: center;
    margin: 5px 10px;
    font-size: 1.2em;
}

#level-complete-screen .fruit-item .emoji {
    font-size: 1.5em;
    margin-right: 5px;
}

/* --- Responsive Design for Mobile --- */
@media screen and (max-width: 600px) {
    body {
        min-height: auto;
        padding: 5px 0; /* Even less padding */
    }

    h1 {
        font-size: 1.8em; /* Even smaller title */
        margin-bottom: 3px; /* Even less margin */
    }

    /* Screen Management */
    .screen {
        padding: 3px; /* Even less padding */
    }

    /* Level Select Screen */
    #level-select-screen h2 {
        font-size: 1.5em; /* Even smaller heading */
        margin-bottom: 10px; /* Even less margin */
    }

    #level-grid {
        gap: 5px; /* Even less gap */
    }

    .level-button {
        font-size: 0.9em; /* Even smaller font */
        padding: 6px; /* Even less padding */
    }

    /* Game Screen Controls */
    #controls {
        width: 98%; /* Max width */
        max-width: 320px; /* Adjusted max-width */
        padding: 8px; /* Reduced padding */
        margin-bottom: 8px; /* Reduced margin */
        gap: 6px; /* Reduced gap */
    }

    #info-display-area {
        font-size: 0.9em; /* Smaller font */
        padding-bottom: 3px; /* Reduced padding */
    }

    #objective-area {
        font-size: 0.9em; /* Smaller font */
        padding: 3px 0; /* Reduced padding */
    }

    #objective-area > div {
        margin-bottom: 2px; /* Reduced margin */
    }

    #action-buttons-area {
        gap: 10px; /* Reduced gap */
        padding-top: 8px; /* Reduced padding */
    }

    .icon-btn {
        width: 32px; /* Smaller icon buttons */
        height: 32px;
        font-size: 1.1em; /* Smaller emoji font */
    }

    .btn {
        padding: 5px 10px; /* Reduced padding */
        font-size: 0.8em; /* Smaller font */
    }

    #game-board {
        grid-template-columns: repeat(8, 34px); /* Even smaller gems */
        grid-template-rows: repeat(8, 34px);
        padding: 3px; /* Even less padding */
    }

    .gem {
        width: 32px; /* Even smaller gem size */
        height: 32px;
        font-size: 24px; /* Even smaller emoji font */
    }

    /* Level Complete / Game Over Screens */
    #level-complete-screen, #game-over-screen {
        padding: 15px; /* Reduced padding */
    }

    #level-complete-screen h2, #game-over-screen h2 {
        font-size: 1.8em; /* Smaller font */
        margin-bottom: 10px;
    }

    #level-complete-screen p, #game-over-screen p {
        font-size: 1em; /* Smaller font */
        margin-bottom: 8px;
    }

    #level-complete-screen .btn, #game-over-screen .btn {
        width: 100%;
        margin: 3px 0;
        padding: 6px 10px;
        font-size: 0.8em;
    }

    #level-complete-screen .fruit-display {
        flex-direction: column;
        align-items: flex-start;
    }

    #level-complete-screen .fruit-item {
        font-size: 1em;
        margin: 2px 5px;
    }

    #level-complete-screen .fruit-item .emoji {
        font-size: 1.2em;
    }
}