:root {
  /* สีของแถบเดโม โครงสร้างอยู่ที่ /shared/v1/demo-bar.css */
  --demo-bar-bg: #e4577d;
  --demo-bar-ink: #fff3e6;
  --demo-bar-cta-bg: #fff3e6;
  --demo-bar-cta-ink: #b33a5c;

  --demo-bar: 44px;

  /* ---- โทเคนธีม ----
     สีพื้นเคยฝัง hex ไว้ตรง ๆ ใน body และ .ambient-shade ทำให้แก้ที่ :root แล้วไม่เห็นผล
     ย้ายมาเป็นโทเคนแล้ว จึงสลับทั้งหน้าได้จากบล็อกเดียว
     ค่าตรงนี้คือธีมชมพูพาสเทลซึ่งเป็นค่าเริ่มต้นของ Template 01 */
  --stage-bg: linear-gradient(90deg, #f7a5b0 0%, #ffd9ad 25%, #fff9b9 49%, #b9f8c8 72%, #acd8f3 100%);
  --ambient-shade-bg: linear-gradient(
    90deg,
    rgba(247, 165, 176, 0.58),
    rgba(255, 217, 173, 0.44),
    rgba(255, 249, 185, 0.42),
    rgba(185, 248, 200, 0.5),
    rgba(172, 216, 243, 0.58)
  );
  --button-bg: linear-gradient(135deg, #fff1a8, #ffc7d3 52%, #b8edff);
  --card-tint: linear-gradient(
    90deg,
    rgba(247, 165, 176, 0.22),
    rgba(185, 248, 200, 0.2),
    rgba(172, 216, 243, 0.22)
  );
  --answer-bg: linear-gradient(
    135deg,
    rgba(255, 199, 211, 0.92),
    rgba(255, 247, 184, 0.82),
    rgba(185, 248, 200, 0.8)
  );
  /* สีตัวอักษรในจดหมาย แยกจาก --ink เพราะตอนอ่านมันลอยอยู่บนพื้นบรรยากาศ ไม่ได้อยู่บนการ์ด */
  --letter-ink: #51404e;
  --bg: #fff7bb;
  --ink: #3d3340;
  --muted: #715f68;
  --surface: rgba(255, 255, 255, 0.58);
  --line: rgba(132, 100, 112, 0.2);
  --pink: #f8a6b1;
  --peach: #ffd9ad;
  --butter: #fff7b8;
  --mint: #b9f8c8;
  --sky: #afd8f4;
  --coral: #ff8f9a;
  --rose: #ffc8d4;
  --gold: #ffd777;
  --cream: #fffaf2;
  --plum: #46314a;
  --lavender: #d7c7ff;
  --blue-soft: #b8dcf5;
  --shadow: 0 30px 90px rgba(132, 100, 112, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    var(--stage-bg);
  font-family: "Noto Sans Thai", "Kanit", system-ui, sans-serif;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.experience {
  position: relative;
  display: grid;
  min-height: 100svh;
  overflow: hidden;
  padding: clamp(14px, 3vw, 34px);
  padding-top: calc(clamp(14px, 3vw, 34px) + var(--demo-bar));
}

.ambient-art,
.ambient-shade,
.grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ambient-art {
  object-fit: cover;
  opacity: 0.2;
  mix-blend-mode: soft-light;
  transform: scale(1.04);
}

.ambient-shade {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.76), transparent 24rem),
    radial-gradient(circle at 82% 78%, rgba(255, 255, 255, 0.52), transparent 28rem),
    var(--ambient-shade-bg);
}

.grain {
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.38) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black, transparent 76%);
}

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(1060px, 100%);
  min-height: calc(100svh - clamp(28px, 6vw, 68px) - var(--demo-bar));
  margin: auto;
  /* เดิมตรงนี้เป็นการ์ดแก้วมีขอบ เงา และ blur
     ถอดออกเพราะมันเป็นกล่องที่ห่อข้อความเฉย ๆ ไม่ได้แทนของอะไร
     และมันกินพื้นที่แนวตั้งไป 112px จนปุ่มในฉากซองตกออกนอกจอบนคอม
     เหลือไว้เป็นกล่องจัดวางอย่างเดียว ตำแหน่งลูกและ min-height ยังพึ่งมันอยู่ */
  padding: clamp(10px, 2vw, 18px);
  overflow: hidden;
}

