body {
    margin: 0;
    overflow: hidden;
    font-family: Arial, sans-serif;
}

#gameCanvas {
    width: 100vw;
    height: 100vh;
    display: block;
    cursor: pointer;
}

.menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    text-align: center;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

.close-menu-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    z-index: 2001;
}

.close-menu-btn:hover {
    background: #cc0000;
}

.close-menu-btn:active {
    background: #aa0000;
}

.menu.hidden {
    display: none;
    pointer-events: none;
}

.goal-section {
    margin: 1.5rem 0;
}

.goal-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 1rem;
}

.goal-input input {
    width: 80px;
    padding: 5px;
    font-size: 16px;
    border: 2px solid #4CAF50;
    border-radius: 5px;
    text-align: center;
}

.color-section {
    margin: 1.5rem 0;
}

.preset-colors {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 1rem;
}

.color-btn {
    width: 70px;
    height: 70px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    font-size: 0.75em;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.color-btn:hover {
    transform: scale(1.1);
}

#colorPicker {
    width: 100px;
    height: 40px;
    margin: 1rem 0;
}

#startGame, .menu-button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

#startGame:hover, .menu-button:hover {
    background: #45a049;
}

.menu-button {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.click-indicator {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: none;
    animation: clickRipple 1s ease-out;
    z-index: 99;
}

@keyframes clickRipple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.animal-section {
    margin: 1.5rem 0;
}

.animal-choices label {
    margin-right: 1.5rem;
    font-size: 1.1rem;
    cursor: pointer;
}

.animal-choices input[type="radio"] {
    margin-right: 0.3rem;
}

.rpg-dialog {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.97);
    padding: 2rem 2.5rem;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    z-index: 2000;
    text-align: center;
    font-size: 1.2rem;
    min-width: 320px;
}

.rpg-dialog button {
    margin-top: 1.2rem;
    background: #4fc3f7;
    color: #fff;
    border: none;
    padding: 0.7rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.rpg-dialog button:hover {
    background: #1976d2;
}

.hud {
    position: fixed;
    left: 20px;
    bottom: 0;
    width: 280px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    padding: 1rem;
    z-index: 1000;
    pointer-events: auto;
    background: rgba(0,0,0,0.2);
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    gap: 15px;
}

#score {
    position: relative;
    top: auto;
    left: auto;
    color: white;
    font-size: 24px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 0;
    pointer-events: auto;
    width: 100%;
    text-align: left;
}

.hud-bar-container {
    position: relative;
    top: auto;
    left: auto;
    width: 200px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    overflow: hidden;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.5);
    margin-bottom: 0;
    pointer-events: auto;
}

#waterBarContainer {
    top: auto;
    background-color: rgba(0, 0, 100, 0.6);
}

.hud-bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.3s ease-out, background-color 0.3s ease-out;
}

.health-bar {
    background-color: #4CAF50;
}

.water-bar {
    background-color: #3399ff;
}

.hud-diamond-container {
    position: relative;
    top: auto;
    left: auto;
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 5px 10px;
    z-index: 100;
    color: white;
    font-size: 20px;
    line-height: 20px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.4);
    margin-bottom: 0;
    pointer-events: auto;
}

.diamond-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
}

.hud-birds {
    position: relative;
    top: auto;
    left: auto;
    margin-bottom: 0;
    background: #fff;
    color: #1976d2;
    font-weight: bold;
    font-size: 1.2rem;
    border-radius: 8px;
    padding: 0.5em 1em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    pointer-events: auto;
}

.hud-attacks {
    position: relative;
    top: auto;
    left: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 1em;
    margin-bottom: 0;
    pointer-events: auto;
    width: 100%;
}

.hud-attacks button {
    padding: 0.5em 0.8em;
    font-size: 0.9rem;
    white-space: nowrap;
    background: #4fc3f7;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: background 0.2s;
}

.hud-attacks button:hover {
    background: #1976d2;
}

#saveLoadSection {
    background: #f7f7f7;
    border-radius: 8px;
    padding: 1em;
    margin-top: 2em;
}

#saveString, #loadString {
    font-family: monospace;
    border-radius: 5px;
    border: 1px solid #bbb;
    margin-bottom: 0.5em;
}

#copySave, #loadSave {
    background: #4fc3f7;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.4em 1.2em;
    font-size: 1em;
    margin-right: 0.5em;
    cursor: pointer;
    margin-top: 0.3em;
}

#copySave:hover, #loadSave:hover {
    background: #1976d2;
}

.rpg-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1976d2;
    color: #fff;
    padding: 0.8em 2em;
    border-radius: 8px;
    font-size: 1.1em;
    z-index: 3000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    animation: fadeInOut 1.8s;
    pointer-events: none;
    max-width: 300px;
    text-align: left;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; }
}

.menu:not(.hidden) ~ .hud {
    /* REMOVE THIS RULE. We will control HUD visibility directly in JS to avoid conflicts. */
    /* display: none; */
}

/* New: Health and Water Bar Styles */
.hud-bar-container {
    position: relative;
    top: auto;
    left: auto;
    width: 200px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    overflow: hidden;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
    pointer-events: auto;
}

#waterBarContainer {
    top: auto;
    background-color: rgba(0, 0, 100, 0.6);
}

.hud-bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.3s ease-out, background-color 0.3s ease-out;
}

