/* ============================================================
   ความรักของเรา · RIRIN ♥ PREAM
   ------------------------------------------------------------
   หลักการของไฟล์นี้
   1. ตัวหนังสืออ่านชัดก่อนความสวย (คอนทราสต์ 14:1 ขึ้นไป)
   2. ใช้ property ที่รองรับกว้าง + มี fallback ให้ Safari/iOS รุ่นเก่า
   3. เอฟเฟกต์ hover เปิดเฉพาะเครื่องที่มีเมาส์จริง (iPad/iPhone ไม่ค้าง)
   4. เว้น safe-area ให้ iPhone ที่มีติ่งและแถบล่าง
   ============================================================ */

:root {
  /* ฟอนต์: Kanit=หัวข้อ / Noto Sans Thai=เนื้อหา / Itim=ลายมือ / Cormorant=ละติน */
  --f-display: "Kanit", "Noto Sans Thai", "Leelawadee UI", "Thonburi", sans-serif;
  --f-body: "Noto Sans Thai", "Kanit", "Leelawadee UI", "Thonburi", sans-serif;
  --f-hand: "Itim", "Noto Sans Thai", "Leelawadee UI", sans-serif;
  --f-latin: "Cormorant Garamond", Georgia, "Times New Roman", serif;

  --pink: #ff6fa5;
  --pink-200: #ffc2da;
  --pink-100: #ffdfeb;
  --pink-deep: #d63a72;
  --gold: #ffcf8f;
  --lilac: #c19bff;

  --n900: #150418;
  --n800: #22072a;
  --n700: #340d33;

  --t-hi: #fff8fb;
  --t-md: #f3e2ee;
  --t-lo: #d9bfd2;

  --ink: #3d2135;
  --ink-soft: #6a4059;

  --card: linear-gradient(158deg, rgba(255, 255, 255, 0.11), rgba(24, 5, 26, 0.5));
  --card-brd: rgba(255, 255, 255, 0.17);
  --sh-1: 0 18px 40px rgba(0, 0, 0, 0.34);
  --sh-2: 0 28px 64px rgba(0, 0, 0, 0.42);
  --inset-hi: inset 0 1px 0 rgba(255, 255, 255, 0.2);

  --ease: cubic-bezier(0.22, 0.72, 0.24, 1);

  /* ระยะเว้นขอบจอปลอดภัย (iPhone มีติ่ง / แถบล่าง) */
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);

  /* JS จะเซ็ตค่านี้ให้ เผื่อเบราว์เซอร์เก่าที่ยังไม่รู้จัก svh */
  --vh: 1vh;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  font-family: var(--f-body);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.9; /* ภาษาไทยต้องการระยะบรรทัดมากกว่าอังกฤษ */
  color: var(--t-md);
  background: var(--n900);
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body.locked {
  overflow: hidden;
  height: 100vh;
  height: calc(var(--vh) * 100);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  touch-action: manipulation; /* ตัดดีเลย์ 300ms บนมือถือ */
}

a {
  text-decoration: none;
  touch-action: manipulation;
}

::selection {
  background: var(--pink);
  color: #fff;
}

/* โฟกัสด้วยคีย์บอร์ด — มี fallback ให้ Safari เก่าที่ยังไม่รู้จัก :focus-visible */
:focus-visible {
  outline: 2px solid var(--pink-200);
  outline-offset: 3px;
  border-radius: 6px;
}
@supports not selector(:focus-visible) {
  button:focus,
  a:focus,
  [tabindex]:focus {
    outline: 2px solid var(--pink-200);
    outline-offset: 3px;
  }
}

::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--pink), var(--lilac));
  border-radius: 99px;
}

/* ฟิล์มเกรนบาง ๆ ให้ดูเป็นงานทำมือ */
body::before {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 55;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   พื้นหลัง
   ============================================================ */
.bg {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -4;
  background: linear-gradient(168deg, var(--n800) 0%, var(--n700) 42%, var(--n900) 100%);
}
.bg::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: radial-gradient(ellipse at 50% 38%, transparent 0%, rgba(8, 2, 12, 0.62) 100%);
}

.blob {
  position: fixed;
  z-index: -3;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.26;
  animation: floatBlob 22s ease-in-out infinite;
  pointer-events: none;
}
.blob.b1 {
  width: 44vw;
  height: 44vw;
  left: -10vw;
  top: -8vw;
  background: radial-gradient(circle, var(--pink) 0%, transparent 70%);
}
.blob.b2 {
  width: 40vw;
  height: 40vw;
  right: -8vw;
  top: 28vh;
  background: radial-gradient(circle, var(--lilac) 0%, transparent 70%);
  animation-delay: -7s;
}
.blob.b3 {
  width: 36vw;
  height: 36vw;
  left: 22vw;
  bottom: -12vw;
  background: radial-gradient(circle, var(--gold) 0%, transparent 70%);
  animation-delay: -13s;
  opacity: 0.16;
}

