/* โทนสี ครีม ขาว น้ำตาลอ่อน ทองอ่อน — เขียนแบบ Mobile-First แล้วขยายด้วย media query */
:root {
  --cream: #fbf6ee;
  --paper: #fffdf8;
  --sand: #efe3d0;
  --latte: #c9a27a;
  --gold: #c9a46a;
  --gold-soft: #e8d3a8;
  --ink: #4a3728;
  --ink-soft: #7a6450;

  --font-display: "Mali", "Leelawadee UI", "Thonburi", "Noto Sans Thai", sans-serif;
  --font-body: "Sarabun", "Leelawadee UI", "Thonburi", "Noto Sans Thai", sans-serif;

  --gutter: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --ease: cubic-bezier(.22, .61, .36, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cream);
  background-image: radial-gradient(ellipse at 50% 0%, #fffaf2 0%, var(--cream) 60%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: hidden;
  overflow-wrap: break-word;
}

img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
[tabindex="-1"]:focus { outline: none; }

/* ---------- ปุ่ม ---------- */
.btn {
  font: inherit;
  font-family: var(--font-display);
  font-weight: 600;
  min-height: 48px;
  min-width: 48px;
  padding: .7rem 1.6rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .2s var(--ease), background-color .2s, box-shadow .2s, opacity .4s;
}
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  font-size: 1.15rem;
  padding: .85rem 2rem;
  box-shadow: 0 6px 18px rgba(74, 55, 40, .18);
}
.btn-primary:hover { background: #5c4532; }
.btn-ghost {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--gold-soft);
}
.btn-ghost:hover { background: #fff7ea; }
.btn[disabled] { cursor: default; }

/* ---------- ฉาก ---------- */
.scene {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(var(--safe-top) + 24px);
  padding-bottom: calc(var(--safe-bottom) + 32px);
  padding-left: max(var(--gutter), var(--safe-left));
  padding-right: max(var(--gutter), var(--safe-right));
  opacity: 0;
  transition: opacity .8s var(--ease);
}
.scene.is-active { opacity: 1; }

/* ---------- ฉากที่ 1 : เค้ก ---------- */
.scene-cake {
  display: flex;
  align-items: center;
  justify-content: center;
}
.cake-inner {
  width: 100%;
  max-width: 44rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(.5rem, 2.2vh, 1.25rem);
  text-align: center;
}
.cake-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.75rem, 8.5vw, 3.25rem);
  line-height: 1.25;
  text-wrap: balance;
}
.cake-subtitle {
  margin: 0;
  font-size: clamp(1.05rem, 4.2vw, 1.3rem);
  color: var(--ink-soft);
  text-wrap: balance;
}
.cake-wrap {
  position: relative;
  width: min(78vw, 300px, 46vh);
  width: min(78vw, 300px, 46dvh);
  min-width: 150px;
  margin-top: .25rem;
}
.cake {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
  transform-origin: 50% 100%;
  animation: cakeBob 3.2s ease-in-out infinite;
}
/* เค้กลอยขึ้นลงและเอียงเบา ๆ ตลอดเวลา พอเป่าเทียนแล้วเด้งดีใจหนึ่งครั้ง */
@keyframes cakeBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25%      { transform: translateY(-6px) rotate(-1.5deg); }
  50%      { transform: translateY(0) rotate(0deg); }
  75%      { transform: translateY(-6px) rotate(1.5deg); }
}
.is-blown .cake { animation: cakeHop .9s var(--ease) .35s 1 both, cakeBob 3.2s ease-in-out 1.25s infinite; }
@keyframes cakeHop {
  0%   { transform: translateY(0) scale(1, 1); }
  20%  { transform: translateY(2px) scale(1.06, .92); }
  50%  { transform: translateY(-22px) scale(.96, 1.05); }
  75%  { transform: translateY(0) scale(1.04, .96); }
  100% { transform: translateY(0) scale(1, 1); }
}

.cake-action {
  display: grid;
  place-items: center;
  min-height: 64px;
  width: 100%;
}
.cake-action > * { grid-area: 1 / 1; }
.blow-message {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 6vw, 1.9rem);
  color: var(--ink);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
  pointer-events: none;
}
.is-blown .blow-message { opacity: 1; transform: none; }
.is-blown #blow-button { opacity: 0; pointer-events: none; }