.top-bar {
  position: absolute;
  top: clamp(16px, 3vw, 28px);
  left: clamp(16px, 3vw, 28px);
  right: clamp(16px, 3vw, 28px);
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.mini-label,
.eyebrow,
.response-label {
  display: block;
  color: #b45b70;
  font-family: "Kanit", sans-serif;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-bar strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(0.96rem, 2vw, 1.05rem);
}

.sound-button,
.primary-button,
.secondary-button,
.answer-button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.98rem;
  font-weight: 800;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.sound-button:active,
.primary-button:active,
.secondary-button:active,
.answer-button:active {
  transform: scale(0.97);
}

button:disabled {
  cursor: default;
  opacity: 0.48;
  transform: none;
}

.sound-button {
  flex: 0 0 auto;
  padding: 0 15px;
  color: var(--plum);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.66);
}

.primary-button,
.secondary-button {
  margin-top: clamp(18px, 3vw, 28px);
  padding: 0 24px;
}

.primary-button {
  color: var(--plum);
  background: var(--button-bg);
  box-shadow: 0 18px 48px rgba(244, 134, 154, 0.26);
}

.secondary-button {
  color: var(--plum);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
}

.scene {
  position: absolute;
  /* เว้นบนให้ชื่อคนส่งคนรับ เว้นล่างให้จุดบอกฉาก ที่เหลือคืนให้เนื้อหาทั้งหมด */
  inset: clamp(70px, 8vw, 92px) clamp(14px, 4vw, 56px) clamp(62px, 7vw, 76px);
  display: grid;
  align-content: center;
  justify-items: start;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(20px) scale(0.985);
  transition:
    opacity 520ms ease,
    transform 520ms ease,
    visibility 0ms linear 520ms;
}

.scene.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition-delay: 0ms;
}

.scene-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.78fr);
  align-items: center;
  gap: clamp(22px, 5vw, 58px);
  width: 100%;
}

.hero-visual-card {
  position: relative;
  width: min(380px, 100%);
  margin: 0;
  justify-self: end;
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.42)),
    var(--card-tint);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 28px 70px rgba(132, 100, 112, 0.22);
  overflow: hidden;
  transform: rotate(1.5deg);
}

.hero-visual-card::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  pointer-events: none;
}

.hero-visual-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 12px;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  margin: 0;
  max-width: 840px;
  font-family: "Noto Serif Thai", "Kanit", serif;
  letter-spacing: 0;
}

/* ภาษาไทยมีสระบนกับวรรณยุกต์ที่ล้นออกนอกกล่องบรรทัด
   line-height ที่ดูพอดีกับภาษาอังกฤษจะทำให้ตัวบนไปทับบรรทัดหรือองค์ประกอบข้างบน
   ซึ่งวัดด้วย getBoundingClientRect ไม่เจอ เพราะกล่องไม่ทับกันแต่ตัวอักษรทับ
   1.04 เคยทำให้พาดหัวไปทับ eyebrow มาแล้ว ต่ำกว่า 1.25 ห้ามใช้กับพาดหัวไทย */
/* พาดหัวทุกฉากในเทมเพลตนี้เป็น "ประโยคเต็ม" ไม่ใช่พาดหัวโชว์คำสั้น ๆ
   ขนาดจึงต้องมาจากหน้าที่ของข้อความ ไม่ใช่จากระดับแท็ก
   ของเดิมตั้งไว้ 4.72rem ซึ่งเรนเดอร์ที่ 67-75px บนคอม
   ประโยคเดียวกินสามบรรทัด 257px แล้วดันปุ่มตกออกนอกจอ เกิดมาแล้วทั้งฉากซองและฉากไทม์ไลน์

   clamp คุมทั้งมือถือและคอมในบรรทัดเดียว จึงไม่ต้องมี media query ซ้อนอีกชั้น
   ซึ่งเมื่อก่อนมีแล้วกลายเป็นแหล่งความจริงสองที่ */
h1 {
  max-width: 22ch;
  font-size: clamp(1.7rem, 3vw, 2.7rem);
  line-height: 1.42;
  text-wrap: balance;
}

h2 {
  max-width: 24ch;
  font-size: clamp(1.55rem, 2.6vw, 2.3rem);
  line-height: 1.45;
  text-wrap: balance;
}