@keyframes floatBlob {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  33% {
    transform: translate3d(4vw, 5vh, 0) scale(1.1);
  }
  66% {
    transform: translate3d(-3vw, -4vh, 0) scale(0.94);
  }
}

#stars,
#hearts-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#stars {
  z-index: -3;
}
/* หัวใจลอยอยู่ "หลัง" เนื้อหา จะไม่บังตัวหนังสือ */
#hearts-canvas {
  z-index: -2;
}

/* เอฟเฟกต์ฉลอง อยู่บนสุด (เกิดเฉพาะตอนกดปุ่ม) */
#fx-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 150;
  pointer-events: none;
}

/* แถบความคืบหน้าการเลื่อนหน้า */
.progress {
  position: fixed;
  left: 0;
  top: 0;
  height: 3px;
  width: 0;
  z-index: 90;
  background: linear-gradient(90deg, var(--gold), var(--pink), var(--lilac));
  box-shadow: 0 0 12px rgba(255, 111, 165, 0.7);
  transition: width 0.12s linear;
}

/* ============================================================
   หน้าแรก (ล็อกรหัส + ซองจดหมาย)
   ============================================================ */
.intro {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(22px + var(--sa-t)) calc(18px + var(--sa-r)) calc(22px + var(--sa-b)) calc(18px + var(--sa-l));
  background: radial-gradient(ellipse at 50% 35%, #3d0c38 0%, #1c0522 70%, #120315 100%);
  transition: opacity 0.85s var(--ease), visibility 0.85s var(--ease);
}
.intro.hide {
  opacity: 0;
  visibility: hidden;
}

.intro-inner {
  margin: auto;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.stage {
  animation: fadeUp 0.75s var(--ease) both;
}
.stage[hidden] {
  display: none;
}

.intro-kicker {
  font-family: var(--f-latin);
  font-style: italic;
  font-size: 1rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
  margin-bottom: 18px;
}

/* ---------- แผงใส่รหัส ---------- */
.lock-badge {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  background: linear-gradient(150deg, rgba(255, 111, 165, 0.9), rgba(193, 155, 255, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45), var(--inset-hi);
  transition: transform 0.5s var(--ease);
}
.lock-badge.open {
  transform: rotate(-14deg) scale(1.12);
}

.lock-title {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: clamp(1.4rem, 5.6vw, 1.8rem);
  line-height: 1.5;
  color: var(--t-hi);
  margin-bottom: 8px;
}

.lock-hint {
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--t-lo);
  margin-bottom: 22px;
}

/* ช่องโชว์รหัสเป็นจุด */
.pin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
  min-height: 30px;
}
.pin span {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  transition: transform 0.22s var(--ease), background 0.22s ease, box-shadow 0.22s ease;
}
.pin span.on {
  background: var(--pink);
  border-color: var(--pink-200);
  transform: scale(1.22);
  box-shadow: 0 0 14px rgba(255, 111, 165, 0.85);
}
.pin.shake {
  animation: shake 0.5s ease;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  15% {
    transform: translateX(-11px);
  }
  30% {
    transform: translateX(9px);
  }
  45% {
    transform: translateX(-7px);
  }
  60% {
    transform: translateX(5px);
  }
  80% {
    transform: translateX(-3px);
  }
}

.lock-msg {
  min-height: 1.9em;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--gold);
  margin-bottom: 16px;
}
.lock-msg.ok {
  color: #9ff5c8;
}

/* คีย์แพด — ปุ่มใหญ่พอสำหรับนิ้ว (สูงกว่า 44px ตามเกณฑ์ของ Apple) */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 300px;
  margin: 0 auto;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}
