/* 基本樣式 */
body {
    font-family: 'Microsoft JhengHei', sans-serif;
    background-color: #87CEEB; /* 藍色背景 */
    display: flex;
    flex-direction: column; /* 讓內容垂直排列 */
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* 確保 body 至少佔滿整個視口高度 */
    margin: 0;
    padding: 10px;
    box-sizing: border-box; /* 確保 padding 不會影響佈局 */
}

/* 遊戲容器樣式 */
.game-container {
    position: relative; /* 讓全螢幕按鈕可以定位 */
    text-align: center;
    background-color: #8FBC8F; /* 綠色背景 */
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 500px; /* 遊戲容器的最大寬度 */
    margin: 20px 0; /* 增加上下間距 */
}

/* 全螢幕按鈕的樣式 */
.top-right-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000; /* 確保按鈕在最上層 */
}

.fullscreen-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: #FF4500; /* 橙色 */
    transition: transform 0.2s;
}

.fullscreen-button:hover {
    transform: scale(1.1);
}

.fullscreen-button:active {
    transform: scale(0.95);
}

/* 標題樣式 */
h1 {
    font-family: 'Microsoft JhengHei', sans-serif;
    font-size: 40px;
    font-weight: bold;
    color: #FF4500; /* 橙色 */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

/* 得分和時間樣式 */
.score, .time {
    font-family: 'Microsoft JhengHei', sans-serif;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #8B4513; /* 棕色 */
    transition: transform 0.2s;
}

.score:hover, .time:hover {
    transform: scale(1.1);
}

/* 地鼠網格樣式 */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px; /* 洞與洞之間的距離 */
    margin-bottom: 20px;
    justify-content: center; /* 確保網格內容居中 */
    margin-left: auto; /* 自動左邊距 */
    margin-right: auto; /* 自動右邊距 */
    width: fit-content; /* 讓網格寬度根據內容調整 */
}

/* 地鼠洞樣式 */
.hole {
    position: relative;
    overflow: hidden;
    border-radius: 50%; /* 圓形 */
    background: radial-gradient(circle, #8B4513 40%, #5a2c0d 100%); /* 地鼠洞的顏色 */
    width: 120px; /* 洞的寬度 */
    height: 120px; /* 洞的高度 */
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.5),
        0 4px 6px rgba(0, 0, 0, 0.3);
    z-index: 1; /* 洞的 z-index 設為 1 */
    cursor: pointer; /* 讓洞穴變成可點擊的 */
}

/* 地鼠樣式 */
.mole {
    width: 100%; /* 地鼠大小與洞穴相同 */
    height: 100%; /* 地鼠大小與洞穴相同 */
    background-image: url('cute-mole.png');
    background-size: cover;
    background-position: center bottom; /* 讓地鼠的頭部對齊洞穴底部 */
    position: absolute;
    top: 60%; /* 初始位置：地鼠的身體在洞裡，頭部稍微露出 */
    left: 50%; /* 從洞的正中央出來 */
    transform: translateX(-50%); /* 水平居中 */
    transition: top 0.3s;
    z-index: 3; /* 地鼠的 z-index 設為 3，確保在地洞上面 */
    animation: shake 0.5s infinite; /* 添加抖動動畫 */
}

.mole.up {
    top: 8%; /* 彈出時的位置：地鼠跳得更高，超出洞穴上方 */
    animation: none; /* 彈出時停止抖動 */
}

/* 分數提示樣式 */
.score-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: bold;
    color: #FFD700; /* 分數提示的顏色 */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    opacity: 1;
    transition: transform 0.5s, opacity 0.5s;
    z-index: 4; /* 分數提示在地鼠的上層 */
}

/* 開始按鈕樣式 */
#startButton {
    padding: 15px 30px;
    font-size: 20px;
    font-family: 'Microsoft JhengHei', sans-serif;
    font-weight: bold;
    cursor: pointer;
    border: none;
    background-color: #FF6347; /* 橙色 */
    color: white;
    border-radius: 25px;
    width: 100%;
    max-width: 200px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s, transform 0.2s;
}

#startButton:hover {
    background-color: #FF4500; /* 更深的橙色 */
    transform: scale(1.05);
}

#startButton:active {
    transform: scale(0.95);
    animation: bounce 0.5s;
}

/* 遊戲結束訊息樣式 */
#gameOverMessage {
    margin-top: 20px;
    font-size: 24px;
    font-family: 'Microsoft JhengHei', sans-serif;
    font-weight: bold;
    color: #8B0000; /* 深紅色 */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.hidden {
    display: none;
}

