body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align items to the top */
    margin-top: 20px;
    background-color: #f0f0f0;
    height: 100vh;
    overflow: hidden; /* Hide scrollbars during splash */
    cursor: url('monkey_hand_cursor.png'), auto;
}

body.game-started {
    height: auto;
    overflow: auto;
}

#start-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(to bottom, #87CEEB, #E0F6FF);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#splash-animation-container {
    position: relative;
    width: 600px;
    height: 400px;
}

#main-menu-container, #difficulty-selection-container, #map-selection-container {
    position: absolute;
    text-align: center;
}

#main-menu-container h1, #difficulty-selection-container h2, #map-selection-container h2 {
    font-size: 4em;
    color: white;
    text-shadow: 2px 2px 4px #00000080;
    margin-bottom: 20px;
}

#difficulty-selection-container h2, #map-selection-container h2 {
    font-size: 3em;
}

#difficulty-selection-container {
    display: none; /* starts hidden */
    flex-direction: column;
    align-items: center;
}

#map-selection-container {
    display: none; /* starts hidden */
    flex-direction: column;
    align-items: center;
}

#maps-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

.map-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    cursor: url('monkey_hand_pointer.png'), pointer;
    min-width: 160px;
}

.map-card:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.map-preview-img {
    width: 160px;
    height: 107px;
    border: 2px solid white;
    border-radius: 4px;
    margin-bottom: 8px;
    pointer-events: none; /* Clicks should go to parent card */
}

.map-select-button {
    font-size: 1em;
    padding: 8px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: url('monkey_hand_pointer.png'), pointer;
    width: 160px; /* match image width */
    pointer-events: none; /* Clicks should go to parent card */
}

.difficulty-button {
    font-size: 1.5em;
    padding: 15px 30px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: url('monkey_hand_pointer.png'), pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    margin-bottom: 15px;
    width: 250px;
}

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

.difficulty-desc {
    font-size: 0.7em;
    font-weight: normal;
}

.back-button {
    font-size: 1em;
    padding: 10px 20px;
    background-color: #f44336; /* Red for back */
    color: white;
    border: none;
    border-radius: 8px;
    cursor: url('monkey_hand_pointer.png'), pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    margin-top: 10px;
    width: 250px;
}

.back-button:hover {
    background-color: #d32f2f;
}

#back-to-menu-button {
    font-size: 1em;
    padding: 10px 20px;
    background-color: #f44336; /* Red for back */
    color: white;
    border: none;
    border-radius: 8px;
    cursor: url('monkey_hand_pointer.png'), pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    margin-top: 10px;
    width: 250px;
}

#back-to-menu-button:hover {
    background-color: #d32f2f;
}

#splash-monkey {
    position: absolute;
    width: 80px;
    height: 80px;
    left: 100px;
    top: 160px;
    transform: scaleX(-1); /* Face right */
}

#splash-balloon {
    position: absolute;
    width: 60px;
    height: 80px;
    left: 400px;
    top: 160px;
    transition: transform 0.2s, opacity 0.2s;
}

#splash-balloon.popped {
    transform: scale(1.5);
    opacity: 0;
}

.splash-dart {
    position: absolute;
    width: 36px;
    height: 16px;
    left: 160px; /* Start near monkey's hand */
    top: 180px;
    visibility: hidden;
}

.splash-dart.flying {
    visibility: visible;
    animation: fly-across 0.4s linear forwards;
}

@keyframes fly-across {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(240px); /* Target (400) - Start (160) */
        opacity: 1;
    }
}

#play-game-button {
    font-size: 1.5em;
    padding: 15px 30px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: url('monkey_hand_pointer.png'), pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

#play-game-button:hover {
    background-color: #45a049;
}

#game-container {
    display: none; /* Initially hidden */
    gap: 20px;
}

#gameCanvas {
    border: 2px solid #333;
    background-color: #fff; /* Will be covered by background image */
    cursor: url('monkey_hand_pointer.png'), pointer;
}

#gameCanvas.placing-tower {
    cursor: none;
}

#ui-panel {
    width: 200px;
    padding: 15px;
    background-color: #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

#ui-panel h1 {
    font-size: 1.5em;
    text-align: center;
    margin-bottom: 10px;
}

