@font-face {
    font-family: 'Cinzel';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../vendor/fonts/cinzel.woff2') format('woff2');
}

:root {
    --bg-deep: #090503;
    --gold-bright: #fff4d4;
    --gold-main: #f3c46b;
    --gold-warm: #c98b32;
    --gold-border: rgba(243, 196, 107, 0.34);
    --gold-border-strong: rgba(255, 224, 158, 0.68);
    --surface-glass: rgba(20, 12, 6, 0.72);
    --polaroid-paper: #fbf5e8;
    --polaroid-ink: #3b2a19;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-deep);
    color: var(--gold-bright);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
    user-select: none;
}

/* 3D 渲染层 */
#canvas-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1;
}

/* 顶部左上方优雅花体标题层 */
#ui-layer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-top: max(42px, 8vh, var(--safe-top));
    padding-left: clamp(28px, 5.2vw, 76px);
    padding-right: 20px;
    transition: opacity 0.4s ease;
}

#ui-layer.dimmed {
    opacity: 0;
    pointer-events: none;
}

h1#main-title {
    margin: 0;
    font-family: 'Snell Roundhand', 'French Script MT', 'Edwardian Script ITC', 'Apple Chancery', 'Palatino Linotype', 'Georgia', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(40px, 5.0vw, 66px);
    letter-spacing: 1.5px;
    line-height: 1.15;
    text-align: left;
    text-transform: none;
    background-image: linear-gradient(165deg, #fffefb 0%, #fbe7d8 48%, #e5be8e 86%, #cc965c 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 18px rgba(255, 224, 198, 0.44)) drop-shadow(0 0 42px rgba(255, 198, 130, 0.20));
    max-width: min(88vw, 520px);
    word-break: break-word;
}

#fade-in {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #090503;
    pointer-events: none;
    opacity: 1;
    animation: fadeAway 0.85s ease 0.1s forwards;
}

@keyframes fadeAway {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* 轻量化底部状态栏 */
#bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: max(12px, 1.8vh, var(--safe-bottom));
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px;
    pointer-events: none;
    transition: opacity 0.32s ease, transform 0.32s ease;
}

#bottom-bar.is-hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.hint-pill {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(243, 196, 107, 0.22);
    background: rgba(16, 9, 4, 0.58);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: rgba(255, 236, 194, 0.82);
    font-size: 12px;
    letter-spacing: 0.6px;
}

.subtle-btn {
    pointer-events: auto;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--gold-border);
    background: rgba(26, 15, 7, 0.76);
    color: var(--gold-bright);
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 12px;
    letter-spacing: 0.6px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: border-color 0.25s ease, background-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.subtle-btn:hover,
.subtle-btn:focus-visible {
    border-color: var(--gold-border-strong);
    background: rgba(48, 28, 12, 0.88);
    outline: none;
}

.subtle-btn:active {
    transform: scale(0.97);
}

.gesture-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(243, 196, 107, 0.45);
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.gesture-btn.is-active {
    border-color: rgba(255, 214, 130, 0.82);
    background: rgba(68, 40, 14, 0.88);
    box-shadow: 0 0 18px rgba(255, 200, 100, 0.22);
}

.gesture-btn.is-active .gesture-dot {
    background: #8ff0a4;
    box-shadow: 0 0 8px rgba(143, 240, 164, 0.8);
}

/* 顶部星光 / 手势状态轻提示 */
#toast-tip {
    position: fixed;
    top: max(76px, 11vh);
    left: 50%;
    transform: translate(-50%, -8px);
    z-index: 45;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 224, 158, 0.58);
    background: rgba(30, 17, 7, 0.92);
    color: #fff4d4;
    font-size: 12.5px;
    letter-spacing: 0.6px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.62);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.28s ease, transform 0.28s ease;
    white-space: nowrap;
    max-width: calc(100vw - 28px);
    overflow: hidden;
    text-overflow: ellipsis;
}

#toast-tip.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* =========================================
   3D 环绕相册浮层（中间区域透空直触 3D Canvas）
   ========================================= */
#album-overlay {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

#album-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.album-topbar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(16px, 2.4vh, var(--safe-top)) 22px 12px;
    background: linear-gradient(180deg, rgba(9, 5, 3, 0.86) 0%, rgba(9, 5, 3, 0.38) 72%, transparent 100%);
}

