#opening {
    z-index: 10;
    isolation: isolate;
    overflow: hidden;
    color: #fff0d7;
    background: #08130e;
    --inset-x: clamp(18px, 3.15vw, 64px);
    --inset-y: clamp(18px, 4.3vh, 48px);
}
.gift-paper {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #03100bbf, #06150e8a 28%, transparent 63%),
                url("../images/noel-velvet-gift.webp") center 54% / cover no-repeat, #0b1a10;
    transition: transform 1.05s cubic-bezier(.34,.02,.16,1), opacity .9s ease;
}
.paper-left { clip-path: polygon(0 0, 52.1% 0, 46.1% 100%, 0 100%); }
.paper-right { clip-path: polygon(52% 0, 100% 0, 100% 100%, 46% 100%); }
.gift-border {
    position:absolute; inset:var(--inset-y) var(--inset-x);
    border:1px solid #dac7a648;
    box-shadow: inset 0 0 0 4px #09181220;
    pointer-events:none;
}
.gift-border::before,.gift-border::after {
    content:""; position:absolute;width:36px;height:36px;border:solid #e7ce9b9c;
}
.gift-border::before {top:-1px;left:-1px;border-width:1px 0 0 1px}
.gift-border::after {bottom:-1px;right:-1px;border-width:0 1px 1px 0}
.opening-signature {
    position:absolute; top:calc(var(--inset-y) + clamp(14px,2.7vw,42px));
    left:calc(var(--inset-x) + clamp(18px,4.7vw,94px));
    display:flex;align-items:center;gap:.16em;
    color:#e9d7b5;font:500 clamp(21px,2.4vw,37px)/1 var(--serif);
}
.opening-signature .icon {width:.55em;height:.55em;margin-right:.35em;color:#edd29a;fill:#d9bd87;stroke-width:.7}
.opening-signature em {font-weight:500}
.opening-copy {
    position:absolute; left:calc(var(--inset-x) + clamp(18px,4.7vw,94px));
    top:53%; transform:translateY(-46%);
    width:min(43%,720px); max-height:70%; overflow-y:auto; scrollbar-width:thin;
    padding:5px 8px 12px 0;
}
.foil-rule {display:flex;align-items:center;gap:8px;width:clamp(100px,12vw,200px);color:#dec798;margin-bottom:clamp(12px,2.8vh,29px)}
.foil-rule::before,.foil-rule::after {content:"";height:1px;background:linear-gradient(90deg,#c3a26f,transparent);flex:1}
.foil-rule::before {flex:0 0 23%;background:linear-gradient(90deg,#8b7655,#dcc499)}
.foil-rule span {font-size:18px;line-height:1}
.opening-wish {animation:unseal-copy .55s ease-out both}
.opening-wish h1 {
    font:500 clamp(52px,7.9vw,144px)/.87 var(--serif);
    color:#fff1d6;letter-spacing:-.045em;text-shadow:0 3px 34px #05110880;
    overflow-wrap:anywhere;margin:0;padding-bottom:.08em;
}
.opening-wish h1 em {display:block;font-weight:500;color:#f2d3a0}
.opening-wish h1[data-personal] {font-size:clamp(36px,5.3vw,86px);line-height:1.18;letter-spacing:.015em;text-wrap:balance}
.opening-wish h1[data-length=long] {font-size:clamp(23px,2.7vw,44px)}
.opening-wish p {margin:clamp(16px,2.5vh,30px) 0 0;font-size:clamp(13px,1.05vw,18px);line-height:1.8;letter-spacing:.095em;color:#eee5d3;white-space:pre-line;overflow-wrap:anywhere}
#open-gift {display:inline-flex;align-items:center;gap:10px;margin-top:clamp(16px,4.2vh,46px);border:0;padding:2px;background:transparent;color:#f4dec0;text-align:left}
.seal {display:grid;place-items:center;width:43px;height:43px;border-radius:50%;color:#f6ddb1;border:1px solid #e5d1a9a6;background:linear-gradient(135deg,#a48b5e45,#0c1b14af);box-shadow:inset 0 0 0 3px #17231b,inset 0 0 0 4px #d5c29666;transition:transform .25s}
.seal .icon {width:19px;height:19px;stroke-width:1.35}
.seal-caption {font-size:12px;letter-spacing:.1em}
.seal-arrow {font-size:16px;color:#dcc39b;transition:transform .25s}
#open-gift:hover .seal {transform:rotate(-7deg)} #open-gift:hover .seal-arrow {transform:translate(2px,-2px)}
#opening[data-phase=ready] {cursor:pointer}
#opening-status {margin:16px 0 0;color:#eddec4;font-size:12px;letter-spacing:.08em}
#opening-status:empty {display:none}
#opening[data-phase=opening] {background:transparent;pointer-events:auto;animation:gift-away .96s ease both}
#opening[data-phase=opening] .paper-left {transform:translate(-15%,-3%) rotate(-4deg);opacity:0}
#opening[data-phase=opening] .paper-right {transform:translate(18%,-3%) rotate(5deg);opacity:0}
#opening[data-phase=opening] :is(.opening-copy,.opening-signature,.gift-border) {opacity:0;transition:opacity .3s ease}
@keyframes unseal-copy {from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes gift-away {0%,15%{opacity:1}100%{opacity:0}}
@media (max-width:700px) and (orientation:portrait) {
    #opening {--inset-x:max(14px,env(safe-area-inset-left));--inset-y:max(16px,env(safe-area-inset-top))}
    .gift-paper {background:linear-gradient(to bottom,#06130c22 0%,transparent 28%,#07150de6 52%,#07150d 69%),
        url("../images/noel-velvet-gift.webp") 78% 0 / auto 66% no-repeat,#07150d}
    .opening-signature {top:calc(var(--inset-y) + 16px);left:calc(var(--inset-x) + 18px);font-size:24px;text-shadow:0 2px 10px #031009}
    .opening-copy {top:auto;bottom:max(6vh,calc(env(safe-area-inset-bottom) + 26px));transform:none;left:calc(var(--inset-x) + 20px);width:calc(100% - 2 * var(--inset-x) - 40px);max-height:57%;padding-bottom:4px}
    .opening-wish h1 {font-size:clamp(48px,min(16vw,8.8vh),82px)}
    .opening-wish h1[data-personal] {font-size:clamp(30px,9vw,50px)}
    .opening-wish h1[data-length=long] {font-size:24px}
    .opening-wish p {font-size:13px;margin-top:13px;letter-spacing:.06em}
    .foil-rule {margin-bottom:14px} #open-gift {margin-top:21px}
}
@media (max-height:460px) and (orientation:landscape) {
    .opening-signature {top:calc(var(--inset-y) + 10px);font-size:19px}
    .opening-copy {top:54%;max-height:73%}
    .opening-wish h1,.opening-wish h1[data-personal]{font-size:clamp(25px,8vh,39px);line-height:1.06}
    .opening-wish h1 em{display:inline}.opening-wish p{margin-top:6px;font-size:12px}
    #open-gift{margin-top:8px}.seal{width:33px;height:33px}.foil-rule{margin-bottom:5px}
}
@media(prefers-reduced-motion:reduce) {
    #opening[data-phase=opening] {animation:none}
    #opening :is(.gift-paper,.opening-copy,.opening-wish,.seal,.seal-arrow){animation:none;transition:none}
}