/* เปลวไฟ */
.flame, .flame-glow, .smoke {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}
.flame { animation: flicker 1.6s ease-in-out infinite alternate; }
.flame-glow { transform-origin: 50% 50%; animation: glow 2s ease-in-out infinite alternate; }
.smoke { opacity: 0; }
.wind path { stroke-dasharray: 60; stroke-dashoffset: 60; opacity: 0; }

@keyframes flicker {
  0%   { transform: rotate(-2deg) scale(1, 1); }
  50%  { transform: rotate(1.5deg) scale(.96, 1.05); }
  100% { transform: rotate(-1deg) scale(1.03, .97); }
}
@keyframes glow {
  from { opacity: .35; transform: scale(1); }
  to   { opacity: .55; transform: scale(1.12); }
}

.is-blown .flame { animation: blowOut 1s var(--ease) forwards; }
.is-blown .flame-glow { animation: fadeOut .7s ease forwards; }
.is-blown .smoke { animation: smokeUp 2.2s ease-out .55s forwards; }
.is-blown .wind path { animation: windSweep .9s ease-out forwards; }
.is-blown .wind path:nth-child(2) { animation-delay: .08s; }
.is-blown .wind path:nth-child(3) { animation-delay: .16s; }

@keyframes blowOut {
  0%   { transform: none; opacity: 1; }
  30%  { transform: skewX(-22deg) scale(.95, .85); opacity: 1; }
  60%  { transform: skewX(-14deg) scale(.6, .5); opacity: .7; }
  100% { transform: scale(.1, .05); opacity: 0; }
}
@keyframes fadeOut { to { opacity: 0; transform: scale(.4); } }
@keyframes smokeUp {
  0%   { opacity: 0; transform: translateY(0); }
  25%  { opacity: .75; }
  100% { opacity: 0; transform: translateY(-18px); }
}
@keyframes windSweep {
  0%   { opacity: 0; stroke-dashoffset: 60; transform: translateX(0); }
  40%  { opacity: .9; }
  100% { opacity: 0; stroke-dashoffset: 0; transform: translateX(30px); }
}

/* ประกายเล็ก ๆ หลังเป่าเทียน */
.sparkles { position: absolute; inset: 0; pointer-events: none; }
.sparkles span {
  position: absolute;
  color: var(--gold);
  font-size: clamp(.8rem, 3vw, 1.1rem);
  opacity: 0;
}
.sparkles span:nth-child(1) { left: 18%; top: 4%; }
.sparkles span:nth-child(2) { left: 78%; top: 2%; }
.sparkles span:nth-child(3) { left: 6%;  top: 30%; }
.sparkles span:nth-child(4) { left: 90%; top: 28%; }
.sparkles span:nth-child(5) { left: 34%; top: -6%; }
.sparkles span:nth-child(6) { left: 62%; top: -8%; }
.is-blown .sparkles span { animation: sparkle 1.4s ease-out forwards; }
.is-blown .sparkles span:nth-child(2n) { animation-delay: .9s; }
.is-blown .sparkles span:nth-child(2n+1) { animation-delay: 1.1s; }
@keyframes sparkle {
  0%   { opacity: 0; transform: scale(.3) rotate(0); }
  40%  { opacity: 1; transform: scale(1.1) rotate(20deg); }
  100% { opacity: 0; transform: scale(.8) rotate(45deg) translateY(-6px); }
}

/* ---------- ฉากที่ 2 : รูปภาพ ---------- */
.scene-gallery {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.gallery-header {
  text-align: center;
  padding-block: clamp(1rem, 6vh, 3rem) clamp(1.5rem, 5vh, 2.5rem);
  max-width: 34rem;
}
.gallery-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  line-height: 1.3;
}
.gallery-hint { margin: .35rem 0 0; color: var(--ink-soft); font-size: 1rem; }
.gallery-hint::after {
  content: "↓";
  display: block;
  margin-top: .4rem;
  color: var(--latte);
  animation: nudge 2s ease-in-out infinite;
}
@keyframes nudge { 50% { transform: translateY(5px); } }

.photo-list {
  width: 100%;
  max-width: 920px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(3rem, 12vh, 6rem);
}

