:root {
  --brand-orange: #F15A22;      /* สีแสด — สีประจำจังหวัดอุดรธานี */
  --brand-orange-dark: #C4460F;
  --brand-teal: #1D63C4;        /* สีน้ำเงิน — สีองค์กร */
  --brand-teal-dark: #164A94;
  --brand-duck: #FFC93C;        /* เหลืองเป็ด */
  --brand-duck-bill: #F15A22;
}

/* โฮสต์ฟอนต์ไอคอนเองแทนโหลดจาก fonts.googleapis.com — ไฟล์ตัวแปรเต็ม (ครอบคลุมทุก opsz/wght/FILL/GRAD)
   หนักหลาย MB บางทีโหลดไม่ทันหรือโดนบล็อกในบางเครือข่าย ทำให้ไอคอนกลายเป็นชื่อ text ธรรมดา (เช่น "task_alt")
   ใช้ตัวสถิตน้ำหนัก 400 ตัวเดียวแทน (~320KB) ครอบคลุมไอคอนทั้งหมดที่ใช้ในเว็บนี้ */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("../fonts/material-symbols-outlined.66cd90b70dae.woff2") format('woff2');
}
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

html, body { overflow-x: hidden; max-width: 100vw; }
body { font-family: 'Prompt', system-ui, sans-serif; }
.font-brand { font-family: 'Space Grotesk', 'Prompt', system-ui, sans-serif; }

h1 { line-height: 1.1; letter-spacing: -0.03em; }
p { line-height: 1.7; }

