:root {
  --giay: #f8efe3;
  --giay-2: #f0e2d2;
  --muc: #5b3f45;
  --muc-nhat: #75555d;
  --hong: #f2c9d2;
  --hong-phan: #f8e1e6;
  --hong-dam: #a45a70;
  --hong-sap: #c47d8f;
  --oai-huong: #d9cde9;
  --xa-cu: #b9c9a8;
  --dong: #c9a46b;
  --dem: #3a3563;
  --kem: #fbf6ef;

  --chu-de: 'Cormorant Garamond', 'Times New Roman', serif;
  --chu-than: 'Lora', Georgia, serif;
  --chu-tay: 'Dancing Script', cursive;

  --bong-giay: 0 18px 40px -12px rgba(58, 36, 52, .45), 0 4px 10px -4px rgba(58, 36, 52, .3);
  --ra-mem: cubic-bezier(.16, 1, .3, 1);
  --nhieu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .26 0 0 0 0 .22 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--chu-than);
  color: var(--muc);
  background: var(--dem);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--hong); color: var(--muc); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible {
  outline: 2px dashed var(--hong-sap); outline-offset: 4px; border-radius: 4px;
}
[hidden] { display: none !important; }
.kho-hinh { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 22px; height: 22px; flex: none; }
.icon.nho { width: 17px; height: 17px; }

/* ---------- Cảnh 3D ---------- */
.canh { position: fixed; inset: 0; touch-action: none; }
.canh canvas { display: block; }
.lop-nhan { position: fixed !important; inset: 0; pointer-events: none; }

/* ---------- Lớp phim cũ ---------- */
.phim {
  position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(46, 26, 44, .42) 100%),
    linear-gradient(180deg, rgba(255, 226, 214, .07), rgba(214, 170, 196, .08));
}
.phim-hat {
  position: absolute; inset: -60px;
  background-image: var(--nhieu); background-size: 180px;
  opacity: .55; mix-blend-mode: multiply;
  animation: hat-phim 1s steps(6) infinite;
}
@keyframes hat-phim {
  0% { transform: translate(0, 0); } 20% { transform: translate(-22px, 14px); }
  40% { transform: translate(18px, -26px); } 60% { transform: translate(-12px, 30px); }
  80% { transform: translate(28px, 8px); } 100% { transform: translate(0, 0); }
}

/* ---------- Giấy cũ + ren ---------- */
.giay {
  position: relative; isolation: isolate;
  background-color: var(--giay);
  background-image:
    radial-gradient(ellipse at 12% 8%, rgba(201, 164, 107, .16), transparent 45%),
    radial-gradient(ellipse at 92% 96%, rgba(196, 125, 143, .12), transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(201, 164, 107, .08) 0 6%, transparent 7%),
    var(--nhieu);
  box-shadow: var(--bong-giay);
}
/* mép ren: các chấm tròn chỉ lộ ở dải 7px bên ngoài mép giấy */
.giay-ren::before {
  content: ''; position: absolute; inset: -7px; z-index: -1; padding: 7px;
  background: radial-gradient(circle, var(--giay) 6px, transparent 6.6px) 0 0 / 15px 15px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
/* hàng lỗ xâu chỉ của ren */
.giay-ren::after {
  content: ''; position: absolute; inset: 9px; pointer-events: none;
  border: 5px solid transparent;
  background: radial-gradient(circle, rgba(164, 90, 112, .32) 1.3px, transparent 1.8px) 0 0 / 9px 9px border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0) border-box;
  mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0) border-box;
}

