body {
    margin: 0;
    overflow: hidden;
    background-color: #333; /* Added a background color for the letterbox */
}

#game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
}

#game-area {
    position: relative;
    background-size: cover;
    background-position: center;
    overflow: hidden; /* Ensures nothing spills out of the game area */
}

/* Aspect ratio handling */
@media (orientation: landscape) {
    #game-area {
        width: calc(100vh * (9 / 16)); /* Height is the constraint */
        height: 100vh;
    }
}

@media (orientation: portrait) {
    #game-area {
        width: 100vw;
        height: calc(100vw * (16 / 9)); /* Width is the constraint */
    }
    /* Adjust if height is the constraint in portrait */
    @media (min-aspect-ratio: 9/16) {
        #game-area {
            width: calc(100vh * (9/16));
            height: 100vh;
        }
    }
}

#stick {
    position: absolute;
    width: 5%; /* より太くする */
    height: 15%; /* Use percentage for responsiveness */
    background-color: rgba(0, 0, 0, 0.7); /* 黒の半透明 */
    border-radius: 50px; /* 先を丸っぽくする */
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.5); /* 影を少し濃く */
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    border: 1px solid rgba(255, 255, 255, 0.1); /* 薄い白い境界線で輪郭を強調 */
}

#hole {
    position: absolute;
    width: 10%; /* Use percentage for responsiveness */
    height: 3%; /* Use percentage for responsiveness */
    background-color: rgba(0, 0, 0, 0.7); /* より濃い透明度 */
    border: 2px solid rgba(139, 69, 19, 0.8); /* 茶色の境界線 */
    border-radius: 50px; /* 穴も丸っぽくする */
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8); /* 内側の影で深さを表現 */
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
}

#message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 3em;
    text-align: center;
    display: none; /* Initially hidden */
    text-shadow: 2px 2px 4px #000000;
    background: rgba(0, 0, 0, 0.7);
    padding: 20px 40px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#level-display {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    font-size: 2em;
    font-weight: bold;
    text-shadow: 2px 2px 4px #000000;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
}

#lives-display {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #ff6b6b;
    font-size: 2em;
    font-weight: bold;
    text-shadow: 2px 2px 4px #000000;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    gap: 10px;
}

#lives-display::before {
    content: '♥';
    color: #ff4757;
    font-size: 1.2em;
}

#clear-button {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    font-size: 1.5em;
    cursor: pointer;
    background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    font-weight: bold;
}

#clear-button:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

#restart-button {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    font-size: 1.5em;
    cursor: pointer;
    background: linear-gradient(45deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    border: none;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    font-weight: bold;
}

#restart-button:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}