.album-heading {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.album-title {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 15px;
    letter-spacing: 3px;
    color: #ffe6ad;
    text-transform: uppercase;
}

.album-subtitle {
    font-size: 12px;
    color: rgba(242, 218, 174, 0.74);
    letter-spacing: 0.4px;
}

.album-close-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid var(--gold-border-strong);
    background: rgba(28, 16, 7, 0.90);
    color: #fff3d6;
    font-size: 13px;
    letter-spacing: 1px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.48), 0 0 18px rgba(243, 196, 107, 0.18);
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.album-close-btn:hover,
.album-close-btn:focus-visible {
    background: rgba(66, 38, 16, 0.96);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.58), 0 0 24px rgba(255, 212, 130, 0.30);
    outline: none;
}

.album-close-btn:active {
    transform: scale(0.96);
}

.album-bottom-bar {
    pointer-events: auto;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: max(14px, 2.2vh, var(--safe-bottom));
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(14, 8, 4, 0.62);
    border: 1px solid rgba(243, 196, 107, 0.20);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.album-zoom-btn {
    border-color: rgba(255, 224, 158, 0.54);
    background: rgba(54, 31, 12, 0.85);
}

#album-counter {
    font-family: 'Cinzel', serif;
    font-size: 11px;
    color: #f6cf83;
}

/* =========================================
   拍立得大图查看器
   ========================================= */
#lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(20px, var(--safe-top)) 20px max(20px, var(--safe-bottom));
    background: rgba(8, 4, 2, 0.86);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#lightbox-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.lightbox-shell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    width: 100%;
    max-width: 720px;
}

.lightbox-card {
    position: relative;
    width: min(86vw, 430px);
    max-height: 86dvh;
    padding: 16px 16px 22px;
    border-radius: 8px;
    background: linear-gradient(168deg, #fffaf0 0%, #f4ead4 100%);
    border: 1px solid rgba(255, 224, 160, 0.65);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.78), 0 0 42px rgba(255, 200, 110, 0.16);
    color: var(--polaroid-ink);
    display: flex;
    flex-direction: column;
    transform: scale(0.94);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    touch-action: pan-y;
}

#lightbox-overlay.is-open .lightbox-card {
    transform: scale(1);
}

.lightbox-photo-wrap {
    width: 100%;
    aspect-ratio: 6 / 7;
    max-height: 58dvh;
    overflow: hidden;
    border-radius: 4px;
    background: #160d06;
    border: 1px solid rgba(120, 82, 36, 0.2);
}

#lightbox-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.lightbox-footer {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#lightbox-caption {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: #3a2816;
    text-align: center;
    min-height: 24px;
    word-break: break-word;
}

.lightbox-subbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #8f6b3e;
    padding-top: 4px;
    border-top: 1px solid rgba(154, 110, 50, 0.16);
}

.lightbox-nav-btn {
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--gold-border-strong);
    background: rgba(24, 14, 6, 0.84);
    color: #fff1cf;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.lightbox-nav-btn:hover,
.lightbox-nav-btn:focus-visible {
    background: rgba(68, 40, 16, 0.92);
    outline: none;
}

.lightbox-nav-btn:active {
    transform: scale(0.92);
}

.lightbox-close-btn {
    position: fixed;
    top: max(18px, var(--safe-top));
    right: 20px;
    z-index: 65;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--gold-border-strong);
    background: rgba(26, 15, 7, 0.92);
    color: #fff3d6;
    font-size: 13px;
    letter-spacing: 0.6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.lightbox-close-btn:hover,
.lightbox-close-btn:focus-visible {
    background: rgba(68, 40, 16, 0.95);
    outline: none;
}

.lightbox-mobile-nav {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
}

/* =========================================
   树下礼盒祝福卡片弹窗
   ========================================= */
#gift-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(20px, var(--safe-top)) 18px max(20px, var(--safe-bottom));
    background: rgba(8, 4, 2, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

#gift-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.gift-card {
    position: relative;
    width: min(90vw, 440px);
    padding: 30px 26px 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 222, 156, 0.52);
    background: radial-gradient(120% 100% at 50% 0%, rgba(56, 31, 13, 0.96) 0%, rgba(22, 12, 5, 0.98) 72%);
    box-shadow:
        0 26px 70px rgba(0, 0, 0, 0.78),
        0 0 42px rgba(243, 196, 107, 0.16),
        inset 0 0 28px rgba(255, 214, 140, 0.06);
    text-align: center;
    color: var(--gold-bright);
    transform: translateY(14px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

#gift-modal.is-open .gift-card {
    transform: translateY(0) scale(1);
}

.gift-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid rgba(243, 196, 107, 0.34);
    background: rgba(243, 196, 107, 0.10);
    color: #f6cf83;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 14px;
}

