/* =========================================================================
   Thiệp mời tốt nghiệp — Hồng Phúc
   Màu theo logo Bách Khoa: #042B94 (xanh đậm), #0B51B0, #148BDB (xanh da trời)
   Chữ: Noto Serif Display (tiêu đề), Be Vietnam Pro (nội dung), Corinthia (tên)
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #040A22;
  color: #F2F7FF;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; }
.noscript { padding: 24px; text-align: center; }

.stage { position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden; display: flex; flex-direction: column; }
.backdrop {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 45% at 50% 0%, rgba(140,200,255,.16), rgba(140,200,255,0) 70%),
    radial-gradient(70% 40% at 50% 100%, rgba(20,139,219,.16), rgba(20,139,219,0) 70%);
}

/* ---------- Hệ chữ ---------- */
.serif { font-family: 'Noto Serif Display', 'Noto Serif', 'Times New Roman', serif; }
.display { font-family: 'Noto Serif Display', 'Noto Serif', 'Times New Roman', serif; font-style: italic; font-weight: 500; line-height: 1.3; text-wrap: balance; }
.script-name { display: block; font-family: 'Corinthia', cursive; font-weight: 400; font-style: normal; line-height: 1.4; padding: 0 .15em; }
.overline { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; line-height: 1.6; text-wrap: balance; }

