:root {
  --ink: #24304a;
  --ink-soft: rgba(36, 48, 74, .72);
  --paper: #f4eee3;
  --linen: #d6c9b4;
  --gold: #a37f45;
  --claret: #6e1c28;
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sc: "Cormorant SC", "Cormorant Garamond", serif;
  --script: "Pinyon Script", cursive;
  --hand: "Playwrite VN", cursive;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html { background: var(--linen); overflow-x: clip; }
html.is-loading, html.is-loading body { overflow: hidden; }
body { margin: 0; color: var(--ink); font-family: var(--serif); font-size: 18px; -webkit-font-smoothing: antialiased; background: var(--linen); }
button { font: inherit; color: inherit; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- sân khấu ---------- */
.stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.scroll { position: relative; z-index: 0; pointer-events: none; }
.scroll i { display: block; height: 1px; position: absolute; left: 0; width: 1px; }
.fail { position: fixed; inset: auto 16px 40% 16px; text-align: center; font-size: 20px; z-index: 30; }

/* ---------- màn chờ ---------- */
.loader { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 6px; background: var(--paper); transition: opacity 1.1s ease, visibility 1.1s; }
.loader.done { opacity: 0; visibility: hidden; }
.ld-wreath { width: 92px; height: 92px; transform: rotate(-90deg); }
.ld-ring { fill: none; stroke: rgba(163, 127, 69, .18); stroke-width: .8; }
.ld-prog { fill: none; stroke: var(--gold); stroke-width: 1; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0) * 100); stroke-linecap: round; transition: stroke-dashoffset .4s ease; }
.ld-mono { margin: -70px 0 30px; font-family: var(--script); font-size: 34px; color: var(--gold); line-height: 1; }
.ld-mono i { font-family: var(--serif); font-size: 18px; }
.ld-t { margin: 0; font-family: var(--sc); letter-spacing: .32em; font-size: 12px; color: var(--ink-soft); }

/* ---------- thanh trên ---------- */
.hud { position: fixed; z-index: 20; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + var(--safe-t)) calc(20px + var(--safe-r)) 10px calc(20px + var(--safe-l)); pointer-events: none; }
.hud > * { pointer-events: auto; }
.brand { font-family: var(--script); font-size: 26px; text-decoration: none; color: var(--ink); white-space: nowrap; line-height: 1; }
.brand i { font-family: var(--serif); font-size: 17px; }
.brand span { font-family: var(--sc); font-size: 12.5px; letter-spacing: .24em; margin-left: 6px; color: var(--ink-soft); vertical-align: 3px; }
.hud-btns { display: flex; gap: 8px; }
.hb { display: inline-flex; align-items: center; gap: 7px; border: 1px solid rgba(36, 48, 74, .22); background: rgba(244, 238, 227, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-radius: 999px; padding: 6px 13px 6px 10px; font-family: var(--sc); font-size: 13px; letter-spacing: .14em; cursor: pointer; min-height: 36px; }
.hb svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.hb[data-sound] .on { opacity: .25; }
.hb[data-sound][aria-pressed="true"] .on { opacity: 1; }
.hb[data-auto] svg path { fill: currentColor; stroke: none; }
.hb[data-auto] .pause { display: none; }
.hb[data-auto][aria-pressed="true"] .pause { display: block; }
.hb[data-auto][aria-pressed="true"] .play { display: none; }
.hb:hover { background: rgba(244, 238, 227, .85); }

/* ---------- chấm hồi ---------- */
.dots { position: fixed; z-index: 20; right: calc(16px + var(--safe-r)); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px; }
.dots button { width: 28px; height: 22px; border: 0; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; position: relative; }
.dots button::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: rgba(36, 48, 74, .3); transition: transform .3s, background .3s; }
.dots button[aria-current="step"]::before { background: var(--claret); transform: scale(1.6); }
.dots button span { position: absolute; right: 30px; white-space: nowrap; font-family: var(--sc); font-size: 12px; letter-spacing: .16em; opacity: 0; transform: translateX(4px); transition: .25s; pointer-events: none; }
.dots button:hover span, .dots button:focus-visible span { opacity: .85; transform: none; }