.keypad button {
  height: 62px;
  border-radius: 18px;
  font-family: var(--f-display);
  font-size: 1.45rem;
  font-weight: 500;
  color: var(--t-hi);
  background: var(--card);
  border: 1px solid var(--card-brd);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--sh-1), var(--inset-hi);
  transition: transform 0.14s var(--ease), background 0.2s ease;
}
.keypad button:active {
  transform: scale(0.93);
  background: linear-gradient(158deg, rgba(255, 111, 165, 0.5), rgba(193, 155, 255, 0.4));
}
.keypad button.act {
  font-size: 1.25rem;
  color: var(--pink-100);
}
.keypad button.ok {
  background: linear-gradient(120deg, var(--pink-deep), var(--pink));
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

/* ---------- ซองจดหมาย ---------- */
.intro-hint {
  color: var(--pink-100);
  font-size: clamp(1rem, 2.8vw, 1.18rem);
  line-height: 1.85;
  margin-bottom: 30px;
}

.envelope {
  width: min(72vw, 300px);
  height: calc(min(72vw, 300px) * 0.66);
  margin: 0 auto;
  position: relative;
  cursor: pointer;
  filter: drop-shadow(0 24px 44px rgba(0, 0, 0, 0.55));
  animation: breathe 3s ease-in-out infinite;
  transition: transform 0.5s var(--ease);
}

.env-body {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(155deg, #fff0f5, #ffd0e0 58%, #ffb3cd);
  border-radius: 12px;
  overflow: hidden;
}
.env-body::before,
.env-body::after {
  content: "";
  position: absolute;
  width: 130%;
  height: 130%;
  background: rgba(255, 255, 255, 0.32);
}
.env-body::before {
  left: -65%;
  top: -15%;
  transform: rotate(28deg);
}
.env-body::after {
  right: -65%;
  top: -15%;
  transform: rotate(-28deg);
}

.env-flap {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 62%;
  background: linear-gradient(175deg, #ffa8c6, #ef7099);
  -webkit-clip-path: polygon(0 0, 100% 0, 50% 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.8s cubic-bezier(0.6, -0.2, 0.4, 1.4);
  z-index: 4;
  border-radius: 12px 12px 0 0;
}
.envelope.open .env-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.env-letter {
  position: absolute;
  left: 8%;
  width: 84%;
  bottom: 12%;
  background: #fffdf8;
  border-radius: 8px;
  padding: 16px 14px;
  text-align: center;
  font-family: var(--f-hand);
  color: var(--pink-deep);
  font-size: clamp(1rem, 3.2vw, 1.22rem);
  line-height: 1.7;
  box-shadow: 0 12px 26px rgba(80, 10, 45, 0.3);
  transform: translateY(0) scale(0.9);
  opacity: 0;
  z-index: 2;
  transition: transform 0.85s 0.35s var(--ease), opacity 0.5s 0.35s ease;
}
.envelope.open .env-letter {
  transform: translateY(-74%) scale(1);
  opacity: 1;
}

.env-seal {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8fb1, #b81f52);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  z-index: 5;
  box-shadow: 0 8px 20px rgba(90, 5, 45, 0.55), inset 0 -3px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.45s var(--ease), opacity 0.4s ease;
}
.envelope.open .env-seal {
  transform: scale(0) rotate(140deg);
  opacity: 0;
}

.open-btn {
  margin-top: 40px;
  padding: 15px 42px;
  border-radius: 99px;
  font-family: var(--f-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(100deg, var(--pink-deep), var(--pink), var(--lilac));
  background-size: 210% 100%;
  box-shadow: 0 14px 34px rgba(214, 58, 114, 0.45), var(--inset-hi);
  animation: shimmer 5s linear infinite;
  transition: transform 0.25s var(--ease), box-shadow 0.25s ease;
}
.open-btn:active {
  transform: scale(0.96);
}

@keyframes shimmer {
  to {
    background-position: 210% 0;
  }
}
@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.035);
  }
}

/* ============================================================
   โครงหลัก
   ============================================================ */
.page {
  position: relative;
  z-index: 2;
  opacity: 0;
  transition: opacity 1.1s var(--ease);
}
.page.show {
  opacity: 1;
}

section {
  position: relative;
  padding: clamp(72px, 11vw, 130px) calc(20px + var(--sa-r)) clamp(72px, 11vw, 130px) calc(20px + var(--sa-l));
}

.wrap {
  width: min(1080px, 100%);
  margin: 0 auto;
}

.eyebrow {
  display: inline-block;
  font-family: var(--f-latin);
  font-style: italic;
  font-size: 1.02rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
  opacity: 0.92;
}

.sec-title {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: clamp(1.72rem, 5.2vw, 2.9rem);
  line-height: 1.42; /* เผื่อที่ให้สระบน–ล่างของไทย */
  color: var(--t-hi);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}
.sec-title::after {
  content: "";
  display: block;
  width: 62px;
  height: 3px;
  border-radius: 99px;
  margin-top: 18px;
  background: linear-gradient(90deg, var(--gold), var(--pink));
}
.center .sec-title::after {
  margin-left: auto;
  margin-right: auto;
}

.sec-sub {
  margin-top: 18px;
  color: var(--t-md);
  font-size: clamp(1rem, 2.5vw, 1.08rem);
  line-height: 2;
  max-width: 60ch;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
}
.sec-sub b {
  color: var(--pink-100);
  font-weight: 600;
}

.center {
  text-align: center;
}
.center .sec-sub {
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  min-height: 100vh;
  min-height: calc(var(--vh) * 100);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: calc(86px + var(--sa-t));
}

.hero-badge {
  font-family: var(--f-latin);
  font-size: clamp(0.9rem, 2.4vw, 1.1rem);
  font-weight: 600;
  letter-spacing: 0.34em;
  color: var(--gold);
  margin-bottom: 18px;
  animation: fadeUp 1s 0.1s both;
}

.hero-hi {
  font-family: var(--f-hand);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  color: var(--pink-100);
  animation: fadeUp 1s 0.24s both;
}

.hero-name {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(3.2rem, 15vw, 8.5rem);
  line-height: 1.25;
  margin: 2px 0 6px;
  background: linear-gradient(96deg, #ffffff 0%, var(--pink-200) 26%, var(--gold) 50%, var(--pink) 74%, #ffffff 100%);
  background-size: 240% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
  animation: shimmer 7s linear infinite, popIn 1.1s 0.32s both;
}

.hero-love {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 6vw, 2.9rem);
  line-height: 1.5;
  color: var(--t-hi);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
  animation: fadeUp 1s 0.52s both;
}
.hero-love .beat {
  display: inline-block;
  animation: beat 1.3s ease-in-out infinite;
  filter: drop-shadow(0 0 14px rgba(255, 60, 120, 0.8));
}

.typewriter {
  margin-top: 24px;
  min-height: 3.8em;
  font-size: clamp(1rem, 2.9vw, 1.2rem);
  line-height: 1.9;
  color: var(--t-md);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
  animation: fadeUp 1s 0.72s both;
}
.typewriter .caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  background: var(--pink);
  margin-left: 4px;
  vertical-align: -0.16em;
  animation: blink 0.9s steps(1) infinite;
}

.hero-actions {
  margin-top: 32px;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  animation: fadeUp 1s 0.92s both;
}

.btn {
  display: inline-block;
  padding: 14px 30px;
  border-radius: 99px;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(100deg, var(--pink-deep), var(--pink));
  box-shadow: 0 12px 28px rgba(214, 58, 114, 0.4), var(--inset-hi);
  transition: transform 0.24s var(--ease), box-shadow 0.24s ease;
}
.btn:active {
  transform: scale(0.97);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--card-brd);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: none;
  color: var(--t-hi);
}