#gift-headline {
    margin: 0 0 16px;
    font-size: clamp(20px, 4.6vw, 26px);
    font-weight: 500;
    letter-spacing: 1.5px;
    line-height: 1.35;
    color: #fff6de;
    text-shadow: 0 0 18px rgba(255, 206, 118, 0.35);
    word-break: break-word;
}

.gift-message-wrap {
    margin-bottom: 10px;
}

#gift-message-input {
    width: 100%;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid rgba(243, 196, 107, 0.30);
    background: rgba(12, 7, 3, 0.65);
    color: #ffe9be;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.55;
    text-align: center;
    resize: none;
    overflow: hidden;
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

#gift-message-input:focus {
    border-color: rgba(255, 224, 158, 0.72);
    background: rgba(18, 10, 4, 0.85);
}

#gift-edit-hint {
    margin: 0 0 20px;
    font-size: 11.5px;
    color: rgba(235, 210, 168, 0.62);
    letter-spacing: 0.4px;
}

.gift-close-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 132px;
    padding: 10px 24px;
    border-radius: 999px;
    border: 1px solid var(--gold-border-strong);
    background: linear-gradient(180deg, rgba(255, 232, 178, 0.92), rgba(226, 169, 76, 0.92));
    color: #241305;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.2px;
    box-shadow: 0 6px 24px rgba(243, 196, 107, 0.24);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gift-close-btn:hover,
.gift-close-btn:focus-visible {
    box-shadow: 0 8px 28px rgba(255, 214, 130, 0.42);
    outline: none;
}

.gift-close-btn:active {
    transform: scale(0.96);
}

/* =========================================
   可选手势预览窗 & 诊断面板（默认隐藏）
   ========================================= */
#webcam-wrapper {
    position: fixed;
    right: 14px;
    bottom: 62px;
    width: 96px;
    height: 72px;
    z-index: 35;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(243, 196, 107, 0.34);
    background: rgba(14, 8, 4, 0.72);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

#webcam-wrapper.is-visible {
    opacity: 0.68;
}

#webcam-preview {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

#diag {
    display: none;
    position: fixed;
    left: 14px;
    top: 74px;
    z-index: 40;
    font: 11px/1.65 Consolas, "Microsoft YaHei", monospace;
    color: #f0dcb4;
    background: rgba(20, 12, 5, 0.72);
    border: 1px solid rgba(243, 196, 107, 0.25);
    padding: 8px 11px;
    border-radius: 8px;
    pointer-events: none;
    white-space: pre;
}

/* =========================================
   手机竖屏（390px / 375px）精细适配
   ========================================= */
@media (max-width: 640px) {
    #ui-layer {
        padding-top: max(16px, 2.8vh, var(--safe-top));
        padding-left: 18px;
        padding-right: 18px;
    }

    h1#main-title {
        font-size: clamp(30px, 8.6vw, 40px);
        letter-spacing: 1px;
    }

    #bottom-bar {
        gap: 6px;
        bottom: max(10px, 1.4vh, var(--safe-bottom));
    }

    .hint-pill {
        font-size: 11px;
        padding: 6px 11px;
    }

    .subtle-btn {
        font-size: 11px;
        padding: 6px 11px;
    }

    .album-topbar {
        padding: max(12px, var(--safe-top)) 14px 10px;
    }

    .album-title {
        font-size: 13px;
        letter-spacing: 2px;
    }

    .album-subtitle {
        font-size: 11px;
    }

    .album-close-btn {
        padding: 8px 13px;
        font-size: 12px;
    }

    .album-bottom-bar {
        gap: 6px;
        padding: 6px 9px;
        margin-bottom: max(12px, var(--safe-bottom));
    }

    .lightbox-shell > .lightbox-nav-btn {
        display: none;
    }

    .lightbox-card {
        width: min(90vw, 344px);
        padding: 12px 12px 16px;
    }

    .lightbox-mobile-nav {
        display: flex;
    }

    .lightbox-close-btn {
        top: max(12px, var(--safe-top));
        right: 12px;
        padding: 8px 14px;
        font-size: 12px;
    }

    #webcam-wrapper {
        width: 72px;
        height: 54px;
        right: 10px;
        bottom: 58px;
    }
}

/* =========================================
   prefers-reduced-motion 无障碍动态减弱
   ========================================= */
@media (prefers-reduced-motion: reduce) {
    #fade-in {
        animation: none;
        opacity: 0;
        visibility: hidden;
    }

    .lightbox-card,
    .gift-card,
    #album-overlay,
    #lightbox-overlay,
    #gift-modal,
    #bottom-bar,
    #ui-layer,
    #toast-tip {
        transition-duration: 0.15s !important;
        transition-delay: 0ms !important;
    }
}
