/* --- 全局與基本設定 --- */
:root {
    --sky-blue-light: #a6c0fe;
    --sky-blue-dark: #82a3fc;
    --sunny-yellow: #ffda77;
    --text-dark: #4a4a4a;
    --white: #ffffff;
}

html, body {
    margin: 0;
    padding: 0;
    /* 使用從 Google 引入的圓體字型 */
    font-family: 'M PLUS Rounded 1c', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* --- 首頁專屬樣式 (全新手機版設計) --- */
body.homepage {
    /* 柔和的天空漸層背景 */
    background: linear-gradient(to bottom, var(--sky-blue-light), var(--sky-blue-dark));
    min-height: 100vh;
    overflow-x: hidden; /* 防止雲朵跑出去產生卷軸 */
    position: relative;
    display: flex;
    justify-content: center; /* 水平置中 */
    padding: 20px;
    box-sizing: border-box;
}

/* 背景雲朵裝飾 */
.cloud {
    position: absolute;
    background-color: var(--white);
    border-radius: 50%;
    opacity: 0.3;
    filter: blur(2px);
}
.cloud-1 { width: 200px; height: 200px; top: 10%; left: -80px; }
.cloud-2 { width: 150px; height: 150px; top: 25%; right: -70px; }
.cloud-3 { width: 100px; height: 100px; bottom: 15%; left: 20px; }


.main-container {
    width: 100%;
    max-width: 400px; /* 在大螢幕上不會過寬 */
    display: flex;
    flex-direction: column; /* 讓所有內容垂直排列 */
    align-items: center; /* 讓所有內容水平置中 */
    z-index: 1;
}

/* 狀態區 (等級、經驗值) */
.status-bar {
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
}
.level-display {
    background-color: var(--sunny-yellow);
    color: var(--text-dark);
    font-weight: 800; /* 使用更粗的字體 */
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 1.1em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.xp-bar {
    flex-grow: 1;
    background-color: rgba(0,0,0,0.1);
    height: 20px;
    border-radius: 20px;
    position: relative;
}
.xp-bar-fill {
    background: var(--sunny-yellow);
    height: 100%;
    border-radius: 20px;
    transition: width 0.5s ease-out;
}
.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-dark);
    font-size: 0.8em;
    font-weight: 700;
}

/* 狗狗顯示區 */
.dog-display {
    text-align: center;
    margin: 30px 0;
    width: 100%;
}
.dog-display img {
    width: 65%; /* 讓狗狗佔據畫面主要位置 */
    max-width: 280px;
    height: auto;
    background: var(--white);
    padding: 12px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    /* 使用 drop-shadow 讓陰影更自然 */
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}
.dog-name {
    margin-top: 15px;
    font-size: 1.8em;
    font-weight: 800;
    color: var(--white);
    text-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

/* 功能按鈕區 - 改為垂直排列 */
.action-buttons {
    display: flex;
    flex-direction: column; /* 垂直排列 */
    gap: 15px; /* 按鈕間距 */
    width: 100%;
}
.action-btn {
    background-color: var(--white);
    border: none;
    border-radius: 20px;
    padding: 18px;
    text-align: center;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 1.3em;
    font-weight: 700;
    box-shadow: 0 6px 0px #dcdcdc; /* 製作立體感陰影 */
    transition: transform 0.1s, box-shadow 0.1s;
}

/* 按鈕點擊效果 */
.action-btn:active {
    transform: translateY(4px); /* 按下時往下移動 */
    box-shadow: 0 2px 0px #dcdcdc; /* 陰影變短 */
}

.action-btn.disabled {
    background-color: #e0e0e0;
    color: #9e9e9e;
    box-shadow: 0 6px 0px #c7c7c7;
    pointer-events: none;
}

/* --- 【新增】通用彈出視窗 (Modal) 樣式 --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none; /* 預設隱藏 */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex; /* 透過 JS 加入 active class 來顯示 */
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
    width: 90%;
    max-width: 350px;
    animation: fadeIn 0.3s ease-out;
    color: var(--text-dark);
}

@keyframes fadeIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    color: var(--sky-blue-dark);
    margin-top: 0;
}

.modal-content input[type="text"] {
    width: 80%;
    padding: 12px;
    margin: 15px 0;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1.1em;
    text-align: center;
}

.modal-btn {
    background-color: var(--sunny-yellow);
    color: var(--text-dark);
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}

.modal-btn:hover {
    transform: scale(1.05);
}
/* --- 【新增】首頁重新開始按鈕樣式 --- */
.action-btn.restart-btn {
    background-color: #ff7f7f; /* 使用不同的顏色以示區別 */
    box-shadow: 0 6px 0px #d96d6d;
}

.action-btn.restart-btn:active {
    box-shadow: 0 2px 0px #d96d6d;
}
/* --- 【新增】通用返回按鈕樣式 --- */
.back-btn {
    display: inline-block;
    background-color: #87ceeb; /* 柔和的天藍色 */
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    text-decoration: none; /* 移除超連結底線 */
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
    border: none; /* 確保在不同瀏覽器上樣式一致 */
    cursor: pointer;
}

.back-btn:hover {
    transform: translateY(-2px); /* 滑鼠懸停時輕微上浮 */
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}


/* --- 【美化後】通用音樂按鈕樣式 --- */
/* --- 【美化後】通用音樂按鈕樣式 --- */
.music-btn-global {
    position: fixed;
    bottom: 20px; /* 【修改】從 top 改為 bottom，讓按鈕定位在畫面底部 */
    right: 20px;
    z-index: 999;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #555;
    background: linear-gradient(145deg, #f0f0f0, #ffffff);
    box-shadow: 4px 4px 8px #cccccc, 
                -4px -4px 8px #ffffff;
    transition: all 0.2s ease-in-out;
}
/* 滑鼠懸停時的效果 */
.music-btn-global:hover {
    /* 讓陰影稍微變化，並放大按鈕 */
    box-shadow: 6px 6px 12px #c7c7c7, 
                -6px -6px 12px #ffffff;
    transform: scale(1.05);
}

/* 按鈕被點擊時的效果 */
.music-btn-global:active {
    /* 使用內陰影，做出按鈕被「壓下去」的感覺 */
    box-shadow: inset 4px 4px 8px #cccccc, 
                inset -4px -4px 8px #ffffff;
    transform: scale(0.95); /* 稍微縮小，模擬按壓 */
    color: #007bff; /* 點擊時圖示變色，給予明確回饋 */
}


.level-display {
    background-color: var(--sunny-yellow);
    color: var(--text-dark);
    font-weight: 800;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 1.1em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 【新增】骨頭幣顯示區塊的樣式 */
.coin-display {
    background-color: #a8e063; /* 使用一個清新的綠色 */
    color: var(--text-dark);
    font-weight: 800;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 1.1em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    white-space: nowrap; /* 防止文字換行 */
}

/* --- 【新增】主頁按鈕並排樣式 --- */
.button-row {
    display: flex; /* 啟用 Flexbox 佈局，讓內部的元素可以並排 */
    gap: 15px;     /* 設定並排按鈕之間的間距 */
    width: 100%;   /* 讓這個橫排容器佔滿寬度 */
}

/* 讓橫排內的按鈕自動分配寬度 */
.button-row .action-btn {
    flex: 1; /* 讓每個按鈕都佔據一份可用空間，實現均分效果 */
    padding: 15px 10px; /* 微調 padding，讓文字在小按鈕上更好看 */
    font-size: 1.1em; /* 微調字體大小 */
}