.scene-copy {
  max-width: 660px;
  margin: clamp(14px, 2.4vw, 22px) 0 0;
  color: var(--muted);
  font-size: clamp(0.96rem, 1.65vw, 1.16rem);
  line-height: 1.72;
}

.scene-envelope,
.scene-letter,
.scene-timeline,
.scene-question,
.scene-response {
  justify-items: center;
  text-align: center;
}

.scene-letter {
  overflow: hidden;
}

.envelope {
  position: relative;
  width: min(360px, 74vw);
  height: min(250px, 52vw);
  /* การ์ดจดหมายในซองถูกเลื่อนลงมาเลยขอบซองราว 57px ตอนยังไม่เปิด
     ถ้าเว้นล่างแค่ 28px พาดหัวใต้ซองจะถูกการ์ดทับ ต้องเผื่อให้พ้นจริง */
  margin: 12px 0 clamp(30px, 5vw, 42px);
  perspective: 900px;
  filter: drop-shadow(0 26px 38px rgba(160, 107, 121, 0.22));
}

.envelope-back,
.envelope-front,
.envelope-flap,
.letter-card {
  position: absolute;
  inset: 0;
  border-radius: 20px;
}

.envelope-back {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(255, 200, 212, 0.42));
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.envelope-front {
  clip-path: polygon(0 34%, 50% 72%, 100% 34%, 100% 100%, 0 100%);
  background: linear-gradient(135deg, rgba(255, 247, 184, 0.8), rgba(255, 200, 212, 0.76), rgba(185, 248, 200, 0.62));
  border: 1px solid rgba(255, 255, 255, 0.58);
}

.envelope-flap {
  transform-origin: top;
  clip-path: polygon(0 0, 50% 54%, 100% 0);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.82), rgba(172, 216, 243, 0.54));
}

.letter-card {
  display: grid;
  /* ต้องบวกกันแล้วไม่เกิน 100% ไม่งั้นการ์ดจะห้อยพ้นซองตั้งแต่ยังไม่เปิด
     แล้วไปทับพาดหัวที่อยู่ใต้ซอง ซึ่งเคยเกิดขึ้นมาแล้ว
     top + height + ระยะ translate ตอนพัก = 34 + 60 + 1.2 = 95.2% */
  top: 34%;
  inset-inline: 12%;
  height: 60%;
  align-content: center;
  justify-items: center;
  color: #342334;
  background: linear-gradient(180deg, #ffffff, #fff1f4);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 20px 54px rgba(244, 134, 154, 0.2);
  transform: translateY(2%);
}

/* สองบรรทัดนี้เคยชนกันตอนย่อความสูงการ์ด เพราะบรรทัดบนดันลงล่างและบรรทัดล่างดันขึ้นบน
   เปลี่ยนมาวางเรียงกันตรงกลางพร้อมระยะห่างจริง จะไม่ชนไม่ว่าการ์ดสูงเท่าไหร่ */
.letter-card span,
.letter-card strong {
  align-self: auto;
}

.letter-card span {
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.4;
}

.letter-card strong {
  margin-top: 2px;
  font-family: "Noto Serif Thai", serif;
  font-size: clamp(1.1rem, 4.4vw, 1.42rem);
  line-height: 1.3;
}

.experience[data-scene="letter"] .envelope-flap,
.experience[data-scene="timeline"] .envelope-flap,
.experience[data-scene="question"] .envelope-flap,
.experience[data-scene="response"] .envelope-flap,
.scene-envelope.is-opening .envelope-flap {
  transform: rotateX(162deg);
}

.experience[data-scene="letter"] .letter-card,
.experience[data-scene="timeline"] .letter-card,
.experience[data-scene="question"] .letter-card,
.experience[data-scene="response"] .letter-card,
.scene-envelope.is-opening .letter-card {
  transform: translateY(-34%);
}

/* ---------- จดหมาย · ไหลขึ้นแบบเครดิตท้ายหนัง ----------
   ของเดิมโชว์ทีละบรรทัดแล้วสลับ บรรทัดเก่าหายเลย อ่านไม่ทันแล้วตามกลับไม่ได้
   แบบนี้วางทั้งฉบับต่อกันแล้วเลื่อนขึ้นช้า ๆ ย้อนสายตากลับได้ตลอด
   ------------------------------------------------------- */

.letter-sheet {
  position: relative;
  width: min(700px, 100%);
  padding: clamp(14px, 2.6vw, 24px);
  color: #372637;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.22);
}

.line {
  color: var(--letter-ink);
  font-size: clamp(1.16rem, 2.4vw, 1.72rem);
}

.letter-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: clamp(20px, 3.4vw, 28px);
}