.scroll-cue {
  position: absolute;
  bottom: calc(22px + var(--sa-b));
  left: 50%;
  transform: translateX(-50%);
  color: var(--t-lo);
  font-size: 0.85rem;
  text-align: center;
}
.scroll-cue span {
  display: block;
  width: 22px;
  height: 36px;
  margin: 8px auto 0;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 99px;
  position: relative;
}
.scroll-cue span::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 7px;
  width: 4px;
  height: 8px;
  margin-left: -2px;
  border-radius: 99px;
  background: var(--pink-200);
  animation: wheel 1.7s ease-in-out infinite;
}
@keyframes wheel {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  70% {
    transform: translateY(12px);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

/* ============================================================
   นับเวลา + นับถอยหลัง
   ============================================================ */
.counter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(10px, 2vw, 18px);
  margin-top: 42px;
}

.tile {
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: 20px;
  padding: clamp(18px, 3vw, 28px) 6px clamp(14px, 2.4vw, 20px);
  text-align: center;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--sh-1), var(--inset-hi);
  transition: transform 0.32s var(--ease);
}
.tile b {
  display: block;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 6.2vw, 3.2rem);
  line-height: 1.2;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}
.tile i {
  display: block;
  margin-top: 4px;
  font-style: normal;
  font-family: var(--f-body);
  font-weight: 500;
  font-size: clamp(0.78rem, 2.2vw, 0.95rem);
  color: var(--pink-100);
}

.counter-note {
  margin-top: 24px;
  text-align: center;
  color: var(--t-md);
  font-family: var(--f-hand);
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  line-height: 1.9;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
}

/* การ์ดนับถอยหลัง */
.cd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 40px;
  text-align: left;
}

.cd-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: 22px;
  padding: 26px 24px;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--sh-1), var(--inset-hi);
  overflow: hidden;
  transition: transform 0.32s var(--ease), border-color 0.32s ease;
}
.cd-card .cd-ic {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 12px;
  display: block;
}
.cd-card .cd-name {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.55;
  color: var(--t-hi);
}
.cd-card .cd-date {
  font-size: 0.92rem;
  color: var(--gold);
  margin-bottom: 16px;
}
.cd-nums {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cd-nums div {
  flex: 1 1 0;
  min-width: 58px;
  text-align: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 4px 8px;
}
.cd-nums b {
  display: block;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.15rem, 4.4vw, 1.6rem);
  line-height: 1.25;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.cd-nums i {
  font-style: normal;
  font-size: 0.74rem;
  color: var(--pink-100);
}
/* วันนั้นมาถึงแล้ว */
.cd-card.today {
  border-color: rgba(255, 207, 143, 0.6);
  box-shadow: var(--sh-1), 0 0 34px rgba(255, 207, 143, 0.28), var(--inset-hi);
}
.cd-today-msg {
  display: none;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: clamp(1.15rem, 4.4vw, 1.5rem);
  line-height: 1.6;
  color: var(--gold);
  padding: 6px 0 2px;
}
.cd-card.today .cd-today-msg {
  display: block;
}
.cd-card.today .cd-nums {
  display: none;
}

/* ============================================================
   เหตุผลที่รัก
   ============================================================ */
.reason-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(256px, 1fr));
  gap: 20px;
  margin-top: 44px;
}