.photo {
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .9rem;
}
/* กรอบรูปแบบขอบขาว ทุกรูปขนาดเท่ากัน (4:3) เห็นรูปเต็มทั้งรูป ไม่บีบ ไม่ยืด ไม่ครอป
   รูปแนวตั้งจะมีพื้นสีครีมด้านข้าง รูปที่ยาวกว่า 4:3 จะมีพื้นสีครีมด้านบนล่าง
   ความกว้างจำกัดด้วยความสูงจอด้วย (ราว 70% ของความสูง × 4/3) รูปจึงไม่ล้นจอ */
.photo-frame {
  --frame-w: min(100%, 640px, 93vh);
  --frame-w: min(100%, 640px, 93svh);
  width: var(--frame-w);
  background: var(--paper);
  padding: clamp(6px, 2vw, 12px);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(74, 55, 40, .12);
}
.photo-frame img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: 3px;
  background: var(--cream);
}
.photo-caption {
  margin: 0;
  max-width: 36rem;
  text-align: center;
  font-size: clamp(1.02rem, 4vw, 1.15rem);
  line-height: 1.65;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* Placeholder เมื่อยังไม่มีไฟล์รูป */
.photo-placeholder {
  width: min(100%, 640px, 93vh);
  width: min(100%, 640px, 93svh);
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--latte);
  border-radius: 6px;
  background: repeating-linear-gradient(-45deg, #f8efe1 0 14px, #f4e9d8 14px 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: 1rem;
  text-align: center;
  color: var(--ink-soft);
}
.photo-placeholder strong {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 4.5vw, 1.3rem);
  color: var(--ink);
}
.photo-placeholder code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: .9rem;
  background: var(--paper);
  border-radius: 4px;
  padding: .1rem .4rem;
  overflow-wrap: anywhere;
}
.photo-placeholder small { font-size: .9rem; line-height: 1.5; }

/* ค่อย ๆ ปรากฏเมื่อเลื่อนมาถึง (ใช้แค่ opacity + transform ไม่ทำให้เลื่อนกระตุก) */
.reveal .photo {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}
.reveal .photo.is-visible { opacity: 1; transform: none; }

/* โหมด slideshow: รูปซ้อนกันในตำแหน่งเดียว แสดงทีละรูป */
.slideshow .photo-list { display: grid; gap: 0; }
.slideshow .photo {
  grid-area: 1 / 1;
  align-self: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s var(--ease), visibility 0s linear 1s;
}
.slideshow .photo.is-current {
  opacity: 1;
  visibility: visible;
  transition: opacity 1s var(--ease), visibility 0s;
}
.slideshow .photo-frame { --frame-w: min(100%, 640px, 72vh); --frame-w: min(100%, 640px, 72svh); }
.slideshow .gallery-hint::after { content: none; }

/* ---------- แสดงรูปแบบม้วนฟิล์ม ----------
   แต่ละรูปเป็นเฟรมบนแถบฟิล์มสีน้ำตาลเข้ม มีรูหนามเตยสองข้าง
   โหมดเลื่อนดู เฟรมต่อกันเป็นม้วนยาวเส้นเดียว ค่อย ๆ ปรากฏทีละเฟรมเมื่อเลื่อนมาถึง */