.letter-controls .primary-button,
.letter-controls .secondary-button {
  margin-top: 0;
}

.memory-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: min(900px, 100%);
  margin-top: clamp(18px, 3.8vw, 30px);
}

.memory-strip article {
  position: relative;
  min-height: 164px;
  padding: 20px;
  text-align: left;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid var(--line);
  border-radius: 24px;
  opacity: 0;
  transform: translateY(18px);
  overflow: hidden;
}

.memory-strip article b {
  position: absolute;
  top: 14px;
  right: 16px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #b45b70;
  background: var(--answer-bg);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  box-shadow: 0 12px 24px rgba(132, 100, 112, 0.14);
  font-family: "Kanit", sans-serif;
  font-size: 1.18rem;
  font-style: normal;
}

.memory-strip span {
  display: inline-flex;
  margin-bottom: 14px;
  color: #b45b70;
  font-family: "Kanit", sans-serif;
  font-weight: 800;
}

.memory-strip p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.62;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: min(760px, 100%);
  margin-top: clamp(18px, 4vw, 30px);
}

.answer-button {
  min-height: 58px;
  padding: 0 18px;
  color: var(--plum);
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid var(--line);
}

.answer-button:hover,
.answer-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}

.answer-button.yes {
  color: var(--plum);
  background: linear-gradient(135deg, #fff2a8, #ffc5d1);
}

.answer-button.maybe {
  background: rgba(172, 216, 243, 0.5);
}

.answer-button.no {
  background: rgba(255, 255, 255, 0.52);
}

.response-label {
  margin-bottom: 10px;
}

.scene-response h2 {
  color: #b45b70;
}

.gift-back-button {
  position: absolute;
  right: 0;
  bottom: 0;
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--plum);
  font-size: 0.84rem;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 14px 38px rgba(132, 100, 112, 0.14);
  backdrop-filter: blur(18px);
  transition:
    transform 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.gift-back-button::before {
  content: "♡";
  margin-right: 7px;
  color: #b45b70;
}

.gift-back-button:hover,
.gift-back-button:focus-visible {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 18px 44px rgba(132, 100, 112, 0.2);
}

.progress-dots {
  position: absolute;
  left: 50%;
  bottom: clamp(18px, 4vw, 30px);
  z-index: 5;
  display: flex;
  gap: 9px;
  transform: translateX(-50%);
}

.progress-dots span {
  width: 8px;
  height: 8px;
  background: rgba(70, 49, 74, 0.18);
  border-radius: 999px;
  transition:
    width 220ms ease,
    background 220ms ease;
}

.progress-dots span.is-active {
  width: 28px;
  background: #b45b70;
}

@media (max-width: 900px) {
  .experience {
    padding: 10px;
  }

  .stage {
    min-height: calc(100svh - 20px - var(--demo-bar));
    border-radius: 30px;
  }

  .scene {
    inset: 86px 18px 76px;
  }

  .memory-strip,
  .answer-grid {
    grid-template-columns: 1fr;
  }

  .scene-layout {
    grid-template-columns: 1fr;
  }

  .hero-visual-card {
    width: min(292px, 82%);
    justify-self: center;
    order: -1;
  }

  .memory-strip article {
    min-height: auto;
  }
}

@media (max-width: 520px) {
  .stage {
    padding: 16px;
    border-radius: 26px;
  }

  .top-bar {
    align-items: flex-start;
  }

  .sound-button {
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.82rem;
  }

  .scene {
    inset: 78px 14px 58px;
  }

  .scene-copy {
    font-size: 0.92rem;
    line-height: 1.6;
  }

  .letter-sheet {
    padding: 14px;
    border-radius: 22px;
  }

  .hero-visual-card {
    width: min(218px, 76%);
    border-radius: 26px;
  }

  .line {
    font-size: clamp(1.04rem, 5.4vw, 1.34rem);
    line-height: 1.52;
  }

  .letter-controls {
    gap: 9px;
  }

  .letter-controls .primary-button,
  .letter-controls .secondary-button {
    min-height: 44px;
    padding: 0 17px;
    font-size: 0.9rem;
  }

  .gift-back-button {
    right: 50%;
    bottom: -42px;
    min-height: 34px;
    transform: translateX(50%);
    font-size: 0.78rem;
  }

  .gift-back-button:hover,
  .gift-back-button:focus-visible {
    transform: translateX(50%) translateY(-2px);
  }

  .envelope {
    width: min(300px, 70vw);
    height: min(208px, 48vw);
    margin-bottom: 24px;
  }

  .memory-strip {
    gap: 8px;
    margin-top: 14px;
  }

  .memory-strip article {
    padding: 14px 16px;
  }

  .memory-strip article b {
    width: 34px;
    height: 34px;
    border-radius: 13px;
    font-size: 0.95rem;
  }

  .memory-strip span {
    margin-bottom: 6px;
    font-size: 0.9rem;
  }

  .memory-strip p {
    padding-right: 36px;
    font-size: 0.88rem;
    line-height: 1.45;
  }

  .answer-button {
    min-height: 50px;
    font-size: 0.92rem;
  }
}

@media (max-width: 380px) {
  .stage {
    padding: 14px;
  }

  .scene {
    inset: 74px 12px 54px;
  }

  h1 {
    font-size: clamp(1.74rem, 9.6vw, 2.28rem);
  }

  h2 {
    font-size: clamp(1.58rem, 8.4vw, 2.08rem);
  }

  .hero-visual-card {
    width: min(196px, 72%);
  }

  .scene-copy {
    font-size: 0.88rem;
  }

  .primary-button,
  .secondary-button,
  .answer-button {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .ambient-art {
    animation: slowDrift 16s ease-in-out infinite alternate;
  }

  .scene.is-active .eyebrow,
  .scene.is-active h1,
  .scene.is-active h2,
  .scene.is-active .scene-copy,
  .scene.is-active .primary-button,
  .scene.is-active .secondary-button,
  .scene.is-active .answer-grid {
    animation: riseIn 620ms ease both;
  }

  .scene.is-active h1,
  .scene.is-active h2 {
    animation-delay: 80ms;
  }

  .scene.is-active .scene-copy {
    animation-delay: 170ms;
  }

  .scene.is-active > .primary-button,
  .scene.is-active .secondary-button,
  .scene.is-active .answer-grid {
    animation-delay: 260ms;
  }

  .envelope-flap,
  .letter-card {
    transition: transform 760ms cubic-bezier(0.2, 0.85, 0.22, 1);
  }

  .scene.is-active .memory-strip article {
    animation: riseIn 560ms ease both;
  }

  .scene.is-active .memory-strip article:nth-child(1) {
    animation-delay: 130ms;
  }

  .scene.is-active .memory-strip article:nth-child(2) {
    animation-delay: 280ms;
  }

  .scene.is-active .memory-strip article:nth-child(3) {
    animation-delay: 430ms;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slowDrift {
  from {
    transform: scale(1.04) translate3d(-0.4%, -0.4%, 0);
  }
  to {
    transform: scale(1.08) translate3d(0.8%, 0.6%, 0);
  }
}

/* ==========================================================================
   โหมดอ่านจดหมาย — ถอดกรอบออกตอนเปิด
   ปัญหาเดิม จดหมายซ้อนอยู่ในสามกรอบ .stage → .scene → .letter-sheet
   แล้วหน้าต่างอ่านถูกล็อกไว้สูงสุด 340px จดหมายยาวแค่ไหนก็ดูสั้นและอึดอัด
   พอเข้าฉากจดหมาย จึงละลายกรอบทั้งหมดให้ตัวอักษรลอยอยู่บนบรรยากาศแทน
   เคยลองใส่สคริมนวล ๆ คลุมทั้งจอเพื่อกัน contrast แต่มันกลืนสีพาสเทลของพื้นหลังจนจืด
   พื้นหลังชุดนี้อ่อนพออยู่แล้ว จึงไม่ต้องมีอะไรมาคั่นระหว่างตัวอักษรกับบรรยากาศ
   ========================================================================== */

.experience[data-scene="letter"] .stage {
  /* ไม่ต้องละลายการ์ดแล้ว เพราะถอดออกไปตั้งแต่แรก
     เหลือไว้เป็นจุดยึดเผื่อฉากอ่านต้องปรับอะไรเพิ่มในอนาคต */
  padding: 0;
}

/* ชื่อคนส่งคนรับกับหัวข้อฉากหลบไปตอนอ่าน ไม่ให้มีอะไรแย่งความสนใจกับตัวจดหมาย */
/* พาดหัวฉากต้องยุบความสูงด้วย ไม่ใช่แค่ opacity: 0
   เพราะ opacity ยังกินที่ในตารางอยู่ แล้วดันปุ่มควบคุมตกออกนอกฉาก
   แต่ห้ามใช้ display: none เพราะจะทำให้แถวในตารางเลื่อนไปทั้งชุด
   แล้วช่องจดหมายที่ควรยืดหยุ่นจะกลายเป็นแถว auto ปุ่มตกหนักกว่าเดิม */
.experience[data-scene="letter"] .scene-letter .eyebrow {
  height: 0;
  margin: 0;
  overflow: hidden;
}

.experience[data-scene="letter"] .top-bar {
  /* ต้องปิดแอนิเมชันด้วย ไม่ใช่แค่สั่ง opacity: 0
     เพราะ .scene.is-active .eyebrow มี animation riseIn แบบ fill-mode both
     ซึ่งค่าจากแอนิเมชันชนะค่าที่ประกาศไว้ปกติเสมอ สั่งซ่อนเฉย ๆ จะไม่มีผล */
  animation: none !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
}

/* ใช้ flex ไม่ใช่ grid ตรงนี้ เพราะ grid track แบบ 1fr ที่มีลูกตั้ง height: 100%
   จะเกิดการอ้างอิงวนกันแล้วแทร็กไม่ยอมหด ผลคือปุ่มควบคุมล้นออกนอกฉาก 16px
   flex กับ min-height: 0 หดได้แน่นอนกว่า */
.scene-letter {
  inset: clamp(56px, 7vw, 78px) clamp(14px, 4vw, 44px) clamp(56px, 7vw, 78px);
  z-index: 1;
  display: flex;
  flex-direction: column;
  /* จัดกลางด้วย justify-content ไม่ใช่ margin: auto บนลูก
     เพราะ margin auto ในแนวตั้งจะกินที่ว่างจนดันลูกตัวสุดท้ายพ้นขอบกล่อง
     ซึ่งเป็นที่มาของปุ่มที่ล้นออกไป 16px */
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.scene-letter .letter-sheet {
  /* กล่องจดหมายเอาความสูงตามเนื้อหาหน้าที่สูงสุด ไม่ต้องยืดเต็ม */
  flex: 0 1 auto;
  min-height: 0;
}

.scene-letter .letter-controls {
  flex: 0 0 auto;
  margin-top: clamp(10px, 1.8vw, 16px);
}

.letter-sheet {
  width: min(760px, 100%);
  min-height: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.letter-pages,
.letter-page {
  justify-items: center;
}

.line {
  width: min(34ch, 100%);
  font-size: clamp(1.24rem, 2.9vw, 1.94rem);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .experience[data-scene="letter"] .stage,
  .experience[data-scene="letter"] .scene-letter .eyebrow,
  .experience[data-scene="letter"] .top-bar {
    transition: none;
  }
}

/* ==========================================================================
   ฉากเปิดแบบของขวัญ
   กล่องทั้งกล่องคือปุ่ม ไม่ใช่ปุ่มเล็กใต้ข้อความ เพราะคนรับควรรู้สึกว่ากำลังแกะของ
   ไม่ใช่กำลังกดผ่านสไลด์ พื้นที่แตะจึงต้องใหญ่พอสำหรับนิ้วโป้งบนมือถือ
   ========================================================================== */

.scene-intro {
  align-content: center;
  justify-items: center;
}

.gift-open {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(360px, 100%);
  padding: clamp(22px, 4vw, 32px) clamp(20px, 4vw, 30px) clamp(20px, 3.4vw, 28px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: clamp(28px, 4vw, 38px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.42)),
    var(--card-tint);
  box-shadow: 0 28px 70px rgba(132, 100, 112, 0.24);
  color: inherit;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  transition:
    transform 260ms ease,
    box-shadow 260ms ease;
}

.gift-open:hover,
.gift-open:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 34px 80px rgba(132, 100, 112, 0.3);
}

.gift-open:active {
  transform: translateY(0) scale(0.985);
}

/* กล่องนิ่ง ๆ บนจอในเบราว์เซอร์ของ LINE ตอนเน็ตช้า อ่านว่าโหลดไม่ขึ้น ไม่ใช่ว่ารอให้กด
   จังหวะลอยเบา ๆ นี้คือสิ่งที่บอกว่ามันยังมีชีวิตและกดได้ */
.gift-visual {
  display: block;
  margin-bottom: 6px;
  animation: gift-breathe 3.4s ease-in-out infinite;
}

.gift-visual .icon-tile {
  width: clamp(148px, 34vw, 196px);
  border-radius: 24px;
  filter: drop-shadow(0 18px 26px rgba(132, 100, 112, 0.28));
}

@keyframes gift-breathe {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-7px) rotate(1deg);
  }
}

.gift-eyebrow {
  color: var(--rose-ink, #b45b70);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.gift-title {
  font-family: "Noto Serif Thai", "Kanit", serif;
  font-size: clamp(1.24rem, 3.4vw, 1.62rem);
  font-weight: 700;
  line-height: 1.4;
  text-wrap: balance;
}

.gift-hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

@media (prefers-reduced-motion: reduce) {
  .gift-visual {
    animation: none;
  }

  .gift-open {
    transition: none;
  }
}

/* ==========================================================================
   ฉากแกลเลอรี และฉากจบ — ใช้เฉพาะบางแพ็ก
   Template 01 ตัวเต็มไม่มีสองฉากนี้ แต่ CSS อยู่ในไฟล์เดียวกันทุกแพ็ก
   เพราะแพ็กคือเทมเพลตเดียวกันที่เปิดฉากไม่เท่ากัน ไม่ใช่เว็บคนละตัว
   ========================================================================== */

.scene-gallery,
.scene-ending {
  justify-items: center;
  text-align: center;
}

/* ตารางรูปปรับจำนวนคอลัมน์เองตามที่ว่าง ไม่ต้องมี media query
   และรองรับรูปกี่ใบก็ได้ ตั้งแต่ 3 ถึง 8 ตามแพ็กที่ลูกค้าเลือก
   min() ข้างในจำเป็น ถ้าใส่แค่ 132px พอจอแคบกว่านั้นคอลัมน์จะไม่ยอมหดแล้วหน้าล้น */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100px, 100%), 1fr));
  gap: clamp(8px, 1.4vw, 13px);
  /* จำกัดความกว้างไว้ให้ได้สี่คอลัมน์ ไม่ใช่ห้า
     เพราะแพ็กจดหมายมีแปดรูป ห้าคอลัมน์จะเหลือแถวสองแค่สามใบซึ่งดูไม่ลงตัว
     และสี่คอลัมน์ทำให้สองแถวเตี้ยพอที่ปุ่มจะไม่ตกจอที่ความสูง 820px */
  width: min(560px, 100%);
  margin: clamp(10px, 1.8vw, 16px) 0 clamp(12px, 2vw, 18px);
}