.reason {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: 22px;
  padding: 30px 26px;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--sh-1), var(--inset-hi);
  overflow: hidden;
  transition: transform 0.4s var(--ease), box-shadow 0.4s ease, border-color 0.4s ease;
}
.reason::before {
  content: "";
  position: absolute;
  top: -45%;
  right: -45%;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255, 143, 185, 0.4), transparent 70%);
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
}
.reason .ic {
  font-size: 2.3rem;
  line-height: 1;
  display: block;
  margin-bottom: 16px;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
  transition: transform 0.4s var(--ease);
}
.reason h3 {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 1.18rem;
  line-height: 1.5;
  color: var(--t-hi);
  margin-bottom: 10px;
}
.reason p {
  color: var(--t-md);
  line-height: 2;
  font-size: 0.98rem;
  position: relative;
}
.reason .num {
  position: absolute;
  right: 18px;
  top: 14px;
  font-family: var(--f-latin);
  font-weight: 600;
  font-size: 2.4rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.14);
}

/* ============================================================
   แกลเลอรี่
   ============================================================ */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(214px, 1fr));
  gap: clamp(20px, 3vw, 34px);
  margin-top: 48px;
}

.polaroid {
  background: #fffdf9;
  padding: 13px 13px 0;
  border-radius: 5px;
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.45);
  transform: rotate(var(--rot, -2deg));
  transition: transform 0.42s var(--ease), box-shadow 0.42s ease;
  cursor: pointer;
  position: relative;
}
.polaroid::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -13px;
  width: 76px;
  height: 25px;
  transform: translateX(-50%) rotate(-4deg);
  background: rgba(255, 209, 228, 0.7);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.25);
}
.polaroid .frame {
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  overflow: hidden;
  background: linear-gradient(150deg, #ffe1ec, #ecd6ff);
  display: flex;
  align-items: center;
  justify-content: center;
}
.polaroid .frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease);
}
.polaroid .ph {
  text-align: center;
  color: #a3547f;
  font-size: 0.9rem;
  line-height: 1.8;
  padding: 12px;
}
.polaroid .ph span {
  display: block;
  font-size: 1.9rem;
  margin-bottom: 6px;
}
.polaroid figcaption {
  font-family: var(--f-hand);
  color: #6f3d5b;
  text-align: center;
  padding: 13px 8px 17px;
  font-size: 1.05rem;
  line-height: 1.6;
}

/* Safari รุ่นเก่าที่ยังไม่รู้จัก aspect-ratio */
@supports not (aspect-ratio: 1 / 1) {
  .polaroid .frame {
    position: relative;
    height: 0;
    padding-top: 100%;
  }
  .polaroid .frame > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

/* lightbox */
.lightbox {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 2, 14, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.34s ease, visibility 0.34s ease;
  padding: calc(24px + var(--sa-t)) 24px calc(24px + var(--sa-b));
}
.lightbox.show {
  opacity: 1;
  visibility: visible;
}
.lightbox img {
  max-width: min(92vw, 900px);
  max-height: 72vh;
  border-radius: 12px;
  box-shadow: 0 34px 84px rgba(0, 0, 0, 0.7);
  animation: popIn 0.42s var(--ease) both;
  margin: 0 auto;
}
.lightbox .cap {
  color: var(--t-hi);
  font-family: var(--f-hand);
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  margin-top: 18px;
  text-align: center;
}
.lightbox .close {
  position: absolute;
  right: calc(16px + var(--sa-r));
  top: calc(16px + var(--sa-t));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--card-brd);
  color: #fff;
  font-size: 1.3rem;
  transition: background 0.25s ease, transform 0.25s ease;
}

/* ============================================================
   ไทม์ไลน์
   ============================================================ */
.timeline {
  margin-top: 50px;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 8px;
  bottom: 10px;
  width: 2px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--pink), var(--lilac) 60%, transparent);
}

