/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* === Fullscreen Canvas === */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    background: #87CEEB;
}

/* === UI Overlay === */
#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* === Score Display === */
#score-display {
    position: fixed;
    top: 15px;
    right: 20px;
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
    z-index: 20;
    pointer-events: none;
    background: rgba(0,0,0,0.4);
    padding: 8px 16px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#score-display .label {
    font-size: 0.8rem;
    opacity: 0.8;
    display: block;
    text-align: right;
}

#score-display .value {
    font-size: 2rem;
    line-height: 1;
}

/* === Instructions Overlay === */
#instructions {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 1rem;
    text-align: center;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    z-index: 20;
    pointer-events: none;
    background: rgba(0,0,0,0.5);
    padding: 10px 24px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    white-space: nowrap;
    transition: opacity 0.5s ease;
}

#instructions.hidden {
    opacity: 0;
}

/* === Water Level Indicator === */
#water-level {
    position: fixed;
    bottom: 80px;
    left: 20px;
    z-index: 20;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 0.9rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

#water-bar-bg {
    width: 120px;
    height: 16px;
    background: rgba(0,0,0,0.5);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.3);
}

#water-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #2196F3, #00BCD4);
    border-radius: 8px;
    transition: width 0.2s ease;
}

/* === Game Over / Win Screen === */
#game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.7);
    z-index: 30;
    pointer-events: auto;
}

#game-overlay.active {
    display: flex;
}

#game-overlay .modal {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 2px solid #e94560;
    border-radius: 20px;
    padding: 40px 50px;
    text-align: center;
    color: #fff;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

#game-overlay .modal h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #ff6b6b;
}

#game-overlay .modal p {
    font-size: 1.2rem;
    margin-bottom: 8px;
    opacity: 0.9;
}

#game-overlay .modal .final-score {
    font-size: 3rem;
    font-weight: bold;
    color: #ffd93d;
    margin: 15px 0;
}

#game-overlay .modal button {
    margin-top: 20px;
    padding: 14px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #e94560, #c23152);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(233,69,96,0.4);
}

#game-overlay .modal button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(233,69,96,0.6);
}

#game-overlay .modal button:active {
    transform: scale(0.98);
}

/* === Responsive === */
@media (max-width: 768px) {
    #score-display {
        top: 10px;
        right: 10px;
        font-size: 1.2rem;
        padding: 6px 12px;
    }
    #score-display .value {
        font-size: 1.5rem;
    }
    #instructions {
        font-size: 0.85rem;
        padding: 8px 16px;
        bottom: 20px;
        white-space: normal;
        max-width: 90%;
    }
    #water-level {
        bottom: 60px;
        left: 10px;
    }
    #water-bar-bg {
        width: 80px;
        height: 12px;
    }
    #game-overlay .modal {
        padding: 30px 25px;
    }
    #game-overlay .modal h2 {
        font-size: 1.8rem;
    }
    #game-overlay .modal .final-score {
        font-size: 2.2rem;
    }
    #game-overlay .modal button {
        padding: 12px 30px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    #score-display {
        font-size: 1rem;
        padding: 4px 10px;
    }
    #score-display .value {
        font-size: 1.2rem;
    }
    #water-bar-bg {
        width: 60px;
        height: 10px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    #instructions {
        bottom: 10px;
        font-size: 0.75rem;
        padding: 5px 12px;
    }
    #water-level {
        bottom: 40px;
    }
}