.text-brand-orange { color: var(--brand-orange); }
.text-brand-orange-dark { color: var(--brand-orange-dark); }
.text-brand-teal, .text-brand-blue { color: var(--brand-teal); }
.text-brand-teal-dark, .text-brand-blue-dark { color: var(--brand-teal-dark); }
.bg-brand-orange { background-color: var(--brand-orange); }
.bg-brand-orange-dark { background-color: var(--brand-orange-dark); }
.bg-brand-teal, .bg-brand-blue { background-color: var(--brand-teal); }
.bg-brand-blue-dark { background-color: var(--brand-teal-dark); }
.hover\:bg-brand-orange-dark:hover { background-color: var(--brand-orange-dark); }
.hover\:bg-brand-blue-dark:hover, .hover\:bg-brand-teal-dark:hover { background-color: var(--brand-teal-dark); }
.bg-brand-blue-tint { background-color: #e9f1fc; }
.bg-brand-orange-tint { background-color: #fdece3; }

.shadow-brand { box-shadow: 0 12px 30px -10px rgba(29, 99, 196, 0.22); }

/* ---------- hero ---------- */
.hero-gradient {
  background:
    radial-gradient(60% 50% at 85% 10%, rgba(29, 99, 196, 0.10), transparent 60%),
    radial-gradient(50% 40% at 10% 20%, rgba(241, 90, 34, 0.10), transparent 60%),
    #fbfbfd;
}
.route-svg path { fill: none; }
/* ซ่อนไว้รอ animation เฉพาะเมื่อ GSAP โหลดสำเร็จเท่านั้น */
.has-gsap .route-svg path {
  stroke-dasharray: 1600;
  stroke-dashoffset: 1600;
}

.countdown-box {
  background: #e9f1fc;
  border-radius: 0.9rem;
  padding: 0.6rem 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.countdown-box span {
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--brand-teal-dark);
}
.countdown-box small {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 0.1rem;
}
.countdown-box-sm {
  background: #fff;
  padding: 0.4rem 0.4rem;
}
.countdown-box-sm span {
  font-size: 1rem;
  color: var(--brand-orange);
}

/* ---------- stats ---------- */
.stat-card {
  --accent: #94a3b8;
  background: #fff;
  border: 1px solid #eef0ef;
  border-radius: 1.25rem;
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: 0 4px 16px -8px rgba(15, 23, 42, 0.08);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 10px 28px -10px rgba(15, 23, 42, 0.2);
}
.stat-num {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 2rem;
  color: #1e293b;
  margin: 0.25rem 0 0;
  transition: color 150ms ease;
}
.stat-card:hover .stat-num { color: var(--accent); }
.stat-label { font-size: 0.8rem; color: #94a3b8; }

/* ---------- reveal (ซ่อนรอ animation เฉพาะเมื่อ GSAP โหลดสำเร็จ) ---------- */
.has-gsap .reveal-up { opacity: 0; transform: translateY(24px); }

/* ---------- stat tiles (การ์ดยอดผู้สมัคร 3 แพ็กเกจ + สรุปรวม หน้าแรก) ---------- */
.stat-tile-dot { width: 0.5rem; height: 0.5rem; border-radius: 9999px; flex-shrink: 0; transition: transform 150ms ease; }
.stat-card:hover .stat-tile-dot { transform: scale(1.35); }

/* ---------- distance preview cards ---------- */
.distance-card {
  --accent: #1D63C4;
  background: #fff;
  border: 1px solid #eef0ef;
  border-radius: 1.25rem;
  padding: 1.5rem 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.distance-card:hover { transform: translateY(-4px); box-shadow: 0 16px 28px -14px rgba(15,23,42,.18); }
.distance-card .d-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f4f6fa;
  border-radius: 1rem;
  padding: .75rem;
}
.distance-card .d-thumbs { display: flex; flex: 1; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: .6rem; margin-top: .75rem; }
.distance-card .d-thumb { display: flex; flex-direction: column; align-items: center; gap: .3rem; width: 4.25rem; }
.distance-card .d-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f4f6fa;
  border: 1px solid #eef0ef;
  border-radius: .85rem;
  padding: .35rem;
}
.distance-card .d-thumb span { font-size: .65rem; color: #94a3b8; text-align: center; line-height: 1.25; }

/* ---------- lightbox: ขยายรูปของรางวัล/เสื้อ ---------- */
.gallery-zoomable { cursor: zoom-in; transition: transform 150ms ease, box-shadow 150ms ease; }
.gallery-zoomable:hover { transform: scale(1.04); box-shadow: 0 8px 18px -8px rgba(15,23,42,.28); }

/* กดรูปที่ขยายแล้วเพื่อพลิกดูด้านหลัง (เฉพาะรูปที่มี data-back เช่น เหรียญพระวิศณุ/แก้วน้ำ) */
#galleryLightboxImg[data-back] { cursor: pointer; }
#galleryLightboxImg { transition: transform 150ms ease; }
.gallery-lightbox-frame {
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  border-radius: 1.5rem;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-lightbox-frame img { width: 100%; height: 100%; object-fit: contain; padding: 1rem; }
.distance-card .d-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  color: var(--accent);
  margin-bottom: .75rem;
  min-height: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.distance-card .d-title-sub {
  font-family: 'Prompt', sans-serif;
  font-size: .7rem;
  font-weight: 400;
  letter-spacing: normal;
  color: #94a3b8;
  margin-top: .15rem;
}
.distance-card .d-price {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent);
  font-weight: 700;
  font-size: 2.5rem;
  letter-spacing: -0.02em;
  margin-top: .85rem;
  padding-top: .85rem;
  border-top: 1px dashed #eef0ef;
}
.distance-card .d-price small { font-size: 1rem; font-weight: 500; margin-left: .2rem; }

.d-select-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  margin-top: 1.1rem;
  padding: .7rem 1rem;
  border-radius: 9999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  text-decoration: none;
  transition: filter 150ms ease;
}
.d-select-btn:hover { filter: brightness(1.08); }

/* ---------- ปุ่ม "สมัครเลย" ใน navbar: เด้งเบาๆ + วงแหวนคลื่นล่อสายตา วนทุก 5 วิ ---------- */
@keyframes navCtaPulse {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(29, 99, 196, .45); }
  8%   { transform: scale(1.08); box-shadow: 0 0 0 0 rgba(29, 99, 196, .45); }
  16%  { transform: scale(1); box-shadow: 0 0 0 10px rgba(29, 99, 196, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(29, 99, 196, 0); }
}
.nav-cta-pulse { animation: navCtaPulse 2s ease-in-out infinite; }
.nav-cta-pulse:hover { animation-play-state: paused; }

/* ---------- checkpoints ---------- */
.checkpoints-wrap { position: relative; }
.checkpoints {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  position: relative;
}
.checkpoints-wrap::before {
  content: "";
  position: absolute;
  top: 22px;
  left: 12%;
  right: 12%;
  height: 3px;
  background: #e7e9e8;
  z-index: 0;
}
.cp-fill {
  position: absolute;
  top: 22px;
  left: 12%;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-orange), var(--brand-teal));
  z-index: 1;
  transition: width 300ms ease;
}
.cp {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  color: #b7bcc4;
}
.cp .material-symbols-outlined {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: #fff;
  border: 2px solid #e7e9e8;
  transition: all 200ms ease;
}
.cp small { font-size: .72rem; }
.cp.active { color: var(--brand-orange-dark); }
.cp.active .material-symbols-outlined { border-color: var(--brand-orange); color: var(--brand-orange); }
.cp.done .material-symbols-outlined { background: var(--brand-teal); border-color: var(--brand-teal); color: #fff; }
.cp.done { color: var(--brand-teal-dark); }

/* ---------- distance pick cards (form) ---------- */
.pick-card {
  --accent: #1D63C4;
  display: flex; align-items: center; gap: .75rem;
  border: 2px solid #eef0ef;
  border-radius: 1rem;
  padding: .9rem 1rem;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}
.pick-card .material-symbols-outlined { color: var(--accent); }
.pick-card .pc-title { font-weight: 500; flex: 1; }
.pick-card .pc-price { font-size: .85rem; color: var(--accent); font-weight: 600; }
.pick-card:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, white);
}