/* ---------- chú thích hồi ---------- */
.cap::before { content: ""; position: absolute; z-index: -1; inset: -60px -90px -40px -60px; background: radial-gradient(closest-side, rgba(214, 201, 180, .82), rgba(214, 201, 180, .5) 55%, rgba(214, 201, 180, 0)); pointer-events: none; }
.cap { position: fixed; z-index: 15; left: calc(26px + var(--safe-l)); bottom: calc(24px + var(--safe-b)); max-width: min(420px, 70vw); pointer-events: none; transition: opacity .5s ease; }
.cap.off { opacity: 0; }
.cap-n { margin: 0; font-family: var(--sc); font-size: 13px; letter-spacing: .3em; color: var(--gold); }
.cap-t { margin: 2px 0 2px; font-family: var(--script); font-weight: 400; font-size: 40px; line-height: 1.05; }
.cap-l { margin: 0; font-style: italic; font-size: 17px; color: var(--ink-soft); }
.next { position: fixed; z-index: 16; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(36, 48, 74, .25); background: rgba(244, 238, 227, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-radius: 999px; padding: 8px 16px 8px 20px; font-family: var(--sc); letter-spacing: .2em; font-size: 13.5px; cursor: pointer; min-height: 40px; transition: opacity .4s; }
.next svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; animation: bob 2.4s ease-in-out infinite; }
.next.off { opacity: 0; pointer-events: none; }
@keyframes bob { 50% { transform: translateY(3px); } }

