/* 全局樣式 */
body {
    font-family: 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
    display: flex;
    flex-direction: column;
    align-items: center;
    /* justify-content: center; */ /* 取消置中，讓內容從上方開始 */
    padding-top: 20px; /* 增加頂部間距 */
    min-height: 100vh;
    background-color: #f0f8ff;
    color: #333;
    margin: 0;
}

h1 {
    color: #ff69b4;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    margin: 0; /* 修改：移除 margin */
    flex-grow: 1; /* 修改：讓標題佔據多餘空間 */
    text-align: center; /* 保持文字置中 */
}

/* 新增：圖片顯示區塊 */
.image-display {
    width: 200px;
    height: 200px;
    margin-bottom: 15px;
    border: 5px solid #ff9a9e;
    border-radius: 20px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    overflow: hidden; /* 確保圖片不會超出圓角 */
}

.image-display img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 讓圖片填滿容器且不變形 */
}

/* 資訊欄樣式 */
.info-container {
    display: flex;
    justify-content: space-around;
    width: 90%;
    max-width: 400px;
    margin-bottom: 20px;
    background-color: #fff;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.info-item {
    font-size: 1.2em;
    font-weight: bold;
    color: #555;
}

/* 遊戲容器與網格 */
.game-container {
    perspective: 1000px;
}

.game-grid {
    display: grid;
    gap: 10px;
    /* grid-template-columns 由 JS 動態設定 */
}

/* 卡片樣式 */
.card {
    background-color: transparent;
    width: 70px;
    height: 70px;
    cursor: pointer;
}

/* 新增：空白卡片的樣式 */
.card.is-blank {
    visibility: hidden; /* 讓卡片隱形 */
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card.is-flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.card-front {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    font-size: 40px;
}
.card-front::after {
    content: '?';
}

.card-back {
    background-color: #ffffff;
    color: #333;
    transform: rotateY(180deg);
    font-size: 45px;
}

/* 新增：重新開始按鈕樣式 */
.restart-btn {
    margin-top: 20px;
    padding: 12px 25px;
    font-size: 1em;
    font-weight: bold;
    color: white;
    background-color: #ff69b4;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: background-color 0.3s, transform 0.2s;
}

.restart-btn:hover {
    background-color: #ff85c1;
    transform: translateY(-2px);
}

/* --- 新增的樣式 --- */

/* 音樂按鈕樣式 */
.music-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #fff;
    border: 2px solid #ff9a9e;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 彈出視窗 (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;
}

.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: 400px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    color: #ff69b4;
    margin-top: 0;
}

/* 獎勵選擇區塊 */
.bonus-container {
    margin: 20px 0;
    padding: 15px;
    background-color: #fff8e1;
    border-radius: 10px;
    border: 2px dashed #fecfef;
}

.bonus-btn {
    background-color: #87ceeb; /* 天藍色 */
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 15px;
    margin: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.bonus-btn:hover {
    background-color: #6495ed;
}

/* 彈出視窗中的主按鈕 */
.modal-btn {
    background-color: #32cd32; /* 萊姆綠 */
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.modal-btn:hover {
    background-color: #228b22;
}

/* 當獎勵被選擇後的樣式 */
.bonus-btn.selected {
    background-color: #ff6347; /* 番茄色 */
    transform: scale(1.05);
}

/* --- 新增的樣式 --- */

/* 圖片下方文字描述 */
.image-caption {
    font-size: 1em;
    color: #555;
    margin-top: -10px; /* 讓文字離圖片近一點 */
    margin-bottom: 15px;
    font-weight: bold;
    text-align: center;
    max-width: 90%;
}

/* 影片播放器容器 */
.video-container {
    display: none; /* 預設隱藏 */
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.8); /* 更暗的背景來突顯影片 */
}

#win-video {
    max-width: 90%;
    max-height: 90%;
    border-radius: 15px;
    border: 3px solid #fff;
}

.top-controls {
    /* position: absolute; */ /* 移除 */
    /* top: 15px; */         /* 移除 */
    /* right: 80px; */       /* 移除 */
    display: flex;
    gap: 10px;
}

.music-btn {
    position: static; /* 移除 absolute 定位 */
}

.back-btn {
    display: inline-block;
    background-color: #87ceeb;
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
/* --- 【新增】遊戲結算視窗樣式 --- */
.summary-line {
    font-size: 1.1em;
    margin: 10px 0;
}

.summary-value {
    font-weight: bold;
    font-size: 1.2em;
    color: #ff69b4; /* 粉紅色，呼應主題 */
}

.level-up-message {
    background-color: #fff8e1;
    border: 2px dashed #fecfef;
    border-radius: 10px;
    padding: 5px 15px;
    margin-top: 20px;
}

/* 【新增】頂部標題容器樣式 */
.game-header {
    display: flex;
    justify-content: space-between; /* 讓標題和按鈕左右分開 */
    align-items: center; /* 垂直置中 */
    width: 100%;
    max-width: 960px; /* 給一個最大寬度 */
    padding: 0 20px; /* 左右留白 */
    box-sizing: border-box; /* 讓 padding 不會影響寬度 */
    margin-bottom: 10px;
}

/* --- 【新增】手機版響應式樣式 --- */
@media (max-width: 480px) {

    /* 加大頂部標題 */
    .game-header h1 {
        font-size: 1.2em;
    }

    /* 加大資訊欄的文字 */
    .info-item {
        font-size: 1em;
    }

    /* 加大卡牌的尺寸和裡面的圖案 */
    .card {
        width: 65px;
        height: 65px;
    }

    .card-back {
        font-size: 40px;
    }

    /* 加大彈出視窗的文字和按鈕 */
    .modal-content h2 {
        font-size: 1.8em;
    }
    .bonus-container p {
        font-size: 1.1em;
    }
    .bonus-btn, .modal-btn {
        font-size: 1em;
        padding: 12px 20px;
    }

    /* 加大結算畫面的文字 */
    .summary-line {
        font-size: 1.2em;
    }
    .summary-value {
        font-size: 1.3em;
    }
}