/* ---------- pick cards: 3-up vertical layout (per runner, in form) ---------- */
.pick-card-vertical {
  flex-direction: column;
  text-align: center;
  gap: .3rem;
  padding: 1rem .5rem;
}
.pick-card-vertical .pc-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--accent);
  min-height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}
.pick-card-vertical .pc-price {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: .2rem;
  white-space: nowrap;
}
.pick-card-vertical .pc-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f4f6fa;
  border-radius: .75rem;
  padding: .3rem;
  margin-top: .2rem;
}

/* ---------- delivery method: segmented switch ---------- */
.delivery-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .25rem;
  background: #f1f5f9;
  border-radius: 9999px;
  padding: .25rem;
}
.delivery-switch-thumb {
  position: absolute;
  top: .25rem; bottom: .25rem; left: .25rem;
  width: calc(50% - .25rem);
  background: #fff;
  border-radius: 9999px;
  box-shadow: 0 4px 10px -4px rgba(15,23,42,.18);
  transition: transform 220ms cubic-bezier(.4,0,.2,1);
}
.delivery-switch.is-ship .delivery-switch-thumb { transform: translateX(100%); }
.delivery-switch-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .6rem .5rem;
  border-radius: 9999px;
  font-size: .8rem;
  color: #64748b;
  text-align: center;
  line-height: 1.25;
  transition: color 150ms ease;
}
.delivery-switch-btn.active { color: var(--brand-teal-dark); font-weight: 600; }
.delivery-switch-btn .material-symbols-outlined { font-size: 1.1rem; }

.size-chip {
  border: 2px solid #eef0ef;
  border-radius: 999px;
  padding: .4rem 1.1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
}
.size-chip:has(input:checked) {
  border-color: var(--brand-teal);
  background: var(--brand-teal);
  color: #fff;
}

