* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #000;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#cake-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ========== Start screen ========== */
#start-screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-top: 25vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    transition: opacity 1s ease;
    pointer-events: auto;
    z-index: 100;
}

#start-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.start-content {
    text-align: center;
    padding: 0 1.5rem;
    width: 100%;
}

.star-icon {
    font-size: clamp(3.5rem, 10vw, 5rem);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-12px);
    }
}

.start-text-top {
    font-family: 'Noto Serif SC', serif;
    font-size: clamp(1rem, 3.5vw, 1.3rem);
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 2rem;
    line-height: 1.6;
    padding: 0 1rem;
    letter-spacing: 1px;
}

.start-text {
    font-family: 'Noto Serif SC', serif;
    font-size: clamp(1.6rem, 5.5vw, 2.2rem);
    color: rgba(255, 255, 255, 0.9);
    margin-top: 1.5rem;
    letter-spacing: 3px;
}

.start-sub {
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    color: rgba(255, 255, 255, 0.4);
    margin-top: 1rem;
    animation: pulse-opacity 2s ease-in-out infinite;
}

@keyframes pulse-opacity {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.8;
    }
}

/* ========== Hint ========== */
#hint {
    position: absolute;
    top: 8%;
    transition: opacity 1.5s ease;
    pointer-events: none;
    padding: 0 1rem;
}

#hint.hidden {
    opacity: 0;
}

#hint.visible {
    opacity: 1;
}

.glow-text {
    font-family: 'ZCOOL KuaiLe', 'Dancing Script', cursive;
    font-size: clamp(1.2rem, 4.5vw, 2rem);
    color: #ffecd2;
    text-shadow:
        0 0 10px rgba(255, 200, 100, 0.8),
        0 0 20px rgba(255, 150, 50, 0.5),
        0 0 40px rgba(255, 100, 50, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
    letter-spacing: 2px;
}

@keyframes pulse-glow {

    0%,
    100% {
        text-shadow:
            0 0 10px rgba(255, 200, 100, 0.8),
            0 0 20px rgba(255, 150, 50, 0.5),
            0 0 40px rgba(255, 100, 50, 0.3);
    }

    50% {
        text-shadow:
            0 0 15px rgba(255, 200, 100, 1.0),
            0 0 30px rgba(255, 150, 50, 0.8),
            0 0 60px rgba(255, 100, 50, 0.5);
    }
}

/* ========== Letter ========== */
#letter {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 2s ease;
    pointer-events: none;
    /* Background image from cake.jpg */
    background: url('cake.jpg') center / cover no-repeat;
}

#letter.hidden {
    opacity: 0;
}

#letter.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Dark overlay on top of background image */
#letter::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 15, 0.55);
    backdrop-filter: blur(6px);
}

.letter-card {
    position: relative;
    /* above ::before */
    max-width: 580px;
    width: 92%;
    background: rgba(240, 240, 255, 0.12);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: clamp(1.5rem, 5vw, 2.5rem) clamp(1.2rem, 4vw, 2.2rem) clamp(1rem, 3vw, 1.5rem);
    box-shadow:
        0 0 50px rgba(100, 80, 200, 0.12),
        inset 0 0 30px rgba(255, 255, 255, 0.04);
}

.letter-content {
    font-family: 'ZCOOL KuaiLe', 'Noto Serif SC', serif;
    color: rgba(255, 255, 255, 0.92);
    line-height: 1.8;
    font-size: clamp(1.15rem, 3.5vw, 1.35rem);
}

.letter-greeting {
    font-size: clamp(1.5rem, 4.5vw, 1.8rem);
    color: #ffd700;
    margin-bottom: 1rem;
}

.letter-line {
    font-size: clamp(1.1rem, 3.2vw, 1.25rem);
    margin-bottom: 1.2em;
    /* 1.5x line gap between paragraphs */
    text-indent: 2em;
}

.letter-closing {
    font-size: clamp(1.6rem, 5vw, 2rem);
    color: #ffd700;
    margin-top: 1.5rem;
    text-align: center;
}

.letter-sign {
    font-size: clamp(1.2rem, 3.8vw, 1.45rem);
    text-align: right;
    margin-top: 1.5rem;
    color: rgba(255, 220, 170, 0.9);
}