.photo-grid .polaroid {
  margin: 0;
  padding: 8px 8px 0;
  background: #ffffff;
  border-radius: 5px;
  box-shadow: 0 18px 34px -22px rgba(132, 100, 112, 0.6);
  transition: transform 0.2s ease;
}

.photo-grid .polaroid:nth-child(odd) {
  transform: rotate(-1.5deg);
}

.photo-grid .polaroid:nth-child(even) {
  transform: rotate(1.3deg);
}

.photo-grid .polaroid:hover {
  transform: rotate(0deg) translateY(-3px);
}

.photo-grid .icon-tile {
  width: 100%;
  border-radius: 3px;
}

.photo-grid figcaption {
  padding: 6px 2px 8px;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
  .photo-grid .polaroid {
    transition: none;
  }
}

/* จอแคบต้องได้สามคอลัมน์ ไม่ใช่สอง
   เพราะสองคอลัมน์กับแปดรูปคือสี่แถว ซึ่งดันหัวเรื่องกับปุ่มตกออกนอกจอ */
@media (max-width: 520px) {
  .photo-grid {
    gap: 7px;
    margin: 10px 0 12px;
  }

  .scene-ending .scene-copy {
    margin-top: 6px;
  }

  .pack-ladder {
    margin-top: 14px;
  }
}

