body { margin: 0; background: #222; overflow: hidden; }
canvas { display: block; margin: 0 auto; }

.noscroll {
    overflow: hidden;
}
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #1a1a2e;
    font-family: Arial, sans-serif;

    background-image: url(../assets/under_water.jpg) !important;
    background-size: cover !important;
    background-position: center !important;
}
#gameContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    max-width: 1000px;
    height: 100dvh; /* Use dvh for dynamic viewport height that accounts for mobile browser UI */
    position: relative;
    overflow: hidden;
    margin: auto;
    
    object-fit: contain;
    aspect-ratio: 1 / 1;
    flex-direction: column;

    outline: 2px solid #000000;
}

/* Fallback for browsers that don't support dvh */
@supports not (height: 100dvh) {
    #gameContainer {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
}

#gameCanvas {
    width: 100% !important;
    height: 100%;
    /* object-fit: contain; */
    object-fit: cover;
}
#gameInfo {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    font-size: 18px;
    z-index: 10;
}
#gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    display: none;
    z-index: 101;
}
#gameOverBackdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('../assets/hud_lose.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 99;
    pointer-events: none;
    display: none;
}
#gameOverBackdrop.win {
    background-image: url('../assets/hud_win.png');
}
#gameOver h1 {
    margin: 0 0 20px 0;
    font-size: 48px;
}
#gameOver button {
    background: #e94560;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 20px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
}
#gameOver button:hover {
    background: #c23650;
}
#preloader {
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    flex-direction: column;
    gap: 30px;
    object-fit: contain;
    overflow: hidden;
    aspect-ratio: 1 / 1;

    height: 100%;
}

#preloader {
    background: #0066cc !important;
}
#preloader.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
#startButton {
    display: none;
    background: #e94560;
    color: white;
    border: none;
    padding: 20px 40px;
    font-size: 24px;
    border-radius: 10px;
    cursor: pointer;
    animation: pulse 2s infinite;
}
#startButton:hover {
    background: #c23650;
    transform: scale(1.05);
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
.progress-container {
    width: 400px;
    max-width: 90%;
    height: 40px;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}
.progress-bar {
    width: 0%;
    height: 100%;
    background: white;
    transition: width 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
}
.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 18px;
    z-index: 1;
}
.progress-text-filled {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #0066cc;
    font-weight: bold;
    font-size: 18px;
    z-index: 2;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.3s ease;
}

#pauseOverlay {
    position: absolute;
    top: 0px;
    display: none;
    left: 0px;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.66);
    z-index: 999;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: rgb(255, 255, 255);
    font-weight: bold;
}

#pauseOverlay.paused {
    display: flex;
}

#pauseButton{
    position: fixed;
    top: 1.5em;
    right: 1em;
    z-index: 10001;
    font-size: 20px;
    color: #fff;
    cursor: pointer;
    opacity: 0.92;
}

#restartSpinner{
    position: absolute;
    top: 50%;
    left: 50%;
    font-size: 40px;
    color: white;
    display: none;
    z-index: 10000;
}