:root {
  --bg: #050302;
  --red: #dc2626;
  --red-deep: #7f1d1d;
  --orange: #f97316;
  --amber: #f59e0b;
  --yellow: #fde047;
  --white-hot: #fffbeb;
  --text: #fff7ed;
  --text-soft: rgb(255 237 213 / 0.74);
  --text-faint: rgb(255 237 213 / 0.45);
  --line: rgb(251 146 60 / 0.22);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --mx: 50vw;
  --my: 50vh;
  --ring: 73vh;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Prompt', 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   อินโทรวิดีโอ
   ========================================================= */
/* ระหว่างเล่นอินโทร: หยุดอนิเมชันของหน้าไว้ก่อน แล้วค่อยเริ่มตอนเผยหน้า */
body.intro {
  overflow: hidden;
}
body.intro .page,
body.intro .page *,
body.intro .fx * {
  animation-play-state: paused !important;
}

.intro-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  transition:
    opacity 0.85s ease,
    transform 1.2s var(--ease-out);
}
.intro-layer[hidden] {
  display: none;
}
.intro-layer.out {
  opacity: 0;
  transform: scale(1.1);
  pointer-events: none;
}
.intro-layer video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.intro-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}
.intro-loader.done {
  opacity: 0;
  pointer-events: none;
}
.intro-loader span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgb(255 255 255 / 0.12);
  border-top-color: var(--orange);
  animation: spin 0.8s linear infinite;
}

.intro-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 0.3);
  background: rgb(255 255 255 / 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  animation: fadeIn 0.4s ease both;
}

/* สิงโตชนจอ → กล้องสั่น */
.intro-layer.impact video {
  animation: quake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ตัดเข้าหน้าเว็บ: วงแหวนไฟในคลิปขยายต่อ + แสงวาบอุ่น ๆ จากกลางจอ */
.flash {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle at 50% 50%,
    rgb(255 251 235 / 0.95) 0%,
    rgb(253 224 71 / 0.75) 14%,
    rgb(249 115 22 / 0.45) 34%,
    rgb(220 38 38 / 0.18) 55%,
    transparent 75%
  );
}
.flash.go {
  animation: flash 1.2s ease-out forwards;
}
.shock {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 61;
  /* วงในรูปกว้าง 66% ของรูป → กล่อง = ring ÷ 0.66 เพื่อให้วงเท่ากับวงไฟในคลิปพอดี */
  width: calc(var(--ring) / 0.66);
  height: calc(var(--ring) / 0.66);
  margin: calc(var(--ring) / -1.32) 0 0 calc(var(--ring) / -1.32);
  pointer-events: none;
  opacity: 0;
  /* วงไฟอบไว้เป็นรูป (วงอยู่ที่ ~66% ของรัศมีรูป เท่ากับวงในคลิป) — ขยับแค่ transform/opacity → GPU ล้วน */
  background: url(/fire-ring.webp) center / contain no-repeat;
  will-change: transform, opacity;
}
.shock.go {
  animation: shock 1.4s cubic-bezier(0.3, 0.5, 0.5, 1) forwards;
}

/* =========================================================
   ชั้นพื้นหลัง
   ========================================================= */
.fx {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ไฟส่องจากด้านล่างเหมือนกองไฟ */
.glow {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}
.g1 {
  width: 70vmax;
  height: 70vmax;
  left: -25vmax;
  bottom: -45vmax;
  background: radial-gradient(circle, rgb(220 38 38 / 0.85), rgb(220 38 38 / 0.3) 40%, transparent 70%);
  opacity: 0.45;
  animation: drift1 16s ease-in-out infinite alternate;
}
.g2 {
  width: 60vmax;
  height: 60vmax;
  right: -25vmax;
  bottom: -40vmax;
  background: radial-gradient(circle, rgb(249 115 22 / 0.8), rgb(249 115 22 / 0.28) 40%, transparent 70%);
  opacity: 0.38;
  animation: drift2 19s ease-in-out infinite alternate;
}
.blaze {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -18%;
  height: 60%;
  background: radial-gradient(
    ellipse 60% 70% at 50% 100%,
    rgb(253 224 71 / 0.28) 0%,
    rgb(249 115 22 / 0.3) 25%,
    rgb(220 38 38 / 0.18) 50%,
    transparent 75%
  );
  transform-origin: 50% 100%;
  animation: blaze 2.6s ease-in-out infinite;
}

#embers {
  position: fixed;
  inset: 0;
  z-index: 55;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* แสงอุ่นตามเมาส์ — เลื่อนวงกลมด้วย transform (ไม่ต้องวาดใหม่) */
.spotlight {
  position: absolute;
  left: -420px;
  top: -420px;
  width: 840px;
  height: 840px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(251 146 60 / 0.09), transparent 60%);
  transform: translate3d(var(--mx), var(--my), 0);
  will-change: transform;
}