/* ---------- Bụi sáng & đèn sân khấu ---------- */
.dust { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.dust-dot { position: absolute; border-radius: 50%; background: #CFE8FF; box-shadow: 0 0 6px 1px rgba(150,205,255,.7); opacity: 0; animation: dustRise ease-in-out infinite; }
@keyframes dustRise { 0% { transform: translateY(24px); opacity: 0; } 25% { opacity: .85; } 100% { transform: translateY(-170px); opacity: 0; } }

.beams { position: absolute; inset: 0; pointer-events: none; z-index: 1; opacity: 0; transition: opacity 1.4s ease .5s; }
.beams.is-on { opacity: 1; }
.beam {
  position: absolute; top: -40px; width: 340px; height: 130vh; margin-left: -170px; transform-origin: 50% 0;
  clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%);
  background: linear-gradient(to bottom, rgba(205,230,255,.28), rgba(205,230,255,.06) 60%, rgba(205,230,255,0) 85%);
  animation: sweep 7s ease-in-out infinite alternate;
}
.beam-l { left: 16%; }
.beam-r { left: 84%; animation-direction: alternate-reverse; }
@keyframes sweep { 0% { transform: rotate(-22deg); } 100% { transform: rotate(18deg); } }

.content { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; padding: 112px 16px 64px; }

/* ---------- Rèm nhung ---------- */
.curtain {
  position: absolute; top: 0; bottom: 0; width: 50.5%; z-index: 5;
  background-color: #042B94;
  background-image: repeating-linear-gradient(90deg, #02113B 0px, #042B94 20px, #3655A9 31px, #042B94 42px, #02113B 64px);
  transition: transform 2s cubic-bezier(.76,0,.2,1);
}
.curtain::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.35), rgba(0,0,0,0) 22%, rgba(0,0,0,0) 70%, rgba(0,0,0,.45)); }
.curtain-l { left: 0; transform-origin: 0 50%; border-right: 2px solid rgba(140,200,245,.6); }
.curtain-r { right: 0; transform-origin: 100% 50%; border-left: 2px solid rgba(140,200,245,.6); }
.curtain.is-open { transform: scaleX(.12); }
.valance {
  position: absolute; top: 0; left: 0; right: 0; height: 70px; z-index: 6; box-shadow: 0 6px 18px rgba(0,0,0,.45);
  background-color: #042B94;
  background-image: repeating-linear-gradient(90deg, #021956 0px, #042B94 14px, #3655A9 22px, #042B94 30px, #021956 44px);
}
.valance::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.25), rgba(0,0,0,0) 60%); }
.valance-trim { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #148BDB; z-index: 1; }
.scallops {
  position: absolute; top: 70px; left: 0; right: 0; height: 26px; z-index: 6;
  background-image: radial-gradient(circle at 50% 0, #021956 0px, #021956 20px, #148BDB 20.5px, #148BDB 23px, rgba(0,0,0,0) 23.5px);
  background-size: 52px 26px; background-repeat: repeat-x; background-position: center top;
}

/* ---------- Màn mở đầu ---------- */
/* overflow-y + margin:auto ở .plaque: màn thấp (điện thoại xoay ngang) thì cuộn được tới nút "Mở màn" thay vì bị cắt mất */
.intro { position: absolute; inset: 0; z-index: 7; display: flex; align-items: center; justify-content: center; padding: 120px 16px 48px; overflow-y: auto; }
.intro-out { animation: introOut .8s ease forwards; pointer-events: none; }
@keyframes introOut { to { opacity: 0; transform: scale(1.06); filter: blur(6px); } }
.plaque {
  position: relative; width: 100%; max-width: 520px; margin: auto; text-align: center; padding: 40px 48px;
  background: rgba(4,10,34,.72); border: 1px solid rgba(140,200,245,.55); outline: 1px solid rgba(140,200,245,.25); outline-offset: 7px; border-radius: 4px;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: plaqueIn 1.2s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes plaqueIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.plaque-icon { display: block; width: 44px; height: 44px; margin: 0 auto 16px; color: #8CC8F5; }
.intro-title { margin: 12px 0 8px; font-size: 36px; color: #FFFFFF; text-shadow: 0 0 26px rgba(20,139,219,.55); }
.intro-from { display: flex; flex-direction: column; align-items: center; margin: 8px 0; }
.from-label { font-family: 'Noto Serif Display', 'Noto Serif', 'Times New Roman', serif; font-style: italic; font-size: 20px; line-height: 1.4; color: #C3D2E8; }
.from-name { display: block; font-size: 60px; color: #FFFFFF; }
.intro-sub { margin: 0 0 32px; font-size: 14px; line-height: 1.6; color: #C3D2E8; }

.btn-hero {
  position: relative; display: inline-flex; align-items: center; justify-content: center; height: 52px; padding: 0 40px;
  border: 1px solid rgba(207,232,255,.7); border-radius: 2px; background: transparent;
  font: 500 14px/1 'Be Vietnam Pro', system-ui, sans-serif; letter-spacing: .3em; color: #FFFFFF; cursor: pointer;
  transition: background-color .25s ease, border-color .25s ease, opacity .25s ease;
}
.btn-hero::before { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(207,232,255,.25); pointer-events: none; }
.btn-hero:disabled { opacity: .5; cursor: progress; }
.btn-hero-label { margin-right: -.3em; }
.btn-hero:focus-visible { outline: 2px solid #8CC8F5; outline-offset: 6px; }

/* ---------- Phong bì ---------- */
.env-section { display: flex; flex-direction: column; align-items: center; text-align: center; width: 100%; }
.env-kicker { margin: 0; font-size: 18px; line-height: 1.4; color: #8CC8F5; animation: fadeUp .8s ease .3s both; }
.env-name { margin: 0; font-size: 58px; color: #FFFFFF; animation: fadeUp .8s ease .38s both; }
.env-title { margin: 4px 0 36px; font-size: 40px; color: #FFFFFF; animation: fadeUp .8s ease .45s both; }
.env-hint { margin: 40px 0 0; font-size: 14px; line-height: 1.6; color: #C3D2E8; animation: fadeUp .8s ease 1.1s both, blink 2.4s ease-in-out 2s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.env-wrap { animation: envIn 1.2s cubic-bezier(.18,.9,.24,1.12) both; }
@keyframes envIn { 0% { opacity: 0; transform: translateY(-55vh) rotate(-16deg) scale(.45); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
.env-float { animation: envFloat 4.6s ease-in-out 1.2s infinite; }
@keyframes envFloat { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-8px) rotate(-.6deg); } }
.env { position: relative; width: min(84vw, 460px); aspect-ratio: 3 / 2; perspective: 1000px; }
.env-glow { position: absolute; left: 50%; top: 40%; width: 520px; height: 520px; margin: -260px 0 0 -260px; border-radius: 50%; background: radial-gradient(circle, rgba(160,210,255,.75), rgba(160,210,255,0) 62%); opacity: 0; pointer-events: none; z-index: 0; }
.env-back { position: absolute; inset: 0; z-index: 1; border-radius: 8px; background: #D5DFEC; box-shadow: 0 34px 70px rgba(0,0,0,.55), 0 0 0 1px rgba(140,200,245,.35), 0 0 80px rgba(20,139,219,.22); }
.env-letter { position: absolute; left: 7%; right: 7%; top: 6%; height: 88%; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 6%; background: #FFFFFF; border-radius: 3px; box-shadow: inset 0 0 0 1px #9DB4D6, inset 0 0 0 5px #FFFFFF, inset 0 0 0 6px rgba(11,81,176,.35); }
.env-letter-icon { width: 30px; height: 30px; color: #0B51B0; }
.env-letter-title { font-size: 26px; color: #0A1A40; }
.env-letter-sub { font-size: 11px; letter-spacing: .2em; font-weight: 600; line-height: 1.6; color: #0B51B0; }
.env-side, .env-bottom { position: absolute; inset: 0; z-index: 3; border-radius: 8px; }
.env-side-l { background: #EBF0F7; clip-path: polygon(0 0, 52% 56%, 0 100%); }
.env-side-r { background: #E6EDF6; clip-path: polygon(100% 0, 48% 56%, 100% 100%); }
.env-bottom { background: linear-gradient(to top, #F2F6FB, #E9EFF7); clip-path: polygon(0 100%, 50% 44%, 100% 100%); }
.env-flap { position: absolute; left: 0; right: 0; top: 0; height: 60%; z-index: 5; transform-origin: 50% 0; clip-path: polygon(0 0, 100% 0, 50% 100%); background: linear-gradient(to bottom, #F4F7FB, #DFE7F2); border-radius: 8px 8px 0 0; }
.seal {
  position: absolute; left: 50%; top: 58%; z-index: 6; width: 88px; height: 88px; padding: 0; border: 0; border-radius: 50%;
  transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center; color: #CFE8FF; cursor: pointer;
  background-image: radial-gradient(circle at 34% 30%, #3655A9 0%, #042B94 46%, #02113B 100%);
  box-shadow: 0 6px 14px rgba(0,0,0,.4), inset 0 2px 3px rgba(255,255,255,.25), inset 0 -4px 8px rgba(0,0,0,.35);
  transition: transform .25s ease;
}
.seal:focus-visible { outline: 2px solid #8CC8F5; outline-offset: 6px; }
.seal svg { position: relative; width: 40px; height: 40px; }
.seal-ring { position: absolute; inset: 8px; border-radius: 50%; border: 1.5px dashed rgba(207,232,255,.6); }
.seal::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid rgba(140,200,245,.7); animation: ring 2s ease-out infinite; }
@keyframes ring { 0% { transform: scale(.94); opacity: .9; } 100% { transform: scale(1.18); opacity: 0; } }

/* Chuỗi mở phong bì */
.is-opening .env-head, .is-opening .env-foot { animation: fadeAway .4s ease forwards; }
.is-opening .seal { animation: sealPop .6s cubic-bezier(.5,0,.75,0) forwards; pointer-events: none; }
.is-opening .seal::after { display: none; }
@keyframes sealPop { 0% { transform: translate(-50%,-50%) scale(1); } 35% { transform: translate(-50%,-50%) scale(1.2) rotate(-10deg); } 100% { transform: translate(-50%,-50%) scale(.1) rotate(50deg); opacity: 0; } }
.is-opening .env-flap { animation: flapOpen .8s cubic-bezier(.45,0,.25,1) .45s both, fadeAway .35s ease 2s forwards; }
@keyframes flapOpen { 0% { transform: rotateX(0); z-index: 5; } 49% { z-index: 5; } 50% { z-index: 1; } 100% { transform: rotateX(180deg); z-index: 1; } }
.is-opening .env-letter { animation: letterUp .9s cubic-bezier(.3,.7,.25,1) 1.1s both, letterZoom .45s ease-in 2s forwards; }
@keyframes letterUp { from { transform: translateY(0); } to { transform: translateY(-66%); } }
@keyframes letterZoom { from { transform: translateY(-66%) scale(1); opacity: 1; } to { transform: translateY(-40%) scale(1.7); opacity: 0; } }
.is-opening .env-back, .is-opening .env-side, .is-opening .env-bottom { animation: fadeAway .35s ease 2s forwards; }
.is-opening .env-glow { animation: glowBurst 1.8s ease-out .35s both; }
@keyframes glowBurst { 0% { opacity: 0; transform: scale(.4); } 40% { opacity: .95; } 100% { opacity: 0; transform: scale(2.2); } }
@keyframes fadeAway { to { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---------- Giấy thiệp ---------- */
.card-section, .done-section, .name-section, .error-section { position: relative; width: 100%; display: flex; justify-content: center; scroll-margin-top: 24px; }
.rays {
  position: absolute; left: 50%; top: 50%; width: 1400px; height: 1400px; margin: -700px 0 0 -700px; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(20,139,219,.16) 0deg 5deg, rgba(20,139,219,0) 5deg 15deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, rgba(0,0,0,.6) 25%, transparent 60%);
  mask-image: radial-gradient(circle, #000 0%, rgba(0,0,0,.6) 25%, transparent 60%);
  animation: spin 70s linear infinite, raysIn 1.6s ease both;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes raysIn { from { opacity: 0; } to { opacity: 1; } }
.card-scene { position: relative; width: min(100%, 620px); perspective: 2000px; animation: cardIn 1.1s cubic-bezier(.2,.9,.25,1.12) both; }
@keyframes cardIn { 0% { opacity: 0; transform: translateY(70px) scale(.6) rotateX(20deg); } 100% { opacity: 1; transform: none; } }
/* Hai mặt nằm chồng trong một ô lưới để lật 3D. Mặt đang ẩn (.is-off) ra khỏi luồng bố cục,
   nên thiệp cao đúng bằng mặt đang hiện: lời mời ngắn không bị kéo dài theo form hồi đáp. */
.flipper { position: relative; display: grid; transform-style: preserve-3d; transition: transform 1.1s cubic-bezier(.65,-0.15,.25,1.15); }
.flipper.is-flipped { transform: rotateY(180deg); }
.paper { position: relative; background: #FFFFFF; color: #2E3A55; border-radius: 4px; box-shadow: 0 40px 90px rgba(0,0,0,.55), 0 0 0 1px rgba(140,180,230,.6), 0 0 70px rgba(20,139,219,.22); }
.paper::before { content: ""; position: absolute; inset: 12px; border: 1px solid rgba(11,81,176,.24); pointer-events: none; }
.tick { position: absolute; width: 14px; height: 14px; pointer-events: none; border: 0 solid #0B51B0; }
.t-tl { top: 8px; left: 8px; border-top-width: 2px; border-left-width: 2px; }
.t-tr { top: 8px; right: 8px; border-top-width: 2px; border-right-width: 2px; }
.t-bl { bottom: 8px; left: 8px; border-bottom-width: 2px; border-left-width: 2px; }
.t-br { bottom: 8px; right: 8px; border-bottom-width: 2px; border-right-width: 2px; }
.face { grid-area: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; text-align: center; padding: 40px 56px 48px; -webkit-backface-visibility: hidden; backface-visibility: hidden; transition: visibility 0s linear .55s; }
.face-back { transform: rotateY(180deg); }
.face.is-off { visibility: hidden; position: absolute; top: 0; left: 0; right: 0; }

/* Tiêu đề thư: cơ quan chủ quản trên, tên trường dưới */
.lh { display: flex; align-items: center; gap: 14px; width: 100%; padding-bottom: 16px; margin-bottom: 32px; border-bottom: 1px solid #E3E9F1; text-align: left; }
.lh-logo { flex: none; width: 44px; height: 44px; object-fit: contain; }
.lh-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; text-wrap: balance; }
.lh-parent { font-size: 11px; font-weight: 500; letter-spacing: .04em; line-height: 1.45; color: #5B6680; }
.lh-school { font-size: 13px; font-weight: 600; letter-spacing: .04em; line-height: 1.45; color: #042B94; }

/* Mặt trước */
.reveal { animation: fadeUp .8s ease both; }
.card-title { margin: 10px 0 0; font-size: 64px; color: #042B94; animation: fadeUp .8s ease .4s both; }
.card-of { margin: 4px 0 0; font-size: 18px; color: #5B6680; }
.card-name { margin: 0 0 4px; font-size: 60px; line-height: 1.3; color: #0A1A40; }
.card-school { margin: 0; font-size: 15px; line-height: 1.6; color: #5B6680; }
.rule { display: block; width: 40px; height: 2px; margin: 28px auto 24px; background: #148BDB; }
.msg-label { margin: 0 0 12px; font-size: 21px; color: #0B51B0; }
.msgs { display: flex; flex-direction: column; align-items: center; }
/* pretty: không để một chữ đứng trơ trọi ở dòng cuối đoạn */
.msg { margin: 0 0 14px; max-width: 46ch; font-size: 16px; line-height: 1.75; color: #2E3A55; text-wrap: pretty; }
.sign-off { margin: 10px 0 0; font-size: 14px; line-height: 1.6; color: #5B6680; }
.signature { margin: 0 0 28px; font-size: 55px; color: #0A1A40; }

/* ---------- Nút ---------- */
.btn-primary {
  position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 54px; padding: 0 34px;
  border: 0; border-radius: 2px; background: #042B94; font: 500 13px/1.4 'Be Vietnam Pro', system-ui, sans-serif;
  letter-spacing: .22em; color: #FFFFFF; cursor: pointer; text-decoration: none;
  box-shadow: 0 10px 24px rgba(4,43,148,.22); transition: filter .2s ease, opacity .2s ease;
}
.btn-primary::before { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(255,255,255,.42); pointer-events: none; }
.btn-primary:disabled, .btn-primary[aria-busy="true"] { opacity: .55; cursor: progress; filter: none; box-shadow: none; }
.btn-secondary {
  position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 54px; padding: 0 30px;
  border: 1px solid #042B94; border-radius: 2px; background: transparent; font: 500 13px/1.4 'Be Vietnam Pro', system-ui, sans-serif;
  letter-spacing: .22em; color: #042B94; cursor: pointer; text-decoration: none; transition: background-color .2s ease;
}
.btn-secondary::before { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(4,43,148,.22); pointer-events: none; }
/* Cách gọi dài ("ba mẹ", "anh chị") làm nút xuống dòng ở màn hẹp: chia đều hai dòng, không để một chữ rơi xuống */
.btn-label { margin-right: -.22em; text-wrap: balance; }
.btn-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 6px;
  border: 0; border-radius: 2px; background: none; font: italic 500 17px/1.4 'Noto Serif Display', 'Noto Serif', 'Times New Roman', serif;
  color: #0B51B0; cursor: pointer;
}
.btn-link svg { width: 22px; height: 10px; }
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-link:focus-visible, .map-link:focus-visible { outline: 2px solid #148BDB; outline-offset: 3px; }

@media (hover: hover) {
  .btn-hero:hover:not(:disabled) { background: rgba(140,200,245,.14); border-color: #FFFFFF; }
  .seal:hover { transform: translate(-50%, -50%) scale(1.07); }
  .btn-primary:hover:not(:disabled) { filter: brightness(1.22); }
  .btn-secondary:hover { background: #EEF4FC; }
  .btn-link:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
  .option:hover { background: #F7F9FC; }
  .map-link:hover { color: #042B94; }
}

/* ---------- Mặt sau: form hồi đáp ---------- */
.form { display: flex; flex-direction: column; width: 100%; max-width: 440px; margin: 0 auto; text-align: left; }
.form-back { align-self: flex-start; margin: 0 0 20px -6px; }
.h2 { margin: 0; font-weight: 600; font-size: 28px; line-height: 1.3; color: #0A1A40; }
.h2:focus { outline: none; }
.lead { margin: 8px 0 0; font-size: 15px; line-height: 1.65; color: #5B6680; }
.group { display: block; min-width: 0; margin: 24px 0 0; padding: 0; border: 0; }
.label { display: block; margin: 0 0 8px; padding: 0; font-size: 13px; font-weight: 600; line-height: 1.4; color: #2E3A55; }
.label-optional { font-weight: 400; color: #5B6680; }
.options { border: 1px solid #D3DCE8; border-radius: 6px; overflow: hidden; }
.option { display: flex; align-items: center; gap: 14px; padding: 16px; background: #FFFFFF; cursor: pointer; transition: background-color .15s ease, box-shadow .15s ease; }
.option + .option { border-top: 1px solid #D3DCE8; }
.option.is-on { background: #EEF4FC; box-shadow: inset 0 0 0 1.5px #042B94; }
.radio { flex: none; -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin: 0; border: 1.5px solid #8A96AD; border-radius: 50%; background: #FFFFFF; cursor: pointer; transition: border-width .15s ease, border-color .15s ease; }
.radio:checked { border: 6px solid #042B94; }
.radio:focus-visible { outline: 2px solid #148BDB; outline-offset: 3px; }
.option-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.option-title { font-size: 16px; font-weight: 600; line-height: 1.45; color: #0A1A40; }
.option-meta { font-size: 14px; line-height: 1.5; color: #5B6680; }
.input { display: block; width: 100%; height: 48px; padding: 0 14px; border: 1px solid #D3DCE8; border-radius: 6px; background: #FFFFFF; font: 400 16px/1.4 'Be Vietnam Pro', system-ui, sans-serif; color: #0A1A40; transition: border-color .15s ease, box-shadow .15s ease; }
.input::placeholder { color: #6F7890; }
.input:focus { outline: none; border-color: #0B51B0; box-shadow: 0 0 0 3px rgba(20,139,219,.22); }
.input[aria-invalid="true"] { border-color: #B42318; box-shadow: 0 0 0 3px rgba(180,35,24,.12); }
.textarea { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.6; resize: vertical; }
.field-error { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: #B42318; }
.help { margin: 8px 0 0; font-size: 13px; line-height: 1.55; color: #5B6680; }
.deadline-note { margin-top: 20px; }
.note-inline { margin: 12px 0 0; padding: 10px 12px; border-radius: 6px; background: #EEF4FC; font-size: 14px; line-height: 1.55; color: #0A1A40; }
.form-error { margin: 16px 0 0; padding: 10px 12px; border-radius: 6px; background: #FDF0EF; font-size: 14px; line-height: 1.55; color: #8F1D14; }
.actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: 24px; }
.facts { display: flex; flex-direction: column; gap: 6px; margin: 24px 0 0; padding-top: 16px; border-top: 1px solid #E3E9F1; }
.fact { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 16px; font-size: 14px; line-height: 1.55; }
.fact dt { color: #5B6680; }
.fact dd { margin: 0; font-weight: 500; color: #0A1A40; }
.venue-lines { display: flex; flex-direction: column; gap: 2px; }
.venue-sub { font-weight: 400; color: #5B6680; }
.map-link { display: inline-flex; align-items: center; align-self: flex-start; gap: 6px; min-height: 44px; font-size: 14px; font-weight: 500; color: #0B51B0; text-decoration: underline; text-underline-offset: 3px; border-radius: 4px; }
.map-link svg { flex: none; width: 16px; height: 16px; }
.fact-link .map-link { margin: -11px 0; }

/* ---------- Đã hồi đáp & lỗi ---------- */
.ticket { width: min(100%, 520px); padding: 48px 48px 40px; text-align: center; animation: cardIn 1s cubic-bezier(.2,.9,.25,1.12) both; }
.name-card { width: min(100%, 460px); padding: 44px 44px 36px; text-align: left; animation: cardIn 1s cubic-bezier(.2,.9,.25,1.12) both; }
.done-icon { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; margin: 0 auto 20px; border-radius: 50%; background: #042B94; color: #FFFFFF; animation: pop .6s cubic-bezier(.3,1.6,.5,1) .5s both; }
.done-icon svg { width: 26px; height: 26px; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.ticket .lead { max-width: 40ch; margin-left: auto; margin-right: auto; }
.lead-strong { font-weight: 600; color: #0A1A40; overflow-wrap: anywhere; }
.summary { margin: 28px 0 0; border: 1px solid #D3DCE8; border-radius: 6px; text-align: left; }
.summary-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 16px; padding: 14px 16px; font-size: 14px; line-height: 1.55; }
.summary-row + .summary-row { border-top: 1px solid #E3E9F1; }
.summary-row dt { color: #5B6680; }
.summary-row dd { margin: 0; display: flex; flex-direction: column; gap: 2px; font-weight: 500; color: #0A1A40; }
.summary-sub { font-weight: 400; color: #5B6680; }
.summary-gap { margin-top: 10px; }
.note { margin: 20px auto 0; max-width: 40ch; font-size: 14px; line-height: 1.6; color: #5B6680; }
.personal-link { margin: 24px 0 0; text-align: left; }
.link-box { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 4px 4px 4px 12px; border: 1px solid #D3DCE8; border-radius: 6px; background: #F7F9FC; }
.link-box code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 500 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #0A1A40; }
.link-box .btn-link { font-size: 15px; }
.done-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 28px; }

/* ---------- Pháo hoa & kim tuyến ---------- */
.fx { position: absolute; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
.fw { position: absolute; width: 0; height: 0; }
.fw-core { position: absolute; left: -40px; top: -40px; width: 80px; height: 80px; border-radius: 50%; background: radial-gradient(circle, rgba(225,240,255,.95), rgba(225,240,255,0) 65%); opacity: 0; animation: fwFlash .9s ease-out both; }
@keyframes fwFlash { 0% { opacity: 0; transform: scale(.2); } 20% { opacity: 1; } 100% { opacity: 0; transform: scale(1.6); } }
.fw-arm { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.fw-spark { position: absolute; left: -1.5px; top: -9px; width: 3px; height: 18px; border-radius: 2px; opacity: 0; box-shadow: 0 0 8px 1px currentColor; animation: sparkFly 1.5s cubic-bezier(.15,.7,.35,1) both; }
.fw-spark-s { top: -4px; height: 8px; animation-name: sparkFlyS; animation-duration: 1.3s; }
@keyframes sparkFly { 0% { transform: translateY(0) scaleY(.3); opacity: 0; } 8% { opacity: 1; } 60% { opacity: 1; } 100% { transform: translateY(-120px) scaleY(.15); opacity: 0; } }
@keyframes sparkFlyS { 0% { transform: translateY(0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translateY(-66px); opacity: 0; } }
.conf { position: absolute; top: -24px; animation: confFall cubic-bezier(.25,.4,.55,1) both; }
.conf-bit { display: block; animation: confSpin linear infinite; }
@keyframes confFall { 0% { transform: translateY(0); opacity: 1; } 85% { opacity: 1; } 100% { transform: translateY(112vh); opacity: 0; } }
@keyframes confSpin { 0% { transform: translateX(-12px) rotate(0) rotateY(0); } 50% { transform: translateX(12px) rotate(180deg) rotateY(180deg); } 100% { transform: translateX(-12px) rotate(360deg) rotateY(360deg); } }

/* ---------- Điện thoại ---------- */
@media (max-width: 600px) {
  .valance { height: 48px; }
  .scallops { top: 48px; height: 20px; background-size: 40px 20px; }
  .content { padding: 84px 22px 40px; }
  .curtain.is-open { transform: scaleX(.05); }
  .plaque { padding: 32px 22px; }
  .intro-title { font-size: 30px; }
  .from-name { font-size: 52px; }
  .env-name { font-size: 50px; }
  .env-title { font-size: 32px; margin-bottom: 28px; }
  .env-letter-title { font-size: 20px; }
  .seal { width: 72px; height: 72px; }
  .seal svg { width: 32px; height: 32px; }
  .face { padding: 32px 24px 36px; }
  .lh { gap: 12px; margin-bottom: 24px; }
  .lh-logo { width: 38px; height: 38px; }
  .lh-parent { font-size: 10px; letter-spacing: .02em; }
  .lh-school { font-size: 12px; letter-spacing: .02em; }
  /* Giữ "Lễ Tốt Nghiệp" trên một dòng ở điện thoại (390px → 41px, 360px → 38px) */
  .card-title { font-size: clamp(32px, 10.5vw, 46px); }
  .face-front .overline { letter-spacing: .14em; }
  .card-name { font-size: 48px; }
  .h2 { font-size: 24px; }
  .option { padding: 14px; }
  .fact { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; }
  .ticket, .name-card { padding: 36px 24px 32px; }
  .summary-row { grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 12px 14px; }
  .done-actions { flex-direction: column-reverse; align-items: stretch; }
  .btn-primary, .btn-secondary { padding: 8px 20px; letter-spacing: .14em; }
  .btn-label { margin-right: -.14em; }
  .beam { width: 220px; margin-left: -110px; }
}

/* Điện thoại xoay ngang (màn thấp): thu gọn rèm và khung mở đầu cho vừa một màn hình */
@media (orientation: landscape) and (max-height: 520px) {
  .valance { height: 48px; }
  .scallops { top: 48px; height: 20px; background-size: 40px 20px; }
  .intro { padding: 76px 16px 16px; }
  .plaque { padding: 22px 32px; outline-offset: 5px; }
  .plaque-icon { display: none; }
  .intro-title { margin: 6px 0 2px; font-size: 28px; }
  .from-label { font-size: 16px; }
  .from-name { font-size: 42px; }
  .intro-sub { margin: 0 0 14px; }
  .content { padding-top: 80px; }
  .env-name { font-size: 42px; }
  .env-title { font-size: 28px; margin-bottom: 16px; }
  /* phong bì theo chiều cao màn hình để con dấu nằm trong tầm nhìn, không phải cuộn */
  .env { width: min(84vw, 460px, calc((100svh - 250px) * 1.5)); min-width: 240px; }
}

/* Xem thử trong trang quản trị (/?preview): hiện ngay, không chạy hiệu ứng */
.is-preview .reveal { animation: none; }
.is-preview .curtain { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .fx, .dust, .beams { display: none; }
  .env-float, .seal::after, .rays, .env-hint { animation: none; }
}