.letter-date {
    font-size: clamp(1.05rem, 3vw, 1.2rem);
    text-align: right;
    color: rgba(255, 220, 170, 0.6);
    margin-top: 0.3rem;
}

/* ========== Replay button ========== */
.replay-button {
    display: block;
    margin: 1.8rem auto 0;
    padding: 0.7rem 1.8rem;
    background: rgba(255, 200, 100, 0.15);
    border: 1px solid rgba(255, 200, 100, 0.35);
    border-radius: 30px;
    color: #ffecd2;
    font-family: 'ZCOOL KuaiLe', serif;
    font-size: clamp(0.95rem, 3vw, 1.1rem);
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: auto;
    letter-spacing: 1px;
}

.replay-button:hover {
    background: rgba(255, 200, 100, 0.28);
    border-color: rgba(255, 200, 100, 0.5);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 200, 100, 0.15);
}

.replay-button:active {
    transform: scale(0.98);
}

/* ========== Scrolling Lyrics ========== */
.lyrics-box {
    position: fixed;
    bottom: 10%;
    left: 0;
    right: 0;
    height: 48px;
    z-index: 15;
    overflow: hidden;
    pointer-events: none;
    transition: opacity 1.5s ease;
    /* Fade edges */
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 15%, black 85%, transparent 100%);
}

.lyrics-box.hidden {
    opacity: 0;
}

.lyrics-box.visible {
    opacity: 1;
}

.lyrics-scroll {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateY(48px);
}

.lyric-line {
    font-family: 'Dancing Script', 'Outfit', sans-serif;
    font-size: clamp(1.1rem, 3.5vw, 1.3rem);
    color: rgba(255, 255, 255, 0.3);
    white-space: nowrap;
    padding: 10px 0;
    letter-spacing: 0.5px;
    transition: all 0.4s ease;
    height: 28px;
    line-height: 28px;
    margin: 0;
}

.lyric-line.active-lyric {
    color: rgba(255, 220, 100, 1.0);
    font-size: clamp(1.3rem, 4.2vw, 1.5rem);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 200, 50, 0.6);
}

.lyric-line.lyric-chorus {
    color: rgba(255, 215, 100, 0.65);
    font-weight: 700;
}

/* ========== Camera preview ========== */
#camera-preview {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: clamp(100px, 18vw, 140px);
    height: clamp(75px, 13.5vw, 105px);
    border-radius: 14px;
    border: 2px solid rgba(255, 200, 100, 0.3);
    object-fit: cover;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    transform: scaleX(-1);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#camera-preview.active {
    opacity: 1;
    pointer-events: auto;
}

/* ========== Gesture button ========== */
.gesture-button {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 0.5rem 1rem;
    background: rgba(255, 200, 100, 0.12);
    border: 1px solid rgba(255, 200, 100, 0.3);
    border-radius: 20px;
    color: #ffecd2;
    font-family: 'ZCOOL KuaiLe', sans-serif;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    cursor: pointer;
    z-index: 50;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.gesture-button.hidden {
    opacity: 0;
    pointer-events: none;
}

.gesture-button.visible {
    opacity: 1;
}

.gesture-button:hover {
    background: rgba(255, 200, 100, 0.25);
    border-color: rgba(255, 200, 100, 0.5);
}

.gesture-button.active {
    background: rgba(100, 255, 150, 0.15);
    border-color: rgba(100, 255, 150, 0.4);
    color: #c0ffd0;
}

/* ========== Blow hint ========== */
.blow-hint-text {
    position: fixed;
    top: 14%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'ZCOOL KuaiLe', sans-serif;
    font-size: clamp(1rem, 3.5vw, 1.4rem);
    color: #ffecd2;
    text-shadow:
        0 0 10px rgba(255, 200, 100, 0.8),
        0 0 20px rgba(255, 150, 50, 0.5),
        0 0 40px rgba(255, 100, 50, 0.3);
    z-index: 20;
    pointer-events: none;
    transition: opacity 1s ease;
    text-align: center;
    white-space: nowrap;
}

.blow-hint-text.hidden {
    opacity: 0;
}

.blow-hint-text.visible {
    opacity: 1;
    animation: pulse-glow 2s ease-in-out infinite;
}