: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: 50%;
  --my: 50%;
  --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;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* =========================================================
   อินโทรวิดีโอ
   ========================================================= */
/* ระหว่างเล่นอินโทร: หยุดอนิเมชันของหน้าไว้ก่อน แล้วค่อยเริ่มตอนเผยหน้า */
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;
  width: var(--ring);
  height: var(--ring);
  margin: calc(var(--ring) / -2) 0 0 calc(var(--ring) / -2);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle,
    transparent 52%,
    rgb(220 38 38 / 0.5) 58%,
    rgb(249 115 22 / 0.95) 63%,
    rgb(253 224 71 / 1) 66%,
    rgb(249 115 22 / 0.9) 69%,
    rgb(220 38 38 / 0.4) 73%,
    transparent 78%
  );
  filter: url(#flame) blur(1px);
}
.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%;
  filter: blur(100px);
  mix-blend-mode: screen;
  will-change: transform;
}
.g1 {
  width: 70vmax;
  height: 70vmax;
  left: -25vmax;
  bottom: -45vmax;
  background: var(--red);
  opacity: 0.32;
  animation: drift1 16s ease-in-out infinite alternate;
}
.g2 {
  width: 60vmax;
  height: 60vmax;
  right: -25vmax;
  bottom: -40vmax;
  background: var(--orange);
  opacity: 0.26;
  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;
}

/* แสงอุ่นตามเมาส์ */
.spotlight {
  position: absolute;
  inset: 0;
  background: radial-gradient(420px circle at var(--mx) var(--my), rgb(251 146 60 / 0.09), transparent 60%);
}

/* เกรนฟิล์มบาง ๆ */
.grain {
  position: absolute;
  inset: -100%;
  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;
  animation: grain 1.2s steps(6) infinite;
}

.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: conic-gradient(from 0deg, var(--red), var(--orange), var(--yellow), var(--orange), var(--red), var(--red-deep), var(--red));
  filter: blur(80px);
  opacity: 0.3;
  transform: translateZ(-80px);
  animation:
    spin 14s linear infinite,
    breathe 3.2s ease-in-out infinite;
}

/* วงแหวนไฟคุกรุ่น — ต่อเนื่องจากวงแหวนในวิดีโอ */
.ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(520px, 96vw);
  aspect-ratio: 1;
  margin: calc(min(520px, 96vw) / -2) 0 0 calc(min(520px, 96vw) / -2);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    transparent 60%,
    rgb(127 29 29 / 0.45) 64%,
    rgb(220 38 38 / 0.6) 66.5%,
    rgb(249 115 22 / 0.75) 68%,
    rgb(253 224 71 / 0.55) 69%,
    rgb(249 115 22 / 0.5) 70.5%,
    transparent 74%
  );
  filter: url(#flame);
  transform: translateZ(-40px);
  opacity: 0.85;
  animation:
    ringIn 1.6s var(--ease-out) 0.05s both,
    spin 40s linear infinite,
    smolder 2.4s ease-in-out infinite;
}