/* ---------- Nút ---------- */
.nut-chinh {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 12px 26px;
  border: 1px solid #8f4a5f; border-radius: 999px;
  background: var(--hong-dam); color: var(--kem);
  font-family: var(--chu-de); font-weight: 600; font-size: 1.22rem; letter-spacing: .01em;
  box-shadow: 0 10px 22px -10px rgba(122, 52, 76, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .5s var(--ra-mem), box-shadow .5s var(--ra-mem), background-color .3s, opacity .3s;
}
.nut-chinh:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 28px -12px rgba(122, 52, 76, .75), inset 0 1px 0 rgba(255, 255, 255, .25); }
.nut-chinh:active:not(:disabled) { transform: translateY(1px); }
.nut-chinh:disabled { cursor: progress; background: #b98794; border-color: #a67785; }
.nut-chinh:disabled .icon { animation: dung-dua 1.6s ease-in-out infinite; }
.nut-chinh.nho { min-height: 44px; font-size: 1.1rem; padding: 10px 22px; }
.nut-chu {
  background: none; border: 0; padding: 6px 2px;
  font-family: var(--chu-than); font-size: .92rem; color: var(--hong-dam);
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px;
}
.nut-noi {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: 999px;
  border: 1px solid rgba(91, 63, 69, .25);
  background: rgba(248, 239, 227, .94); color: var(--muc);
  font-family: var(--chu-de); font-weight: 600; font-size: 1.08rem;
  box-shadow: 0 10px 24px -10px rgba(30, 20, 40, .55);
  transition: transform .5s var(--ra-mem), background-color .3s;
}
.nut-noi:hover { transform: translateY(-2px); background: var(--kem); }

/* ============ Màn chào ============ */
.man-chao {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 20px;
  background: radial-gradient(ellipse at 50% 40%, rgba(58, 53, 99, .25), rgba(34, 28, 58, .72));
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  transition: opacity 1.1s var(--ra-mem), backdrop-filter 1.1s var(--ra-mem);
}
.man-chao.an { opacity: 0; pointer-events: none; -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0); }
.man-chao.an .the-chao { transform: translateY(-40px) rotate(-3deg) scale(.94); filter: blur(6px); }
.the-chao {
  width: min(100%, 420px);
  padding: 38px 30px 30px; text-align: center; border-radius: 3px;
  display: flex; flex-direction: column; align-items: center;
  transform-origin: 50% 100%;
  animation: the-hien 1.4s var(--ra-mem) both;
  transition: transform 1.1s var(--ra-mem), filter 1.1s var(--ra-mem);
}
@keyframes the-hien {
  from { opacity: 0; transform: translateY(30px) rotate(2deg); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: none; }
}
.tem {
  position: relative; width: 112px; margin-bottom: 20px; transform: rotate(-4deg);
  filter: drop-shadow(0 6px 8px rgba(58, 36, 52, .25));
}
.tem > svg:first-child {
  display: block; width: 100%;
  /* răng cưa tem thư: lỗ tròn chỉ ở viền, phần trong phủ kín */
  -webkit-mask:
    radial-gradient(circle, #0000 4px, #000 4.6px) -6px -6px / 12px 12px,
    linear-gradient(#000 0 0) center / calc(100% - 12px) calc(100% - 12px) no-repeat;
  mask:
    radial-gradient(circle, #0000 4px, #000 4.6px) -6px -6px / 12px 12px,
    linear-gradient(#000 0 0) center / calc(100% - 12px) calc(100% - 12px) no-repeat;
  background: var(--kem);
}
.dau-buu-dien {
  position: absolute; width: 86px; right: -58px; top: 34px;
  transform: rotate(14deg); opacity: .72; mix-blend-mode: multiply;
}
.chao-tieu-de {
  font-family: var(--chu-de); font-style: italic; font-weight: 600;
  font-size: clamp(2.1rem, 8.5vw, 2.75rem); line-height: 1.08; letter-spacing: -.01em;
  color: var(--muc); text-wrap: balance; margin-bottom: 12px;
}
.chao-loi {
  font-size: 1rem; line-height: 1.65; color: var(--muc-nhat);
  max-width: 32ch; text-wrap: pretty; margin-bottom: 26px;
}
.chao-ghi-chu {
  display: flex; align-items: center; gap: 6px; margin-top: 14px;
  font-size: .86rem; color: var(--muc-nhat);
}

/* Phong bì ở màn chào: chạm dấu sáp → nắp lật, phong bì trôi xuống, thiệp hiện lên */
.man-chao.dong-pb .the-chao { display: none; }
.man-chao:not(.dong-pb) .phong-bi-chao, .man-chao:not(.dong-pb) .goi-y-chao { display: none; }
.phong-bi-chao { margin-top: 0; width: min(86vw, 400px); }
.goi-y-chao { margin: 24px 0 0; transition: opacity .3s; }
.man-chao.mo-pb .pb-nap-thu { transform: rotateX(180deg); z-index: 1; }
.man-chao.mo-pb .dau-sap { transform: scale(1.4); opacity: 0; animation: none; pointer-events: none; }
.man-chao.mo-pb .phong-bi-chao { animation: pb-di .9s var(--ra-mem) .5s forwards; }
.man-chao.mo-pb .goi-y-chao { opacity: 0; }

/* ============ Màn đăng nhập ============ */
.dang-nhap {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 24px 18px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 35%, #4a3f70 0%, #2a2248 55%, #1c1733 100%);
}
.dang-nhap.an { animation: dn-tan 1s var(--ra-mem) forwards; }
@keyframes dn-tan { to { opacity: 0; transform: scale(1.06); filter: blur(6px); visibility: hidden; } }
.dn-khung { position: relative; width: min(100%, 380px); padding-top: 124px; animation: the-hien 1.2s var(--ra-mem) both; }
.dn-tho {
  position: absolute; z-index: 2; left: 50%; top: 0; width: 200px; margin-left: -100px;
  overflow: visible; pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(20, 12, 30, .35));
}
.dn-tai { transform-box: fill-box; transform-origin: 50% 100%; animation: tai-ve 3.2s ease-in-out infinite; }
.dn-tai.phai { animation-delay: -1.1s; }
@keyframes tai-ve { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-7deg); } 86% { transform: rotate(4deg); } }
.dn-nhay { transform-box: fill-box; transform-origin: 50% 50%; animation: chop-mat 4.2s infinite; }
@keyframes chop-mat { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.dn-mat { transition: transform .5s var(--ra-mem); }
.dn-khung.dang-go .dn-mat { transform: translateY(4px); }
.dn-khung.sai .dn-tho { animation: lac-dau .6s ease; }
.dn-khung.sai .the-dn { animation: lac-the .5s ease; }
@keyframes lac-dau { 20% { transform: rotate(-8deg); } 45% { transform: rotate(7deg); } 70% { transform: rotate(-4deg); } }
@keyframes lac-the { 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.dn-khung.dung .dn-tho { animation: tho-nhay .9s var(--ra-mem); }
@keyframes tho-nhay { 30% { transform: translateY(-26px) rotate(-4deg); } 60% { transform: translateY(0); } 75% { transform: translateY(-8px); } }

.the-dn {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 34px 26px 28px; border-radius: 3px;
}
.dn-o-khoa { width: 50px; margin-bottom: 8px; overflow: visible; }
.dn-quai { transform-box: fill-box; transform-origin: 100% 100%; transition: transform .6s var(--ra-mem); }
.dn-khung.dung .dn-quai { transform: translateY(-8px) rotate(24deg); }
.dn-tieu-de {
  font-family: var(--chu-de); font-style: italic; font-weight: 600;
  font-size: clamp(1.8rem, 7vw, 2.25rem); line-height: 1.1; color: var(--muc); text-wrap: balance;
}
.dn-loi { margin: 10px 0 18px; max-width: 30ch; font-size: .98rem; line-height: 1.6; color: var(--muc-nhat); text-wrap: pretty; }
.dn-cau-hoi {
  margin-bottom: 12px; font-family: var(--chu-tay); font-weight: 700; font-size: 1.55rem; line-height: 1.25;
  color: var(--hong-dam); text-wrap: balance;
}
.dn-o {
  width: 100%; padding: 12px 18px; border-radius: 999px;
  border: 1px dashed rgba(164, 90, 112, .5); background: rgba(255, 255, 255, .55);
  font-family: var(--chu-than); font-size: 1.05rem; color: var(--muc); text-align: center;
  outline: none; transition: border-color .3s, background-color .3s, box-shadow .3s;
}
.dn-o::placeholder { color: #8f6b74; font-style: italic; }
.dn-o:focus { border-style: solid; border-color: var(--hong-sap); background: #fff; box-shadow: 0 0 0 4px rgba(242, 201, 210, .6); }
.dn-o:disabled { opacity: .7; }
.dn-bao { min-height: 1.5em; margin: 10px 0 14px; font-size: .93rem; line-height: 1.45; color: var(--hong-dam); text-wrap: balance; }
.tim-bay {
  position: absolute; z-index: 3; width: 18px; height: 16px; margin: -8px 0 0 -9px; pointer-events: none;
  color: var(--mau, #f2a2b9);
  animation: tim-bung 1.3s var(--ra-mem) forwards; animation-delay: var(--tre, 0s);
}
.tim-bay svg { width: 100%; height: 100%; fill: currentColor; display: block; }
@keyframes tim-bung {
  0% { opacity: 0; transform: translate(0, 0) scale(.3); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(var(--xoay, 0deg)); }
}

/* màn thấp (điện thoại nằm ngang, cửa sổ nhỏ): thu gọn để nút Mở khóa không bị đẩy khỏi màn */
@media (max-height: 720px) {
  .dn-khung { padding-top: 96px; }
  .dn-tho { width: 160px; margin-left: -80px; }
  .the-dn { padding: 22px 22px 20px; }
  .dn-o-khoa { width: 38px; margin-bottom: 4px; }
  .dn-loi { margin: 6px 0 12px; }
  .dn-bao { margin: 6px 0 10px; }
}

/* ============ Gợi ý ============ */
.goi-y {
  position: fixed; z-index: 10; left: 50%; top: calc(16px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100vw - 32px); padding: 9px 18px; border-radius: 999px;
  background: rgba(248, 239, 227, .92); color: var(--muc);
  font-family: var(--chu-de); font-style: italic; font-weight: 600; font-size: 1.08rem; line-height: 1.25;
  box-shadow: 0 10px 24px -12px rgba(30, 20, 40, .6);
  opacity: 0; transform: translate(-50%, -12px); filter: blur(4px);
  transition: opacity .7s var(--ra-mem), transform .7s var(--ra-mem), filter .7s var(--ra-mem);
  pointer-events: none;
}
.goi-y.hien { opacity: 1; transform: translate(-50%, 0); filter: none; }
.goi-y .icon { color: var(--hong-dam); }
#nut-qua-cong {
  position: fixed; z-index: 10; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  animation: noi-len 1s var(--ra-mem) both;
}
#nut-qua-cong:hover { transform: translate(-50%, -2px); }
@keyframes noi-len { from { opacity: 0; transform: translate(-50%, 16px); } }

/* ============ Nút nhạc ============ */
.nut-nhac {
  position: fixed; z-index: 12;
  right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(91, 63, 69, .25);
  background: rgba(248, 239, 227, .94); color: var(--hong-dam);
  box-shadow: 0 10px 24px -10px rgba(30, 20, 40, .6);
  transition: transform .5s var(--ra-mem);
}
.nut-nhac:hover { transform: scale(1.06); }
.nut-nhac .tat { display: none; }
.nut-nhac[aria-pressed='false'] .bat { display: none; }
.nut-nhac[aria-pressed='false'] .tat { display: block; }
.nut-nhac[aria-pressed='true']::after {
  content: ''; position: absolute; inset: -5px; border-radius: 50%;
  border: 1px solid rgba(248, 239, 227, .6);
  animation: song-nhac 2.2s ease-out infinite;
}
@keyframes song-nhac { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }

/* ============ Lóe sáng qua cổng ============ */
.chuyen-canh {
  position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: 0;
  background:
    radial-gradient(circle at 50% 50%, #fffaf4 0 18%, #f9dce4 38%, #e3d3f0 62%, #c9b8e2 100%);
}
.chuyen-canh.vao { animation: loe-vao .95s cubic-bezier(.7, 0, .84, 0) forwards; }
.chuyen-canh.ra { animation: tan-ra 1.6s var(--ra-mem) forwards; }
@keyframes loe-vao {
  from { opacity: 1; clip-path: circle(0% at 50% 50%); filter: blur(20px); }
  to { opacity: 1; clip-path: circle(75% at 50% 50%); filter: blur(0); }
}
@keyframes tan-ra {
  from { opacity: 1; clip-path: circle(75% at 50% 50%); }
  to { opacity: 0; clip-path: circle(75% at 50% 50%); }
}

/* ============ Nhãn trong cảnh (CSS2D) ============ */
.bang-ten {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 14px 5px 10px; border-radius: 3px;
  background: var(--kem); color: var(--hong-dam);
  font-family: var(--chu-tay); font-weight: 700; font-size: 1.35rem; line-height: 1;
  white-space: nowrap;
  box-shadow: 0 6px 14px -6px rgba(30, 20, 40, .6);
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 50%, 100% 100%, 0 100%, 8px 50%);
  padding-left: 16px; padding-right: 18px;
  transition: opacity .4s;
  animation: bang-nhun 3s ease-in-out infinite;
}
.bang-ten .icon { width: 24px; height: 16px; color: var(--hong-sap); }
@keyframes bang-nhun { 0%, 100% { translate: 0 0; } 50% { translate: 0 -4px; } }
.bong-noi {
  position: relative; max-width: 210px; padding: 10px 14px; border-radius: 14px;
  background: var(--kem); color: var(--muc);
  font-family: var(--chu-de); font-style: italic; font-weight: 600; font-size: 1.02rem; line-height: 1.3;
  text-align: center; text-wrap: balance;
  box-shadow: 0 10px 22px -10px rgba(30, 20, 40, .6);
  opacity: 0; transform: translateY(8px) scale(.9); filter: blur(3px);
  transition: opacity .5s var(--ra-mem), transform .5s var(--ra-mem), filter .5s var(--ra-mem);
}
.bong-noi::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; width: 14px; height: 14px; margin-left: -7px;
  background: var(--kem); transform: rotate(45deg); border-radius: 0 0 3px 0;
}
.bong-noi.hien { opacity: 1; transform: none; filter: none; }
.an-sau-trang { opacity: 0 !important; }

/* ============ Lá thư ============ */
.lop-thu {
  position: fixed; inset: 0; z-index: 25;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 18px;
  scrollbar-width: thin; scrollbar-color: var(--hong-sap) transparent;
  background: rgba(34, 28, 58, .55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: mo-mo .6s var(--ra-mem);
}
@keyframes mo-mo { from { opacity: 0; } }
.lop-thu.dong { opacity: 0; transition: opacity .6s var(--ra-mem); }

.phong-bi-thu {
  position: relative; width: min(84vw, 360px); aspect-ratio: 7 / 5;
  margin-top: auto; flex: none;
  perspective: 900px; animation: pb-roi 1s var(--ra-mem) both;
}
@keyframes pb-roi { from { opacity: 0; transform: translateY(-60px) rotate(-8deg) scale(.8); } }
.pb-lung, .pb-truoc-thu, .pb-nap-thu { position: absolute; inset: 0; border-radius: 4px; }
.pb-lung { background: #eddccb; box-shadow: var(--bong-giay); }
.pb-truoc-thu {
  z-index: 3;
  background: linear-gradient(160deg, #f8efe3, #f1e3d3) , var(--nhieu);
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}
.pb-nap-thu {
  z-index: 4; bottom: auto; height: 60%;
  background: #f3e6d7;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform .8s var(--ra-mem), z-index 0s .35s;
  filter: drop-shadow(0 4px 3px rgba(58, 36, 52, .15));
}
.dau-sap {
  position: absolute; z-index: 5; left: 50%; top: 58%;
  width: 78px; height: 78px; margin: -39px 0 0 -39px;
  border: 0; background: none; border-radius: 50%;
  filter: drop-shadow(0 5px 5px rgba(90, 40, 60, .35));
  transition: transform .5s var(--ra-mem), opacity .4s;
  animation: sap-nhip 2.4s ease-in-out infinite;
}
.dau-sap svg { width: 100%; height: 100%; }
.dau-sap:hover { transform: scale(1.06) rotate(-4deg); }
@keyframes sap-nhip { 0%, 100% { scale: 1; } 50% { scale: 1.05; } }
.pb-ghi {
  position: absolute; z-index: 4; left: 0; right: 0; bottom: 12%;
  text-align: center; font-family: var(--chu-tay); font-size: 1.5rem; color: var(--hong-dam);
}
.goi-y-sap {
  margin: 22px 0 auto; color: var(--kem);
  font-family: var(--chu-de); font-style: italic; font-size: 1.1rem;
  animation: nhap-nhe 2.4s ease-in-out infinite;
}
@keyframes nhap-nhe { 50% { opacity: .55; } }

.lop-thu.da-mo .pb-nap-thu { transform: rotateX(180deg); z-index: 1; }
.lop-thu.da-mo .dau-sap { transform: scale(1.4); opacity: 0; animation: none; pointer-events: none; }
.lop-thu.da-mo .phong-bi-thu {
  animation: pb-di .9s var(--ra-mem) .5s forwards;
}
@keyframes pb-di { to { opacity: 0; transform: translateY(90px) scale(.9); } }
.lop-thu.da-mo .goi-y-sap { display: none; }
.lop-thu.doc .phong-bi-thu { display: none; }

.la-thu {
  display: none;
  width: min(100%, 620px); margin: auto 0;
  padding: 52px 30px 36px; border-radius: 2px;
  color: var(--muc);
}
.lop-thu.doc .la-thu { display: block; animation: thu-mo 1.2s var(--ra-mem) both; }
@keyframes thu-mo {
  from { clip-path: inset(48% 0 48% 0); filter: blur(6px); transform: translateY(24px); }
  to { clip-path: inset(-20px -20px -20px -20px); filter: none; transform: none; }
}
.la-thu:focus { outline: none; }
.hoa-ep {
  position: absolute; width: 74px; left: -18px; bottom: -22px; transform: rotate(-18deg);
  opacity: .9; pointer-events: none;
}
.anh-thu {
  position: relative; float: right; width: 38%; max-width: 180px;
  margin: -8px -6px 14px 18px; padding: 8px 8px 0;
  background: var(--kem); transform: rotate(3deg);
  box-shadow: 0 10px 18px -8px rgba(58, 36, 52, .5);
}
.trinh-chieu {
  position: relative; aspect-ratio: 4 / 5; overflow: hidden;
  background: var(--hong-phan); cursor: pointer; outline: none;
}
.trinh-chieu:focus-visible { outline: 2px dashed var(--hong-sap); outline-offset: 3px; }
.trinh-chieu::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 28px rgba(91, 63, 69, .32);
}
/* ảnh đổi chậm: mờ dần vào, thu từ 1.08 về 1 trong lúc đứng hình */
.trinh-chieu img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: scale(1.08); filter: blur(6px) sepia(.18);
  transition: opacity 1.1s var(--ra-mem), filter 1.1s var(--ra-mem), transform 3.8s ease-out;
}
.trinh-chieu img.hien { opacity: 1; transform: scale(1); filter: sepia(.08); }
.anh-thu figcaption {
  padding: 6px 2px 4px; min-height: 1.9em; text-align: center;
  font-family: var(--chu-tay); font-size: 1.05rem; color: var(--hong-dam); line-height: 1.2;
}
.anh-thu figcaption.doi { animation: dong-hien .8s var(--ra-mem); }
.cham-ngoc { display: flex; justify-content: center; gap: 8px; padding: 2px 0 10px; }
.ngoc {
  position: relative; width: 9px; height: 9px; padding: 0; border: 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #efe2da 60%, #d9c6bd);
  box-shadow: 0 1px 2px rgba(58, 36, 52, .3);
  opacity: .6; transition: transform .4s var(--ra-mem), opacity .4s;
}
.ngoc::before { content: ''; position: absolute; inset: -9px; }
.ngoc[aria-current='true'] {
  opacity: 1; transform: scale(1.4);
  background: radial-gradient(circle at 35% 30%, #fff, #f7d4df 55%, #d99aae);
}
.bang-dinh {
  position: absolute; z-index: 1; top: -12px; left: 50%; width: 70px; height: 22px; margin-left: -35px;
  transform: rotate(-6deg);
  background: repeating-linear-gradient(90deg, rgba(242, 201, 210, .85) 0 8px, rgba(248, 225, 230, .85) 8px 16px);
  box-shadow: 0 1px 2px rgba(58, 36, 52, .15);
}
.loi-chao {
  font-family: var(--chu-de); font-style: italic; font-weight: 600;
  font-size: clamp(2rem, 7vw, 2.5rem); line-height: 1.1; color: var(--hong-dam);
  margin-bottom: 18px;
}
.loi-chuc p {
  font-size: 1.04rem; line-height: 1.8; margin-bottom: 14px; text-wrap: pretty;
}
.lop-thu.doc .loi-chuc p, .lop-thu.doc .ky-ten {
  animation: dong-hien 1s var(--ra-mem) both;
  animation-delay: calc(.5s + var(--i, 0) * .28s);
}
@keyframes dong-hien { from { opacity: 0; filter: blur(5px); transform: translateY(10px); } }
.ky-ten {
  clear: both; text-align: right; margin: 20px 0 26px;
  font-family: var(--chu-tay); font-weight: 700; font-size: 2rem; color: var(--hong-dam);
}
.la-thu .nut-chinh { display: flex; margin: 0 auto; }

/* ============ Xem ảnh ============ */
.xem-anh {
  position: fixed; inset: 0; z-index: 26;
  display: grid; place-items: center; padding: 70px 16px;
  background: rgba(34, 28, 58, .8);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: mo-mo .5s var(--ra-mem);
}
.khung-xem {
  padding: 12px 12px 0; border-radius: 2px; max-width: min(92vw, 520px);
  animation: anh-hien .7s var(--ra-mem);
}
.khung-xem.doi { animation: anh-doi .5s var(--ra-mem); }
@keyframes anh-hien { from { opacity: 0; transform: translateY(20px) rotate(-2deg) scale(.95); filter: blur(4px); } }
@keyframes anh-doi { from { opacity: .3; filter: blur(6px); } }
.khung-xem img { display: block; max-width: 100%; max-height: 68vh; object-fit: contain; background: var(--hong-phan); }
.khung-xem figcaption {
  padding: 10px 4px 14px; text-align: center;
  font-family: var(--chu-tay); font-size: 1.4rem; color: var(--hong-dam);
}
.nut-tron {
  position: absolute; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(91, 63, 69, .2); background: rgba(248, 239, 227, .94); color: var(--muc);
  box-shadow: 0 8px 18px -8px rgba(30, 20, 40, .6);
  transition: transform .4s var(--ra-mem);
}
.nut-tron:hover { transform: scale(1.08); }
.xem-anh .dong { top: calc(16px + env(safe-area-inset-top)); right: 16px; }
.xem-anh .truoc { left: 12px; top: 50%; margin-top: -23px; }
.xem-anh .sau { right: 12px; top: 50%; margin-top: -23px; }

/* ============ Kết ============ */
.ket {
  position: fixed; z-index: 15; left: 0; right: 0; top: calc(64px + env(safe-area-inset-top));
  display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 0 16px;
  pointer-events: none;
}
.ket-chu {
  font-family: var(--chu-de); font-style: italic; font-weight: 600;
  font-size: clamp(2.4rem, 10vw, 4.4rem); line-height: 1.05; letter-spacing: -.01em;
  color: var(--kem); text-align: center; text-wrap: balance;
  text-shadow: 0 2px 18px rgba(58, 30, 60, .7), 0 1px 2px rgba(58, 30, 60, .5);
}
.ket-chu .tu { display: inline-block; white-space: nowrap; }
.ket-chu .chu-cai {
  display: inline-block;
  animation: chu-roi 1.1s var(--ra-mem) both;
  animation-delay: calc(var(--i) * 55ms);
}
@keyframes chu-roi { from { opacity: 0; transform: translateY(-18px); filter: blur(8px); } }
.ket-nut {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  pointer-events: auto;
  animation: nut-hien 1s var(--ra-mem) 1.6s both;
}
@keyframes nut-hien { from { opacity: 0; transform: translateY(12px); } }
.ket.an { opacity: 0; transition: opacity .6s; }

@keyframes dung-dua { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

@media (max-width: 480px) {
  .the-chao { padding: 32px 22px 24px; }
  .la-thu { padding: 46px 22px 30px; }
  .anh-thu { float: none; width: 62%; max-width: 220px; margin: 0 auto 22px; }
  .dau-buu-dien { right: -48px; width: 74px; }
}
@media (prefers-reduced-motion: reduce) {
  .phim-hat, .bang-ten, .dau-sap, .goi-y-sap { animation: none; }
  .trinh-chieu img, .trinh-chieu img.hien { transform: none; }
}