/* ในฉากจบให้ปุ่มทำของขวัญกลับอยู่ในลำดับปกติ ไม่ใช่ลอยมุมขวาล่าง
   เพราะฉากจบมีที่ว่างพอ และตอนลอยมันยื่นพ้นขอบฉากลงไป 41px บนมือถือ
   ฉากตอบกลับของแพ็กใหญ่ยังใช้แบบลอยเหมือนเดิม เพราะที่นั่นแน่นกว่า */
.scene-ending .gift-back-button {
  position: static;
  margin-top: clamp(14px, 2.4vw, 20px);
  transform: none;
}

.scene-ending .gift-back-button:hover,
.scene-ending .gift-back-button:focus-visible {
  transform: translateY(-2px);
}

/* ---------- แถบเทียบแพ็ก ----------
   อยู่ในฉากสุดท้ายเท่านั้น เพราะเป็นจังหวะที่คนดูเห็นของครบแล้ว
   จึงเป็นตอนที่การเทียบราคามีความหมาย ไม่ใช่ตอนยังไม่ได้ดูอะไรเลย
   หน้าลูกค้าจริงต้องลบบล็อกนี้ออก เพราะเขาไม่ได้มาเลือกซื้อ */
.pack-ladder {
  margin-top: clamp(18px, 3vw, 26px);
}