#ui-panel div {
    margin-bottom: 8px;
    font-size: 0.9em;
}

#ui-panel button {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: url('monkey_hand_pointer.png'), pointer;
    font-size: 0.9em;
}

#ui-panel button:hover {
    background-color: #45a049;
}

#autoStartButton {
    background-color: #5bc0de; /* Info blue */
}

#autoStartButton:hover {
    background-color: #31b0d5;
}

#autoStartButton.active {
    background-color: #337ab7; /* Darker blue to show it's active */
    box-shadow: inset 0 3px 5px rgba(0,0,0,.125);
}

#ui-panel button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

#tower-selection h3 {
    font-size: 1.1em;
    margin-top: 15px;
    margin-bottom: 5px;
}

.tower-button {
    background-color: #007bff !important; /* Use important to override general button styles if needed */
    text-align: left;
    cursor: url('monkey_hand_pointer.png'), pointer;
}

.tower-button.selected {
    background-color: #0056b3 !important;
    outline: 2px solid #003366;
}

.tower-button:hover {
    background-color: #0056b3 !important;
}

#messageDisplay {
    margin-top: 15px;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 40px;
    font-size: 0.85em;
    text-align: center;
}

#upgrade-panel {
    border-top: 1px solid #ccc;
    margin-top: 15px;
    padding-top: 10px;
}

.upgrade-path {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 8px;
    margin-bottom: 10px;
}

.upgrade-path.locked {
    background-color: #e9ecef;
    opacity: 0.6;
}

.upgrade-path h4 {
    font-size: 1em;
    margin: 0 0 5px 0;
}

.upgrade-path p {
    font-size: 0.85em;
    margin: 0 0 5px 0;
}

.upgrade-desc {
    font-style: italic;
    color: #666;
    font-size: 0.8em !important;
}

.upgrade-button {
    font-size: 0.8em !important;
    padding: 5px !important;
    background-color: #28a745 !important; /* Green for upgrade */
    cursor: url('monkey_hand_pointer.png'), pointer;
}

.upgrade-button:hover {
     background-color: #218838 !important;
}

.sell-button {
    background-color: #dc3545 !important; /* Red for sell */
    cursor: url('monkey_hand_pointer.png'), pointer;
}

#lock-shooting-button {
    background-color: #17a2b8 !important; /* Info blue */
    cursor: url('monkey_hand_pointer.png'), pointer;
    margin-bottom: 10px;
}

#lock-shooting-button:hover {
    background-color: #138496 !important;
}

#speedToggleButton {
    background-color: #ff9500; /* Orange color */
}

#speedToggleButton:hover {
    background-color: #e6850e;
}

#speedToggleButton.active {
    background-color: #cc7a00; /* Darker orange to show it's active */
    box-shadow: inset 0 3px 5px rgba(0,0,0,.125);
}

#sandbox-mode-button {
    font-size: 1.5em;
    padding: 15px 30px;
    background-color: #ff9500; /* Orange color for sandbox */
    color: white;
    border: none;
    border-radius: 8px;
    cursor: url('monkey_hand_pointer.png'), pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    margin-top: 10px;
}

#sandbox-mode-button:hover {
    background-color: #e6850e;
}

.balloon-button {
    background-color: #ff6b35 !important; /* Orange color for balloons */
    text-align: left;
    cursor: url('monkey_hand_pointer.png'), pointer;
}

.balloon-button.selected {
    background-color: #e55a2b !important;
    outline: 2px solid #b8441f;
}

.balloon-button:hover {
    background-color: #e55a2b !important;
}

#sandbox-toggle-button {
    background-color: #9c27b0 !important; /* Purple for sandbox toggle */
    margin-bottom: 10px;
    cursor: url('monkey_hand_pointer.png'), pointer;
}

#sandbox-toggle-button:hover {
    background-color: #7b1fa2 !important;
}

.balloon-to-tower-button {
    background-color: #9c27b0 !important; /* Purple for consistency with sandbox toggle */
    margin-bottom: 10px;
    cursor: url('monkey_hand_pointer.png'), pointer;
    width: 100%;
    padding: 10px;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9em;
}

.balloon-to-tower-button:hover {
    background-color: #7b1fa2 !important;
}