body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f0f0f0;
    margin: 20px;
}

h1, h2 {
    color: #333;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 1000px;
}

.item-selection, .grid-actions, .statistics, .profile-management { /* Added .profile-management */
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    text-align: center;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fafafa;
}

.item-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.item-buttons button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 5px;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    width: 60px;
    height: 60px;
}

.item-buttons button img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    pointer-events: none;
}


.item-buttons button:hover {
    background-color: #45a049;
}

.item-buttons button.selected {
    background-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.5);
}

#clear-all-items {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 10px 15px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

#clear-all-items:hover {
    background-color: #c82333;
}

/* Styles for instructions */
.instruction-text {
    font-size: 0.9em;
    color: #555;
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #e9e9e9;
    border-radius: 5px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
    max-width: 250px;
    line-height: 1.4;
}

/* Style for the Pressure Nozzle Toggle */
.nozzle-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1em;
    color: #333;
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f8f8f8;
    transition: background-color 0.2s ease;
}

.nozzle-toggle-label:hover {
    background-color: #e0e0e0;
}

.nozzle-toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4CAF50;
}

/* Ensure grid-actions content stacks vertically and is centered */
.grid-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* NEW: Styles for Profile Management */
.profile-management h2 {
    margin-bottom: 5px;
}

.profile-input-group,
.profile-selection-group {
    display: flex;
    flex-wrap: wrap; /* Allows items to wrap on smaller screens */
    gap: 10px;
    justify-content: center;
    align-items: center;
    width: 100%; /* Ensure groups take full width of parent */
}

#profile-name-input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
    flex-grow: 1; /* Allow input to grow */
    min-width: 150px; /* Minimum width before wrapping */
}

#save-profile-btn,
#load-profile-btn,
#delete-profile-btn {
    padding: 10px 15px;
    font-size: 1em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#save-profile-btn {
    background-color: #007bff;
    color: white;
}

#save-profile-btn:hover {
    background-color: #0056b3;
}

#profile-select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
    background-color: white;
    flex-grow: 1;
    min-width: 150px;
}

#load-profile-btn {
    background-color: #28a745;
    color: white;
}

#load-profile-btn:hover {
    background-color: #218838;
}

.delete-btn { /* Specific style for delete button */
    background-color: #dc3545;
    color: white;
}

.delete-btn:hover {
    background-color: #c82333;
}


.farm-grid {
    display: grid;
    border: 1px solid #333;
    width: fit-content;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    margin-bottom: 20px;
    position: relative;
}

.grid-cell {
    width: 30px;
    height: 30px;
    border: 1px solid #eee;
    box-sizing: border-box;
    background-color: #D3BE1B;
    cursor: pointer;
    position: relative;
    overflow: visible;
    z-index: 0;
}

.grid-cell:hover {
    background-color: #D3C691;
}

/* Base styles for all placed items on the grid */
.grid-cell.regular-sprinkler,
.grid-cell.quality-sprinkler,
.grid-cell.iridium-sprinkler,
.grid-cell.normal-scarecrow,
.grid-cell.deluxe-scarecrow {
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: center bottom;
    background-size: contain;
    background-image: none;
}

/* Specific styles for sprites (using pseudo-elements for better control) */
.grid-cell.regular-sprinkler::after,
.grid-cell.quality-sprinkler::after,
.grid-cell.iridium-sprinkler::after,
.grid-cell.normal-scarecrow::after,
.grid-cell.deluxe-scarecrow::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background-repeat: no-repeat;
    background-position: center bottom;
    z-index: 1;
    pointer-events: none;
}

/* Individual sprite images and their specific heights for overlap */
.grid-cell.regular-sprinkler::after {
    background-image: url('assets/regular_sprinkler.png');
    height: 100%;
    background-size: contain;
}

.grid-cell.quality-sprinkler::after {
    background-image: url('assets/quality_sprinkler.png');
    height: 100%;
    background-size: contain;
}

.grid-cell.iridium-sprinkler::after {
    background-image: url('assets/iridium_sprinkler.png');
    height: 100%;
    background-size: contain;
}

/* Styles for pressurized sprinklers */
.grid-cell.regular-sprinkler.has-nozzle::after {
    background-image: url('assets/regular_sprinkler_nozzle.png');
}

.grid-cell.quality-sprinkler.has-nozzle::after {
    background-image: url('assets/quality_sprinkler_nozzle.png');
}

.grid-cell.iridium-sprinkler.has-nozzle::after {
    background-image: url('assets/iridium_sprinkler_nozzle.png');
}


.grid-cell.normal-scarecrow::after {
    background-image: url('assets/normal_scarecrow.png');
    height: 48px;
    background-size: contain;
    top: -18px;
    bottom: unset;
}

.grid-cell.deluxe-scarecrow::after {
    background-image: url('assets/deluxe_scarecrow.png');
    height: 48px;
    background-size: contain;
    top: -18px;
    bottom: unset;
}


/* Range indication styles */
.watered-tile {
    background-color: #624DFF;
}

.protected-tile {
    background-color: #4CAF50;
}