* { box-sizing: border-box; }

body {
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #1a1a1a;
    overflow: hidden;
    font-family: 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}
/* 顯示紅框 *//* 顯示半透明紅色 */
/* 
.option-area {
    position: absolute;
    cursor: pointer;
    border: 2px solid red;
    background: rgba(255, 0, 0, 0.3); 
    border-radius: 10px;
    transition: all 0.3s ease;
}
 */

/* 修改你的 .book-container */
.book-container {
    perspective: 1500px; 
    width: 100%;
    max-width: 1067px; /* 開放最大寬度到你的圖片寬度 */
    aspect-ratio: 1067 / 1050; /* 根據你的圖片比例 (寬/高) 自動計算高度，取代原本的 height: 80vh */
    max-height: 90vh; /* 避免在某些橫式螢幕超出版面 */
    margin: 0 auto; /* 讓整個書本在畫面中置中 */
}

.book {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

/* 每一頁的共通樣式 */
.page {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: #fff;
    transform-origin: left center; /* 以左側為軸心翻轉 */
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1), opacity 0.8s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 5px 15px 15px 5px;
    overflow: hidden;
}

/* 翻頁後的狀態 */
.page.flipped {
    transform: rotateY(-180deg);
    opacity: 0; /* 翻過去後漸隱 */
    pointer-events: none;
}

/* 修改你的圖片顯示方式 */
.page img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 改用 contain 確保 1067 的圖片完整顯示，不被裁切 */
    display: block;
}

/* 封面與結果按鈕 */
.start-btn, .reveal-btn {
    position: absolute;
    bottom: 11%;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 40px;
    font-size: 22px;
    font-weight: bold;
    background: #ff5e57;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(255, 94, 87, 0.4);
    transition: transform 0.2s;
}

.start-btn:active, .reveal-btn:active {
    transform: translateX(-50%) scale(0.95);
}

.reveal-btn {
    display: none; /* 初始隱藏 */
    animation: popIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* 圖片上的選項點擊區塊 */
.img-wrapper { position: relative; width: 100%; height: 100%; }

.option-area {
    position: absolute;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 10px;
    transition: all 0.3s ease;
}

/* 根據圖片選項排版新增的 4 個絕對定位區塊 */
.zone-a { top: 23%; left: 4%; width: 45%; height: 33%; }
.zone-b { top: 23%; left: 51%; width: 45%; height: 33%; }
.zone-c { top: 58%; left: 4%; width: 45%; height: 33%; }
.zone-d { top: 58%; left: 51%; width: 45%; height: 33%; }

/* 滑鼠移上去的特效 (可選)
.option-area:hover {
    background: rgba(255, 255, 255, 0.2);
}
 */
/* 點擊時的特效框
.option-area.selected {
    border-color: #ffd32a;
    background: rgba(255, 211, 42, 0.3);
    box-shadow: 0 0 20px rgba(255, 211, 42, 0.8);
    transform: scale(0.98);
}
 */

/* 最終結果遮罩與動畫 */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none; /* 初始隱藏 */
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#confetti-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

.result-content {
    text-align: center;
    z-index: 101;
    animation: zoomFadeIn 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.result-content img {
    max-width: 90vw;
    max-height: 70vh;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
}

.btn-group { margin-top: 25px; }

.btn-group button {
    margin: 0 10px;
    padding: 12px 30px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
}

.line-btn { background: #06C755; color: white; }
.retry-btn { background: #4b6ffa; color: white; }

.btn-group button:hover { opacity: 0.8; }

/* 動畫 Keyframes */
@keyframes popIn {
    0% { transform: translateX(-50%) scale(0); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes zoomFadeIn {
    0% { transform: scale(0.5); opacity: 0; filter: blur(10px); }
    100% { transform: scale(1); opacity: 1; filter: blur(0); }
}