.photo {
  --film: #2b221c;
  --film-hole: #fbf6ee;
  --film-side: clamp(24px, 7vw, 38px);
  position: relative;
  width: min(100%, calc(640px + 2 * var(--film-side)), calc(93vh + 2 * var(--film-side)));
  width: min(100%, calc(640px + 2 * var(--film-side)), calc(93svh + 2 * var(--film-side)));
  padding: clamp(12px, 3vw, 18px) var(--film-side);
  gap: .7rem;
  background: var(--film);
}
/* รูหนามเตยด้านซ้ายและขวา */
.photo::before,
.photo::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(9px, 2.6vw, 13px);
  background: repeating-linear-gradient(to bottom,
    transparent 0 6px, var(--film-hole) 6px 16px, transparent 16px 24px);
  opacity: .92;
}
.photo::before { left: calc((var(--film-side) - clamp(9px, 2.6vw, 13px)) / 2); }
.photo::after { right: calc((var(--film-side) - clamp(9px, 2.6vw, 13px)) / 2); }
/* ตัวรูปในเฟรมฟิล์ม: ขนาดเท่ากันทุกเฟรม เห็นรูปเต็ม */
.photo .photo-frame {
  --frame-w: 100%;
  padding: 0;
  background: #15110e;
  border-radius: 2px;
  box-shadow: none;
}
.photo .photo-frame img { background: #15110e; border-radius: 2px; }
.photo .photo-caption { color: #f3e6cf; }
.photo .photo-placeholder { width: 100%; }
/* เลขเฟรมเล็ก ๆ ที่ขอบฟิล์มเหมือนฟิล์มจริง */
.film-no {
  position: absolute;
  top: 1px;
  left: calc(var(--film-side) + 2px);
  font-size: .7rem;
  line-height: 1;
  letter-spacing: .08em;
  color: #e8b45c;
  opacity: .8;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
/* โหมดเลื่อนดู: เฟรมต่อกันเป็นม้วนเดียว มีเส้นคั่นบาง ๆ ระหว่างเฟรม */
.reveal .photo-list { gap: 0; }
.reveal .photo + .photo { border-top: 2px solid #1c1612; }
.reveal .photo:first-child { border-radius: 6px 6px 0 0; }
.reveal .photo:last-child { border-radius: 0 0 6px 6px; }
.reveal .photo:only-child { border-radius: 6px; }
/* โหมด slideshow: แต่ละสไลด์เป็นฟิล์มหนึ่งเฟรม */
.slideshow .photo {
  width: min(100%, calc(640px + 2 * var(--film-side)), calc(72vh + 2 * var(--film-side)));
  width: min(100%, calc(640px + 2 * var(--film-side)), calc(72svh + 2 * var(--film-side)));
  border-radius: 6px;
}
.slide-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .75rem 1rem;
  margin-top: 1.5rem;
}
.slide-counter { min-width: 4ch; text-align: center; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.gallery-end {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  padding-block: clamp(4rem, 18vh, 8rem) 2rem;
}
.slideshow .gallery-end { padding-block: 2rem; }
.gallery-end-text {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 5vw, 1.5rem);
  text-wrap: balance;
}

/* ---------- ฉากที่ 3 : โปสการ์ด ---------- */
.scene-postcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  perspective: 1200px;
}
.postcard {
  position: relative;
  width: min(100%, 36rem);
  background: var(--paper);
  background-image:
    linear-gradient(rgba(201, 164, 106, .05) 1px, transparent 1px);
  background-size: 100% 2.1em;
  border-radius: 6px;
  padding: clamp(1.4rem, 6vw, 2.75rem);
  box-shadow: 0 2px 4px rgba(74, 55, 40, .06), 0 18px 40px rgba(74, 55, 40, .14);
  transform-origin: 50% 0%;
}
/* ขอบบาง ๆ ด้านใน */
.postcard::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid var(--gold-soft);
  border-radius: 3px;
  pointer-events: none;
}
/* ลายมุมเล็ก ๆ */
.postcard::after {
  content: "❦";
  position: absolute;
  bottom: 14px;
  right: 18px;
  font-size: 1.1rem;
  color: var(--gold-soft);
  pointer-events: none;
}
.postcard-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px dashed var(--gold-soft);
}
.postcard-heading {
  margin: 0;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.45rem, 6.5vw, 2.1rem);
  line-height: 1.3;
  text-wrap: balance;
}
.stamp {
  flex: none;
  width: clamp(48px, 13vw, 64px);
  aspect-ratio: 4 / 5;
  border: 2px dashed var(--latte);
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-size: clamp(1.3rem, 6vw, 1.8rem);
  background: #fbf3e4;
  transform: rotate(4deg);
}
.postcard-message {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.1rem, 4.6vw, 1.35rem);
  line-height: 1.9;
  white-space: pre-line;
}
.postcard-message .line { display: block; }
.postcard-signature {
  margin: 1.2rem 0 0;
  text-align: right;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 4.4vw, 1.25rem);
  color: var(--ink-soft);
}
.postcard-signature:empty { display: none; }

