:root {
  --giay: #f2ebdc;
  --giay-dam: #e9e0cd;
  --muc: #2a2826;
  --muc-vua: #5b564e;
  --muc-nhat: rgba(42, 40, 38, .28);
  --xanh: #1f5f7a;
  --xanh-dam: #174d63;
  --dong: #b87333;
  --dong-chu: #8c531f;
  --kt-rong: 236px;
  --vien: 8px;
  --chu: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--giay); color: var(--muc); font: 400 16px/1.5 var(--chu); overflow-x: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; }
.so { font-variant-numeric: tabular-nums; }

/* Tờ giấy + khung bản vẽ */
.giay { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 35%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%),
    repeating-linear-gradient(0deg, rgba(42, 40, 38, .028) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(42, 40, 38, .028) 0 1px, transparent 1px 28px),
    var(--giay); }
.giay::after { content: ""; position: absolute; inset: var(--vien); border: 1.5px solid var(--muc); }
#c3d { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; display: block; opacity: 0; transition: opacity .6s ease; }
body.san-sang #c3d { opacity: 1; }
#kt { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; overflow: visible; }
#kt line { stroke: var(--muc); stroke-width: 1; vector-effect: non-scaling-stroke; }
#kt text { font: 500 11px var(--chu); fill: var(--muc); text-anchor: middle; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--giay); stroke-width: 4px; stroke-linejoin: round; }
#nhan { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.np { position: absolute; left: 0; top: 0; text-align: center; white-space: nowrap; will-change: transform, opacity; opacity: 0;
  text-shadow: 0 0 3px var(--giay), 0 0 3px var(--giay), 0 0 6px var(--giay), 0 0 6px var(--giay); }
.np b { display: block; font: 700 10.5px/1.2 var(--chu); letter-spacing: .06em; text-transform: uppercase; }
.np span { display: block; font: 500 10.5px/1.25 var(--chu); color: var(--muc-vua); font-variant-numeric: tabular-nums; }
.np.nho b { font-size: 9.5px; letter-spacing: .03em; }