.pack-ladder p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.pack-ladder-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
}

.pack-ladder a,
.pack-ladder span {
  padding: 6px 13px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.8rem;
  text-decoration: none;
}

.pack-ladder .is-current {
  background: var(--coral);
  border-color: var(--coral);
  color: #ffffff;
  font-weight: 500;
}

/* ป้ายบอกแพ็กมุมบนขวา คู่กับชื่อคนส่งคนรับที่อยู่มุมบนซ้าย */
.pack-chip {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ==========================================================================
   ธีมแพ็กการ์ด 99 — เรียบ สว่าง สีเดียว
   ต้องดูต่างจากอีกสองแพ็กตั้งแต่วินาทีแรก ไม่ใช่ต้องกดครบทุกฉากถึงจะรู้ว่าต่างกัน
   แพ็กเล็กที่สุดจึงใช้สีน้อยที่สุด อ่านว่าเรียบร้อยแต่ไม่ได้อ่านว่าน้อย
   ========================================================================== */

:root {
  --stage-bg: linear-gradient(160deg, #d9f6e4 0%, #eaf7d8 46%, #fdf6d2 100%);
  --ambient-shade-bg: linear-gradient(
    160deg,
    rgba(185, 240, 205, 0.5),
    rgba(226, 244, 200, 0.4),
    rgba(253, 246, 210, 0.5)
  );
  --button-bg: linear-gradient(135deg, #c9f0d4, #eaf6c8);
  --card-tint: linear-gradient(90deg, rgba(185, 240, 205, 0.2), rgba(240, 246, 200, 0.18));
  --coral: #4f8f6a;
  --plum: #23412f;
  --ink: #23412f;
  --letter-ink: #2c4a37;
}

/* จอแคบไม่มีที่ให้ปุ่มทำของขวัญกลับลอยมุมขวาล่าง มันจะยื่นพ้นขอบฉากลงไป 41px
   ให้อยู่ในลำดับปกติแทน */
@media (max-width: 520px) {
  .scene-response .gift-back-button {
    position: static;
    margin-top: 16px;
    transform: none;
  }

  .scene-response .gift-back-button:hover,
  .scene-response .gift-back-button:focus-visible {
    transform: translateY(-2px);
  }
}

/* ไอคอนของขวัญในฉากเฉลย ให้เล็กกว่าไอคอนฉากเปิด
   เพราะตรงนี้ตัวเอกคือประโยคเฉลย ไม่ใช่ภาพ */
.icon-card-reveal {
  margin: 0 0 clamp(12px, 2.2vw, 18px);
}

.icon-card-reveal .icon-tile {
  width: clamp(96px, 20vw, 128px);
}
