/* เอฟเฟกต์ฉลองแบบใช้ซ้ำ (celebrate-fx.js · 5 ต.ค.) — ชั้น Popup (--z-popup 300)
   ทุกชั้นแสงคือภาพ texture (assets/particles · Kenney CC0) ที่ใช้เป็น mask แล้วลงสีตามธีม
   แกนทึบ (normal) + ชั้นแสง (screen) — กฎสไตล์ข้อ 2: อ่านออกบนพื้นทราย/หญ้าสว่าง ไม่ใช่แสงบวกอย่างเดียว · ไม่มีอะไรขาวจ้า
   big/small ไม่รับการแตะ (pointer-events: none) = ไม่บล็อกการควบคุม · epic มีพื้นหลังมืด + ปุ่ม */
.cf-layer { position: fixed; inset: 0; z-index: var(--z-popup, 300); display: grid; place-items: center; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  --c1: #e8b64a; --c2: #fff2c0; --c3: #a8681a; --rib1: #d24a3a; --rib2: #9d2a22; }
.cf-t-teal { --c1: #3f9a9e; --c2: #c8f4ee; --c3: #1f5a5d; --rib1: #2f6f73; --rib2: #1d4a4d; }
.cf-t-violet { --c1: #9a6ae0; --c2: #ecdcff; --c3: #5a3a90; --rib1: #7a4ac0; --rib2: #4c2a80; }
.cf-t-rose { --c1: #e07a9a; --c2: #ffe0ea; --c3: #a0405a; --rib1: #c8506e; --rib2: #8a2a44; }
.cf-modal { pointer-events: auto; }
.cf-dim { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, #2a1c3299, #120c18d9); opacity: 0; transition: opacity .3s; }
.cf-layer.in .cf-dim { opacity: 1; }

.cf-stage { position: relative; display: flex; flex-direction: column; align-items: center; width: var(--w); --w: min(380px, 70vw, 66vh); --R: calc(var(--w) * .62); }
.cf-small { place-items: start center; }
.cf-small .cf-stage { --w: min(230px, 50vw); margin-top: max(12vh, 70px); }
.cf-epic .cf-stage { --w: min(780px, 94vw); }
.cf-stage > * { position: relative; z-index: 1; }
.cf-stage > .cf-aura { z-index: 0; }

/* ── ออร่า (กล่อง: ผืนผ้าใบ .cf-cv + ประกาย/ฝุ่น) ── */
.cf-aura { position: absolute; left: 50%; top: var(--ay, 38%); width: calc(var(--w) * 1.45); aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none; }
.cf-epic .cf-aura { --ay: 46%; width: min(150vh, 140vw); }
.cf-l { position: absolute; inset: 0; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
/* ชั้นแสง (รัศมี วงแหวน ดาว ลำแสง วงเวท) วาดลงผืนผ้าใบใบเดียว — celebrate-fx.js LAYERS (ค่าทุกค่ายกมาจาก CSS เดิม)
   6 ต.ค.: เดิมเป็น <i> 6–7 ชั้น mask + หมุน + mix-blend ขนาด ~800px → Safari iPhone สร้างภาพชั้นละ (กว้าง×DPR)²×2 ≈ 240 MB → แท็บโดนฆ่า
   ห้ามกลับไปทำชั้นแสงใหญ่เป็น DOM ที่มี animation/mask — เพิ่มชั้นใหม่ใน LAYERS แทน */
.cf-cv { position: absolute; left: -20%; top: -20%; width: 140%; height: 140%; pointer-events: none; }
.cf-sp { position: absolute; left: 50%; top: 50%; width: calc(30px * var(--s)); aspect-ratio: 1; margin: calc(-15px * var(--s));
  -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; background: var(--c2);
  filter: drop-shadow(0 0 1.5px var(--c3)); opacity: 0; animation: cf-burst 1.2s var(--dl) cubic-bezier(.15, .7, .3, 1) both; }
.cf-epic .cf-sp { animation-iteration-count: infinite; animation-duration: 2.4s; }
.cf-dust { position: absolute; left: calc(50% + var(--x) * 32%); top: 64%; width: calc(14px * var(--s)); aspect-ratio: 1;
  -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; background: var(--c1); opacity: 0;
  animation: cf-rise 2.6s var(--dl) ease-in infinite; }
@keyframes cf-spin { to { transform: rotate(360deg); } }
@keyframes cf-burst { 0% { transform: translate(0, 0) scale(.2); opacity: 0; } 18% { opacity: 1; }
  100% { transform: translate(calc(var(--x) * var(--R)), calc(var(--y) * var(--R))) scale(1) rotate(80deg); opacity: 0; } }
@keyframes cf-rise { 0% { transform: translateY(0) scale(.6); opacity: 0; } 20% { opacity: .9; } 100% { transform: translateY(calc(var(--w) * -.7)) scale(1); opacity: 0; } }

/* ── เนื้อหา ── */
.cf-art { order: 1; width: 62%; aspect-ratio: 1; display: grid; place-items: center; filter: drop-shadow(0 6px 10px #3a1e0866); }
.cf-art > img, .cf-art > svg { width: 100%; height: 100%; object-fit: contain; }
.cf-small .cf-art { width: 34%; }
.cf-epic .cf-art { width: auto; aspect-ratio: auto; filter: none; }
.cf-banner { order: 2; margin-top: -8%; padding: .28em 1.6em .34em; font: 900 calc(var(--w) * .105) / 1.05 var(--font-head, inherit); letter-spacing: .02em; color: #fff7de;
  text-shadow: 0 2px 0 var(--rib2), 0 0 6px #0006; white-space: nowrap;
  background: linear-gradient(var(--rib1), var(--rib2)); border: 3px solid var(--c1); border-radius: 10px;
  box-shadow: 0 0 0 2px var(--c3), 0 6px 14px #0006, inset 0 2px 0 #ffffff40; }
.cf-banner::before, .cf-banner::after { content: ''; position: absolute; top: 22%; width: 1.1em; height: 78%; background: var(--rib2); z-index: -1;
  border: 2px solid var(--c3); }
.cf-banner::before { left: -.75em; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 34% 50%); }
.cf-banner::after { right: -.75em; clip-path: polygon(0 0, 100% 0, 66% 50%, 100% 100%, 0 100%); }
.cf-banner.art { background: var(--banner) center / 100% 100% no-repeat; border: 0; box-shadow: none; padding: .55em 2.6em .9em; }
.cf-banner.art::before, .cf-banner.art::after { display: none; }
.cf-small .cf-banner { font-size: 15px; margin-top: 4px; }
.cf-epic .cf-banner { order: 0; margin: 0 0 10px; font-size: clamp(22px, 4.4vw, 40px); }
.cf-title { order: 3; margin-top: 6px; padding: .45em 1.2em; max-width: 100%; font: 800 calc(var(--w) * .05) / 1.25 var(--font-head, inherit); color: #fff4d6; text-align: center;
  background: linear-gradient(#5a3a28, #3e2618); border: 2px solid var(--c1); border-radius: 12px; box-shadow: 0 4px 10px #0005; }
.cf-small .cf-title { font-size: 12px; }
.cf-sub { order: 4; margin-top: 6px; padding: .2em .9em; border-radius: 999px; font: 800 calc(var(--w) * .05) / 1.25 var(--font-head, inherit); color: #ffd76a; background: #3e2618e0; border: 1.5px solid var(--c3); box-shadow: 0 3px 8px #0005; }
.cf-epic .cf-title, .cf-epic .cf-sub { font-size: 15px; }
.cf-stage > .cf-body { order: 5; }
.cf-acts { order: 6; display: flex; gap: 10px; margin-top: 12px; pointer-events: auto; }
.cf-btn { min-height: 46px; padding: 0 26px; border-radius: 999px; font: 800 17px var(--font-head, inherit); cursor: pointer; color: #5a3a0e;
  background: linear-gradient(#fff6dc, #efd9a4); border: 2px solid var(--c3); box-shadow: 0 4px 0 var(--c3), 0 8px 16px #0005; }
.cf-btn.main { color: #4a2a06; background: linear-gradient(#ffe48a, var(--c1)); }
.cf-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--c3); }

/* จอเตี้ย (มือถือแนวนอน 320–430px · 113): ฉลองเต็มจอต้องพอดีจอ — ย่อภาพกล่องตามความสูง (คอมสูง ≥ 520px ไม่โดน) · ช่องไฟแน่นขึ้น · ปุ่ม ≥ 44px ต้องไม่ตกจอ
   ใช้ dvh (ถ้ามี) ตามแถบเบราว์เซอร์มือถือที่ขยับ · ออร่าอยู่หลังเนื้อหา (pointer-events: none) ไม่บังปุ่ม */
@media (max-height: 520px) {
  .cf-epic .cf-art > img { width: auto; height: auto; max-width: 100%; max-height: 34vh; max-height: 34dvh; }
  .cf-epic .cf-banner { margin-bottom: 4px; }
  .cf-epic .cf-title { margin-top: 4px; padding: .3em 1em; }
  .cf-epic .cf-sub { margin-top: 4px; }
  .cf-epic .cf-acts { margin-top: 8px; }
  .cf-epic .cf-btn { min-height: 44px; }
}
@media (max-height: 400px) {
  .cf-epic .cf-art > img { max-height: 29vh; max-height: 29dvh; }
  .cf-epic .cf-banner { font-size: 20px; padding-top: .2em; padding-bottom: .26em; }
  .cf-epic .cf-title, .cf-epic .cf-sub { font-size: 14px; }
}

/* ── จังหวะเข้า/ออก ── */
.cf-stage { opacity: 0; }
/* backwards (ไม่ใช่ both): จบท่าเข้าแล้วไม่ค้าง animation — Safari คืนชั้นภาพของกล่องเหล่านี้ (6 ต.ค.) · ค่าสุดท้ายเท่าเดิม */
.cf-layer.in .cf-stage { opacity: 1; animation: cf-pop .5s cubic-bezier(.2, 1.4, .4, 1) backwards; }
.cf-layer.in .cf-art { animation: cf-art .55s .05s cubic-bezier(.25, 1.6, .5, 1) backwards; }
.cf-layer.in .cf-banner { animation: cf-drop .42s .22s cubic-bezier(.2, 1.5, .4, 1) backwards; }
.cf-layer.in .cf-title, .cf-layer.in .cf-sub { animation: cf-up .35s .38s ease-out backwards; }
.cf-layer.out .cf-stage { animation: cf-out .26s ease-in both; }
@keyframes cf-pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
@keyframes cf-art { from { transform: scale(.3) rotate(-14deg); opacity: 0; } }
@keyframes cf-drop { from { transform: scale(.5) translateY(-20px); opacity: 0; } }
@keyframes cf-up { from { transform: translateY(10px); opacity: 0; } }
@keyframes cf-out { to { opacity: 0; transform: scale(.92) translateY(-8px); } }

/* ชิ้นบินเข้าปุ่ม + ปุ่มเด้งรับ */
.cf-ghost { position: fixed; z-index: var(--z-popup, 300); pointer-events: none; margin: 0; }
.cf-catch { animation: cf-catch .55s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes cf-catch { 30% { transform: scale(1.3); filter: drop-shadow(0 0 8px #ffd76a); } }

/* ออร่าหลังกล่องที่มีอยู่แล้ว (aura()) — วางกลางกล่องเป้าหมาย ใต้กล่อง */
.cf-aura.cf-free { position: fixed; z-index: 0; top: var(--ay); left: var(--ax); width: var(--aw); transform: translate(-50%, -50%);
  --c1: #e8b64a; --c2: #fff2c0; --c3: #a8681a; --w: var(--aw); --R: calc(var(--aw) * .42); }
/* กล่องที่มีพื้นสว่างอยู่แล้ว (การ์ดคราฟ) — แสงนุ่มจางลง (.26) ไม่ให้ขาวจ้ารอบกล่อง (กฎ 2) · ค่าอยู่ใน celebrate-fx.js baseOp */
.cf-aura.cf-free.cf-t-teal { --c1: #3f9a9e; --c2: #c8f4ee; --c3: #1f5a5d; }
.cf-aura.cf-free.cf-t-violet { --c1: #9a6ae0; --c2: #ecdcff; --c3: #5a3a90; }

/* ลดการเคลื่อนไหว: ไม่หมุน ไม่มีประกาย — ค่อย ๆ ปรากฏ */
.cf-still .cf-l, .cf-still .cf-sp, .cf-still .cf-dust { animation: none !important; }
.cf-still.in .cf-stage, .cf-still .cf-art, .cf-still .cf-banner, .cf-still .cf-title, .cf-still .cf-sub { animation: none !important; }
.cf-still .cf-stage { opacity: 1; transition: opacity .25s; }
@media (prefers-reduced-motion: reduce) { .cf-catch { animation: none; } }
/* โหมดเบา Safari ชั่วคราว (html.fx-lite · 06742f5) ถอดแล้ว 6 ต.ค. — ต้นเหตุแก้ที่ราก: ชั้นแสงใหญ่วาดลงผืนผ้าใบเดียว + งดวาดฉาก 3D ระหว่างฉากใหญ่ (celebrate-fx.js หัวไฟล์) · iPhone เห็นเหมือนคอม */