.tl-item {
  position: relative;
  padding: 0 0 36px 54px;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #ffb3ce, var(--pink));
  box-shadow: 0 0 0 5px rgba(255, 111, 165, 0.16), 0 0 18px rgba(255, 111, 165, 0.8);
}
.tl-item .date {
  display: inline-block;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--gold);
  margin-bottom: 6px;
}
.tl-item h3 {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 1.24rem;
  line-height: 1.5;
  color: var(--t-hi);
  margin-bottom: 8px;
}
.tl-item p {
  color: var(--t-md);
  line-height: 2;
  max-width: 58ch;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   จดหมาย
   ============================================================ */
.letter-paper {
  margin: 44px auto 0;
  max-width: 700px;
  /* background-color + background-image ต้องอยู่ในบล็อกเดียวกัน
     ห้ามประกาศ background-image แยกทีหลัง ไม่งั้นสีพื้นจะหายกลายเป็นโปร่งใส */
  background-color: #fffdf7;
  background-image:
    radial-gradient(120% 90% at 18% 0%, rgba(255, 218, 234, 0.5), transparent 58%),
    radial-gradient(100% 80% at 100% 100%, rgba(255, 236, 214, 0.55), transparent 60%),
    linear-gradient(180deg, #fffdf8 0%, #fff7f4 100%);
  border-radius: 14px;
  padding: clamp(28px, 6vw, 60px) clamp(24px, 6vw, 60px);
  box-shadow: 0 34px 72px rgba(0, 0, 0, 0.5);
  position: relative;
  color: var(--ink);
  transform: rotate(-0.4deg);
}
.letter-paper::before,
.letter-paper::after {
  content: "";
  position: absolute;
  width: 92px;
  height: 26px;
  background: rgba(255, 205, 226, 0.55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.letter-paper::before {
  left: -18px;
  top: 24px;
  transform: rotate(-38deg);
}
.letter-paper::after {
  right: -18px;
  top: 24px;
  transform: rotate(38deg);
}

.letter-paper h3 {
  font-family: var(--f-hand);
  font-size: clamp(1.42rem, 4.6vw, 2rem);
  line-height: 1.6;
  color: var(--pink-deep);
  margin-bottom: 22px;
}
.letter-paper p {
  font-family: var(--f-hand);
  font-size: clamp(1.08rem, 3.2vw, 1.3rem);
  line-height: 2.05;
  color: var(--ink);
  margin-bottom: 20px;
}
.letter-paper p:last-child {
  margin-bottom: 0;
}

.letter-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0 20px;
  color: var(--pink);
}
.letter-rule::before,
.letter-rule::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(214, 58, 114, 0.35), transparent);
}

.letter-sign {
  text-align: right;
}
.letter-sign .from {
  font-family: var(--f-hand);
  font-size: clamp(1.05rem, 3vw, 1.22rem);
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.letter-sign .who {
  font-family: var(--f-hand);
  font-size: clamp(1.7rem, 5.4vw, 2.4rem);
  line-height: 1.5;
  color: var(--pink-deep);
}

/* ============================================================
   ปิดท้าย
   ============================================================ */
.finale {
  text-align: center;
  min-height: 86vh;
  min-height: calc(var(--vh) * 86);
  display: flex;
  align-items: center;
  justify-content: center;
}
.finale-q {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: clamp(1.45rem, 5.4vw, 2.7rem);
  line-height: 1.55;
  color: var(--t-hi);
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.5);
  margin: 0 auto 36px;
  max-width: 22ch;
}
.finale-btns {
  display: flex;
  gap: 18px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  min-height: 96px;
}
#btn-yes {
  padding: 17px 44px;
  font-family: var(--f-display);
  font-size: 1.12rem;
  font-weight: 600;
  border-radius: 99px;
  color: #fff;
  background: linear-gradient(100deg, var(--pink-deep), var(--pink), var(--lilac));
  background-size: 210% 100%;
  animation: shimmer 5s linear infinite;
  box-shadow: 0 16px 38px rgba(214, 58, 114, 0.5), var(--inset-hi);
  transform: scale(var(--s, 1));
  transition: transform 0.4s var(--ease);
}
#btn-no {
  padding: 15px 32px;
  font-family: var(--f-display);
  font-size: 1rem;
  font-weight: 400;
  border-radius: 99px;
  color: var(--t-md);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--card-brd);
  transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--ns, 1));
  transition: transform 0.42s cubic-bezier(0.2, 0.9, 0.2, 1.4), opacity 0.3s ease;
  position: relative;
}
.tease {
  position: absolute;
  left: 50%;
  bottom: -32px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--f-body);
  font-size: 0.9rem;
  color: var(--gold);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.tease.show {
  opacity: 1;
}