/* Đầu trang */
.dau { position: fixed; z-index: 6; top: calc(var(--vien) + 10px); left: calc(var(--vien) + 14px); right: calc(var(--vien) + 12px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none; }
.dau > * { pointer-events: auto; }
.logo, .kt-logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
.logo img, .kt-logo img { width: 30px; height: auto; }
.logo-chu { display: flex; flex-direction: column; line-height: 1; }
.logo-chu b { font: 800 19px/1 var(--chu); color: var(--xanh); letter-spacing: .01em; }
.logo-chu b i { font-style: normal; color: var(--dong); }
.logo-chu small { margin-top: 4px; font: 500 7.5px/1 var(--chu); letter-spacing: .2em; color: var(--xanh); }

.nut { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 3px;
  font: 700 14px/1.2 var(--chu); text-decoration: none; text-align: center; cursor: pointer; border: 1.5px solid var(--xanh);
  background: var(--xanh); color: #fff; transition: background .15s, transform .15s; -webkit-tap-highlight-color: transparent; }
.nut:hover { background: var(--xanh-dam); }
.nut:active { transform: translateY(1px); }
.nut:focus-visible, .logo:focus-visible, #mucluc button:focus-visible { outline: 3px solid var(--dong); outline-offset: 2px; }
.nut-phu { background: transparent; color: var(--xanh); }
.nut-phu:hover { background: rgba(31, 95, 122, .08); }
.nut-dau { min-height: 44px; padding: 0 14px; font-size: 13px; }

/* Khung tên: dải dọc bên phải (máy tính) */
#khungten { position: fixed; z-index: 5; top: var(--vien); right: var(--vien); bottom: var(--vien); width: var(--kt-rong);
  border-left: 1.5px solid var(--muc); background: rgba(242, 235, 220, .9); display: flex; flex-direction: column; }
.kt-o { padding: 12px 16px; border-bottom: 1px solid var(--muc); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kt-logo { flex-direction: row; padding: 16px; }
.kt-n { font: 500 9.5px/1.2 var(--chu); letter-spacing: .14em; text-transform: uppercase; color: var(--muc-vua); }
.kt-v { font: 700 15px/1.25 var(--chu); }
.kt-p { font: 400 12px/1.35 var(--chu); color: var(--muc-vua); }
.kt-ten .kt-v { font-size: 17px; text-transform: uppercase; letter-spacing: .02em; min-height: 2.5em; }
.kt-doi { flex-direction: row; gap: 0; padding: 0; }
.kt-doi > div { flex: 1; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kt-doi > div + div { border-left: 1px solid var(--muc); }
.kt-thuoc { display: flex; flex-direction: column; gap: 3px; font: 500 11px/1 var(--chu); min-height: 22px; }
.kt-thuoc i { display: block; height: 6px; width: 60px; border: 1px solid var(--muc); border-top: 0; background: linear-gradient(90deg, var(--muc) 50%, transparent 50%); }
.kt-thuoc em { font-style: normal; }
.kt-thuoc.truc-do i { display: none; }
.kt-ml { flex: 1; min-height: 0; overflow: auto; }
#mucluc { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; }
#mucluc button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; gap: 10px; align-items: baseline; width: 100%; padding: 6px 0; font: 400 12.5px/1.3 var(--chu); color: var(--muc-vua); border-bottom: 1px dotted var(--muc-nhat); }
#mucluc button b { font: 700 11px/1 var(--chu); font-variant-numeric: tabular-nums; color: var(--muc); }
#mucluc button[aria-current="true"] { color: var(--muc); font-weight: 700; }
#mucluc button[aria-current="true"] b { color: var(--dong-chu); }
#mucluc button:hover { color: var(--muc); }
.kt-so { flex-direction: row; align-items: baseline; flex-wrap: wrap; column-gap: 8px; }
.kt-so .kt-n { width: 100%; }
.kt-so .kt-v { font: 800 30px/1 var(--chu); color: var(--xanh); }
.kt-nut { margin: 14px 16px 16px; }
.nut-dau { display: none; }

/* Thẻ chú giải của từng tờ */
#the { position: fixed; z-index: 4; left: calc(var(--vien) + 34px); top: 50%; transform: translateY(-46%); width: clamp(300px, 27vw, 400px);
  transition: opacity .28s ease; }
#the.doi { opacity: 0; }
.the-ma { display: inline-flex; align-items: center; gap: 8px; font: 700 11px/1 var(--chu); letter-spacing: .16em; color: var(--dong-chu); text-transform: uppercase; }
.the-ma::before { content: ""; width: 26px; height: 2px; background: var(--dong); }
#the h1, #the h2 { margin: 12px 0 10px; font: 800 clamp(26px, 2.3vw, 36px)/1.12 var(--chu); letter-spacing: -.01em; text-wrap: balance; }
#the p { margin: 0 0 14px; font-size: 15.5px; line-height: 1.55; color: #3d3a35; text-wrap: pretty; }
#the .xuong { display: block; }
#the .tach { display: none; }
.the-so { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.the-so li { border: 1px solid var(--muc); padding: 5px 9px; font: 500 12px/1.2 var(--chu); background: rgba(255, 255, 255, .35); font-variant-numeric: tabular-nums; }
.the-so li b { font-weight: 700; }
.the-goi { margin-top: 16px; display: flex; align-items: center; gap: 8px; font: 500 12px/1 var(--chu); color: var(--muc-vua); letter-spacing: .04em; }
.the-goi::after { content: ""; width: 1px; height: 22px; background: var(--muc-vua); animation: goi 1.6s ease-in-out infinite; transform-origin: top; }
@keyframes goi { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
.the-nut { margin-top: 16px; }

/* Vùng cuộn */
#cuon { position: relative; z-index: 0; }
.to { height: 140vh; height: 140svh; }
.to:last-child { height: 115vh; height: 115svh; }
.di-vao { height: 640vh; height: 640svh; }
.di-noi { height: 110vh; height: 110svh; }
/* Chặng đi vào nhà: phối cảnh phủ kín màn hình nên thẻ chữ cần nền giấy */
body.di #the { background: rgba(242, 235, 220, .93); border: 1px solid var(--muc); padding: 18px 20px 6px; left: calc(var(--vien) + 18px); width: clamp(280px, 25vw, 360px); }
body.di #the h2 { font-size: clamp(22px, 1.9vw, 30px); }
body.di .kt-doi .kt-v { font-size: 13px; }

/* Chờ tải */
#cho { position: fixed; z-index: 7; left: 50%; top: 46%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 10px;
  font: 500 13px/1 var(--chu); letter-spacing: .08em; color: var(--muc-vua); transition: opacity .4s; }
.cho-vach { width: 140px; height: 2px; background: var(--muc-nhat); overflow: hidden; }
.cho-vach i { display: block; width: 40%; height: 100%; background: var(--muc); animation: cho 1.1s ease-in-out infinite; }
@keyframes cho { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
body.san-sang #cho, body.tinh #cho { display: none; }

/* Liên hệ */
#lien-he { position: relative; z-index: 8; background: var(--xanh-dam); color: #fff; padding: 72px 24px 56px; scroll-margin-top: 0; }
.lh-trong { max-width: 720px; margin: 0 auto; }
.lh-nhan { margin: 0 0 10px; font: 700 11px/1 var(--chu); letter-spacing: .18em; text-transform: uppercase; color: #e3b07c; }
#lien-he h2 { margin: 0 0 14px; font: 800 clamp(28px, 4.4vw, 44px)/1.1 var(--chu); letter-spacing: -.01em; text-wrap: balance; }
.lh-mo { margin: 0 0 26px; font-size: 16.5px; line-height: 1.6; color: #dbe7ec; max-width: 60ch; }
.lh-nut { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 36px; }
.lh-nut .nut { min-height: 52px; padding: 0 24px; font-size: 16px; }
.lh-nut .nut-chinh { background: #fff; color: var(--xanh-dam); border-color: #fff; }
.lh-nut .nut-chinh:hover { background: #f2ebdc; }
.lh-nut .nut-phu { color: #fff; border-color: rgba(255, 255, 255, .7); }
.lh-nut .nut-phu:hover { background: rgba(255, 255, 255, .1); }
.lh-buoc { list-style: none; margin: 0 0 30px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.lh-buoc li { border-top: 1px solid rgba(255, 255, 255, .35); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; line-height: 1.5; color: #dbe7ec; }
.lh-buoc b { font: 800 22px/1 var(--chu); color: #e3b07c; }
.lh-chan { margin: 0; font-size: 12.5px; line-height: 1.5; color: #b9cdd6; }

/* Chế độ ảnh tĩnh (máy yếu / không có WebGL) */
body.tinh #c3d, body.tinh #kt, body.tinh #nhan, body.tinh #the, body.tinh #khungten, body.tinh .giay::after { display: none; }
body.tinh .dau { position: sticky; top: 0; left: 0; right: 0; padding: 10px 16px; background: rgba(242, 235, 220, .94); border-bottom: 1px solid var(--muc); }
body.tinh .nut-dau { display: inline-flex; }
body.tinh .to { height: auto; max-width: 760px; margin: 0 auto; padding: 28px 18px 8px; }
body.tinh .to figure { margin: 0 0 14px; }
body.tinh .to img { width: 100%; height: auto; }
body.tinh .to h1, body.tinh .to h2 { margin: 10px 0 8px; font: 800 26px/1.15 var(--chu); }
body.tinh .to .xuong { display: block; }
body.tinh .to .tach { display: none; }
body.tinh .to .the-so { flex-wrap: wrap; overflow: visible; }
body.tinh .to .the-nut { display: inline-flex; margin-top: 14px; }
body.tinh .to p { margin: 0 0 12px; font-size: 16px; line-height: 1.55; }
body.tinh .di-vao { height: auto; max-width: 760px; margin: 0 auto; padding: 8px 18px; }
body.tinh .di-vao figure { margin: 22px 0 12px; }
body.tinh .di-vao img { width: 100%; height: auto; }
body.tinh .di-vao h2 { margin: 8px 0 6px; font: 800 22px/1.2 var(--chu); }
body.tinh .di-vao p { margin: 0 0 12px; font-size: 16px; line-height: 1.55; }
body.tinh .di-vao .the-ma { margin-top: 18px; }
body.tinh .di-noi { display: none; }

/* Chế độ chụp ảnh tĩnh */
body.chup #mo-dau, body.chup .dau, body.chup #khungten, body.chup #the, body.chup #cho, body.chup #lien-he { display: none; }
body.xem #mo-dau { display: none; }
body.chup .np b { font-size: 11.5px; }
body.chup .np span { font-size: 11px; }
body.chup .np.nho b { font-size: 10px; }
body.chup #kt text { font-size: 13px; }

/* Điện thoại + máy tính bảng dọc: khung tên thành dải ngang dưới đáy */
@media (max-width: 899px) {
  :root { --vien: 5px; }
  .nut-dau { display: inline-flex; }
  .dau { top: calc(var(--vien) + 6px); left: calc(var(--vien) + 8px); right: calc(var(--vien) + 6px); }
  .logo-chu b { font-size: 17px; }
  #khungten { top: auto; left: var(--vien); width: auto; border-left: 0; border-top: 1.5px solid var(--muc); background: rgba(242, 235, 220, .96);
    display: grid; grid-template-columns: 1fr auto; grid-template-areas: "ten so" "ml ml"; padding-bottom: env(safe-area-inset-bottom); }
  #khungten .kt-logo, #khungten .kt-o:nth-child(2), #khungten .kt-nut, #khungten .kt-doi > div:last-child, .kt-ml .kt-n, .kt-so .kt-n { display: none; }
  .kt-o { padding: 6px 10px; border-bottom: 0; }
  .kt-ten { grid-area: ten; flex-direction: row; align-items: baseline; gap: 8px; }
  .kt-ten .kt-n { display: none; }
  .kt-ten .kt-v { font-size: 12.5px; min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    /* chữ in hoa có dấu chồng (Ằ, Ầ, Ẳ...) cao hơn dòng: chừa chỗ trên + dưới để overflow:hidden không cắt dấu */
    line-height: 1.9; padding: 3px 0 1px; margin: -3px 0 -1px; }
  .kt-doi { position: fixed; left: calc(var(--vien) + 9px); top: calc(var(--vien) + 58px); }
  .kt-doi > div { padding: 3px 7px; background: var(--giay); border: 1px solid var(--muc); flex-direction: row; align-items: baseline; gap: 6px; }
  .kt-doi .kt-n { font-size: 8.5px; letter-spacing: .1em; }
  .kt-doi .kt-v { font-size: 12px; }
  .kt-so { grid-area: so; flex-direction: row; align-items: baseline; gap: 4px; flex-wrap: nowrap; padding-left: 0; }
  .kt-so .kt-v { font-size: 15px; }
  .kt-so .kt-p { font-size: 11px; }
  .kt-ml { grid-area: ml; padding: 0; border-top: 1px solid var(--muc); overflow: visible; }
  #mucluc { flex-direction: row; margin: 0; }
  #mucluc li { flex: 1; }
  #mucluc li + li { border-left: 1px solid var(--muc-nhat); }
  #mucluc button { justify-content: center; min-height: 44px; padding: 0; border-bottom: 0; align-items: center; }
  #mucluc button span { display: none; }
  #mucluc button b { font-size: 13px; color: var(--muc-vua); font-weight: 500; }
  #mucluc button[aria-current="true"] { background: var(--muc); }
  #mucluc button[aria-current="true"] b { color: var(--giay); font-weight: 700; }
  #the { left: calc(var(--vien) + 1px); right: calc(var(--vien) + 1px); top: auto; bottom: calc(var(--vien) + 77px + env(safe-area-inset-bottom)); width: auto; transform: none;
    padding: 10px 12px 11px; background: rgba(242, 235, 220, .93); border-top: 1px solid var(--muc); height: 164px; overflow: hidden; }
  #the h1, #the h2 { margin: 6px 0 5px; font-size: 19px; }
  #the p { font-size: 13.5px; line-height: 1.45; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .the-so { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -12px; padding-right: 34px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); }
  .the-so::-webkit-scrollbar { display: none; }
  .the-so li { flex: none; font-size: 11.5px; padding: 4px 7px; }
  .the-goi, #the .the-nut { display: none; }
  #the .xuong, #the .tach { display: inline; }
  body.di #the { left: calc(var(--vien) + 1px); width: auto; padding: 10px 12px 11px; border: 0; border-top: 1px solid var(--muc); }
  body.di #the h2 { font-size: 19px; }
  body.di #the p { -webkit-line-clamp: 5; }
  .np b { font-size: 9.5px; letter-spacing: .03em; }
  .np span { font-size: 9.5px; }
  .np.nho b { font-size: 8.5px; letter-spacing: 0; }
  #kt text { font-size: 10px; }
  #lien-he { padding: 52px 20px 44px; }
  .lh-buoc { grid-template-columns: 1fr; gap: 12px; }
  .lh-buoc li { flex-direction: row; align-items: baseline; gap: 12px; }
  .lh-nut .nut { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .the-goi::after, .cho-vach i { animation: none; }
  #the, #c3d { transition: none; }
}

/* Ảnh mở đầu */
#mo-dau { position: relative; z-index: 12; height: 100vh; height: 100svh; min-height: 520px; overflow: hidden; background: #1d2a30; color: #fff; }
#mo-dau > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 62%; }
#mo-dau::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14, 22, 26, .5) 0%, rgba(14, 22, 26, 0) 26%, rgba(14, 22, 26, 0) 48%, rgba(14, 22, 26, .78) 100%); pointer-events: none; }
.md-logo { position: absolute; z-index: 2; top: 18px; left: clamp(16px, 4vw, 48px); display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.md-logo .logo-chu b, .md-logo .logo-chu small, .md-logo .logo-chu i { color: #fff; }
.md-chu { position: absolute; z-index: 2; left: clamp(16px, 4vw, 48px); right: clamp(16px, 4vw, 48px); bottom: clamp(24px, 7vh, 72px); max-width: 640px; }
.md-nhan { margin: 0 0 8px; font: 700 12px/1.2 var(--chu); letter-spacing: .16em; text-transform: uppercase; color: #f0c79a; padding-top: 4px; }
.md-ten { margin: 0 0 10px; font: 800 clamp(34px, 6vw, 64px)/1.08 var(--chu); letter-spacing: -.01em; }
.md-mo { margin: 0 0 18px; font: 400 clamp(15px, 1.6vw, 18px)/1.5 var(--chu); color: rgba(255, 255, 255, .9); }
.md-nut { display: inline-flex; }
@media (max-width: 899px) {
  #mo-dau { background: #14202a; display: flex; flex-direction: column; }
  #mo-dau > img { position: relative; inset: auto; flex: 1 1 0; min-height: 0; height: auto; object-position: 50% 60%; }
  #mo-dau::after { bottom: auto; height: 22%; background: linear-gradient(180deg, rgba(14, 22, 26, .55) 0%, rgba(14, 22, 26, 0) 100%); }
  .md-chu { position: relative; left: auto; right: auto; bottom: auto; flex: none; max-width: none; margin-top: -72px; padding: 72px 16px clamp(18px, 3.5vh, 34px);
    background: linear-gradient(180deg, rgba(20, 32, 42, 0) 0, rgba(20, 32, 42, .86) 46px, #14202a 72px); }
  .md-ten { font-size: 34px; }
}
