body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 20px;
    -webkit-tap-highlight-color: transparent; 
}

h1 {
    text-align: center;
    color: #333;
}

.gallery-container {
    display: grid;
    
    /* * 【修正點：在電腦上，明確指定 5 欄】
     * 這樣您的 10 本書就會是 5x2 的整齊排列
     */
    grid-template-columns: repeat(5, 1fr);
    
    gap: 15px; /* 圖片間的縫隙 */
    max-width: 1000px; /* 網格最大寬度 */
    margin: 20px auto; /* 讓整個網格在頁面中置中 */
}

.gallery-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    background-color: #ffffff; 
}

.gallery-item:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.gallery-item:active {
    transform: scale(0.98);
}

.gallery-item img {
    width: 100%;
    height: auto; 
    aspect-ratio: 3 / 4; /* 保持書本 3:4 的長寬比 */
    object-fit: cover; 
    display: block;
    cursor: pointer;
    flex-shrink: 0; 
}

/* === 控制按鈕的容器 === */
.controls-container {
    text-align: center; 
    margin-bottom: 20px; 
}

#pauseButton {
    padding: 10px 20px;
    font-size: 16px;
    color: #fff;
    background-color: #007bff; 
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#pauseButton:hover {
    background-color: #0056b3; 
}

/* --- 書本資訊樣式 --- */
.book-info {
    font-size: 14px; 
    color: #333;     
    padding: 10px;   
    text-align: left; 
    width: 100%;      
    box-sizing: border-box; 
    flex-grow: 1; /* 讓文字區塊填滿卡片剩餘空間 */
}
.book-info p {
    margin: 5px 0; 
}

/* * ========================================
 * === 響應式設計 (RWD) - 解決平板與手機排版 ===
 * ========================================
 */

/* * 當螢幕寬度「小於等於 768px」時 (例如平板)
 * 我們把網格改成 3 欄
 */
@media (max-width: 768px) {
    .gallery-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* * 當螢幕寬度「小於等於 480px」時 (例如手機)
 * 我們把網格改成 2 欄
 */
@media (max-width: 480px) {
    .gallery-container {
        grid-template-columns: repeat(2, 1fr);
    }
}
/* --- 樣式結束 --- */
