body {
    margin: 0;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(to bottom, #1a2980, #26d0ce);
    font-family: 'Arial', sans-serif;
    overflow: hidden;
}

#gameContainer {
    position: relative;
    min-width: 0;
    max-width: 100%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    background-color: #000;
}

#gameCanvas {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    margin: 0 auto;
    background: linear-gradient(to bottom, #87CEEB, #FFFFFF);
    border-radius: 10px;
}

#menuButton,
#fullscreenButton,
#pauseButton {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

#menuButton {
    flex-direction: column;
    gap: 4px;
}

#fullscreenButton {
    top: 60px;
}

#pauseButton {
    top: 108px;
}

#pauseButton .play-icon {
    display: none;
}

#pauseButton.paused .pause-icon {
    display: none;
}

#pauseButton.paused .play-icon {
    display: block;
}

#menuButton span {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 1px;
    background: #fff;
}

#menuButton:hover,
#fullscreenButton:hover {
    background: rgba(0, 0, 0, 0.7);
}

#score,
#time {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 10;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    color: white;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#time {
    top: 54px;
}

#gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

#gameOver h2 {
    margin-top: 0;
    color: #ff6b6b;
}

#restartButton {
    background-color: #4ECDC4;
    border: none;
    padding: 12px 24px;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.3s;
}

#restartButton:hover {
    background-color: #1a936f;
}

.hidden {
    display: none;
}

#instructions {
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: white;
    font-size: 16px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Keep the whole board (and its overlays) inside the viewport on phones */
@media (max-width: 600px) {
    body {
        padding: 6px;
    }

    #gameContainer {
        display: flex;
        flex-direction: column;
        align-items: center;
        background: transparent;
        box-shadow: none;
    }

    #gameCanvas {
        max-height: calc(100vh - 40px);
        max-height: calc(100dvh - 40px);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    }

    #score,
    #time {
        top: 8px;
        left: 8px;
        font-size: 16px;
    }

    #time {
        top: 44px;
    }

    #menuButton,
    #fullscreenButton,
    #pauseButton {
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
    }

    #fullscreenButton {
        top: 52px;
    }

    #pauseButton {
        top: 96px;
    }

    #instructions {
        position: static;
        transform: none;
        width: auto;
        margin-top: 6px;
        text-align: center;
        font-size: 12px;
        line-height: 1.2;
    }

    #instructions p {
        margin: 0;
    }

    #gameOver {
        padding: 20px;
        width: 80%;
        max-width: 320px;
    }
}