.health-bar {
    background-color: #4CAF50;
}

.water-bar {
    background-color: #3399ff;
}

/* New: Diamond Counter Styles */
.hud-diamond-container {
    position: relative;
    top: auto;
    left: auto;
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 5px 10px;
    z-index: 100;
    color: white;
    font-size: 20px;
    line-height: 20px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.4);
    margin-bottom: 20px;
    pointer-events: auto;
}

.diamond-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .hud {
        width: 100%;
        left: 0;
        bottom: 0;
        padding: 0.8rem;
        gap: 10px;
        background: rgba(0,0,0,0.4);
        border-radius: 0;
    }
    
    #score {
        font-size: 18px;
        text-align: center;
        width: 100%;
    }
    
    .hud-bar-container {
        width: 100%;
        height: 18px;
        margin-bottom: 10px;
    }
    
    .hud-diamond-container {
        font-size: 16px;
        padding: 5px 10px;
        margin-bottom: 10px;
        justify-content: center;
    }
    
    .diamond-icon {
        width: 18px;
        height: 18px;
        margin-right: 8px;
    }
    
    .hud-birds {
        font-size: 1rem;
        padding: 0.4em 1em;
        text-align: center;
        width: 100%;
    }
    
    .hud-attacks {
        gap: 0.6em;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .hud-attacks button {
        padding: 0.4em 0.8em;
        font-size: 0.9rem;
        min-width: 60px;
    }
    
    .camera-controls {
        justify-content: center;
        width: 100%;
        margin-top: 10px;
    }
    
    .camera-btn {
        padding: 0.5em 1em;
        font-size: 1.2rem;
        min-width: 50px;
    }
    
    .rpg-dialog {
        padding: 1.5rem 2rem;
        font-size: 1rem;
        min-width: 280px;
        bottom: 16px;
    }
    
    .rpg-dialog button {
        padding: 0.5rem 1.5rem;
        font-size: 1rem;
    }
    
    .menu {
        padding: 1.5rem;
        max-width: 90vw;
    }
    
    .color-btn {
        width: 50px;
        height: 50px;
        font-size: 0.6em;
    }
    
    .goal-input input {
        width: 60px;
        font-size: 14px;
    }
    
    .animal-choices label {
        font-size: 1rem;
        margin-right: 1rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .hud {
        width: 100%;
        left: 0;
        bottom: 0;
        padding: 0.6rem;
        gap: 8px;
        background: rgba(0,0,0,0.5);
        border-radius: 0;
    }
    
    #score {
        font-size: 16px;
        text-align: center;
        width: 100%;
    }
    
    .hud-bar-container {
        width: 100%;
        height: 16px;
        margin-bottom: 8px;
    }
    
    .hud-diamond-container {
        font-size: 14px;
        padding: 4px 8px;
        margin-bottom: 8px;
        justify-content: center;
    }
    
    .diamond-icon {
        width: 16px;
        height: 16px;
        margin-right: 6px;
    }
    
    .hud-birds {
        font-size: 0.9rem;
        padding: 0.3em 0.8em;
        text-align: center;
        width: 100%;
    }
    
    .hud-attacks {
        gap: 0.4em;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .hud-attacks button {
        padding: 0.3em 0.6em;
        font-size: 0.8rem;
        min-width: 50px;
    }
    
    .camera-controls {
        justify-content: center;
        width: 100%;
        margin-top: 8px;
    }
    
    .camera-btn {
        padding: 0.4em 0.8em;
        font-size: 1.1rem;
        min-width: 45px;
    }
    
    .rpg-dialog {
        padding: 1rem 1.5rem;
        font-size: 0.9rem;
        min-width: 250px;
        bottom: 12px;
    }
    
    .rpg-dialog button {
        padding: 0.4rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .menu {
        padding: 1rem;
        max-width: 95vw;
    }
    
    .color-btn {
        width: 40px;
        height: 40px;
        font-size: 0.5em;
    }
    
    .goal-input input {
        width: 50px;
        font-size: 12px;
    }
    
    .animal-choices label {
        font-size: 0.9rem;
        margin-right: 0.8rem;
    }
}

/* Camera rotation controls */
.camera-controls {
    display: flex;
    gap: 0.5em;
    margin-top: 0.5em;
}

.camera-btn {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: 0.5em 0.8em;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 40px;
    text-align: center;
}

.camera-btn:hover {
    background: rgba(255, 255, 255, 0.5);
}

.camera-btn:active {
    background: rgba(255, 255, 255, 0.7);
}

/* Mobile responsive camera controls */
@media (max-width: 768px) {
    .camera-controls {
        gap: 0.3em;
        margin-top: 0.3em;
    }
    
    .camera-btn {
        padding: 0.3em 0.6em;
        font-size: 1rem;
        min-width: 35px;
    }
}

@media (max-width: 480px) {
    .camera-controls {
        gap: 0.2em;
        margin-top: 0.2em;
    }
    
    .camera-btn {
        padding: 0.2em 0.5em;
        font-size: 0.9rem;
        min-width: 30px;
    }
}

/* Zoom slider improvements */
#zoomSlider {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    cursor: pointer;
}

#zoomSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

#zoomSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
}

/* Mobile zoom slider improvements */
@media (max-width: 768px) {
    #zoomSlider {
        height: 12px;
    }
    
    #zoomSlider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    #zoomSlider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
} 