* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden; /* Prevent scrolling */
    background-color: #f0f8ff; /* AliceBlue base sky color */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    touch-action: none; /* Prevent browser default touch actions */
}

#stage {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* --- UI Elements --- */

#game-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 30px 20px;
    text-align: center;
    pointer-events: none; /* Let touches pass through to the canvas */
    z-index: 10;
    /* Soft gradient for readability */
    background: linear-gradient(to bottom, rgba(240, 248, 255, 0.95) 0%, rgba(240, 248, 255, 0) 100%);
}

#game-header h1 {
    font-family: 'Fredoka', system-ui, sans-serif;
    font-weight: 700;
    font-size: 3.5rem;
    color: #4a90e2; /* Deep playful blue */
    text-transform: uppercase;
    letter-spacing: 3px;
    margin: 0;
    text-shadow: 2px 2px 0px #fff, 
                 4px 4px 0px rgba(0,0,0,0.1);
    /* Glassmorphism/premium touch */
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

#score-container {
    position: absolute;
    top: 20px;
    left: 20px;
    font-family: 'Fredoka', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #4a90e2;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 10px 25px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 15;
    pointer-events: none;
}

#scoreDisplay {
    color: #FF6B6B;
    font-size: 1.8rem;
    margin-left: 5px;
}

#game-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 10;
    background: linear-gradient(to top, rgba(240, 248, 255, 0.95) 0%, rgba(240, 248, 255, 0) 100%);
}

#game-footer p, #counter-container {
    font-family: 'Fredoka', system-ui, sans-serif;
    font-weight: 500;
    font-size: 1rem;
    color: #8892b0;
    margin: 0;
    letter-spacing: 1px;
}

#balloonCounter {
    color: #4ECDC4;
    font-weight: 700;
}

/* Responsiveness */
@media (max-width: 768px) {
    #game-header h1 {
        font-size: 2.5rem;
    }
    #game-footer p {
        font-size: 0.85rem;
    }
}

/* Controls - Toggle Switch */
#controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.7);
    padding: 10px 15px;
    border-radius: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    backdrop-filter: blur(5px);
}

.control-label {
    font-family: 'Fredoka', system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 500;
    color: #4a90e2;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #4ECDC4;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.control-btn {
    background: #4a90e2;
    color: white;
    border: none;
    padding: 6px 14px;
    font-size: 0.9rem;
    font-family: 'Fredoka', system-ui, sans-serif;
    font-weight: 500;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(74, 144, 226, 0.2);
}

.control-btn:hover {
    background: #357ABD;
    transform: translateY(-1px);
}

.control-btn:active {
    transform: translateY(1px);
}

/* --- Modal Overlays --- */
#gameOverModal, #levelCompleteModal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(240, 248, 255, 0.85); /* Frosty backdrop */
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
}

#gameOverModal.hidden, #levelCompleteModal.hidden {
    opacity: 0;
    pointer-events: none;
    /* We don't use display: none so the fade out transition can work conceptually */
}

.modal-content {
    background: white;
    padding: 40px 50px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#gameOverModal.hidden .modal-content, #levelCompleteModal.hidden .modal-content {
    transform: translateY(20px);
}

#levelCompleteModal .modal-content h2 {
    font-family: 'Fredoka', system-ui, sans-serif;
    font-size: 2.5rem;
    color: #2ecc71; /* Green for success */
    margin-bottom: 10px;
}

.modal-content h2 {
    font-family: 'Fredoka', system-ui, sans-serif;
    font-size: 2.5rem;
    color: #FF6B6B; /* Default Red for fail */
    margin-bottom: 10px;
}

.modal-content p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 25px;
}

#restartBtn, #nextLevelBtn {
    background: #4a90e2;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.2rem;
    font-family: 'Fredoka', system-ui, sans-serif;
    font-weight: 500;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(74, 144, 226, 0.3);
}

#restartBtn:hover, #nextLevelBtn:hover {
    background: #357ABD;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(74, 144, 226, 0.4);
}

#restartBtn:active, #nextLevelBtn:active {
    transform: translateY(0);
}
