/* 基本樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* 禁止文字選取 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #ffeef8 0%, #ffe0f0 50%, #ffd1e8 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
    padding: 10px 0;
}

.container {
    text-align: center;
    padding: 15px;
    max-width: 500px;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* 標題樣式 */
.title {
    font-size: 2rem;
    color: #d63384;
    margin-bottom: 1.5rem;
    margin-top: 1rem;
    text-shadow: 2px 2px 4px rgba(214, 51, 132, 0.3);
    animation: titleBounce 2s ease-in-out infinite alternate;
}

@keyframes titleBounce {
    0% { transform: translateY(0px); }
    100% { transform: translateY(-10px); }
}

/* 多頁賀卡樣式 */
.card-book-container {
    margin: 1rem auto;
    max-width: 100%;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-book {
    position: relative;
    width: 100%;
    height: 500px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(214, 51, 132, 0.3);
    background: #fff;
    flex: 1;
    min-height: 500px;
}

.card-page {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ff9bb5 0%, #ff7a9a 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 25px;
    box-sizing: border-box;
    transform: translateX(100%);
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
}

.card-page.active {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

.card-page.prev {
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
}

.page-content {
    text-align: center;
    color: white;
    width: 100%;
}

/* 封面樣式 */
.cover-content h2 {
    font-size: 5rem;
    margin-bottom: 25px;
    animation: bounce 2s ease-in-out infinite;
}

.cover-content p {
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 20px;
}

.heart {
    font-size: 3rem;
    animation: heartBeat 1.5s ease-in-out infinite;
    margin: 25px 0;
}

.tap-hint {
    font-size: 1rem;
    opacity: 0.8;
    animation: pulse 2s ease-in-out infinite;
    margin-top: 20px;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

/* 內頁樣式 */
.page-content h3 {
    font-size: 2.2rem;
    margin-bottom: 30px;
    color: #fff;
}

.page-content p {
    font-size: 1.3rem;
    line-height: 1.8;
    margin-bottom: 15px;
}

.page-decoration {
    font-size: 2.5rem;
    margin: 30px 0;
    animation: heartBeat 1.5s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
}

.signature {
    margin-top: 30px;
    font-style: italic;
    font-size: 1.2rem;
    opacity: 0.9;
}

/* 蛋糕頁面特殊樣式 */
.cake-page {
    background: linear-gradient(135deg, #ffb3c6 0%, #ff91a4 100%) !important;
    padding: 20px 25px !important;
}

.cake-page h3 {
    font-size: 1.8rem;
    margin-bottom: 20px;
}

/* 頁面指示器 */
.page-indicators {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(214, 51, 132, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator.active {
    background: #d63384;
    transform: scale(1.2);
}

.indicator:hover {
    background: rgba(214, 51, 132, 0.6);
}

/* 滑動提示 */
.swipe-hint {
    text-align: center;
    margin: 20px 0 15px 0;
    padding: 0 10px;
}

.swipe-hint p {
    font-size: 0.9rem;
    color: #d63384;
    opacity: 0.8;
    animation: pulse 2s ease-in-out infinite;
    margin: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

/* 蛋糕樣式 */

.cake-wrapper {
    display: inline-block;
    margin: 15px 0;
}

.birthday-cake {
    width: 250px;
    height: 200px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.birthday-cake:hover {
    transform: scale(1.05);
}

/* 蠟燭火焰動畫 */
.flame, .flame-inner {
    animation: flicker 0.5s ease-in-out infinite alternate;
    transform-origin: center bottom;
}

@keyframes flicker {
    0% { transform: scale(1) rotate(-1deg); }
    100% { transform: scale(1.1) rotate(1deg); }
}

.candle.blown-out .flame,
.candle.blown-out .flame-inner {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* 蛋糕說明 */
.cake-instructions {
    margin: 10px 0;
}

.cake-instructions p {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: white;
}

/* 簡化的說明文字 */
.instruction {
    font-size: 0.9rem;
    color: white;
    margin-bottom: 10px;
}

/* 手機權限提示 */
.mobile-permission-hint {
    background: rgba(255, 193, 7, 0.9);
    color: #333;
    padding: 8px 12px;
    border-radius: 15px;
    margin: 8px 0;
    font-size: 0.8rem;
    animation: permissionPulse 2s ease-in-out infinite;
}

.mobile-permission-hint p {
    margin: 0;
    font-weight: bold;
}

@keyframes permissionPulse {
    0%, 100% {
        background: rgba(255, 193, 7, 0.9);
        transform: scale(1);
    }
    50% {
        background: rgba(255, 193, 7, 1);
        transform: scale(1.02);
    }
}



/* 手機權限提示 */
.mobile-permission-hint {
    margin: 10px 0;
    padding: 8px 12px;
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid rgba(255, 193, 7, 0.5);
    border-radius: 15px;
    animation: permissionPulse 2s ease-in-out infinite;
}

.mobile-permission-hint p {
    font-size: 0.8rem;
    color: #FFC107;
    margin: 0;
    text-align: center;
}

@keyframes permissionPulse {
    0%, 100% {
        background: rgba(255, 193, 7, 0.2);
        border-color: rgba(255, 193, 7, 0.5);
    }
    50% {
        background: rgba(255, 193, 7, 0.4);
        border-color: rgba(255, 193, 7, 0.8);
    }
}

.mic-button {
    background: linear-gradient(135deg, #ff7a9a 0%, #ff5577 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(255, 122, 154, 0.4);
}

.mic-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 122, 154, 0.6);
}

.mic-button:active {
    transform: translateY(0);
}

/* 音量指示器 */
.volume-indicator {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.volume-label {
    font-size: 0.8rem;
    color: white;
}

.volume-bar {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.volume-level {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #FFC107, #FF5722);
    width: 0%;
    transition: width 0.1s ease;
    border-radius: 4px;
}

/* 吹氣進度條 */
.blow-progress {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.progress-label {
    font-size: 0.8rem;
    color: white;
}

.progress-bar {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-level {
    height: 100%;
    background: linear-gradient(90deg, #FF6B35, #F7931E, #FFD700);
    width: 0%;
    transition: width 0.2s ease;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* 控制按鈕 */
.controls {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
    z-index: 10;
    touch-action: manipulation; /* 防止滑動手勢干擾 */
}

.control-btn {
    background: linear-gradient(135deg, #ff91a4 0%, #ff7a9a 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(255, 145, 164, 0.4);
    position: relative;
    z-index: 10;
    min-height: 44px; /* 確保觸摸目標足夠大 */
    min-width: 120px;
    touch-action: manipulation; /* 優化觸摸響應 */
}

.control-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 145, 164, 0.6);
}

/* 彩帶動畫 */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff6b9d;
    animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* 全屏烟火效果 */
.fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 0.5s ease;
    will-change: opacity;
    transform: translateZ(0); /* 啟用硬件加速 */
}

.fireworks-container.active {
    opacity: 1;
}

.firework {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    will-change: transform;
    transform: translateZ(0);
}

.firework-trail {
    position: absolute;
    width: 2px;
    height: 20px;
    border-radius: 1px;
    animation: fireworkTrail 1s ease-out forwards;
    will-change: transform, opacity;
    transform: translateZ(0);
}

.firework-explosion {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: fireworkExplosion 1.5s ease-out forwards;
    will-change: transform, opacity;
    transform: translateZ(0);
}

.firework-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    animation: fireworkParticle 2s ease-out forwards;
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes fireworkTrail {
    0% {
        transform: translate3d(0, 100vh, 0) scale3d(1, 1, 1);
        opacity: 1;
    }
    100% {
        transform: translate3d(0, 0, 0) scale3d(0.5, 0.5, 1);
        opacity: 0.8;
    }
}

@keyframes fireworkExplosion {
    0% {
        transform: scale3d(0, 0, 1);
        opacity: 1;
    }
    50% {
        transform: scale3d(8, 8, 1);
        opacity: 0.8;
    }
    100% {
        transform: scale3d(15, 15, 1);
        opacity: 0;
    }
}

@keyframes fireworkParticle {
    0% {
        transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
        opacity: 1;
    }
    100% {
        transform: translate3d(var(--dx), var(--dy), 0) scale3d(0, 0, 1);
        opacity: 0;
    }
}

/* 烟火闪烁效果 */
@keyframes fireworkSparkle {
    0%, 100% {
        opacity: 0;
        transform: scale3d(0, 0, 1);
    }
    50% {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

.firework-sparkle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: fireworkSparkle 0.5s ease-in-out infinite;
    will-change: transform, opacity;
    transform: translateZ(0);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }

    .card-book {
        width: 420px;
        height: 220px;
    }

    .cover-content h2 {
        font-size: 3rem;
    }

    .page-content h3 {
        font-size: 1.5rem;
    }

    .page-content p {
        font-size: 1rem;
    }

    .birthday-cake {
        width: 180px;
        height: 140px;
    }

    .navigation {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .nav-btn {
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .title {
        font-size: 1.5rem;
    }

    .card-book {
        width: 350px;
        height: 200px;
    }

    .cover-content h2 {
        font-size: 2.5rem;
    }

    .page-content h3 {
        font-size: 1.3rem;
    }

    .page-content p {
        font-size: 0.9rem;
    }

    .birthday-cake {
        width: 160px;
        height: 120px;
    }

    .controls {
        flex-direction: column;
        gap: 8px;
    }

    .control-btn, .mic-button {
        width: 150px;
        margin: 0 auto;
    }
}