/* เกรนฟิล์มบาง ๆ */
.grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.55'/></svg>");
  opacity: 0.06;
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 45%, rgb(0 0 0 / 0.65) 100%);
}

/* =========================================================
   เนื้อหา
   ========================================================= */
.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(32px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  perspective: 1200px;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 900px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transform-style: preserve-3d;
  will-change: transform;
}

/* แกนความร้อนด้านหลังหัวข้อ */
.core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(620px, 130vw);
  aspect-ratio: 1;
  margin: calc(min(620px, 130vw) / -2) 0 0 calc(min(620px, 130vw) / -2);
  border-radius: 50%;
  background: radial-gradient(circle, rgb(253 224 71 / 0.55), rgb(249 115 22 / 0.4) 25%, rgb(220 38 38 / 0.22) 45%, transparent 68%);
  opacity: 0.3;
  transform: translateZ(-80px);
  animation: breathe 3.2s ease-in-out infinite;
}

/* วงแหวนไฟคุกรุ่น — ต่อเนื่องจากวงแหวนในวิดีโอ */
.ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(760px, 140vw);
  aspect-ratio: 1;
  margin: calc(min(760px, 140vw) / -2) 0 0 calc(min(760px, 140vw) / -2);
  background: url(/fire-ring.webp) center / contain no-repeat;
  transform: translateZ(-40px);
  opacity: 0.85;
  will-change: transform, opacity;
  animation:
    ringIn 1.6s var(--ease-out) 0.05s both,
    spin 40s linear infinite,
    smolder 2.4s ease-in-out 1.7s infinite;
}

/* แสงเรืองหลังตัวหนังสือ — แทน drop-shadow ขนาดใหญ่ + ไฟกะพริบแบบ filter */
.title-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(780px, 125vw);
  height: min(420px, 75vw);
  margin: calc(min(420px, 75vw) / -2) 0 0 calc(min(780px, 125vw) / -2);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgb(249 115 22 / 0.42), rgb(220 38 38 / 0.2) 42%, transparent 70%);
  transform: translateZ(-20px);
  will-change: transform, opacity;
  animation:
    glowIn 1.2s ease-out 0.15s both,
    emberPulse 2.8s ease-in-out 1.4s infinite;
}

.brand,
.title,
.countdown {
  position: relative;
  transform: translateZ(40px);
}

