/* SmartRegister — shared styles
   โทนสีอ้างอิงภาพตัวอย่าง: เขียวเข้ม + ทอง + พื้นหลังเขียว/ฟ้าอ่อน */

:root {
  --g-950: #0c2416;
  --g-900: #133821;
  --g-800: #1b4a2e;
  --g-700: #22603b;
  --g-600: #2d7a4c;
  --g-500: #3f9463;
  --g-200: #cde3d3;
  --g-100: #e4f0e6;
  --g-50: #f2f8f3;
  --gold: #c9a24a;
  --gold-2: #e3c578;
  --gold-soft: #f7edd2;
  --gold-ink: #6f5214;
  --ink: #17251c;
  --ink-2: #4a5b4f;
  --ink-3: #7b897f;
  --line: #dde7df;
  --bg: #f3f7f2;
  --card: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #1d5f9e;
  --info-soft: #eaf2fb;
  --warn: #8a5a00;
  --warn-soft: #fff4e0;
  --shadow-sm: 0 1px 2px rgba(19, 56, 33, .06);
  --shadow: 0 1px 2px rgba(19, 56, 33, .05), 0 10px 30px rgba(19, 56, 33, .09);
  --font: "Noto Sans Thai", "Sukhumvit Set", Thonburi, Tahoma, system-ui, sans-serif;
  --font-display: Prompt, "Noto Sans Thai", "Sukhumvit Set", Thonburi, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.screen-entry :focus-visible, .screen-confirm :focus-visible { outline: 3px solid var(--g-800); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-3); font-size: 13.5px; }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 999px;
  font-weight: 600; font-size: 15.5px; line-height: 1.3;
  text-decoration: none; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, box-shadow .15s, transform .06s, opacity .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, var(--g-600), var(--g-800));
  box-shadow: 0 6px 16px rgba(27, 74, 46, .26);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, var(--g-500), var(--g-700)); }
