* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #222;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.game-container {
    position: relative;
    width: min(800px, 95vw);
    height: min(450px, calc(95vw * 0.5625), calc(100vh - 80px));
    background-color: #333;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    transition: opacity 0.3s ease;
}

.hidden {
    display: none;
}

h1 {
    font-size: 36px;
    margin-bottom: 20px;
    color: #ffcc00;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

h2 {
    font-size: 32px;
    margin-bottom: 20px;
    color: #ff6b6b;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.instructions {
    margin-bottom: 30px;
    font-size: 18px;
    line-height: 1.5;
}

button {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 20px;
}

button:hover {
    background-color: #45a049;
}

#game-canvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    background-color: #111;
    display: block;
}

.hud {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 18px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

#score, #high-score {
    margin-bottom: 5px;
}

#final-score {
    font-size: 24px;
    margin: 15px 0;
}

#new-high-score {
    color: #ffcc00;
    font-size: 20px;
    margin-bottom: 15px;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

/* 用於遊戲內反饋文字和效果 */
.feedback-text {
    position: absolute;
    left: 50%;
    top: 30%;
    transform: translate(-50%, -50%);
    color: #FF5722;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.5s ease-out;
    pointer-events: none; /* 避免阻擋點擊 */
    z-index: 10;
}

.feedback-flash {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease-out;
    pointer-events: none; /* 避免阻擋點擊 */
    z-index: 1000;
}

/* 添加一個用於顯示 feedback 元素的類 */
.visible {
    display: block; /* 或者 flex, grid 等，取決於元素類型 */
    opacity: 1;
}
/* Footer */
.game-footer {
    text-align: center;
    padding: 10px;
    position: fixed;
    bottom: 10px;
    left: 0;
    right: 0;
}
.game-footer a {
    color: #87CEEB;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 16px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    transition: all 0.3s;
}
.game-footer a:hover {
    background: rgba(255,255,255,0.2);
}

/* 手機 RWD：360~600px 視窗完整顯示，無水平捲軸 */
@media (max-width: 600px) {
    .game-container {
        width: 100vw;
        border-radius: 0;
    }

    .screen {
        padding: 12px;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 14px;
    }

    h2 {
        font-size: 22px;
        margin-bottom: 14px;
    }

    .instructions {
        margin-bottom: 20px;
        font-size: 15px;
    }

    button {
        min-height: 44px;
        padding: 12px 28px;
        font-size: 16px;
        margin-top: 14px;
    }

    .hud {
        font-size: 14px;
        top: 8px;
        left: 8px;
    }

    #final-score {
        font-size: 20px;
    }

    #new-high-score {
        font-size: 16px;
    }

    .feedback-text {
        font-size: 18px;
    }

    .game-footer a {
        font-size: 12px;
        padding: 6px 12px;
    }
}