/* ชื่อแบรนด์ — ติดไฟขึ้นมาหลังตัวอักษรระเบิดออก */
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  margin-bottom: 18px;
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(20px, 5.2vw, 34px);
  line-height: 1;
  letter-spacing: 0.34em;
  /* ชดเชยระยะห่างตัวสุดท้าย ให้อยู่กึ่งกลางจริง */
  padding-left: 0.34em;
  filter: drop-shadow(0 0 12px rgb(249 115 22 / 0.6));
  animation: ignite 1.1s var(--ease-out) 0.75s both;
}
.brand::before,
.brand::after {
  content: '';
  width: clamp(28px, 9vw, 72px);
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--orange), var(--yellow));
}
.brand::after {
  background: linear-gradient(90deg, var(--yellow), var(--orange), transparent);
  /* ชดเชย padding-left ของ .brand */
  margin-right: 0.34em;
}
.brand-mk {
  background: linear-gradient(180deg, var(--white-hot) 10%, var(--yellow) 60%, var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-plus {
  background: linear-gradient(180deg, var(--yellow) 0%, var(--orange) 55%, var(--red));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* หัวข้อใหญ่ — ตัวอักษรระเบิดออกจากกลางจอ แล้วลุกเป็นไฟ */
.title {
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(64px, 17vw, 180px);
  line-height: 0.95;
  letter-spacing: -0.035em;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 0.22em;
}
/* หลังตัวอักษรเข้าที่: ใส่เงาไฟ (วาดครั้งเดียว ไม่ได้ขยับ) */
.title.lit {
  filter: drop-shadow(0 0 18px rgb(249 115 22 / 0.5));
}
.word {
  display: inline-flex;
}
.word > span {
  --fx: 0px;
  --fy: 0px;
  --rot: 0deg;
  --d: 0s;
  display: inline-block;
  padding-bottom: 0.06em;
  background: linear-gradient(180deg, var(--white-hot) 8%, var(--yellow) 38%, var(--orange) 70%, var(--red) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: burst 1.15s cubic-bezier(0.18, 0.9, 0.24, 1.12) both;
  animation-delay: calc(0.08s + var(--d));
}

/* นับถอยหลัง */
.countdown {
  margin-top: 36px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: min(440px, 100%);
  animation: fadeUp 0.9s var(--ease-out) 1.65s both;
}
.countdown[hidden] {
  display: none;
}
.unit {
  padding: 14px 4px 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgb(70 24 8 / 0.7), rgb(12 5 3 / 0.75));
  border: 1px solid var(--line);
  box-shadow: inset 0 -12px 24px -14px rgb(249 115 22 / 0.45);
  overflow: hidden;
}
.unit b {
  display: block;
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(26px, 8vw, 40px);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  background: linear-gradient(180deg, var(--white-hot), var(--yellow) 45%, var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.unit b.tick {
  animation: tick 0.5s var(--ease-out);
}
.unit span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-faint);
}

.foot {
  position: relative;
  margin-top: 32px;
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  animation: fadeIn 1s ease 2s both;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 14px;
}
.replay {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-faint);
  font: 400 12px/1 'Prompt', system-ui, sans-serif;
  cursor: pointer;
  transition:
    color 0.2s ease,
    background 0.2s ease;
}
.replay:hover {
  color: var(--text);
  background: rgb(249 115 22 / 0.12);
}
.replay[hidden] {
  display: none;
}

@media (min-width: 640px) {
  .page {
    padding-left: 24px;
    padding-right: 24px;
  }
}

/* มือถือ: ไม่มีเมาส์ → ไม่ต้องมีแสงตามเมาส์ */
@media (hover: none) {
  .spotlight {
    display: none;
  }
}

/* =========================================================
   Keyframes
   ========================================================= */
@keyframes burst {
  0% {
    opacity: 0;
    transform: translate(var(--fx), var(--fy)) scale(0.08) rotate(var(--rot));
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: none;
  }
}
@keyframes ignite {
  0% { opacity: 0; scale: 1.6 1; }
  45% { opacity: 1; }
  100% { opacity: 1; scale: 1; }
}
@keyframes glowIn {
  0% { opacity: 0; scale: 0.3; }
  35% { opacity: 1; scale: 1.15; }
  100% { opacity: 0.85; scale: 1; }
}
@keyframes emberPulse {
  0%, 100% { opacity: 0.85; scale: 1; }
  23% { opacity: 1; scale: 1.04; }
  47% { opacity: 0.7; scale: 0.98; }
  71% { opacity: 0.95; scale: 1.02; }
}
@keyframes ringIn {
  from { opacity: 0; scale: 1.9; }
  to { opacity: 0.85; scale: 1; }
}
@keyframes smolder {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.62; }
}
@keyframes breathe {
  0%, 100% { opacity: 0.26; scale: 1; }
  50% { opacity: 0.36; scale: 1.06; }
}
@keyframes blaze {
  0%, 100% { opacity: 0.85; transform: scaleY(1); }
  30% { opacity: 1; transform: scaleY(1.06); }
  55% { opacity: 0.75; transform: scaleY(0.96); }
  78% { opacity: 0.95; transform: scaleY(1.03); }
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translate3d(0, 16px, 40px);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 40px);
  }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin {
  to { rotate: 360deg; }
}
@keyframes tick {
  from { transform: translateY(-40%); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes drift1 {
  to { transform: translate(16vw, -8vh) scale(1.15); }
}
@keyframes drift2 {
  to { transform: translate(-14vw, -6vh) scale(1.2); }
}
@keyframes flash {
  0% { opacity: 0; }
  10% { opacity: 0.9; }
  100% { opacity: 0; }
}
@keyframes shock {
  0% { opacity: 1; transform: scale(1); }
  70% { opacity: 0.55; }
  100% { opacity: 0; transform: scale(2.7); }
}
@keyframes quake {
  0%, 100% { transform: scale(1.06) translate3d(0, 0, 0); }
  12% { transform: scale(1.06) translate3d(-18px, 10px, 0) rotate(-0.8deg); }
  26% { transform: scale(1.06) translate3d(16px, -12px, 0) rotate(0.7deg); }
  40% { transform: scale(1.06) translate3d(-11px, 8px, 0); }
  55% { transform: scale(1.06) translate3d(8px, -5px, 0); }
  72% { transform: scale(1.06) translate3d(-4px, 3px, 0); }
}

/* ผู้ใช้ที่ตั้งค่าลดการเคลื่อนไหว — ปิดอนิเมชันทั้งหมด */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
  }
}