.btn-ghost { color: var(--g-800); background: #fff; border-color: var(--g-200); }
.btn-ghost:hover:not(:disabled) { background: var(--g-50); border-color: var(--g-500); }
.btn-danger { color: var(--danger); background: #fff; border-color: #f2c7c3; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-lg { min-height: 56px; font-size: 17.5px; padding: 0 24px; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 13.5px; }
.btn-block { width: 100%; }

.spinner {
  display: none; width: 18px; height: 18px; flex: none;
  border: 2.5px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%;
  animation: spin360 .8s linear infinite;
}
.is-loading .spinner { display: inline-block; }
@keyframes spin360 { to { transform: rotate(360deg); } }

/* =====================================================================
   MOBILE — หน้า 1, 2, 3
   ===================================================================== */

body.mobile {
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
  background: linear-gradient(180deg, #d9eaf2 0, #e8f2e8 260px, var(--bg) 520px);
}
.app { position: relative; max-width: 480px; margin: 0 auto; }
.screen { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* การ์ดสีขาวของหน้า 2 */
.sheet {
  position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column;
  margin: 0 12px 12px; padding: clamp(14px, 2.6dvh, 22px) 18px clamp(10px, 2dvh, 16px);
  background: var(--card); border-radius: 26px; box-shadow: var(--shadow);
}
.msg { min-height: 22px; margin: clamp(2px, .8dvh, 6px) 0; text-align: center; font-size: 14.5px; line-height: 1.5; text-wrap: balance; }
.msg[data-kind="error"] { color: var(--danger); font-weight: 500; }
.msg[data-kind="info"] { color: var(--ink-2); }
.nw { white-space: nowrap; }
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

/* ---------- หน้า 1 (ตาม design) ----------
   ต้องอยู่ในหน้าจอเดียว ไม่ต้องเลื่อน: ความสูงคงที่เท่าจอ แล้วให้ปุ่มตัวเลขยืด/หดตามพื้นที่ที่เหลือ
   ขนาดอื่น ๆ ย่อตามความสูงจอ (dvh) และความกว้างจอ (vw, มีเพดานสำหรับจอใหญ่) — iPhone Safari มีพื้นที่จริงราว 550–660px */

.screen-entry {
  position: relative; isolation: isolate;
  height: 100vh; height: 100dvh; min-height: 540px;
  padding: clamp(6px, 1.6dvh, 18px) 12px clamp(8px, 1.6dvh, 16px);
}

/* พื้นหลังเต็มหน้าจอ (กว้างกว่าคอลัมน์บนจอใหญ่): ฟ้าด้านบน → ขาว → เขียวอ่อนด้านล่าง */
.entry-bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(60% 18% at 50% 46%, rgba(255, 255, 255, .9), rgba(255, 255, 255, 0) 72%),
    linear-gradient(180deg, #cfe4f8 0%, #e3eefa 12%, #f1f5fb 22%, #fdfefe 36%, #f7fbf9 62%, #eef6f1 100%);
}
.entry-deco { position: absolute; background-repeat: no-repeat; background-size: 100% 100%; }
/* เส้นโค้งเขียวอ่อนด้านขวา + ดอกขิงแดงมุมซ้ายล่าง อยู่ข้างการ์ด (มือถือเห็นเพียงขอบ จอใหญ่เห็นเต็ม) */
.entry-deco-swoosh { right: 0; bottom: 9%; height: 30%; aspect-ratio: 168 / 420; background-image: url(../img/hero-swoosh.webp); }
.entry-deco-ginger { left: 0; bottom: 5%; height: 32%; aspect-ratio: 178 / 445; background-image: url(../img/hero-ginger.webp); }
.entry-footer {
  position: absolute; left: 0; right: 0; bottom: 0; height: clamp(70px, 12dvh, 150px);
  background: url(../img/hero-footer.webp) 30% 100% / cover no-repeat;
}
/* ท้องฟ้า + อาคารศูนย์ราชการ: พื้นหลังของส่วนหัว เต็มความกว้างจอ ตั้งแต่ขอบบนจอถึงกลางป้าย "ระบบลงทะเบียนอัตโนมัติ"
   ตรา/ชื่อหน่วยงานอยู่บนท้องฟ้า ตัวอาคารอยู่ในช่องว่างเหนือป้าย (margin-top ของ .entry-system) */
.entry-hero {
  position: absolute; z-index: -1; left: 50%; width: 100vw; translate: -50% 0;
  top: calc(-1 * clamp(6px, 1.6dvh, 18px)); bottom: 18px;
  background: url(../img/hero-top.webp) 50% 100% / cover no-repeat;
  -webkit-mask-image: linear-gradient(to bottom, #000 84%, transparent);
  mask-image: linear-gradient(to bottom, #000 84%, transparent);
  transform-origin: 50% 100%;
}
.screen-entry .entry-event { position: relative; margin-top: clamp(6px, 1.2dvh, 12px); }
.screen-entry .entry-event-name { line-height: 1.22; }

/* หัวหน้า: ตรา → ชื่อหน่วยงาน → อำเภอ/จังหวัด (มีเส้นสองข้าง) → ภาพอาคาร → ป้ายระบบลงทะเบียนอัตโนมัติ */
.entry-head { position: relative; flex: none; display: flex; flex-direction: column; align-items: center; text-align: center; }
.entry-emblem { width: clamp(40px, 7dvh, 64px); height: auto; aspect-ratio: 1; filter: drop-shadow(0 3px 6px rgba(70, 55, 20, .28)); }
.entry-host {
  margin: clamp(2px, .7dvh, 6px) 0 0; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(18px, 3.1dvh, 26px); line-height: 1.25; color: #1f4d33;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .85), 0 0 14px rgba(255, 255, 255, .95);
}
.entry-host-sub { margin: 0; font-size: clamp(12px, 1.9dvh, 15px); font-weight: 500; color: #1d2b24; text-shadow: 0 0 10px rgba(255, 255, 255, .95); }
.screen-entry .entry-host-sub { display: flex; align-items: center; justify-content: center; gap: .8em; width: 100%; }
.screen-entry .entry-host-sub::before, .screen-entry .entry-host-sub::after { content: ""; flex: 0 1 clamp(22px, 10vw, 72px); height: 1px; background: rgba(30, 50, 40, .42); }
/* ป้ายสีเขียวอ่อนวางทับขอบล่างของภาพอาคาร — ระยะห่างด้านบนคือช่องที่เห็นตัวอาคาร */
.entry-system {
  display: inline-flex; align-items: center; gap: 10px; margin: clamp(52px, 32dvh - 165px, 140px) 0 0;
  padding: clamp(4px, .8dvh, 9px) clamp(20px, 7vw, 34px);
  border: 1px solid rgba(255, 255, 255, .95); border-radius: 999px;
  background: linear-gradient(180deg, rgba(240, 249, 242, .97), rgba(222, 240, 228, .95));
  box-shadow: 0 8px 20px rgba(30, 80, 50, .16), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-family: var(--font-display); font-weight: 600; font-size: clamp(15.5px, 2.7dvh, 21px); line-height: 1.35; color: #1b4a2e;
}
.entry-system svg { flex: none; width: 1.25em; height: 1.25em; color: #1f5a37; }

/* ชื่องาน: ป้ายทอง "งานพิธีเปิด" + ชื่อโครงการ 2 บรรทัดขนาบด้วยช่อชัยพฤกษ์ */
.entry-event { flex: none; display: flex; flex-direction: column; align-items: center; margin-top: clamp(7px, 1.7dvh, 16px); text-align: center; }
.entry-event-label {
  padding: .2em 1.8em .26em; border-radius: 999px;
  font-weight: 600; font-size: clamp(13px, 2.1dvh, 17px); line-height: 1.5; color: #fff;
  background: linear-gradient(180deg, #a4782e 0%, #b18437 50%, #c79c4c 100%);
  box-shadow: 0 3px 8px rgba(140, 100, 30, .28), inset 0 1px 0 rgba(255, 255, 255, .35);
  text-shadow: 0 1px 2px rgba(70, 45, 5, .45);
}
.screen-entry .entry-event-label { background: linear-gradient(180deg, #c98d0c 0%, #d49c13 45%, #e3b02c 100%); }
.entry-event-name {
  display: flex; align-items: center; justify-content: center; gap: clamp(4px, 1.6vw, 8px);
  max-width: 100%; margin: clamp(3px, .9dvh, 8px) 0 0;
  font-family: var(--font-display); font-weight: 700; line-height: 1.3; color: #1b4a2e;
  font-size: min(clamp(18px, 3.4dvh, 30px), 5.2vw, 25px);
  text-shadow: 0 0 14px rgba(255, 255, 255, .9);
}
.entry-event-name > span { min-width: 0; }
.entry-event-name .ph { display: block; }
.laurel { flex: none; width: clamp(22px, 3.8dvh, 36px); height: auto; }
.laurel-r { scale: -1 1; }

/* การ์ดกรอกเลข */
.entry-card {
  position: relative; flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column;
  margin-top: clamp(8px, 1.8dvh, 18px);
  padding: clamp(10px, 2dvh, 20px) clamp(12px, 4.4vw, 22px) clamp(12px, 2.2dvh, 22px);
  border: 1px solid rgba(255, 255, 255, .95); border-radius: 28px;
  background: linear-gradient(180deg, rgba(253, 252, 249, .95), rgba(249, 249, 246, .92));
  box-shadow: 0 12px 34px rgba(32, 66, 48, .13), 0 2px 6px rgba(32, 66, 48, .05);
}
.entry-prompt {
  margin: 0; text-align: center; text-wrap: balance;
  font-weight: 600; font-size: clamp(14px, 2.3dvh, 18px); line-height: 1.45; color: #1b4a2e;
}
.entry-prompt svg { display: inline-block; width: 1.5em; height: 1.5em; margin-right: .4em; vertical-align: -.42em; color: #2d7a4c; }
.entry-prompt .ico-alert { display: none; }
.entry-prompt[data-kind="error"] { color: var(--danger); }
.entry-prompt[data-kind="error"] svg { color: var(--danger); }
.entry-prompt[data-kind="error"] .ico-person { display: none; }
.entry-prompt[data-kind="error"] .ico-alert { display: inline-block; }

/* ช่องแสดงเลข: แคปซูลขอบทอง "— — —" */
.code {
  flex: none; align-self: center; display: flex; align-items: center; justify-content: center; gap: clamp(6px, 1.8vw, 10px);
  width: min(80%, 340px); height: clamp(40px, 6dvh, 54px); margin: clamp(6px, 1.2dvh, 12px) 0 clamp(8px, 1.4dvh, 14px);
  border: 2px solid transparent; border-radius: 999px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(100deg, #f0d896, #c69a42 30%, #f3dfa5 55%, #c69a42 80%, #ecd18a) border-box;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .06), 0 3px 10px rgba(180, 140, 60, .16);
}
.code.is-error {
  background: linear-gradient(#fff, #fff) padding-box, linear-gradient(90deg, #eeb1aa, var(--danger), #eeb1aa) border-box;
}
.code.shake { animation: shake .42s; }
.slot { width: .7em; text-align: center; font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 4.6dvh, 38px); line-height: 1; color: #19432e; }
.slot:empty::before { content: ""; display: block; width: .58em; height: 5px; margin: 0 auto; border-radius: 3px; background: #a7a9ab; }
.slot.caret:empty::before { background: var(--gold); animation: caretBlink 1.1s steps(1) infinite; }
@keyframes caretBlink { 50% { opacity: .3; } }

.keypad {
  flex: 0 1 290px; min-height: 160px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, minmax(36px, 1fr));
  gap: clamp(6px, 1.2dvh, 11px) clamp(8px, 2.8vw, 13px);
}
.keypad button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0;
  border: 1px solid #e3e9e2; border-radius: clamp(12px, 2dvh, 17px);
  background: linear-gradient(180deg, #ffffff, #f5f7f4);
  box-shadow: inset 0 1px 0 #fff, 0 2px 6px rgba(28, 64, 42, .08), 0 1px 1px rgba(28, 64, 42, .05);
  font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 3.9dvh, 31px); line-height: 1; color: #19432e;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform .06s, background-color .15s, box-shadow .15s;
}
.keypad button:active { transform: scale(.96); background: #ecf4ea; box-shadow: inset 0 1px 3px rgba(28, 64, 42, .12); }
.keypad .key-fn { font-family: var(--font); font-weight: 600; font-size: clamp(12px, 1.9dvh, 15px); line-height: 1.2; color: #1f5a37; }
.keypad .key-fn svg { flex: none; width: clamp(22px, 3.7dvh, 32px); height: auto; }
.keypad .key-fn span { white-space: nowrap; }
.keypad .key-clear { background: linear-gradient(180deg, #e7f3da, #dcedcb); border-color: #d2e4c0; }
.keypad .key-clear svg { color: #2b7c45; }
.keypad .key-back { background: linear-gradient(180deg, #e9f1ea, #dde9de); border-color: #d3e0d5; }

/* ปุ่มตรวจสอบข้อมูล */
.btn-check {
  flex: none; margin-top: clamp(10px, 2dvh, 18px); min-height: clamp(48px, 7.4dvh, 62px);
  font-family: var(--font-display); font-size: clamp(16px, 2.7dvh, 21px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 55%),
    linear-gradient(90deg, #4f7d2d 0%, #2c6e3c 45%, #145a35 100%);
  box-shadow: 0 8px 18px rgba(20, 80, 45, .28), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-check:hover:not(:disabled) {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 55%),
    linear-gradient(90deg, #578934 0%, #317a43 45%, #18663c 100%);
}
.btn-check .chev { width: 1.15em; height: 1.15em; margin-left: 2px; }
.entry-note { margin: 6px 0 0; text-align: center; font-size: 11.5px; color: var(--ink-2); }

/* มือถือ (จอแคบ) */
@media (max-width: 600px) {
  .keypad { flex-basis: 224px; }
  .btn-check { min-height: clamp(48px, 6dvh, 54px); }
  .keypad .key-fn svg { width: clamp(22px, 3dvh, 28px); }
}
/* แท็บเล็ต/เดสก์ท็อป: ภาพอาคารไม่ขยายเกินจริง — สูงเท่าส่วนหัว กว้างตามสัดส่วนภาพ กึ่งกลางจอ ขอบซ้าย/ขวาจางเข้ากับท้องฟ้า */
@media (min-width: 601px) {
  .entry-hero {
    width: auto; aspect-ratio: 1086 / 528; background-size: 100% 100%;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent), linear-gradient(to bottom, #000 84%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent), linear-gradient(to bottom, #000 84%, transparent);
    mask-composite: intersect;
  }
  /* เนินเขาด้านล่าง: เต็มความกว้างตามสัดส่วนภาพ (ไม่ตัดยอดเนินโค้งทิ้ง) */
  .entry-footer { height: min(14.56vw, 220px); background-size: 100% auto; background-position: 50% 0; }
  /* ดอกขิง/เส้นโค้งอยู่ชิดการ์ด (สัดส่วนเดียวกับ design) แทนที่จะไปอยู่ขอบจอ — ขอบที่เคยเป็นขอบภาพจางหาย */
  .entry-deco-ginger {
    left: max(0px, calc(50% - 240px - 13vh));
    -webkit-mask-image: linear-gradient(to right, transparent, #000 32%), linear-gradient(to bottom, transparent, #000 14%, #000 86%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to right, transparent, #000 32%), linear-gradient(to bottom, transparent, #000 14%, #000 86%, transparent);
    mask-composite: intersect;
  }
  .entry-deco-swoosh {
    right: max(0px, calc(50% - 240px - 12vh));
    -webkit-mask-image: linear-gradient(to left, transparent, #000 40%), linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to left, transparent, #000 40%), linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
    mask-composite: intersect;
  }
}

/* จอเตี้ย (เช่น iPhone ใน Safari ที่มีแถบเครื่องมือ): ย่อหัวหน้าเพื่อให้ปุ่มตัวเลขสูงพอกดสบาย */
@media (max-height: 720px) {
  .entry-emblem { width: clamp(36px, 6.4dvh, 48px); }
  .entry-system { margin-top: clamp(36px, 7.5dvh, 60px); padding-block: clamp(4px, .8dvh, 7px); }
}
/* จอสูงไม่เกิน 800px: ชื่องานไหลต่อกันตามความกว้าง (ปกติ 2 บรรทัด) แทนการขึ้นบรรทัดทุกจุดที่กำหนด — ประหยัดความสูงให้ปุ่มตัวเลข */
@media (max-height: 800px) {
  .screen-entry .entry-event-name .ph { display: inline; }
}
/* จอเตี้ยมาก (เช่น iPhone SE ใน Safari): วางตราไว้ข้างชื่อหน่วยงาน เพื่อเพิ่มพื้นที่ให้ปุ่มตัวเลข */
@media (max-height: 620px) {
  .entry-head { display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center; column-gap: 10px; }
  .entry-emblem { grid-row: 1; width: 40px; }
  .entry-host { grid-row: 1; grid-column: 2; margin: 0; }
  .entry-system { grid-column: 1 / -1; justify-self: center; margin-top: 14px; }
  .entry-host-sub, .screen-entry .entry-host-sub { display: none; }
  /* จอเตี้ยมาก: เห็นท้องฟ้ากับยอดอาคาร (ไม่ให้ตัวอาคารอยู่หลังตัวหนังสือ) */
  .entry-hero { background-position: 50% 0; }
  .entry-event-name { font-size: min(17px, 5vw); }
  .keypad .key-fn { flex-direction: row; gap: 6px; }
}

/* ---------- หน้า 2 (ตาม design) ----------
   หัวหน้าใช้ชุดเดียวกับหน้า 1 (ตรา ชื่อหน่วยงาน ป้ายงานพิธีเปิด ชื่องาน) + เส้นโค้งทอง/พื้นเขียว + การ์ดยืนยันตัวตน
   ต้องอยู่ในหน้าจอเดียว: ความสูงคงที่เท่าจอ แล้วให้รูปบุคคลย่อลงเมื่อพื้นที่ไม่พอ ปุ่ม YES / NO จึงอยู่ในจอเสมอ */

.screen-confirm {
  position: relative; isolation: isolate;
  height: 100vh; height: 100dvh; min-height: 540px;
  padding: clamp(6px, 1.4dvh, 14px) 12px clamp(8px, 2.2dvh, 40px);
}
.confirm-bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(50% 16% at 50% 16%, rgba(255, 255, 255, .8), rgba(255, 255, 255, 0) 72%),
    linear-gradient(180deg, #c6dff5 0%, #d9e8f4 11%, #e9f0f1 22%, #f3f6f4 32%, #eef4ef 60%, #e8f0e9 100%);
}
.cf-deco { position: absolute; background-repeat: no-repeat; background-size: cover; }
.cf-deco-sun {
  left: 0; top: min(10vw, 64px); width: min(34vw, 320px); aspect-ratio: 300 / 234;
  background-image: url(../img/p2-sun.webp);
  -webkit-mask-image: linear-gradient(to right, #000 55%, transparent), linear-gradient(to bottom, transparent, #000 18%, #000 55%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, #000 55%, transparent), linear-gradient(to bottom, transparent, #000 18%, #000 55%, transparent);
  mask-composite: intersect;
}
.cf-deco-flowers {
  left: 0; top: min(19vw, 170px); width: min(12.5vw, 120px); aspect-ratio: 130 / 204;
  background-image: url(../img/p2-flowers.webp);
  -webkit-mask-image: radial-gradient(100% 50% at 0 50%, #000 45%, transparent 100%);
  mask-image: radial-gradient(100% 50% at 0 50%, #000 45%, transparent 100%);
}
.cf-deco-right {
  right: 0; top: 0; width: min(33vw, 320px); aspect-ratio: 301 / 345;
  background-image: url(../img/p2-right.webp); background-position: right top;
  -webkit-mask-image: linear-gradient(to left, #000 60%, transparent), linear-gradient(to bottom, #000 60%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to left, #000 60%, transparent), linear-gradient(to bottom, #000 60%, transparent);
  mask-composite: intersect;
}
.cf-footer {
  position: absolute; left: 0; right: 0; bottom: 0; height: clamp(46px, 12vw, 120px);
  background: url(../img/p2-footer.webp) 70% 100% / cover no-repeat;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 18%);
  mask-image: linear-gradient(to bottom, transparent, #000 18%);
}

/* หัวหน้า: ปุ่มย้อนกลับมุมซ้าย + ตรา ชื่อหน่วยงาน ชื่องาน (คลาส entry-* ใช้ร่วมกับหน้า 1) */
.confirm-head { position: relative; flex: none; display: flex; flex-direction: column; align-items: center; text-align: center; }
.confirm-head .entry-emblem { width: clamp(36px, 6.6dvh, 60px); }
.confirm-nav { position: absolute; left: -2px; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; }
.confirm-nav-title {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(15px, 2.2dvh, 18px); color: #1b2a20;
  text-shadow: 0 0 10px rgba(255, 255, 255, .95);
}
.icon-btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  border: 0; border-radius: 50%; background: #fff; color: #1b3a28;
  box-shadow: 0 4px 12px rgba(30, 60, 45, .16); cursor: pointer;
}

/* พื้นเขียว + เส้นโค้งทองด้านหลังการ์ด (เต็มความกว้างจอ) */
.confirm-ground { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin-top: clamp(20px, 3.2dvh, 30px); }
.confirm-ground::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: -37px; width: 100vw; height: 100px; translate: -50% 0;
  background: url(../img/p2-curve.svg) center top / 100% 100% no-repeat;
}

/* การ์ดยืนยันตัวตน */
.sheet-confirm {
  flex: 0 1 auto; min-height: 0; margin: 0; align-items: center; text-align: center;
  padding: clamp(8px, 1.4dvh, 16px) clamp(14px, 4.4vw, 22px) clamp(12px, 2dvh, 18px);
  border-radius: 28px; background: rgba(255, 255, 255, .97);
  box-shadow: 0 14px 36px rgba(32, 66, 48, .14), 0 2px 6px rgba(32, 66, 48, .05);
}
.found { flex: none; display: inline-flex; align-items: center; gap: 10px; padding: 3px 3px 3px 5px; border-radius: 999px; background: #e3eee5; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7); }
.found-ok { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: clamp(14px, 2.1dvh, 16px); color: #1b4a2e; }
.found-ok svg { width: 1.4em; height: 1.4em; padding: .3em; border-radius: 50%; background: #2a7347; color: #fff; }
.found-no { padding: 1px 12px; border-radius: 999px; background: #fff; font-family: var(--font-display); font-weight: 700; font-size: clamp(14px, 2.1dvh, 16px); color: #1b2a20; box-shadow: 0 1px 2px rgba(28, 64, 42, .08); }

/* รูปบุคคล: ขนาดตามความสูงจอ และย่อลงได้เมื่อพื้นที่ไม่พอ (เช่นตอนมีข้อความ "ลงทะเบียนแล้ว") */
.id-photo-wrap {
  flex: 0 1 auto; min-height: clamp(56px, 9vh, 88px); min-height: clamp(56px, 9dvh, 88px); height: clamp(110px, 29vh, 270px); height: clamp(110px, 29dvh, 270px);
  display: flex; justify-content: center; margin: clamp(6px, 1.1dvh, 14px) 0 clamp(4px, .8dvh, 10px);
}
.id-photo {
  height: 100%; width: auto; aspect-ratio: 15 / 16; margin: 0;
  border: 4px solid #fff; border-radius: 20px; overflow: hidden; background: var(--g-50);
  box-shadow: 0 0 0 1px #e3ebe5, 0 12px 26px rgba(19, 56, 33, .16);
}
.id-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.id-name { flex: none; margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(20px, 3.3dvh, 27px); line-height: 1.3; color: #1b3a28; text-wrap: balance; }
.id-position {
  flex: none; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; margin: clamp(5px, 1dvh, 10px) 0 0;
  padding: .3em 1.3em; border-radius: 999px; background: linear-gradient(180deg, #f8eed6, #f2e3c0);
  font-weight: 600; font-size: clamp(14px, 2.1dvh, 16px); line-height: 1.45; color: #5c4512; text-align: left;
}
.id-position svg { flex: none; width: 1.3em; height: 1.3em; color: #c39a45; }
.note {
  flex: none; display: flex; align-items: center; gap: 10px; width: 100%; margin: clamp(8px, 1.4dvh, 12px) 0 0;
  padding: 5px 12px; border-radius: 18px; background: #edf4ee; color: #24432f; text-align: left;
}
.note svg { flex: none; width: 26px; height: 26px; color: #2a7347; }
.note p { margin: 0; font-size: 12px; line-height: 1.5; }
.confirm-bottom { flex: none; width: 100%; margin-top: clamp(8px, 1.6dvh, 14px); }
.orn-divider { display: flex; align-items: center; gap: 6px; width: min(88%, 330px); margin: 0 auto clamp(6px, 1.2dvh, 12px); }
.orn-divider i { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(169, 196, 177, 0), #a9c4b1); }
.orn-divider i:last-child { background: linear-gradient(90deg, #a9c4b1, rgba(169, 196, 177, 0)); }
.orn-divider em { width: 5px; height: 5px; rotate: 45deg; background: #a9c4b1; }
.orn-divider b { width: 10px; height: 10px; rotate: 45deg; border: 1.5px solid #9dbca7; background: #f4f8f5; }
.question { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(15px, 2.4dvh, 20px); line-height: 1.4; color: #1d2b22; }
/* ข้อความแจ้งเตือนหลังกด YES แสดงแทนคำถาม (ไม่ดันปุ่มลง) */
.question.is-error { color: var(--danger); font-family: var(--font); font-weight: 600; font-size: clamp(14px, 2.2dvh, 17px); }

/* ปุ่มตอบ NO / YES วางคู่กัน (YES อยู่ขวา ใกล้นิ้วโป้ง) */
.answer { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-answer {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: clamp(46px, 7.1dvh, 62px); padding: 4px 10px;
  border: 1.5px solid transparent; border-radius: 18px;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform .06s, background-color .15s, box-shadow .15s, opacity .15s;
}
.btn-answer:active:not(:disabled) { transform: translateY(1px); }
.btn-answer:disabled { opacity: .5; cursor: not-allowed; }
.btn-answer.is-loading { opacity: 1; }
.btn-answer b { display: inline-flex; align-items: center; gap: .35em; font-family: var(--font-display); font-size: clamp(16px, 2.5dvh, 21px); font-weight: 700; line-height: 1.2; letter-spacing: .04em; }
.btn-answer b svg { width: .95em; height: .95em; }
.btn-answer small { font-size: clamp(12px, 1.8dvh, 14px); font-weight: 500; line-height: 1.4; }
.btn-answer.is-loading b { display: none; }
.btn-answer .spinner { width: 22px; height: 22px; margin: 2px 0 3px; }
.btn-yes { color: #fff; background: linear-gradient(180deg, #24804a, #0e4f29); box-shadow: 0 8px 18px rgba(14, 79, 41, .3), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn-yes small { color: rgba(255, 255, 255, .9); }
.btn-yes:hover:not(:disabled) { background: linear-gradient(180deg, #2a8c51, #11592f); }
.btn-no { color: #fff; background: linear-gradient(180deg, #d93a2b, #a31b10); box-shadow: 0 8px 18px rgba(163, 27, 16, .28), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn-no small { color: rgba(255, 255, 255, .9); }
.btn-no:hover:not(:disabled) { background: linear-gradient(180deg, #e04434, #b01f13); }

/* จอแคบ: ซ่อนคำว่า "ยืนยันตัวตน" ข้างปุ่มย้อนกลับ ไม่ให้ชนตรา */
@media (max-width: 380px) {
  .confirm-nav-title { display: none; }
  .note { gap: 8px; padding-inline: 10px; }
  .note svg { width: 22px; height: 22px; }
  .note p { font-size: 12px; }
}
@media (max-height: 680px) and (max-width: 379px) {
  .sheet-confirm:has(#cf-already:not([hidden])) .orn-divider { display: none; }
}
@media (max-height: 620px) and (max-width: 340px) {
  .confirm-head .entry-emblem { margin-left: 28px; }
}
/* มือถือ: เว้นที่ให้ภาพภูเขา/วัดด้านล่างโผล่พ้นการ์ด (การ์ดทับขอบบนเล็กน้อยเหมือน design) */
@media (max-width: 600px) and (min-height: 621px) {
  .screen-confirm { padding-bottom: calc(clamp(46px, 12vw, 120px) - 8px); }
}
/* แท็บเล็ต: ภาพอาคาร/พระอาทิตย์ไม่ล้ำเข้ามาทับชื่องาน */
@media (min-width: 601px) {
  .cf-deco-right, .cf-deco-sun { max-width: calc((100vw - 480px) / 2 + 30px); }
}
/* จอเตี้ยมาก (เช่น iPhone SE ใน Safari): ตราอยู่ข้างชื่อหน่วยงาน ซ่อนเส้นคั่น */
@media (max-height: 620px) {
  .confirm-head { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 10px; }
  .confirm-head .entry-emblem { width: 38px; }
  .confirm-head .entry-host { margin: 0; }
  .confirm-head .entry-event { flex-basis: 100%; }
  .confirm-nav-title, .orn-divider { display: none; }
  .note p { font-size: 12.5px; }
}

/* ---------- หน้า 3 ---------- */

.screen-done { height: 100vh; height: 100dvh; background: #1a6b3a; }
.stage-mobile { flex: 1 1 auto; min-height: 0; }
.done-bar {
  display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: #1a6b3a; color: #fff;
}
.done-status { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; margin: 0; font-weight: 600; }
.done-status svg { color: #86dca2; }
.done-meta { font-weight: 400; color: rgba(255, 255, 255, .75); }
.link-btn { padding: 6px 10px; border: 0; background: none; color: rgba(255, 255, 255, .7); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* =====================================================================
   VIP PRESENTATION — หน้า 3 บนมือถือ และจอ LED / Backoffice ใช้ layout เดียวกัน
   โทนเดียวกับหน้า 1–2 (ท้องฟ้า ดอกไม้ อาคารเทศบาล การ์ดสีขาว ทอง/เขียว)
   ปรับสัดส่วนด้วย container query units (cqh / cqw) ตามขนาดเวที
   ===================================================================== */

.stage { position: relative; overflow: hidden; background: #e9f1ea; isolation: isolate; }
.stage-layer { position: absolute; inset: 0; }

.vip {
  position: absolute; inset: 0; overflow: hidden;
  container-type: size;
  color: var(--ink);
  background:
    radial-gradient(45% 14% at 50% 14%, rgba(255, 255, 255, .85), rgba(255, 255, 255, 0) 72%),
    linear-gradient(180deg, #c6dff5 0%, #d9e8f4 10%, #e9f0f1 20%, #f3f6f4 30%, #eef4ef 58%, #e8f0e9 100%);
}

/* ฉากหลัง: พระอาทิตย์ขึ้น (ซ้าย) ดอกเฟื่องฟ้า อาคารเทศบาล (ขวา) ภูเขา/วัด (ล่าง) — ภาพชุดเดียวกับหน้า 2 */
.vip-bg { position: absolute; inset: 0; pointer-events: none; }
.vip-bg i { position: absolute; display: block; background-repeat: no-repeat; background-size: cover; }
.vip-sun {
  left: 0; top: min(6cqh, 10cqw); width: min(34cqw, 50cqh); aspect-ratio: 300 / 234;
  background-image: url(../img/p2-sun.webp);
  -webkit-mask-image: linear-gradient(to right, #000 55%, transparent), linear-gradient(to bottom, transparent, #000 18%, #000 55%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, #000 55%, transparent), linear-gradient(to bottom, transparent, #000 18%, #000 55%, transparent);
  mask-composite: intersect;
}
.vip-flowers {
  left: 0; top: min(12cqh, 19cqw); width: min(10cqw, 18cqh); aspect-ratio: 130 / 204;
  background-image: url(../img/p2-flowers.webp);
  -webkit-mask-image: radial-gradient(100% 50% at 0 50%, #000 45%, transparent 100%);
  mask-image: radial-gradient(100% 50% at 0 50%, #000 45%, transparent 100%);
}
.vip-right {
  right: 0; top: 0; width: min(33cqw, 46cqh); aspect-ratio: 301 / 345;
  background-image: url(../img/p2-right.webp); background-position: right top;
  -webkit-mask-image: linear-gradient(to left, #000 60%, transparent), linear-gradient(to bottom, #000 60%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to left, #000 60%, transparent), linear-gradient(to bottom, #000 60%, transparent);
  mask-composite: intersect;
}
.vip-footer {
  left: 0; right: 0; bottom: 0; height: min(13cqh, 30cqw);
  background: url(../img/p2-footer.webp) 70% 100% / cover no-repeat;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 18%);
  mask-image: linear-gradient(to bottom, transparent, #000 18%);
}

.vip-inner {
  position: relative; z-index: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 2cqh 4cqw min(6cqh, 10cqw);
}

/* หัวหน้า: ตรา → ชื่อหน่วยงาน → ชื่องาน + ช่อชัยพฤกษ์ (หน้า 3 / จอ LED ไม่มีป้ายทอง) */
.vip-head { position: relative; flex: none; display: flex; flex-direction: column; align-items: center; max-width: 100%; }
/* เส้นโค้งทอง + พื้นเขียวจาง ๆ ใต้หัวหน้า (จุดต่ำสุดของเส้นโค้งชนขอบบนการ์ดพอดี) */
.vip-head::after {
  content: ""; position: absolute; z-index: -1; left: 50%; top: calc(100% - 1.3cqh); width: 100cqw; height: 9cqh; translate: -50% 0;
  background: url(../img/p2-curve.svg) center top / 100% 100% no-repeat;
}
.vip-emblem { width: min(7.5cqh, 13cqw); height: auto; aspect-ratio: 1; filter: drop-shadow(0 .3cqh .6cqh rgba(70, 55, 20, .28)); }
.vip-host { margin: .4cqh 0 0; line-height: 1.25; }
.vip-host b {
  display: block; font-family: var(--font-display); font-weight: 700; font-size: min(3.2cqh, 5.4cqw); color: #1f4d33;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .85), 0 0 1.4cqh rgba(255, 255, 255, .95);
}
.vip-host small { display: block; margin-top: .2cqh; font-size: min(1.9cqh, 3.3cqw); font-weight: 500; color: #24382c; text-shadow: 0 0 1cqh rgba(255, 255, 255, .95); }
.vip-label {
  margin-top: min(1.4cqh, 2.4cqw); padding: .2em 1.8em .26em; border-radius: 999px;
  font-weight: 600; font-size: min(2.2cqh, 3.8cqw); line-height: 1.5; color: #fff;
  background: linear-gradient(180deg, #a4782e 0%, #b18437 50%, #c79c4c 100%);
  box-shadow: 0 .3cqh .8cqh rgba(140, 100, 30, .28), inset 0 1px 0 rgba(255, 255, 255, .35);
  text-shadow: 0 1px 2px rgba(70, 45, 5, .45);
}
.vip-event {
  display: flex; align-items: center; justify-content: center; gap: min(1cqh, 1.6cqw);
  max-width: 100%; margin: min(.8cqh, 1.4cqw) 0 0;
  font-family: var(--font-display); font-weight: 700; font-size: min(3.4cqh, 5cqw); line-height: 1.25; color: #1b4a2e;
  text-shadow: 0 0 1.4cqh rgba(255, 255, 255, .9);
}
/* ไม่มีป้ายทองคั่น: เว้นระยะจากชื่อหน่วยงานเท่าที่ป้ายเคยเว้นไว้ */
.vip-host + .vip-event { margin-top: min(1.4cqh, 2.4cqw); }
.vip-event > span { min-width: 0; }
.vip-laurel { flex: none; width: min(4.2cqh, 7cqw); height: auto; }
.vip-laurel-r { scale: -1 1; }

/* การ์ดต้อนรับ */
.vip-card {
  position: relative; isolation: isolate; overflow: hidden;
  flex: 0 1 auto; min-height: 0; width: min(92cqw, 100cqh); margin-top: 2cqh;
  display: flex; flex-direction: column; align-items: center; gap: min(1.1cqh, 1.8cqw);
  padding: min(2.4cqh, 4cqw) min(3cqh, 4.5cqw) min(2.6cqh, 4.4cqw);
  border-radius: min(3cqh, 5.5cqw); background: rgba(255, 255, 255, .97);
  box-shadow: 0 1.6cqh 4cqh rgba(32, 66, 48, .16), 0 .3cqh .8cqh rgba(32, 66, 48, .06);
}
.vip-kicker { flex: none; margin: 0; display: flex; align-items: center; gap: min(1.6cqh, 2.6cqw); }
.vip-kicker span {
  padding: .1em 0;
  font-family: var(--font-display); font-weight: 700; font-size: min(4.2cqh, 7cqw); line-height: 1.3;
  background: linear-gradient(180deg, #e6c06a, #a97a22);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.vip-kicker::before,
.vip-kicker::after { content: ""; width: min(8cqh, 11cqw); height: 2px; background: linear-gradient(90deg, transparent, #d0a94f); }
.vip-kicker::after { transform: scaleX(-1); }

/* รูปบุคคล: กรอบทอง + แสงทองหมุนช้า ๆ ด้านหลัง ย่อได้เมื่อพื้นที่ไม่พอ (เช่นชื่อยาว 2 บรรทัด) */
.vip-photo-wrap { position: relative; flex: 0 1 auto; min-height: 15cqh; height: min(32cqh, 60cqw); display: flex; justify-content: center; margin: .3cqh 0; }
.vip-photo-wrap::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 50%; height: 175%; aspect-ratio: 1; translate: -50% -50%;
  background: repeating-conic-gradient(from 0deg, rgba(212, 170, 80, .16) 0deg 5deg, transparent 5deg 15deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 72%);
  mask-image: radial-gradient(closest-side, #000 30%, transparent 72%);
}
.vip-photo {
  height: 100%; width: auto; aspect-ratio: 3 / 4; margin: 0;
  padding: min(.6cqh, 1cqw); border-radius: min(2.4cqh, 4cqw);
  background: linear-gradient(160deg, #f8e7b0, #b98a2e 45%, #f2d68a 70%, #a77a22);
  box-shadow: 0 0 0 min(.7cqh, 1.1cqw) rgba(227, 197, 120, .22), 0 2cqh 4cqh rgba(60, 50, 20, .25);
}
.vip-photo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: min(1.9cqh, 3.2cqw); background: #dfe9f3; }

.vip-name {
  flex: none; margin: .4cqh 0 0; max-width: 100%;
  font-family: var(--font-display); font-weight: 700; font-size: min(6cqh, 8.4cqw); line-height: 1.25; color: #1b3a28;
  text-wrap: balance;
}
.vip-name.is-long { font-size: min(5.2cqh, 7cqw); }
.vip-position {
  flex: none; display: inline-flex; align-items: center; gap: .5em; max-width: 100%; margin: 0;
  padding: .4em 1.3em; border-radius: 999px; background: linear-gradient(180deg, #f8eed6, #f2e3c0);
  font-weight: 600; font-size: min(2.6cqh, 4.2cqw); line-height: 1.4; color: #5c4512; text-align: left;
}
.vip-position svg { flex: none; width: 1.3em; height: 1.3em; color: #c39a45; }
.vip-welcome { flex: none; margin: .2cqh 0 0; max-width: 60ch; font-size: min(2.2cqh, 3.7cqw); line-height: 1.5; color: #3b5245; text-wrap: balance; }

/* จอว่าง: QR Code แทนรูป */
.vip-qr {
  height: 100%; width: auto; aspect-ratio: 1; margin: 0;
  display: grid; place-items: center; padding: min(1.6cqh, 2.6cqw);
  border-radius: min(2.4cqh, 4cqw); background: #fff;
  box-shadow: 0 0 0 min(.6cqh, 1cqw) rgba(212, 170, 80, .55), 0 2cqh 4cqh rgba(32, 66, 48, .18);
}
.vip-qr img, .vip-qr canvas { width: 100% !important; height: 100% !important; image-rendering: pixelated; }
.vip-qr.no-qr { padding: 0; background: none; box-shadow: none; }
.vip-qr.no-qr img { image-rendering: auto; filter: drop-shadow(0 1.4cqh 3cqh rgba(60, 50, 20, .3)); }
.vip.is-idle .vip-name { font-size: min(4.4cqh, 6.4cqw); }

@container (orientation: portrait) {
  .vip-photo-wrap { height: min(30cqh, 58cqw); }
}


/* =====================================================================
   BACKOFFICE — คอนโซลเจ้าหน้าที่
   ===================================================================== */

body.bo { min-height: 100vh; background: #edf3ee; }
.view-console .display-root,
.view-display .bo-app,
.view-display .toasts { display: none; }

.bo-top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 24px;
  background: rgba(255, 255, 255, .9); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.bo-brand { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; }
.bo-brand img { width: 42px; height: 42px; flex: none; }
.bo-brand b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 17px; color: var(--g-900); }
.bo-brand small { display: block; overflow: hidden; font-size: 13px; color: var(--ink-2); white-space: nowrap; text-overflow: ellipsis; }
.bo-stats { display: flex; gap: 22px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.stat-num { font-family: var(--font-display); font-weight: 600; font-size: 24px; color: var(--g-800); font-variant-numeric: tabular-nums; }
.stat-of { font-size: 15px; color: var(--ink-3); font-weight: 500; }
.stat-label { font-size: 12px; color: var(--ink-3); }

.conn {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--warn-soft); color: var(--warn);
}
.conn i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn[data-state="online"] { background: var(--g-100); color: var(--g-700); }
.conn[data-state="online"] i { animation: pulse 2s infinite; }
.conn[data-state="reconnecting"] i, .conn[data-state="connecting"] i { animation: blink 1s infinite; }
.conn[data-state="local"] { background: var(--info-soft); color: var(--info); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(45, 122, 76, .5); } 70% { box-shadow: 0 0 0 7px rgba(45, 122, 76, 0); } 100% { box-shadow: 0 0 0 0 rgba(45, 122, 76, 0); } }
@keyframes blink { 50% { opacity: .25; } }

.bo-grid {
  display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(340px, 1fr);
  gap: 20px; align-items: start;
  max-width: 1600px; margin: 0 auto; padding: 20px 24px 40px;
}
.bo-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card { padding: 18px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 16.5px; color: var(--g-900); }
.badge { min-width: 28px; padding: 1px 9px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-ink); font-weight: 600; font-size: 13px; text-align: center; }

.stage-preview { aspect-ratio: 16 / 9; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05); }
.stage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; }
.kbd-hint { margin-left: auto; font-size: 13px; color: var(--ink-3); }
kbd { padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: #fff; font-family: inherit; font-size: 12px; color: var(--ink-2); }

.auto-status { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.auto-track { flex: 1; height: 6px; overflow: hidden; border-radius: 99px; background: var(--g-100); }
.auto-track i { display: block; height: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--g-500), var(--gold)); }

/* modes */
.modes { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; min-width: 0; }
.mode {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.mode:hover { border-color: var(--g-200); }
.mode:has(input[type="radio"]:checked) { border-color: var(--g-600); background: var(--g-50); box-shadow: 0 0 0 3px rgba(45, 122, 76, .1); }
.mode input[type="radio"] { flex: none; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--g-600); }
.mode b { font-weight: 600; }
.mode small { display: block; margin-top: 2px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.tag { margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-ink); font-style: normal; font-size: 11.5px; font-weight: 600; vertical-align: 1px; }
.secs { width: 62px; padding: 2px 6px; border: 1px solid var(--g-200); border-radius: 8px; background: #fff; text-align: center; }

/* lists */
.list { max-height: 380px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-pos { flex: none; min-width: 26px; height: 26px; padding: 0 6px; display: grid; place-items: center; border-radius: 13px; background: var(--g-100); color: var(--g-800); font-weight: 600; font-size: 13px; }
.row-ava { flex: none; width: 40px; height: 52px; border-radius: 8px; object-fit: cover; }
.row-text { flex: 1; min-width: 0; }
.row-text b, .row-text small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-text b { font-weight: 600; font-size: 14.5px; }
.row-text small { font-size: 12.5px; color: var(--ink-3); }
.row-meta { margin-top: 2px; }
.row-actions { display: flex; flex: none; gap: 6px; }
.chip { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.7; }
.chip-showing { background: var(--g-600); color: #fff; }
.chip-queued { background: var(--gold-soft); color: var(--gold-ink); }
.chip-presented { background: var(--g-100); color: var(--g-800); }
.chip-skipped { background: #eef0ee; color: var(--ink-3); }
.empty { padding: 18px 8px; text-align: center; font-size: 14px; color: var(--ink-3); }

/* log */
.log { max-height: 320px; margin: 0; padding: 0; overflow: auto; list-style: none; font-size: 13.5px; }
.log li:not(.empty) { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 8px 4px; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }
.log time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.log code { margin-right: 8px; padding: 1px 6px; border-radius: 6px; background: var(--g-50); color: var(--g-800); font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.lat { font-size: 12px; font-weight: 600; color: var(--g-700); font-variant-numeric: tabular-nums; }
.lat.slow { color: var(--danger); }
.log li.flash { animation: flash 1.4s ease; }
@keyframes flash { from { background: var(--gold-soft); } to { background: transparent; } }

/* test card */
.qr-test { display: flex; align-items: center; gap: 16px; }
.qr-box { flex: none; width: 120px; height: 120px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.qr-box img, .qr-box canvas { width: 100% !important; height: 100% !important; image-rendering: pixelated; }
.qr-text { min-width: 0; }
.qr-text p { margin: 0 0 6px; }
.mobile-link { font-weight: 600; color: var(--g-700); word-break: break-all; }
.test-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 50; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  min-width: 260px; max-width: 360px; padding: 12px 16px;
  border-left: 4px solid var(--g-600); border-radius: 12px; background: #fff;
  box-shadow: 0 12px 32px rgba(19, 56, 33, .18);
  animation: toastIn .3s ease both; transition: opacity .4s, transform .4s;
}
.toast b { display: block; font-size: 14px; color: var(--g-800); }
.toast span { display: block; font-size: 14px; color: var(--ink); }
.toast.error { border-left-color: var(--danger); }
.toast.error b { color: var(--danger); }
.toast.out { opacity: 0; transform: translateX(16px); }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

@media (max-width: 1040px) {
  .bo-grid { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .bo-top { padding: 12px 16px; }
  .kbd-hint { display: none; }
}
@media (max-width: 560px) {
  .bo-stats { order: 3; }
  .bo-top .btn { order: 4; }
  .row { flex-wrap: wrap; }
  .row-actions { width: 100%; padding-left: 52px; }
}

/* =====================================================================
   DISPLAY — จอนำเสนอ LED (เต็มหน้าจอ)
   ===================================================================== */

body.view-display { overflow: hidden; background: #e9f1ea; }
.display-root { position: fixed; inset: 0; }
.display-root .stage { position: absolute; inset: 0; }
.display-conn {
  position: fixed; right: 16px; bottom: 16px; z-index: 5;
  padding: 8px 14px; border-radius: 999px; background: rgba(138, 90, 0, .9); color: #fff; font-size: 14px; font-weight: 600;
}
.display-hint {
  position: fixed; left: 50%; bottom: 22px; z-index: 5; translate: -50% 0;
  padding: 8px 18px; border-radius: 999px; background: rgba(0, 0, 0, .45); color: #fff; font-size: 14px;
  white-space: nowrap; transition: opacity .8s;
}
.display-hint.out { opacity: 0; pointer-events: none; }
.hide-cursor, .hide-cursor * { cursor: none !important; }

/* =====================================================================
   MOTION — การเคลื่อนไหว
   หน้า 1–2: เข้าฉากนุ่มนวลทีละชิ้น + ตอบสนองการกด (คลื่นที่ปุ่ม เลขเด้ง ปุ่มเรืองเมื่อพร้อม)
   หน้า 3 / จอ LED: เน้นลูกเล่น — แสงวาบ วงแหวนทองกระจาย ประกายดาวระยิบ พลุกระดาษ แสงกวาดผ่าน
   แสงวาบเกิดครั้งเดียวต่อการขึ้นจอ (ต่ำกว่าเกณฑ์ 3 ครั้ง/วินาทีของ WCAG)
   ผู้ใช้ที่ตั้งค่าอุปกรณ์ "ลดการเคลื่อนไหว" (prefers-reduced-motion) จะเห็นแบบนิ่ง
   ===================================================================== */

:root { --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-back: cubic-bezier(.34, 1.5, .64, 1); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.6); } 65% { opacity: 1; transform: scale(1.06); } 100% { opacity: 1; transform: none; } }
@keyframes dropIn { 0% { opacity: 0; transform: translateY(-26px) scale(.7) rotate(-14deg); } 65% { opacity: 1; transform: translateY(3px) scale(1.05) rotate(2deg); } 100% { opacity: 1; transform: none; } }
@keyframes cardRise { from { opacity: 0; transform: translateY(40px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes drawX { from { transform: scaleX(0); } to { transform: none; } }
@keyframes drawStroke { from { stroke-dashoffset: var(--len, 24); } to { stroke-dashoffset: 0; } }
@keyframes laurelIn { from { opacity: 0; transform: rotate(-30deg) scale(.5); } to { opacity: 1; transform: none; } }
@keyframes photoReveal { from { opacity: 0; transform: scale(.86); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes blurIn { from { opacity: 0; transform: translateY(14px) scale(.96); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes sheenSweep { 0% { transform: translateX(-160%) skewX(-20deg); } 50%, 100% { transform: translateX(360%) skewX(-20deg); } }
@keyframes kenBurns { from { transform: scale(1); } to { transform: scale(1.06); } }
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes mistDrift { from { transform: translateX(-4%); } to { transform: translateX(4%); } }
@keyframes sunGlow { 0%, 100% { opacity: .5; transform: scale(.92); } 50% { opacity: 1; transform: scale(1.12); } }
@keyframes slotPop { 0% { opacity: 0; transform: scale(.3); } 60% { opacity: 1; transform: scale(1.3); } 100% { transform: none; } }
@keyframes ripple { from { transform: translate(-50%, -50%) scale(0); opacity: .5; } to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }
@keyframes readyPulse {
  0%, 100% { box-shadow: 0 8px 18px rgba(20, 80, 45, .28), 0 0 0 0 rgba(63, 148, 99, .5); }
  60% { box-shadow: 0 8px 22px rgba(20, 80, 45, .32), 0 0 0 10px rgba(63, 148, 99, 0); }
}
/* หน้า 3 */
@keyframes stageIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes raysSpin { to { rotate: 360deg; } }
@keyframes vipFlash { 0% { opacity: 0; } 18% { opacity: .4; } 100% { opacity: 0; } }
@keyframes burst { 0% { opacity: 0; transform: scale(.3); } 22% { opacity: .95; } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes ringOut { 0% { opacity: .95; transform: scale(.55); } 100% { opacity: 0; transform: scale(1.9); } }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.2) rotate(0deg); } 45% { opacity: 1; transform: scale(1) rotate(45deg); } 60% { opacity: .85; transform: scale(.8) rotate(60deg); } }
@keyframes haloPulse { 0%, 100% { opacity: .45; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes textShimmer { 0% { background-position: 100% 50%, 0 0; } 55%, 100% { background-position: 0% 50%, 0 0; } }
@keyframes stageSweep { from { opacity: 1; transform: translateX(-60%); } to { opacity: 0; transform: translateX(60%); } }
@keyframes confettiFall {
  0% { opacity: 0; transform: translate3d(0, -6cqh, 0) rotate(0deg) rotateY(0deg); }
  8% { opacity: 1; }
  100% { opacity: .9; transform: translate3d(var(--dx, 0), 108cqh, 0) rotate(var(--r, 360deg)) rotateY(900deg); }
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(0, 0); }
  15%, 80% { opacity: var(--o, .6); }
  50% { transform: translate(var(--dx, 2cqw), -50cqh); }
  100% { opacity: 0; transform: translate(0, -100cqh); }
}

/* แสงกวาดผ่าน (ใช้ร่วม: ปุ่ม/ป้ายทอง) — ซ่อนไว้นอกกรอบจนกว่าจะมีแอนิเมชัน */
.btn-check, .btn-yes, .entry-event-label, .vip-label { position: relative; overflow: hidden; }
.btn-check::after, .btn-yes::after, .entry-event-label::after, .vip-label::after {
  content: ""; position: absolute; top: -20%; bottom: -20%; left: 0; width: 38%; pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
  transform: translateX(-160%) skewX(-20deg);
}

/* ---------- หน้า 1: เข้าฉาก ---------- */
.screen-entry.screen-enter .entry-emblem { animation: dropIn .9s var(--ease-out) backwards; }
.screen-entry.screen-enter .entry-host { animation: fadeUp .6s .12s var(--ease-out) backwards; }
.screen-entry.screen-enter .entry-host-sub { animation: fadeUp .6s .18s var(--ease-out) backwards; }
/* ภาพอาคารค่อย ๆ ปรากฏ แล้วขยายช้า ๆ ต่อเนื่อง */
.entry-hero { animation: kenBurns 22s ease-in-out infinite alternate; }
.screen-entry.screen-enter .entry-hero { animation: fadeIn 1s ease-out backwards, kenBurns 22s 1s ease-in-out infinite alternate; }
.screen-entry.screen-enter .entry-system { animation: fadeUp .6s .3s var(--ease-out) backwards; }
.screen-entry.screen-enter .entry-event-label { animation: popIn .6s .4s var(--ease-out) backwards; }
.screen-entry.screen-enter .entry-event-name > span { animation: fadeUp .7s .48s var(--ease-out) backwards; }
.laurel { transform-origin: 50% 100%; }
.screen-entry.screen-enter .laurel { animation: laurelIn .9s .62s var(--ease-back) backwards; }
.screen-entry.screen-enter .entry-card { animation: cardRise .75s .5s var(--ease-out) backwards; }
.screen-entry.screen-enter .keypad button { animation: popIn .45s var(--ease-out) backwards; animation-delay: calc(.7s + var(--i, 0) * 30ms); }
/* กลับมาจากหน้า 2 (กด NO): แค่การ์ดเลื่อนขึ้นเร็ว ๆ ไม่เล่นทั้งฉากซ้ำ */
.screen-entry.screen-return .entry-card { animation: fadeUp .35s var(--ease-out) backwards; }
.entry-event-label::after { animation: sheenSweep 5s 1.8s ease-in-out infinite; }

/* หน้า 1: ฉากหลังมีชีวิต — ดอกขิงไหวเบา ๆ เส้นโค้งด้านขวาขยายช้า ๆ หมอกลอยผ่าน */
.entry-deco-ginger { transform-origin: 30% 100%; animation: sway 7s ease-in-out infinite; }
.entry-deco-swoosh { transform-origin: 100% 50%; animation: kenBurns 18s ease-in-out infinite alternate; }
.cf-deco-sun::after {
  content: ""; position: absolute; width: 46%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 238, 180, .9), rgba(255, 220, 140, .35) 45%, rgba(255, 220, 140, 0) 72%);
  mix-blend-mode: screen; animation: sunGlow 5.5s ease-in-out infinite;
}
.entry-bg::after {
  content: ""; position: absolute; left: -10%; right: -10%; top: 28%; height: 34%; pointer-events: none;
  background:
    radial-gradient(38% 45% at 28% 50%, rgba(255, 255, 255, .6), rgba(255, 255, 255, 0) 70%),
    radial-gradient(32% 40% at 74% 42%, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 70%);
  animation: mistDrift 16s ease-in-out infinite alternate;
}

/* หน้า 1: ตอบสนองการกด */
.keypad button { position: relative; overflow: hidden; }
.keypad .ripple {
  position: absolute; width: 240%; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  background: radial-gradient(closest-side, rgba(45, 122, 76, .3), rgba(45, 122, 76, 0));
  animation: ripple .6s ease-out forwards;
}
.slot.pop { animation: slotPop .38s var(--ease-back); }
.btn-check.is-ready { animation: readyPulse 1.8s ease-in-out infinite; }
.btn-check.is-ready::after { animation: sheenSweep 2.6s .2s ease-in-out infinite; }

/* ---------- หน้า 2: เข้าฉาก ---------- */
.screen-confirm.screen-enter .confirm-head { animation: fadeIn .45s ease-out backwards; }
.screen-confirm.screen-enter .sheet-confirm { animation: cardRise .6s .05s var(--ease-out) backwards; }
.screen-confirm.screen-enter .found { animation: popIn .5s .15s var(--ease-out) backwards; }
.screen-confirm.screen-enter .found-ok svg path { stroke-dasharray: 22; --len: 22; animation: drawStroke .45s .45s ease-out backwards; }
.screen-confirm.screen-enter .id-photo { animation: photoReveal .7s .2s var(--ease-out) backwards; }
.screen-confirm.screen-enter .id-name { animation: fadeUp .5s .3s var(--ease-out) backwards; }
.screen-confirm.screen-enter .id-position { animation: popIn .5s .36s var(--ease-out) backwards; }
.screen-confirm.screen-enter .note { animation: fadeUp .5s .4s var(--ease-out) backwards; }
.orn-divider i:first-child { transform-origin: 100% 50%; }
.orn-divider i:last-child { transform-origin: 0 50%; }
.screen-confirm.screen-enter .orn-divider i { animation: drawX .7s .42s var(--ease-out) backwards; }
.screen-confirm.screen-enter .orn-divider b,
.screen-confirm.screen-enter .orn-divider em { animation: popIn .45s .6s var(--ease-out) backwards; }
.screen-confirm.screen-enter .question { animation: fadeUp .5s .44s var(--ease-out) backwards; }
.screen-confirm.screen-enter .btn-no { animation: fadeUp .45s .46s var(--ease-out) backwards; }
.screen-confirm.screen-enter .btn-yes { animation: fadeUp .45s .5s var(--ease-out) backwards; }
.btn-yes::after { animation: sheenSweep 3.4s 1.6s ease-in-out infinite; }
/* หน้า 2: ฉากหลัง */
.cf-deco-sun { transform-origin: 0 50%; animation: kenBurns 16s ease-in-out infinite alternate; }
.cf-deco-sun::after { left: 62%; top: 57%; }
.cf-deco-right { transform-origin: 100% 0; animation: kenBurns 19s ease-in-out infinite alternate; }
.cf-deco-flowers { transform-origin: 0 50%; animation: sway 6s ease-in-out infinite; }

/* ---------- หน้า 3 (มือถือ): แถบล่าง ---------- */
.screen-done.screen-enter .done-bar { animation: fadeUp .5s .45s var(--ease-out) backwards; }
.screen-done.screen-enter .done-status svg path { stroke-dasharray: 14; --len: 14; animation: drawStroke .6s .8s ease-out backwards; }
/* ระหว่างเข้าฉาก (mobile.js ใส่คลาสนี้ ~1.6 วินาที): ส่วนที่เลื่อนขึ้นจากล่างไม่ทำให้หน้าเลื่อนได้ชั่วคราว */
.screen.is-entering { overflow-y: clip; }

/* ---------- หน้า 3 / จอ LED: เข้าฉากแบบเต็มอลังการ ---------- */
.stage-layer.enter { animation: stageIn .7s ease-out both; }
.stage-layer.enter .vip-emblem { animation: dropIn .9s .1s var(--ease-out) backwards; }
.stage-layer.enter .vip-host { animation: fadeUp .6s .18s var(--ease-out) backwards; }
.stage-layer.enter .vip-label { animation: popIn .6s .26s var(--ease-out) backwards; }
.stage-layer.enter .vip-event { animation: fadeUp .7s .32s var(--ease-out) backwards; }
.vip-laurel { transform-origin: 50% 100%; }
.stage-layer.enter .vip-laurel { animation: laurelIn .9s .45s var(--ease-back) backwards; }
.stage-layer.enter .vip-card { animation: cardRise .8s .2s var(--ease-out) backwards; }
.stage-layer.enter .vip-kicker { animation: popIn .7s .45s var(--ease-out) backwards; }
.stage-layer.enter .vip-photo { animation: photoReveal 1s .5s var(--ease-out) backwards; }
.stage-layer.enter .vip-qr { animation: popIn .8s .5s var(--ease-out) backwards; }
.stage-layer.enter .vip-name { animation: blurIn .8s .85s var(--ease-out) backwards; }
.stage-layer.enter .vip-position { animation: popIn .6s 1.05s var(--ease-out) backwards; }
.stage-layer.enter .vip-welcome { animation: fadeUp .7s 1.2s var(--ease-out) backwards; }
.stage-layer.enter .vip-label::after { animation: sheenSweep 5s 2.2s ease-in-out infinite; }
.stage-layer.enter.swap .vip-head, .stage-layer.enter.swap .vip-head * { animation: none; }

/* "ยินดีต้อนรับ" ตัวทองมีแสงวิ่งผ่าน: แถบแสงโปร่งแสงวิ่งบนทองเดิม (ทั้งต้นและท้ายรอบแถบอยู่นอกตัวอักษร → วนต่อเนื่อง) */
.vip-kicker span {
  background:
    linear-gradient(100deg, rgba(255, 246, 210, 0) 42%, rgba(255, 246, 210, .55) 50%, rgba(255, 246, 210, 0) 58%) 100% 50% / 250% 100% no-repeat,
    linear-gradient(180deg, #e6c06a, #a97a22);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stage-layer.enter .vip-kicker span { animation: textShimmer 3.6s 1.3s ease-in-out infinite; }

/* รูป: แสงกวาดผ่านกรอบทอง + รัศมีเรือง + แสงทองหมุน */
.vip-photo { position: relative; overflow: hidden; }
.vip-photo::after {
  content: ""; position: absolute; top: -10%; bottom: -10%; left: 0; width: 45%; pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .6), rgba(255, 255, 255, 0));
  transform: translateX(-160%) skewX(-18deg);
}
.stage-layer.enter .vip-photo::after { animation: sheenSweep 4.4s 2s ease-in-out infinite; }
.vip-photo-wrap::after {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 50%; width: 125%; height: 118%; translate: -50% -50%;
  border-radius: 28%; opacity: 0; pointer-events: none;
  background: radial-gradient(closest-side, rgba(242, 204, 110, .5), rgba(242, 204, 110, 0));
}
.stage-layer.enter .vip-photo-wrap::after { animation: haloPulse 3.2s 1.3s ease-in-out infinite; }
.stage-layer.enter .vip-photo-wrap::before { animation: raysSpin 200s linear infinite, fadeIn 1.2s .6s backwards; }

/* แสงวาบ + วงแหวนทองกระจายออกจากรูป */
.vip-burst, .vip-ring, .vip-spark { position: absolute; pointer-events: none; }
.vip-burst {
  z-index: 2; left: 50%; top: 50%; width: 230%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; opacity: 0;
  background: radial-gradient(closest-side, #fff, rgba(255, 244, 205, .8) 32%, rgba(255, 222, 140, 0) 70%);
}
.stage-layer.enter .vip-burst { animation: burst 1.1s .55s ease-out forwards; }
.vip-ring {
  z-index: 2; left: 50%; top: 50%; width: 105%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; opacity: 0;
  border: max(2px, .45cqmin) solid rgba(231, 190, 92, .9);
}
.stage-layer.enter .vip-ring { animation: ringOut 1.3s .6s ease-out forwards; }
.stage-layer.enter .vip-ring.r2 { animation-delay: .9s; }

/* ประกายดาวระยิบรอบรูป */
.vip-spark {
  z-index: 3; left: var(--x); top: var(--y); width: calc(var(--s, 1) * min(3.4cqh, 5.6cqw)); aspect-ratio: 1; translate: -50% -50%; opacity: 0;
  background: radial-gradient(closest-side, #fff, #fff4c8 40%, #efc35a 78%);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
}
.stage-layer.enter .vip-spark { animation: twinkle 2.6s var(--d, 1.2s) ease-in-out infinite; }

/* แสงแฟลชทั้งเวที + แถบแสงกวาดผ่าน + พลุกระดาษ (เฉพาะตอนมีคนขึ้นจอ) */
.vip-flash {
  position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0;
  background: radial-gradient(70% 60% at 50% 55%, #fff, rgba(255, 248, 225, .6) 60%, rgba(255, 255, 255, 0));
}
.stage-layer.enter .vip-flash { animation: vipFlash .9s .5s ease-out forwards; }
.vip-sweep {
  position: absolute; top: -20%; bottom: -20%; left: -30%; right: -30%; z-index: 5; pointer-events: none; opacity: 0;
  background: linear-gradient(105deg, rgba(255, 252, 235, 0) 38%, rgba(255, 252, 235, .55) 50%, rgba(255, 252, 235, 0) 62%);
}
.stage-layer.enter .vip-sweep { animation: stageSweep 1.7s .3s ease-in-out forwards; }
.vip-confetti { position: absolute; inset: 0; z-index: 6; overflow: hidden; pointer-events: none; }
.vip-confetti i { position: absolute; top: 0; left: var(--x); width: var(--w); height: calc(var(--w) * 1.6); border-radius: 1px; background: var(--c); opacity: 0; }
.vip-confetti i:nth-child(4n) { height: var(--w); border-radius: 50%; }
.stage-layer.enter .vip-confetti i { animation: confettiFall var(--t) var(--d) cubic-bezier(.25, .6, .45, 1) forwards; }

/* ฟองแสงลอยขึ้นช้า ๆ ด้านหลัง (ทั้งตอนว่างและตอนมีคนขึ้นจอ) */
.vip-bokeh { position: absolute; inset: 0; }
.vip-bokeh i {
  position: absolute; bottom: -6cqh; left: var(--x); width: var(--w); aspect-ratio: 1; border-radius: 50%; opacity: 0;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .95), rgba(255, 238, 190, .45) 55%, rgba(255, 238, 190, 0));
}
.stage-layer.enter .vip-bokeh i { animation: floatUp var(--t) var(--d) linear infinite; }

/* ---------- ลดการเคลื่อนไหว ----------
   จอ LED ที่ต่อกับเครื่องซึ่งปิดแอนิเมชันของระบบ เปิดเอฟเฟกต์ได้ด้วย /display?motion=full (คลาส force-motion ที่ <html>) */
@media (prefers-reduced-motion: reduce) {
  :root:not(.force-motion) :is(.screen-enter, .screen-enter *, .screen-return *, .entry-bg, .entry-bg *, .confirm-bg *, .stage-layer *,
    .keypad button, .slot, .code, .btn-check, .btn-yes) { animation: none !important; }
  :root:not(.force-motion) :is(.entry-bg, .cf-deco-sun, .btn-check, .btn-yes, .entry-event-label, .vip-label, .vip-photo)::after,
  :root:not(.force-motion) .vip-photo-wrap::before, :root:not(.force-motion) .vip-photo-wrap::after,
  :root:not(.force-motion) .slot.caret:empty::before { animation: none !important; }
  :root:not(.force-motion) .stage-layer.enter { animation: stageIn .3s ease-out both !important; }
  :root:not(.force-motion) :is(.vip-confetti, .vip-flash, .vip-sweep, .vip-burst, .vip-ring, .vip-spark, .vip-bokeh, .keypad .ripple) { display: none !important; }
  /* วงหมุนระหว่างโหลดบอกว่าระบบกำลังทำงาน (ไม่ใช่การตกแต่ง) — ให้หมุนต่อ ไม่อย่างนั้นจะดูเหมือนค้าง */
  :root:not(.force-motion) .is-loading .spinner { animation: spin360 .8s linear infinite !important; }
}