.brand,
.title,
.tagline,
.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 14px rgb(249 115 22 / 0.65)) drop-shadow(0 0 32px rgb(220 38 38 / 0.4));
  animation: ignite 1.3s 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;
  filter: drop-shadow(0 0 22px rgb(249 115 22 / 0.55)) drop-shadow(0 0 60px rgb(220 38 38 / 0.45));
}
/* หลังระเบิดเสร็จ: ใส่ไอร้อนพลิ้วให้ตัวหนังสือ */
.title.lit {
  filter: url(#heat) drop-shadow(0 0 22px rgb(249 115 22 / 0.55)) drop-shadow(0 0 60px rgb(220 38 38 / 0.45));
}
.word {
  display: inline-flex;
}
.word > span {
  --fx: 0px;
  --fy: 0px;
  --rot: 0deg;
  --d: 0s;
  display: inline-block;
  padding-bottom: 0.06em;
  background: linear-gradient(
    0deg,
    var(--red) 0%,
    var(--orange) 18%,
    var(--yellow) 34%,
    var(--white-hot) 46%,
    var(--yellow) 58%,
    var(--orange) 76%,
    var(--red) 100%
  );
  background-size: 100% 300%;
  background-position: 50% 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,
    lava 3.6s linear infinite,
    flicker var(--fd, 2.6s) ease-in-out infinite;
  animation-delay:
    calc(0.08s + var(--d)),
    calc(var(--i) * -0.31s),
    calc(1.4s + var(--i) * 0.13s);
}
.word:first-child > span:nth-child(1) { --i: 0; --fd: 2.3s; }
.word:first-child > span:nth-child(2) { --i: 1; --fd: 2.9s; }
.word:first-child > span:nth-child(3) { --i: 2; --fd: 2.1s; }
.word:first-child > span:nth-child(4) { --i: 3; --fd: 3.3s; }
.word:first-child > span:nth-child(5) { --i: 4; --fd: 2.6s; }
.word:first-child > span:nth-child(6) { --i: 5; --fd: 3.1s; }
.word + .word > span:nth-child(1) { --i: 6; --fd: 2.4s; }
.word + .word > span:nth-child(2) { --i: 7; --fd: 3.4s; }
.word + .word > span:nth-child(3) { --i: 8; --fd: 2.2s; }
.word + .word > span:nth-child(4) { --i: 9; --fd: 2.8s; }

.tagline {
  margin-top: 26px;
  min-height: 1.7em;
  font-family: 'Prompt', system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(15px, 4vw, 19px);
  line-height: 1.7;
  letter-spacing: 0.06em;
  color: var(--amber);
  text-shadow: 0 0 18px rgb(245 158 11 / 0.5);
  animation: fadeIn 0.8s ease 1.3s both;
}
.tagline .glyph {
  color: var(--red);
  opacity: 0.9;
}

/* นับถอยหลัง */
.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(249 115 22 / 0.12), rgb(0 0 0 / 0.25));
  border: 1px solid var(--line);
  box-shadow: inset 0 -12px 24px -14px rgb(249 115 22 / 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  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) {
  .title.lit {
    filter: drop-shadow(0 0 18px rgb(249 115 22 / 0.55)) drop-shadow(0 0 44px rgb(220 38 38 / 0.4));
  }
}

/* =========================================================
   Keyframes
   ========================================================= */
@keyframes burst {
  0% {
    opacity: 0;
    transform: translate(var(--fx), var(--fy)) scale(0.08) rotate(var(--rot));
    filter: blur(16px) brightness(3);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: none;
    filter: blur(0) brightness(1);
  }
}
@keyframes ignite {
  0% {
    opacity: 0;
    letter-spacing: 1.1em;
    filter: blur(10px) brightness(2.4) drop-shadow(0 0 14px rgb(249 115 22 / 0.65));
  }
  45% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    letter-spacing: 0.34em;
    filter: blur(0) brightness(1) drop-shadow(0 0 14px rgb(249 115 22 / 0.65)) drop-shadow(0 0 32px rgb(220 38 38 / 0.4));
  }
}
@keyframes lava {
  from { background-position: 50% 100%; }
  to { background-position: 50% 0%; }
}
@keyframes flicker {
  0%, 100% { filter: brightness(1); translate: 0 0; }
  22% { filter: brightness(1.22); translate: 0 -0.015em; }
  41% { filter: brightness(0.9); translate: 0 0.008em; }
  63% { filter: brightness(1.15); translate: 0 -0.01em; }
  80% { filter: brightness(0.96); translate: 0 0; }
}
@keyframes ringIn {
  from { opacity: 0; scale: 1.9; }
  to { opacity: 0.85; scale: 1; }
}
@keyframes smolder {
  0%, 100% { filter: url(#flame) brightness(1); }
  50% { filter: url(#flame) brightness(1.35); }
}
@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 grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-5%, 3%); }
  40% { transform: translate(4%, -6%); }
  60% { transform: translate(-3%, 5%); }
  80% { transform: translate(6%, 2%); }
  100% { transform: translate(0, 0); }
}
@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;
  }
}