/* Animation เปิดการ์ด แล้วค่อย ๆ เผยข้อความทีละบรรทัด */
.scene-postcard.is-opening .postcard { animation: cardOpen 1.1s var(--ease) both; }
.scene-postcard .reveal-line { opacity: 0; transform: translateY(6px); }
.scene-postcard.is-opening .reveal-line {
  animation: lineIn .8s var(--ease) both;
  animation-delay: calc(.9s + var(--i, 0) * .45s);
}
.scene-postcard .replay { opacity: 0; }
.scene-postcard.is-opening .replay { animation: lineIn .8s var(--ease) both; animation-delay: var(--replay-delay, 3s); }

@keyframes cardOpen {
  0%   { opacity: 0; transform: rotateX(-75deg) translateY(10px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; }
}
@keyframes lineIn { to { opacity: 1; transform: none; } }

/* ---------- ปุ่มเพลง ---------- */
.top-tools {
  position: fixed;
  z-index: 20;
  top: calc(var(--safe-top) + 12px);
  right: calc(var(--safe-right) + 12px);
  display: flex;
  gap: 8px;
  align-items: center;
}
.music-toggle, .admin-link {
  min-width: 48px;
  min-height: 48px;
  padding: .4rem .9rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border-radius: 999px;
  border: 1.5px solid var(--gold-soft);
  background: rgba(255, 253, 248, .92);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
  touch-action: manipulation;
}
.admin-link { text-decoration: none; font-family: var(--font-display); font-weight: 600; }
.admin-link:hover { background: #fff7ea; }
.admin-link:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.music-toggle:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.music-toggle .music-icon { font-size: 1.15rem; line-height: 1; }
.music-toggle[aria-pressed="false"] .music-icon { opacity: .45; text-decoration: line-through; }

/* ---------- เพลง YouTube แบบเสียงอย่างเดียว ----------
   ตัวเล่นวิดีโอยังทำงานอยู่ แต่ซ่อนไว้นอกสายตา ผู้ชมได้ยินแค่เสียง */
.yt-audio-host {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
/* กล่องข้อความเพลง (เฉพาะตอนมีเรื่องต้องแจ้ง) */
.music-dock {
  position: fixed;
  z-index: 19;
  right: calc(var(--safe-right) + 12px);
  bottom: calc(var(--safe-bottom) + 12px);
  width: 224px;
  max-width: calc(100vw - 24px);
  padding: 6px 12px 12px;
  background: var(--paper);
  border: 1px solid var(--gold-soft);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(74, 55, 40, .16);
}
.music-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
}
.music-dock-title {
  min-width: 0;
  font-size: .9rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dock-close {
  flex: none;
  width: 44px;
  height: 44px;
  margin-right: -8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.dock-close:focus-visible { outline: 3px solid var(--gold); outline-offset: 0; }
.music-player {
  width: 200px;
  height: 200px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.music-player iframe { display: block; width: 200px; height: 200px; border: 0; }
.music-dock-msg { margin: 0; font-size: .88rem; line-height: 1.5; color: var(--ink); }
.music-dock-msg:empty { display: none; }
/* มีปุ่มมุมขวาบน: เว้นที่ด้านบนไม่ให้ปุ่มทับหัวข้อ */
body.has-tools .scene { padding-top: calc(var(--safe-top) + 76px); }

/* ---------- จอใหญ่ขึ้น ---------- */
@media (min-width: 768px) {
  :root { --gutter: 32px; }
  .photo-frame { padding: 14px; }
  .cake-wrap { width: min(60vw, 360px, 46vh); width: min(60vw, 360px, 46dvh); }
}

/* โทรศัพท์แนวนอน: หน้าจอเตี้ย จัดเค้กให้เล็กลงเพื่อให้ปุ่มอยู่ในจอ */
@media (max-height: 500px) and (orientation: landscape) {
  .scene,
  body.has-tools .scene { padding-top: calc(var(--safe-top) + 12px); padding-bottom: calc(var(--safe-bottom) + 16px); }
  .cake-inner { gap: .35rem; }
  .cake-title { font-size: clamp(1.5rem, 5vw, 2.2rem); }
  .cake-wrap { width: min(40vw, 38vh); width: min(40vw, 38dvh); min-width: 120px; }
}

/* ผู้ที่ตั้งค่าลดการเคลื่อนไหว */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .2s !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  .flame { animation: none; }
  .cake, .is-blown .cake { animation: none; }
  .reveal .photo { transform: none; }
}