.finale-result {
  display: none;
}
.finale-result.show {
  display: block;
  animation: popIn 0.65s var(--ease) both;
}
.finale-result .big {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.9rem, 8vw, 4rem);
  line-height: 1.35;
  background: linear-gradient(96deg, #fff, var(--pink-200), var(--gold), var(--pink), #fff);
  background-size: 240% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 6s linear infinite;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.4));
  margin-bottom: 14px;
}
.finale-result .small {
  font-family: var(--f-hand);
  font-size: clamp(1.15rem, 3.6vw, 1.6rem);
  line-height: 1.9;
  color: var(--t-hi);
}
.finale-result .again {
  margin-top: 28px;
}

/* ============================================================
   เครื่องเล่นเพลง
   ============================================================ */
.player {
  position: fixed;
  z-index: 80;
  right: calc(14px + var(--sa-r));
  bottom: calc(78px + var(--sa-b));
  width: min(320px, calc(100vw - 28px));
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.14), rgba(22, 5, 24, 0.82));
  border: 1px solid var(--card-brd);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: var(--sh-2), var(--inset-hi);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease), visibility 0.28s;
}
.player.show {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.pl-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.pl-art {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  background: linear-gradient(150deg, var(--pink), var(--lilac));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}
.pl-art.playing {
  animation: beat 1.6s ease-in-out infinite;
}
.pl-meta {
  min-width: 0;
  flex: 1 1 auto;
  text-align: left;
}
.pl-title {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--t-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pl-artist {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--t-lo);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-bar {
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 6px;
}
.pl-bar > span {
  display: block;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}
.pl-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), var(--pink));
}
.pl-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--t-lo);
  font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
}

.pl-ctrl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.pl-ctrl button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--t-hi);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: transform 0.18s var(--ease), background 0.2s ease;
}
.pl-ctrl button:active {
  transform: scale(0.9);
}
.pl-ctrl .main {
  width: 54px;
  height: 54px;
  font-size: 1.15rem;
  background: linear-gradient(120deg, var(--pink-deep), var(--pink));
  border-color: rgba(255, 255, 255, 0.26);
}

.pl-list {
  margin-top: 14px;
  max-height: 148px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 10px;
}
.pl-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 11px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--t-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.2s ease;
}
.pl-list button.on {
  background: rgba(255, 111, 165, 0.24);
  color: #fff;
}
.pl-list button.dead {
  opacity: 0.38;
  text-decoration: line-through;
}
.pl-hint {
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--t-lo);
  text-align: center;
}

/* ============================================================
   ปุ่มลอย + จุดนำทาง + ท้ายเว็บ
   ============================================================ */
