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

:root {
    --accent: #f2c76f;
    --accent-rgb: 242, 199, 111;
    --title-grad: linear-gradient(to bottom, #fffdf4 0%, #ffe3a2 48%, #e09a35 100%);
    --bg-css: radial-gradient(circle at 50% 42%, #241407 0%, #0b0603 78%);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    overflow: hidden;
    background: var(--bg-css);
    background-color: #0b0603;
    color: #fff;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Times New Roman', serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body.preview-embed .top-actions,
body.preview-embed #envelope-overlay {
    display: none !important;
}

#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 1;
}

#fireworks-canvas {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

/* ============ 发光圣诞礼盒 / 信封开场 ============ */
.envelope-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: radial-gradient(circle at center, rgba(24, 14, 8, 0.88) 0%, rgba(5, 3, 2, 0.96) 100%);
    backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: opacity 0.85s ease, transform 0.85s ease;
}

.envelope-overlay.opened {
    opacity: 0;
    transform: scale(1.06);
    pointer-events: none;
}

.envelope-card {
    width: 100%;
    max-width: 390px;
    padding: 36px 28px 30px;
    border-radius: 22px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(10, 8, 6, 0.82));
    border: 1px solid rgba(var(--accent-rgb), 0.48);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.78), 0 0 60px rgba(var(--accent-rgb), 0.16);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.envelope-seal {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.35), rgba(var(--accent-rgb), 0.08));
    border: 1.5px solid rgba(var(--accent-rgb), 0.65);
    display: grid;
    place-items: center;
    font-size: 34px;
    animation: floatGift 2.4s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.38);
}

@keyframes floatGift {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-7px) scale(1.05); }
}

.envelope-to {
    font-size: 13px;
    letter-spacing: 3px;
    color: var(--accent);
    padding: 4px 14px;
    border-radius: 999px;
    background: rgba(var(--accent-rgb), 0.14);
    border: 1px solid rgba(var(--accent-rgb), 0.32);
}

.envelope-title {
    margin: 4px 0 0;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.4;
    background: var(--title-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.envelope-from {
    margin: 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.68);
}

.envelope-from:empty { display: none; }

.open-gift-btn {
    margin-top: 10px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #fff6dc 0%, var(--accent) 65%, #d4962e 100%);
    color: #1a1004;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(var(--accent-rgb), 0.48);
    transition: transform 0.2s, box-shadow 0.2s;
}

.open-gift-btn:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 12px 40px rgba(var(--accent-rgb), 0.65);
}

.envelope-tip {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 4px;
}

/* ============ 主界面 UI ============ */
#ui-layer {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 24px 16px 20px;
}

.hero-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    max-width: 92vw;
}

.recipient-tag {
    font-size: 13px;
    letter-spacing: 3px;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.36);
    border: 1px solid rgba(var(--accent-rgb), 0.36);
    padding: 4px 14px;
    border-radius: 999px;
    backdrop-filter: blur(8px);
}
.recipient-tag:empty { display: none; }

h1 {
    margin: 0;
    font-size: clamp(26px, 5.8vw, 52px);
    font-weight: 500;
    letter-spacing: 5px;
    font-family: 'Cinzel', 'PingFang SC', 'Times New Roman', serif;
    background: var(--title-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 36px rgba(var(--accent-rgb), 0.5);
    line-height: 1.22;
}

.timer-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 15px;
    border-radius: 999px;
    background: rgba(6, 10, 20, 0.48);
    border: 1px solid rgba(var(--accent-rgb), 0.28);
    backdrop-filter: blur(8px);
    font-size: 12px;
}
.timer-box[hidden] { display: none; }
.timer-label { color: rgba(255, 255, 255, 0.72); }
.timer-value { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

/* 树顶语音彩蛋按钮 */
.voice-egg-pill {
    pointer-events: auto;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 15px;
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.58);
    background: rgba(var(--accent-rgb), 0.16);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.32);
    transition: all 0.22s;
}

.voice-egg-pill[hidden] { display: none; }
.voice-egg-pill:hover {
    background: rgba(var(--accent-rgb), 0.28);
    transform: scale(1.03);
}
.voice-egg-pill.playing {
    background: var(--accent);
    color: #140c03;
    font-weight: 600;
}
.voice-egg-pill.playing .voice-star {
    display: inline-block;
    animation: spinStar 1.6s linear infinite;
}
@keyframes spinStar { to { transform: rotate(360deg); } }

/* 右上角轻量工具栏 */
.top-actions {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 20;
    pointer-events: auto;
    display: flex;
    gap: 8px;
}

.pill-btn {
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.42);
    background: rgba(10, 12, 20, 0.58);
    color: var(--accent);
    font-size: 12px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.22s;
}
.pill-btn:hover,
.pill-btn.active {
    background: var(--accent);
    color: #0e0a04;
    font-weight: 600;
}

/* 底部告白文案 + 互动胶囊栏 */
.bottom-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 94vw;
}

.love-message {
    margin: 0;
    max-width: 600px;
    text-align: center;
    font-size: clamp(13px, 1.9vw, 15px);
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(6, 10, 20, 0.38);
    padding: 8px 18px;
    border-radius: 12px;
    border: 1px solid rgba(var(--accent-rgb), 0.22);
    backdrop-filter: blur(6px);
}
.love-message:empty { display: none; }

.mode-dock {
    pointer-events: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(8, 12, 22, 0.65);
    border: 1px solid rgba(var(--accent-rgb), 0.34);
    backdrop-filter: blur(12px);
}

.dock-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.84);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.dock-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.dock-btn.active {
    background: var(--accent);
    color: #120c04;
    font-weight: 600;
    box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.45);
}

/* 摄像头小窗 */
#webcam-wrapper {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 170px;
    height: 128px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(var(--accent-rgb), 0.48);
    background: #000;
    z-index: 40;
}
#webcam-wrapper[hidden] { display: none; }
#webcam { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#gesture-status {
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.68);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    text-align: center;
}

.toast {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(12, 16, 28, 0.9);
    border: 1px solid rgba(var(--accent-rgb), 0.5);
    color: #fff;
    font-size: 12px;
    backdrop-filter: blur(10px);
}
.toast[hidden] { display: none; }

@media (max-width: 720px) {
    .top-actions { top: 10px; right: 10px; gap: 5px; }
    .pill-btn { padding: 5px 10px; font-size: 11px; }
    .mode-dock { border-radius: 16px; }
    .dock-btn { padding: 5px 9px; font-size: 11px; }
    #webcam-wrapper { width: 108px; height: 80px; bottom: auto; top: 10px; left: 10px; }
}