/* ---------- hồi âm: ô nhập đè lên thẻ 3D ---------- */
.rsvp { position: fixed; inset: 0; z-index: 18; pointer-events: none; }
.rsvp .rf, .rsvp .rsvp-act { position: absolute; pointer-events: auto; }
.rsvp input, .rsvp textarea { width: 100%; height: 100%; border: 0; background: transparent; outline: none; font-family: var(--hand); font-weight: 300; color: transparent; caret-color: var(--ink); padding: 0 .1em; resize: none; overflow: hidden; line-height: 1.66; }
.rsvp input::placeholder, .rsvp textarea::placeholder { color: rgba(36, 48, 74, .32); }
.rsvp input:not(:placeholder-shown), .rsvp textarea:not(:placeholder-shown) { color: transparent; }
.rsvp .rf:focus-within { background: rgba(255, 252, 240, .18); box-shadow: 0 1px 0 rgba(163, 127, 69, .55); }
.rsvp .tick { position: absolute; border: 0; background: transparent; cursor: pointer; padding: 0; border-radius: 3px; }
.rsvp .tick:focus-visible { outline: 1px dashed var(--gold); outline-offset: 2px; }
.rsvp.flying .rf, .rsvp.flying .btn { visibility: hidden; }
.rsvp [data-edit] { display: none; }
.rsvp.sent .rf, .rsvp.sent [data-send] { display: none; }
.rsvp.sent [data-edit] { display: inline-flex; }
.rsvp-act { display: flex; flex-direction: column; align-items: center; gap: 6px; transform: translateX(-50%); }
.rsvp-msg { margin: 0; font-style: italic; font-size: 15px; min-height: 1.2em; text-align: center; text-shadow: 0 0 8px var(--linen); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 20px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); font-family: var(--sc); letter-spacing: .18em; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn.ghost { background: rgba(244, 238, 227, .6); color: var(--ink); border-color: rgba(36, 48, 74, .35); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- toàn cảnh ---------- */
.finale { position: fixed; z-index: 17; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); width: min(1080px, calc(100vw - 40px)); display: flex; align-items: center; justify-content: space-between; gap: 18px 26px; padding: 14px 24px; border-radius: 14px; background: rgba(244, 238, 227, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(70, 50, 30, .14); transition: opacity .8s ease, transform .8s ease; }
.finale.off { opacity: 0; transform: translate(-50%, 16px); pointer-events: none; }
.fn-a p { margin: 0; }
.fn-k { font-family: var(--script); font-size: 38px; line-height: 1.05; }
.fn-d { font-family: var(--sc); letter-spacing: .2em; font-size: 13px; margin-top: 2px !important; }
.fn-v { font-style: italic; color: var(--ink-soft); font-size: 16px; }
.fn-s { margin-top: 2px !important; font-family: var(--hand); font-weight: 300; font-size: 14px; color: var(--claret); }
.cd { display: flex; justify-content: center; gap: 20px; }
.cd span { display: flex; flex-direction: column; align-items: center; font-family: var(--sc); font-size: 11px; letter-spacing: .22em; color: var(--ink-soft); }
.cd b { font-family: var(--serif); font-weight: 500; font-size: 30px; letter-spacing: 0; color: var(--ink); line-height: 1.05; }
.fn-btns { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; max-width: 420px; }

/* ---------- thiệp dạng chữ ---------- */
.plain { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
html.no3d .plain { position: relative; width: auto; height: auto; clip: auto; overflow: visible; max-width: 560px; margin: 90px auto 60px; padding: 28px 24px; background: var(--paper); text-align: center; border-radius: 4px; box-shadow: 0 10px 30px rgba(60, 40, 20, .15); }
html.no3d .plain h1 { font-family: var(--script); font-weight: 400; font-size: 38px; }
html.no3d .stage, html.no3d .dots, html.no3d .cap, html.no3d .next { display: none; }

/* ---------- điện thoại dọc ---------- */
@media (orientation: portrait) and (max-width: 1100px), (max-width: 560px) {
  .brand { font-size: 22px; }
  .brand span { display: none; }
  .hb span { display: none; }
  .hb { padding: 6px 9px; min-width: 40px; justify-content: center; }
  .dots { right: calc(4px + var(--safe-r)); }
  .dots button { width: 22px; height: 20px; }
  .dots button span { display: none; }
  .cap { left: 18px; right: 18px; max-width: none; bottom: calc(76px + var(--safe-b)); text-align: center; }
  .cap::before { inset: -40px -18px -90px; background: linear-gradient(to top, rgba(214, 201, 180, .9), rgba(214, 201, 180, .7) 55%, rgba(214, 201, 180, 0)); }
  .cap-t { font-size: 34px; }
  .cap-l { font-size: 15.5px; }
  .finale { flex-wrap: wrap; justify-content: center; text-align: center; gap: 8px 16px; padding: 12px 14px 14px; width: calc(100vw - 24px); bottom: calc(10px + var(--safe-b)); }
  .fn-a { flex: 1 1 100%; }
  .fn-k { font-size: 32px; }
  .fn-v { display: none; }
  .cd { gap: 14px; }
  .cd b { font-size: 24px; }
  .fn-btns { justify-content: center; max-width: none; gap: 6px; flex: 1 1 100%; }
  .fn-btns .btn { padding: 7px 12px; font-size: 12px; letter-spacing: .1em; min-height: 40px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .cap { bottom: calc(12px + var(--safe-b)); }
  .cap-t { font-size: 30px; }
  .cap-l { font-size: 14px; }
  .next { bottom: calc(10px + var(--safe-b)); left: auto; right: calc(56px + var(--safe-r)); transform: none; }
  .finale { padding: 8px 14px; bottom: 6px; gap: 12px; width: calc(100vw - 110px); left: calc(50% - 30px); }
  .fn-k { font-size: 26px; }
  .fn-d { font-size: 11px; letter-spacing: .14em; }
  .fn-v { display: none; }
  .cd { gap: 12px; }
  .cd b { font-size: 21px; }
  .fn-btns { flex-wrap: nowrap; gap: 6px; max-width: none; }
  .fn-btns .btn { min-height: 34px; padding: 5px 10px; font-size: 11px; letter-spacing: .1em; white-space: nowrap; }
  .fn-btns [data-replay] { display: none; }
}
@media (pointer: coarse) {
  .hb, .btn, .next { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .next svg { animation: none; }
}