.fab-col {
  position: fixed;
  right: calc(14px + var(--sa-r));
  bottom: calc(14px + var(--sa-b));
  z-index: 82;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fab {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.22rem;
  color: #fff;
  background: linear-gradient(150deg, rgba(255, 111, 165, 0.94), rgba(193, 155, 255, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.4), var(--inset-hi);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: transform 0.25s var(--ease);
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}
.fab:active {
  transform: scale(0.92);
}
.fab.spin {
  animation: spin 5s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.dots {
  position: fixed;
  left: calc(14px + var(--sa-l));
  top: 50%;
  transform: translateY(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.dots a {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: transform 0.3s var(--ease), background 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}
.dots a::after {
  content: attr(data-label);
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  font-family: var(--f-body);
  font-size: 0.78rem;
  color: #fff;
  background: rgba(26, 4, 26, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 11px;
  border-radius: 99px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.dots a.active {
  background: var(--pink);
  box-shadow: 0 0 0 4px rgba(255, 111, 165, 0.22), 0 0 14px var(--pink);
  transform: scale(1.3);
}

footer {
  text-align: center;
  padding: 42px 22px calc(96px + var(--sa-b));
  color: var(--t-lo);
  font-size: 0.92rem;
  line-height: 2;
}
footer b {
  color: var(--pink-100);
  font-weight: 600;
}
footer .tag {
  font-family: var(--f-latin);
  letter-spacing: 0.22em;
  color: var(--gold);
}
footer .hb {
  color: var(--pink);
  display: inline-block;
  animation: beat 1.4s ease-in-out infinite;
}

/* ============================================================
   utility / animation
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
}
.reveal.in {
  opacity: 1;
  transform: none;
}
.reveal.d1 {
  transition-delay: 0.08s;
}
.reveal.d2 {
  transition-delay: 0.16s;
}
.reveal.d3 {
  transition-delay: 0.24s;
}
.reveal.d4 {
  transition-delay: 0.32s;
}
.reveal.d5 {
  transition-delay: 0.4s;
}
.reveal.d6 {
  transition-delay: 0.48s;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.86);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes beat {
  0%,
  100% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.22);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.16);
  }
  70% {
    transform: scale(1);
  }
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ============================================================
   iOS 14 และเก่ากว่า: flexbox ยังไม่รู้จัก gap
   ============================================================ */
@supports not (gap: 1px) {
  .hero-actions {
    margin-left: -7px;
    margin-right: -7px;
  }
  .hero-actions > * {
    margin: 7px;
  }
  .finale-btns > * {
    margin: 9px;
  }
  .fab-col > * + * {
    margin-top: 10px;
  }
  .dots > * + * {
    margin-top: 13px;
  }
  .hero-love > * + * {
    margin-left: 14px;
  }
  .pl-head > * + * {
    margin-left: 12px;
  }
  .pl-ctrl > * + * {
    margin-left: 10px;
  }
  .cd-nums > * + * {
    margin-left: 8px;
  }
  .pin > * + * {
    margin-left: 14px;
  }
  .letter-rule > * + * {
    margin-left: 12px;
  }
}

/* ============================================================
   เบราว์เซอร์ที่รู้จัก svh (iOS 15.4+) ใช้ค่านี้แม่นกว่า
   ============================================================ */
@supports (height: 100svh) {
  .hero {
    min-height: 100svh;
  }
  .finale {
    min-height: 86svh;
  }
  body.locked {
    height: 100svh;
  }
}

/* ============================================================
   เอฟเฟกต์ hover — เปิดเฉพาะเครื่องที่มีเมาส์
   (iPhone/iPad จะไม่มีสถานะ hover ค้างหลังแตะ)
   ============================================================ */
@media (hover: hover) and (pointer: fine) {
  .envelope:hover {
    transform: translateY(-8px) scale(1.03);
  }
  .open-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 20px 44px rgba(214, 58, 114, 0.6), var(--inset-hi);
  }
  .keypad button:hover {
    background: linear-gradient(158deg, rgba(255, 255, 255, 0.2), rgba(24, 5, 26, 0.45));
  }
  .btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 18px 38px rgba(214, 58, 114, 0.55), var(--inset-hi);
  }
  .btn.ghost:hover {
    background: rgba(255, 255, 255, 0.17);
    box-shadow: none;
  }
  .tile:hover,
  .cd-card:hover {
    transform: translateY(-6px);
  }
  .reason:hover {
    transform: translateY(-9px);
    border-color: rgba(255, 175, 205, 0.45);
    box-shadow: var(--sh-2), var(--inset-hi);
  }
  .reason:hover::before {
    opacity: 1;
  }
  .reason:hover .ic {
    transform: scale(1.16) rotate(-8deg);
  }
  .polaroid:hover {
    transform: rotate(0deg) translateY(-10px) scale(1.035);
    box-shadow: 0 32px 62px rgba(0, 0, 0, 0.55);
    z-index: 3;
  }
  .polaroid:hover .frame img {
    transform: scale(1.06);
  }
  .lightbox .close:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: rotate(90deg);
  }
  .fab:hover {
    transform: scale(1.1) rotate(6deg);
  }
  .dots a:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
  #btn-yes:hover {
    transform: scale(calc(var(--s, 1) * 1.06));
  }
  .pl-ctrl button:hover {
    background: rgba(255, 255, 255, 0.2);
  }
  .pl-list button:hover {
    background: rgba(255, 255, 255, 0.12);
  }
}

/* ============================================================
   responsive
   ============================================================ */
@media (max-width: 900px) {
  .dots {
    display: none;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15.5px;
  }
  .counter-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .fab {
    width: 46px;
    height: 46px;
    font-size: 1.08rem;
  }
  .player {
    bottom: calc(72px + var(--sa-b));
  }
  .letter-paper::before,
  .letter-paper::after {
    display: none;
  }
  .letter-paper {
    transform: none;
  }
  .tl-item {
    padding-left: 46px;
  }
  /* ลดความแรงของ blur ให้เลื่อนหน้าลื่นบนมือถือ */
  .tile,
  .reason,
  .cd-card,
  .btn.ghost,
  .keypad button {
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
  }
  .blob {
    filter: blur(72px);
  }
}

/* จอเตี้ยมาก (iPhone SE แนวตั้ง / มือถือแนวนอน) */
@media (max-height: 620px) {
  .keypad button {
    height: 52px;
    font-size: 1.3rem;
  }
  .lock-badge {
    width: 50px;
    height: 50px;
    font-size: 1.4rem;
    margin-bottom: 10px;
  }
  .lock-hint {
    margin-bottom: 14px;
  }
  .envelope {
    width: min(58vw, 240px);
    height: calc(min(58vw, 240px) * 0.66);
  }
  .open-btn {
    margin-top: 24px;
  }
  .hero {
    padding-top: calc(64px + var(--sa-t));
  }
}

/* จอใหญ่ */
@media (min-width: 1440px) {
  body {
    font-size: 17px;
  }
  .wrap {
    width: min(1180px, 100%);
  }
}

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