/* ============ FONT ============
   Lyveros (Envato Elements): nhung file assets/lyveros.woff de moi may (ke ca dien thoai) deu hien dung.
   File da subset tu Font/Lyveros.ttf, chi giu Latin co ban U+0020-007E (du so + dau phay cho so tien), 37KB.
   Khong dung local() de may nao cung render cung 1 file. */
@font-face {
  font-family: 'Lyveros';
  src: url('assets/lyveros.woff') format('woff');
  font-display: swap;
}

:root {
  --bg: #151414;
  --paper: #ece6d8;
  --field: #d3ccb9;
  --brown: #543737;
  --grey: #b8b8b8;
  --line: rgba(0, 0, 0, .5);
  --s: 1; /* he so co gian cua stage, JS cap nhat */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body { font-family: 'Inter', system-ui, sans-serif; color: #000; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ============ STAGE ============ */
.stage-wrap { position: fixed; inset: 0; overflow: hidden; }
/* Stage phu kin cua so (kich thuoc = cua so / S, scale tu goc tren trai).
   Vi tri tung layer tinh theo constraint Figma trong app.js (CONS) */
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.L { position: absolute; margin: 0; display: block; }
img.L { user-select: none; pointer-events: none; }
canvas.gl { pointer-events: none; }
[data-k="kiem"] { opacity: .05; }[data-k="flower1"], [data-k="flower2"], [data-k="flower3"], [data-k="flower4"] { opacity: .5; transition: opacity 1.2s; }
[data-k="rock1"], [data-k="rock2"] { transition: opacity 1.2s; }
/* Transition tren chi de lam mo em khi vao trang thai hoan thanh; trong intro phai tat (GSAP tu dieu khien opacity) */
body.intro-run [data-k^="flower"], body.intro-run [data-k^="rock"] { transition: none; }
body.done [data-k="flower1"], body.done [data-k="flower2"], body.done [data-k="flower3"], body.done [data-k="flower4"] { opacity: .25; }
body.done [data-k="rock1"], body.done [data-k="rock2"] { opacity: .5; }

/* Vien ren (Figma: Frame-ren-tren / Frame-ren-duoi, constraint Left&Right + Top / Bottom) */
/* Ren nam trong .stage (stage da phu kin cua so va scale theo S) nen kich thuoc tinh theo don vi design, khong can nhan --s */
.lace { position: absolute; left: 0; right: 0; height: 48px; pointer-events: none;
  background: url('assets/lace.webp') repeat-x center top / auto 100%; }
.lace-top { top: 0; }
/* Ren duoi: Figma y = 717, cao 48 trong frame 768 => cach day 3px. Lat doc bang pseudo-element
   de transform cua chinh .lace-bottom chi danh cho animation (GSAP khong bi lan voi scaleY(-1)) */
.lace-bottom { bottom: 3px; background: none; }
.lace-bottom::before { content: ''; position: absolute; inset: 0; background-image: url('assets/lace.webp');
  background-repeat: repeat-x; background-position: center top; background-size: auto 100%; transform: scaleY(-1); }

/* Chu */
[data-k="eden"] { font-size: 0; }
[data-k="eden"] canvas { width: 100%; height: 100%; display: block; }
.info { font: 400 14px/15px 'Playfair Display SC', serif; color: #fff; white-space: nowrap; }
.info.right { text-align: right; }
.amount { font: 400 130px/.6 'Lyveros', 'Playfair Display', serif; color: var(--paper); text-align: center;
  white-space: nowrap; font-variant-numeric: lining-nums; display: flex; align-items: center; justify-content: center; }
.goal { font: 400 16px/1 'Playfair Display SC', serif; color: var(--grey); text-align: center; white-space: nowrap; }
.gom { font: 400 14px/1.49 'Playfair Display', serif; color: var(--grey); text-align: center; }
.done-note { font: 400 12px/1.2 'Inter', sans-serif; color: #fff; text-align: center; opacity: 0; }
.btn-home { width: 110px; height: 41px; background: url('assets/btn-home.svg') no-repeat center / 100% 100%;
  font: 400 16px/41px 'Playfair Display', serif; color: #fff; text-align: center; transition: filter .2s; }
.btn-home:hover { filter: brightness(1.35); }
.btn-home:focus-visible, .link-list:focus-visible { outline: 1px solid #fff; outline-offset: 4px; }
.link-list { font: 400 12px/1.2 'Inter', sans-serif; color: #fff; text-transform: uppercase; text-decoration: underline;
  text-underline-offset: 2px; white-space: nowrap; text-align: center; }
.foot { position: fixed; left: 0; right: 0; bottom: calc(16px * var(--s)); z-index: 4; transform-origin: 50% 100%; font: 400 calc(12px * var(--s, 1))/1 'Roboto Mono', monospace; text-transform: uppercase; color: #777; text-align: center; white-space: nowrap; }
.foot b { font-weight: 400; color: #ddd; }
/* Nut Sound On/Off: cung font footer, cach "amazingfan.mew" 4 ky tu nhu anh thiet ke */
.sound { margin-left: 4ch; font: inherit; text-transform: inherit; color: inherit; letter-spacing: inherit; cursor: pointer;
  padding: calc(6px * var(--s)) 0; margin-top: calc(-6px * var(--s)); margin-bottom: calc(-6px * var(--s)); }
.sound:hover b, .sound:focus-visible b { color: #fff; }
.sound:focus-visible { outline: 1px solid #fff; outline-offset: 3px; }

/* Trang thai hoan thanh chi tieu */
body.done .done-note { opacity: 1; }
body.done .btn-home { opacity: 0; visibility: hidden; transition: opacity .6s, visibility 0s .6s; }
.wing { opacity: 0; }
body.done .wing { opacity: 1; }
.feathers { overflow: visible; pointer-events: none; }
.feather-gl { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.feathers img { position: absolute; left: 0; top: 0; will-change: transform; opacity: 0; }

/* Nut test trang thai hoan thanh (chi hien khi local hoac ?test) */
.test-done { position: fixed; left: 50%; top: calc(6px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30; padding: 6px 8px; white-space: nowrap;
  font: 500 12px/1 'Roboto Mono', monospace; color: #fff; background: rgba(139, 26, 26, .9); border: 1px dashed rgba(255, 255, 255, .6); border-radius: 4px; }

/* Truoc khi intro chay: an het de khong nhay */
body.intro-pending .stage .L, body.intro-pending .lace, body.intro-pending .foot { visibility: hidden; }

/* Split text */
.ch { display: inline-block; white-space: pre; will-change: transform, opacity; }

/* ============ PANEL ============ */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 9; opacity: 0; transition: opacity .3s; }
.scrim.on { opacity: 1; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: 450px; max-width: 100%; z-index: 10;
  background-color: var(--paper); color: #000; display: flex; flex-direction: column; padding: 32px 31px;
  transform: translateX(100%); transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.panel::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .2; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .33 0 0 0 0 .22 0 0 0 0 .2 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E"); }
.panel.on { transform: none; }
.panel > * { position: relative; }
.p-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 23px; flex: none; }
.p-title { height: 34px; width: auto; display: block; }
.p-close { width: 17px; height: 17px; display: grid; place-items: center; }
.p-close img { width: 17px; height: 17px; }
.step { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.step-label { font: 500 14px/1.4 'Inter', sans-serif; color: var(--brown); margin: 0 0 40px; }
.fields { display: flex; flex-direction: column; gap: 21px; }
.f-in { width: 100%; height: 38px; background: var(--field); border: 1px solid var(--line); border-radius: 0;
  padding: 0 10.5px; font: 400 14px 'Inter', sans-serif; color: #000; outline: none; -webkit-appearance: none; }
.f-in::placeholder { color: #000; opacity: 1; }
.f-in:focus { border-color: #000; box-shadow: inset 0 0 0 1px #000; }
.f-in.bad { border-color: #8b1a1a; box-shadow: inset 0 0 0 1px #8b1a1a; }
.f-tall { height: 47.5px; }
.f-area { height: 80px; padding: 10.5px; resize: none; }
.hint { font: 500 12px/1.4 'Inter', sans-serif; color: var(--brown); margin: 4px 0 0; }
.chips { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 6.5px; background: var(--field); border: 1px solid var(--line); font: 400 14px 'Inter', sans-serif; }
.chip.on { background: #000; color: #fff; border-color: #000; }
.cb { display: flex; align-items: center; gap: 9px; font: 500 14px 'Inter', sans-serif; cursor: pointer; user-select: none; }
.cb input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cb .box { width: 16px; height: 16px; border: 1px solid #000; flex: none; display: grid; place-items: center; }
.cb input:checked + .box { background: #000; }
.cb input:checked + .box::after { content: ''; width: 4px; height: 8px; border: solid #fff; border-width: 0 1px 1px 0; transform: translateY(-1px) rotate(45deg); }
.cb input:focus-visible + .box { outline: 2px solid var(--brown); outline-offset: 2px; }
.trap { position: absolute; left: -9999px; }
.err { font: 500 13px/1.4 'Inter', sans-serif; color: #8b1a1a; min-height: 18px; margin: 14px 0 0; }

.btn-panel { position: relative; flex: none; height: 46px; width: 100%; margin-top: auto; color: #fff;
  font: 400 16px/46px 'Playfair Display', serif; text-align: center; background: #000; background-clip: content-box;
  padding: 0 19px; transition: opacity .2s; }
.btn-panel::before, .btn-panel::after { content: ''; position: absolute; top: 0; width: 19px; height: 46px; }
.btn-panel::before { left: 0; background: url('assets/btn-cap-l.svg'); }
.btn-panel::after { right: 0; background: url('assets/btn-cap-r.svg'); }
.btn-panel:disabled { opacity: .25; cursor: not-allowed; }
.btn-panel:not(:disabled):hover { opacity: .85; }
.step > .btn-panel { position: sticky; bottom: 0; margin-top: 24px; }
.step > .err + .btn-panel { margin-top: 10px; }

.qr-box { text-align: center; margin-top: -8px; }
.qr { width: 160px; height: 160px; margin: 0 auto; background: #fff; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.code { font: 600 24px/1.4 'Inter', sans-serif; margin: 10px 0 0; display: inline-flex; align-items: center; gap: 12px; }
.ic-copy { width: 14px; height: 14px; display: inline-grid; place-items: center; flex: none; }
.ic-copy img { width: 14px; height: 14px; }
.ic-copy.ok { filter: invert(30%) sepia(60%) saturate(500%) hue-rotate(80deg); }
.save-qr { display: none; margin: 4px auto 0; font: 500 13px 'Inter', sans-serif; color: var(--brown); text-decoration: underline; text-underline-offset: 2px; }
.touch .save-qr { display: block; }
.qr-box + .hint { margin: 16px 0 0; }
.rows { margin: 30px 0 0; display: flex; flex-direction: column; gap: 12px; }
.rows div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.rows dt { font: 500 14px 'Inter', sans-serif; }
.rows dd { margin: 0; font: 600 14px 'Inter', sans-serif; display: inline-flex; align-items: center; gap: 7px; text-align: right; }
.upload { margin-top: 38px; }
.up-label { font: 500 14px 'Inter', sans-serif; margin: 0 0 8px; }
.up-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.up-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.up-btn { background: #000; color: #fff; border-radius: 2px; padding: 3px 8px; font: 500 14px 'Inter', sans-serif; flex: none; }
.up-row input:focus-visible + .up-btn { outline: 2px solid var(--brown); outline-offset: 2px; }
.up-name { font: 400 14px 'Inter', sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.step3 { justify-content: space-between; }
.thanks { margin: auto 0; text-align: center; color: var(--brown); }
.thanks-title { font: 500 14px/1.4 'Inter', sans-serif; margin: 0 0 32px; }
.thanks-title b { font: 700 18px/1.4 'Inter', sans-serif; letter-spacing: .02em; }
.thanks-body { font: 500 14px/1.4 'Inter', sans-serif; margin: 0; }
.thanks-body .ok { display: block; margin-top: 16px; font-weight: 700; }

/* Danh sach donor */
.ds-tools { display: flex; gap: 16px; margin: 17px 0 25px; flex: none; }
.ds-search { flex: 1; position: relative; }
.ds-search input { width: 100%; height: 38px; background: var(--field); border: 1px solid var(--line); padding: 0 32px 0 10.5px;
  font: 400 14px 'Inter', sans-serif; outline: none; -webkit-appearance: none; border-radius: 0; }
.ds-search input::placeholder { color: #000; opacity: 1; }
.ds-search img { position: absolute; right: 10px; top: 13px; width: 12px; }
.ds-sort { position: relative; width: 95px; flex: none; }
.ds-sort select { width: 100%; height: 35px; margin-top: 1.5px; background: var(--field); border: 1px solid var(--line); border-radius: 0;
  padding: 0 24px 0 10.5px; font: 400 14px 'Inter', sans-serif; -webkit-appearance: none; appearance: none; outline: none; }
.ds-sort img { position: absolute; right: 10px; top: 16px; width: 10px; pointer-events: none; }
.ds-list { flex: 1; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.slot { padding-bottom: 20px; }
.slot-row { display: flex; justify-content: space-between; gap: 24px; }
.slot-name { font: 400 10px/1.2 'Inter', sans-serif; text-transform: uppercase; margin: 0; }
.slot-amt { font: 500 24px/1 'Playfair Display', serif; margin: 0; white-space: nowrap; }
.slot-code { font: 400 10px/1.2 'Roboto Mono', monospace; color: var(--brown); margin: 4px 0 0; }
.slot-msg { font: 400 12px/1.2 'Inter', sans-serif; text-align: right; margin: 0; max-width: 222px; overflow-wrap: anywhere; }
.slot-line { position: relative; height: 5px; margin-top: 20px; }
.slot-line::before { content: ''; position: absolute; left: 4px; right: 4px; top: 2.5px; border-top: 1px solid rgba(85, 72, 72, .5); }
.slot-line::after { content: ''; position: absolute; inset: 0; background:
  linear-gradient(#554848, #554848) left / 5px 5px no-repeat, linear-gradient(#554848, #554848) right / 5px 5px no-repeat; }
.slot.hit .slot-code { background: #000; color: #fff; display: inline-block; padding: 0 4px; }
.ds-empty { font: 500 14px 'Inter', sans-serif; color: var(--brown); text-align: center; margin-top: 40px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #000; color: #fff; z-index: 20;
  font: 500 13px 'Inter', sans-serif; padding: 10px 14px; opacity: 0; transition: .3s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ============ MOBILE ============ */
@media (max-width: 767px) {
  .panel { width: 100%; padding: 32px 24px calc(32px + env(safe-area-inset-bottom)); }
  .step-label { margin-bottom: 32px; }
  .amount { font-size: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  .panel, .scrim, .toast { transition: none; }
}

/* Chua co font Lyveros: dung Playfair Display co nho lai cho vua bo cuc */
.no-lyv .amount { font-size: 92px; line-height: 1; }
@media (max-width: 767px) { .no-lyv .amount { font-size: 64px; } }

/* Panel chinh animation (chi hien khi test: localhost / LAN / ?test) */
.tune { position: fixed; right: 10px; top: calc(10px + env(safe-area-inset-top)); z-index: 31; font: 12px/1.35 Inter, system-ui, sans-serif; color: #eee; }
.tune-toggle { display: block; margin-left: auto; padding: 6px 10px; background: rgba(140, 16, 16, .85); color: #fff; border: 1px dashed #ff8a8a; border-radius: 4px; font: inherit; cursor: pointer; }
.tune-toggle.on { background: #8c1010; }
.tune-box { margin-top: 6px; width: 310px; max-height: calc(100vh - 70px); overflow: auto; padding: 10px 12px 12px; background: rgba(12, 12, 12, .92); border: 1px solid rgba(255, 255, 255, .15); border-radius: 6px; backdrop-filter: blur(6px); }
.tune-box[hidden] { display: none; }
.tune-h { margin: 10px 0 4px; font-weight: 600; color: #f0b27a; }
.tune-h:first-child { margin-top: 0; }
.tune-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin: 4px 0 8px; }
.tune-row b { font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.tune-row input { grid-column: 1 / -1; width: 100%; accent-color: #e0582a; margin: 0; }
.tune-note { margin: 6px 0 0; color: #aaa; font-size: 11px; }
.khop-ov { position: fixed; inset: 0; z-index: 29; pointer-events: none; }
.khop-ov[hidden] { display: none; }
.khop-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.khop-svg polyline { fill: none; stroke: #ffd24a; stroke-width: 2; stroke-dasharray: 5 4; }
.khop-dot { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; background: #e0582a; border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .5); pointer-events: auto; cursor: grab; touch-action: none; }
.khop-dot:active { cursor: grabbing; }
.khop-dot::after { content: attr(data-n); position: absolute; left: 22px; top: -2px; white-space: nowrap; font: 600 11px/1 Inter, system-ui, sans-serif; color: #fff; background: rgba(0, 0, 0, .7); padding: 3px 5px; border-radius: 3px; }
.tune-btns { display: flex; gap: 6px; margin-top: 10px; }
.tune-btns button { flex: 1; padding: 7px 4px; white-space: nowrap; background: #262626; color: #fff; border: 1px solid #444; border-radius: 4px; font: inherit; cursor: pointer; }
.tune-btns button:first-child { background: #e0582a; border-color: #e0582a; }
@media (max-width: 767px) {
  .tune { right: 8px; left: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); }
  .tune-box { width: auto; max-height: 38vh; }   /* chua cho canh (y ~320-460) phia tren */
}