.btn-size-chart {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .75rem;
  color: var(--brand-teal-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-size-chart .material-symbols-outlined { font-size: 1rem; }

.size-chart-table { width: 100%; border-collapse: collapse; font-size: .85rem; white-space: nowrap; }
.size-chart-table th, .size-chart-table td {
  border: 1px solid #dbe4f0;
  padding: .5rem .5rem;
  text-align: center;
}
.size-chart-table thead th { background: var(--brand-teal); color: #fff; font-weight: 700; }
.size-chart-table tbody td:first-child {
  background: #eef4fb;
  font-weight: 600;
  color: #1e293b;
  text-align: left;
}
.size-chart-table tbody tr:nth-child(2) { background: #f7fafd; }

/* ---------- summary ---------- */
.summary-list { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: .5rem 1rem; font-size: .95rem; }
.summary-list dt { color: #94a3b8; }
.summary-list dd { font-weight: 500; color: #1e293b; }

/* ---------- status badge ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 500;
}
.status-badge.pending { background: #fff4e6; color: #b45309; }
.status-badge.approved { background: #e7f6ec; color: #15803d; }
.status-badge.rejected { background: #fdecec; color: #b91c1c; }

/* ---------- ใบเสร็จ (step 4) — จำลองหน้าตากระดาษสลิปจริง ---------- */
.receipt-backdrop { background: #eef1f5; }

.receipt-paper {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, .25);
}

/* ขอบหยักแบบกระดาษสลิปที่ถูกฉีกจากม้วน — เจาะเป็นวงกลมสีเดียวกับพื้นหลัง .receipt-backdrop */
.receipt-edge {
  height: 14px;
  background-image: radial-gradient(circle at 10px 7px, #eef1f5 7px, transparent 7.5px);
  background-size: 20px 14px;
  background-position: -4px 0;
}
.receipt-edge.bottom { transform: scaleY(-1); }

.receipt-meta { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; font-size: .8rem; }
.receipt-meta dt { color: #94a3b8; }
.receipt-meta dd { text-align: right; color: #1e293b; }

.receipt-items { display: flex; flex-direction: column; gap: .85rem; }
.receipt-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.receipt-item-label { font-weight: 500; color: #64748b; font-size: .8rem; }
.receipt-item-price { font-weight: 600; color: #1e293b; font-variant-numeric: tabular-nums; white-space: nowrap; }
.receipt-item-name { font-weight: 600; color: #1e293b; font-size: .95rem; margin-top: .15rem; overflow-wrap: break-word; }
.receipt-item-meta { font-size: .78rem; color: #94a3b8; margin-top: .15rem; }

.receipt-total { border-top: 2px solid #1e293b; }

/* QR สแกนได้จริง (ดู renderReceiptQr() ใน app.js) — เปิดหน้าจุดแจกของของออร์เดอร์นี้ตรงๆ เมื่อสแกน */
.receipt-barcode {
  display: flex;
  align-items: center;
  justify-content: center;
}
.receipt-barcode img, .receipt-barcode canvas {
  border-radius: .5rem;
}

@media print {
  .receipt-backdrop { background: none !important; padding: 0 !important; }
  .receipt-paper { box-shadow: none !important; }
  .receipt-edge { display: none; }
}

/* ---------- steps show/hide ---------- */
.step.hidden { display: none; }

/* ---------- multi-runner blocks ---------- */
.runner-block:not(:first-child) { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px dashed #e7e9e8; }

/* ---------- print (ใบเสร็จ) ---------- */
/* ตอนกดปุ่ม "พิมพ์/บันทึกใบเสร็จ" ต้องการให้ PDF/หน้าพิมพ์มีแค่ตัวใบเสร็จล้วนๆ ไม่มีอย่างอื่นติดมา
   (ปุ่มไหนอยากได้ PDF กดปุ่มนี้ตรงๆ ได้เลย ไม่ต้องมีข้อมูลอื่นปน — ถ้าอยากได้ภาพให้ใช้ปุ่ม "บันทึกเป็นภาพ" แทน) */
@media print {
  header, footer, .checkpoints-wrap, #wizardNav, #top, #distances, #route,
  .bg-amber-50, #devReceiptPanel, #wizard > h2, #reuploadSection,
  #wizard .text-center.mt-6 { display: none !important; }
  #wizard { padding: 0; margin: 0; }
}

/* ---------- scroll offset กันแถบเมนู fixed บังเนื้อหาตอนเลื่อนไปหา anchor ---------- */
#top, #distances, #wizard { scroll-margin-top: 76px; }

/* ---------- duck mascot ---------- */
.duck-mascot {
  position: absolute;
  width: 140px;
  height: 140px;
  pointer-events: none;
  z-index: 1;
}

/* ---------- admin dashboard table ---------- */
.table tbody tr { transition: background-color 120ms ease; }

/* ---------- dev-only: panel ทดสอบใบเสร็จ (ไม่ขึ้นในโหมด production) ---------- */
.dev-receipt-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-size: .8rem;
  padding: .55rem .6rem;
  border-radius: .75rem;
  color: #334155;
  transition: background-color 120ms ease;
}
.dev-receipt-btn:hover { background: #f1f5f9; }
.table tbody tr:hover { background-color: #fafaf9; }
