/* Basic Reset & Body Style */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column; /* Stack title above game */
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(to bottom, #87CEEB 60%, #8FBC8F 40%); /* SkyBlue to DarkSeaGreen */
    color: #333;
    overflow: hidden; /* Prevent scrollbars */
    padding: 10px; /* Add padding for small screens */
}

h1 {
    margin-bottom: 15px; /* Reduced margin */
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-size: 2.5em; /* Slightly smaller base size */
    text-align: center; /* Ensure centering */
}

/* Game Area */
#game-container {
    /* Use width/height relative to viewport, but also max */
    width: 90vw; /* Increase vw usage */
    height: 75vh; /* Increase vh usage */
    max-width: 800px;
    max-height: 600px;
    background-color: rgba(143, 188, 143, 0.7);
    border: 3px solid #556B2F;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    cursor: crosshair;
}

/* Info Display Area */
#info-display {
    position: absolute;
    top: 10px; /* Slightly less space */
    left: 10px;
    background-color: rgba(0, 0, 0, 0.65); /* Slightly more opaque */
    color: #fff;
    padding: 8px 12px; /* Reduced padding */
    border-radius: 8px;
    font-size: 1em; /* Adjusted base size */
    font-weight: bold;
    z-index: 10;
    text-shadow: 1px 1px 2px black;
    display: flex;
    gap: 15px; /* Reduced gap */
}

#score-display, #timer-display {
    margin: 0;
}

/* Grass Element Style */
.grass {
    position: absolute;
    font-size: 38px; /* Slightly smaller base size */
    cursor: pointer;
    user-select: none; /* Prevent text selection on tap */
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10+ */
    transition: transform 0.15s ease-out, opacity 0.3s ease-in-out;
    animation: fade-in 0.3s ease-in-out;
    will-change: transform, opacity;
    line-height: 1;
}

.grass:hover {
    /* Hover might not be relevant on mobile, but keep for desktop */
    transform: scale(1.25);
}

.grass.golden {
    filter: drop-shadow(0 0 5px gold);
    /* Golden grass might be slightly larger visually due to emoji */
}

@keyframes fade-in {
    from { opacity: 0; transform: scale(0.5) rotate(-30deg); }
    to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.grass.clicked {
    transform: scale(0.7);
    opacity: 0.3;
    transition: transform 0.1s ease-in, opacity 0.1s ease-in;
}

/* Game Over Screen */
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8); /* Slightly darker */
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
    padding: 15px; /* Add padding */
}

#game-over-screen:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

#game-over-screen h2 {
    font-size: 2.5em; /* Base size adjusted */
    margin-bottom: 15px;
    color: #ffdd57;
}

#game-over-screen p {
    font-size: 1.5em; /* Base size adjusted */
    margin-bottom: 25px;
}

#restart-button {
    padding: 12px 25px; /* Base size adjusted */
    font-size: 1.1em; /* Base size adjusted */
    font-weight: bold;
    color: #333;
    background-color: #ffdd57;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    user-select: none; /* Prevent selection on button */
    -webkit-user-select: none;
    -ms-user-select: none;
}

#restart-button:hover {
    background-color: #ffcc00;
    transform: scale(1.05);
}

/* Style for when button is actively pressed */
#restart-button:active {
    transform: scale(0.98);
    background-color: #e6b800; /* Even darker gold */
}


.hidden {
    /* Use visibility and opacity for transitions */
    /* display: none !important; */
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Prevent interaction when hidden */
}


/* === Responsive Adjustments === */

/* Medium Screens (Tablets, smaller laptops) */
@media (max-width: 768px) {
    h1 {
        font-size: 2.2em;
    }

    #info-display {
        font-size: 0.9em;
        padding: 7px 10px;
        gap: 12px;
    }

    .grass {
        font-size: 35px; /* Slightly smaller grass */
    }

     #game-over-screen h2 {
        font-size: 2.2em;
    }

    #game-over-screen p {
        font-size: 1.3em;
    }

    #restart-button {
        padding: 10px 20px;
        font-size: 1em;
    }
}


/* Small Screens (Mobile Phones) */
@media (max-width: 480px) {
    body {
        min-height: calc(100vh - 20px); /* Account for body padding */
    }

    h1 {
        font-size: 1.8em;
        margin-bottom: 10px;
    }

    #game-container {
        width: 95vw; /* Use even more width */
        height: 70vh; /* Adjust height slightly if needed */
        border-width: 2px; /* Thinner border */
        border-radius: 10px;
    }

    #info-display {
        font-size: 0.85em; /* Smaller text */
        padding: 6px 8px;
        gap: 10px;
        left: 5px; /* Closer to edge */
        top: 5px;
        border-radius: 5px;
    }

    .grass {
        font-size: 32px; /* Smaller grass for easier tapping */
    }

    /* Make hover effect less pronounced on devices that might support it */
    .grass:hover {
        transform: scale(1.15); /* Smaller hover */
    }

    #game-over-screen {
        padding: 10px;
    }

     #game-over-screen h2 {
        font-size: 2em;
    }

    #game-over-screen p {
        font-size: 1.2em;
        margin-bottom: 20px;
    }

    #restart-button {
        padding: 12px 25px; /* Keep button reasonably large for tapping */
        font-size: 1em;
    }
    /* Disable hover styles on devices that don't truly support hover */
    @media (hover: none) {
        #restart-button:hover {
            background-color: #ffdd57; /* Revert to base color */
            transform: none;
        }
         .grass:hover {
            transform: none; /* Remove grass hover */
         }
    }
}

/* Very Small Screens (Optional extra refinement) */
@media (max-width: 360px) {
     h1 {
        font-size: 1.6em;
    }
     #info-display {
        font-size: 0.8em;
         /* Stack score/timer vertically */
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
     }
     .grass {
        font-size: 30px;
     }
      #game-over-screen h2 {
        font-size: 1.8em;
    }
     #game-over-screen p {
        font-size: 1.1em;
    }
}