/* 倒數計時樣式 */
#countdown {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8); /* 黑色背景，半透明 */
    display: none; /* 初始隱藏 */
    justify-content: center;
    align-items: center;
    z-index: 10; /* 確保在最上層 */
}

#countdown.visible {
    display: flex; /* 顯示倒數計時 */
}

#countdownText {
    font-size: 100px;
    font-weight: bold;
    color: white;
    font-family: 'Microsoft JhengHei', sans-serif;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* 遊戲結束彈出畫面樣式 */
#gameOverPopup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.9);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    z-index: 100;
    display: none; /* 初始隱藏 */
    width: 90%; /* 限制彈出畫面寬度 */
    max-width: 500px; /* 最大寬度 */
}

#gameOverPopup.visible {
    display: block; /* 顯示彈出畫面 */
}

#finalScoreDisplay {
    font-size: 2.5em; /* 使用相對單位，字體大小適中 */
    font-weight: bold;
    color: #FF4500;
    margin-bottom: 20px;
    white-space: nowrap; /* 防止文字換行 */
}

#rankDisplay {
    font-size: 2em; /* 使用相對單位，字體大小適中 */
    font-weight: bold;
    color: #8B0000;
    margin-bottom: 30px;
    white-space: nowrap; /* 防止文字換行 */
}

#restartButton {
    padding: 15px 30px;
    font-size: 20px;
    font-family: 'Microsoft JhengHei', sans-serif;
    font-weight: bold;
    cursor: pointer;
    border: none;
    background-color: #FF6347;
    color: white;
    border-radius: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s, transform 0.2s;
}

#restartButton:hover {
    background-color: #FF4500;
    transform: scale(1.05);
}

#restartButton:active {
    transform: scale(0.95);
}

/* 抖動動畫 */
@keyframes shake {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    25% {
        transform: translateX(-50%) translateY(-5px);
    }
    50% {
        transform: translateX(-50%) translateY(0);
    }
    75% {
        transform: translateX(-50%) translateY(5px);
    }
}

/* 按鈕彈跳動畫 */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* 媒體查詢：針對小螢幕裝置 */
@media (max-width: 600px) {
    h1 {
        font-size: 32px;
    }

    .score, .time {
        font-size: 20px;
    }

    .grid {
        gap: 20px; /* 小螢幕上稍微縮小洞與洞之間的距離 */
    }

    .hole {
        width: 100px; /* 小螢幕上進一步縮小洞的寬度 */
        height: 100px; /* 小螢幕上進一步縮小洞的高度 */
    }

    #startButton {
        font-size: 18px;
        padding: 12px 24px;
    }

    #countdownText {
        font-size: 60px;
    }

    #finalScoreDisplay {
        font-size: 1.8em; /* 在小螢幕上進一步縮小字體 */
    }

    #rankDisplay {
        font-size: 1.5em; /* 在小螢幕上進一步縮小字體 */
    }

    #restartButton {
        font-size: 18px;
        padding: 12px 24px;
    }
}

/* 版權聲明樣式 */
footer {
    text-align: center;
    padding: 10px;
    font-family: 'Microsoft JhengHei', sans-serif;
    font-size: 14px;
    color: #555; /* 文字顏色 */
    width: 100%; /* 確保 footer 佔滿整個寬度 */
    box-sizing: border-box; /* 確保 padding 不會影響寬度 */
    margin-top: auto; /* 將 footer 推到頁面底部 */
}

/* 社群分享按鈕樣式 */
.social-share {
    display: flex;
    justify-content: center;
    gap: 15px; /* 按鈕之間的間距 */
    margin-bottom: 20px; /* 與 footer 的間距 */
}

.social-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    text-decoration: none;
    transition: transform 0.2s, background-color 0.3s;
}

.social-button:hover {
    transform: scale(1.1);
}

/* 各社群按鈕的顏色 */
.social-button.facebook {
    background-color: #1877F2; /* Facebook 藍 */
}

.social-button.twitter {
    background-color: #1DA1F2; /* Twitter 藍 */
}

.social-button.line {
    background-color: #00C300; /* LINE 綠 */
}

.social-button.instagram {
    background-color: #E4405F; /* Instagram 粉紅 */
}

.social-button.pinterest {
    background-color: #BD081C; /* Pinterest 紅 */
}

.social-button.linkedin {
    background-color: #0A66C2; /* LinkedIn 藍 */
}