/* =========================================================
   Project Selam – A Royal Tribute
   Mobile-first (390–430px portrait), Telegram webview safe
   ========================================================= */

:root {
  --gold: #D4AF37;
  --gold-light: #F5D78E;
  --gold-pale: #FFF1C9;
  --gold-deep: #9C7A1E;
  --rose: #F4B6C2;
  --rose-deep: #D9738A;

  --plum-950: #12071c;
  --plum-900: #1d0c2b;
  --plum-800: #2c1440;
  --navy: #0e1030;

  --ink: #FBF4EA;
  --ink-soft: rgba(251, 244, 234, .82);
  --ink-mute: rgba(251, 244, 234, .58);

  --glass-bg: linear-gradient(145deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .035));
  --glass-border: rgba(245, 215, 142, .26);
  --radius: 24px;

  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ethiopic: "Noto Sans Ethiopic", "Nyala", "Abyssinica SIL", sans-serif;

  --ease-out: cubic-bezier(.2, .7, .2, 1);
}

[hidden] { display: none !important; }

/* ---------- Base ---------- */
html {
  background: var(--plum-950);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* overflow-x is set on <body> only, so it propagates to the viewport and the page keeps native
   momentum scrolling (setting it on both html and body turns body into a sluggish scroll box) */
body.site {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--plum-950);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body.site button,
body.site a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Small utilities (formerly from the Tailwind CDN) */
.text-center { text-align: center; }
.block { display: block; }
.relative { position: relative; }
.z-10 { z-index: 10; }
.font-body { font-family: var(--font-body); }

main, .site-footer { overflow-x: clip; }

.amharic-text {
  font-family: var(--font-ethiopic);
  letter-spacing: .02em;
}

/* ---------- Background layers ---------- */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(212, 175, 55, .22), transparent 60%),
    radial-gradient(90% 50% at 100% 40%, rgba(244, 182, 194, .14), transparent 65%),
    radial-gradient(90% 60% at 0% 85%, rgba(120, 60, 160, .28), transparent 65%),
    linear-gradient(180deg, var(--plum-900) 0%, var(--plum-950) 45%, var(--navy) 100%);
  transform: translateZ(0); /* own GPU layer: never repainted while scrolling */
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  display: block;
  transform: translateZ(0);
}

/* ---------- Layout ---------- */
.chapter {
  position: relative;
  contain: layout paint; /* lets the browser skip off-screen chapters while scrolling */
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 88px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.chapter--hero {
  min-height: 100vh;
  min-height: 100svh;
  padding-top: calc(76px + env(safe-area-inset-top));
  padding-bottom: 40px;
}

.wrap {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.chapter-head { text-align: center; margin-bottom: 28px; }

.eyebrow {
  margin: 0 0 10px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--gold-light);
  opacity: .9;
}

.h-display {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.9rem, 8.4vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -.01em;
}

.lede {
  margin: 16px auto 0;
  max-width: 34ch;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

.ornament {
  display: block;
  width: 120px;
  height: 12px;
  margin: 16px auto 0;
}

/* Shimmering gold text */
.text-gold {
  background: linear-gradient(100deg, #b8892b 0%, #f5d78e 22%, #fff6d8 38%, #e8c15a 55%, #b8892b 75%, #f5d78e 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  background-position: 30% center;
}
/* only the hero title shimmers – each shimmer repaints its text every frame */
.hero-title .text-gold { animation: shimmer 7s linear infinite; }

/* ---------- Glassmorphism ---------- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, .35),
    inset 0 1px 0 rgba(255, 255, 255, .14);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(44, 20, 64, .9); }
}

/* Phones: live blur over the animated 3D background is re-computed every frame and is the
   main cause of scroll lag on mid-range Android / Telegram. A tinted translucent panel
   looks almost identical on this dark background and costs nothing. */
@media (hover: none), (max-width: 767px) {
  .glass,
  .date-badge,
  .next-chapter {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .glass {
    background:
      linear-gradient(145deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .02)),
      rgba(38, 17, 56, .74);
  }
  .date-badge,
  .next-chapter {
    background:
      linear-gradient(135deg, rgba(212, 175, 55, .22), rgba(244, 182, 194, .1)),
      rgba(38, 17, 56, .7);
  }
}

/* Animations in chapters that are off screen are paused (class set by main.js) */
.is-offscreen *,
.is-offscreen *::before,
.is-offscreen *::after {
  animation-play-state: paused !important;
}

/* ---------- Scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity .9s ease var(--d, 0s),
    transform .9s var(--ease-out) var(--d, 0s);
}
.reveal.is-visible { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

/* =========================================================
   SECTION 1 · Hero
   ========================================================= */
.portrait-stage {
  position: relative;
  width: 220px;
  margin: 70px auto 28px;
}

.tiara {
  position: absolute;
  left: 50%;
  top: -74px;
  width: 168px;
  margin-left: -84px;
  z-index: 3;
  filter: drop-shadow(0 0 12px rgba(245, 215, 142, .65)) drop-shadow(0 4px 6px rgba(0, 0, 0, .35));
  animation: tiaraFloat 5s ease-in-out infinite;
}
.tiara-gem { animation: gemGlow 2.8s ease-in-out infinite; transform-origin: 100px 21px; }

.portrait {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  padding: 6px;
  background: conic-gradient(from 0deg, #b8892b, #fff1b8, #d4af37, #f4b6c2, #d4af37, #fff1b8, #b8892b);
  box-shadow:
    0 0 40px rgba(212, 175, 55, .45),
    0 0 100px rgba(244, 182, 194, .22);
}

.portrait-halo {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px dashed rgba(245, 215, 142, .45);
  animation: spin 40s linear infinite;
  pointer-events: none;
}

.portrait img,
.portrait .photo-fallback {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 22%;
  border: 3px solid var(--plum-900);
  background: var(--plum-900);
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.05rem, 9.6vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: -.015em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .35);
}
.hero-title .block { display: block; }
.hero-title .block:first-child {
  font-size: .56em;
  font-weight: 500;
  font-style: italic;
  color: var(--ink-soft);
  letter-spacing: .01em;
  margin-bottom: 6px;
}
.hero-name { font-style: italic; }

.date-badge {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 10px;
  margin-top: 22px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--gold-pale);
  background: linear-gradient(135deg, rgba(212, 175, 55, .22), rgba(244, 182, 194, .12));
  border: 1px solid rgba(245, 215, 142, .5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 0 24px rgba(212, 175, 55, .25), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.date-badge .amharic-text { font-size: .95rem; }

.hero-lede {
  margin: 22px auto 0;
  max-width: 32ch;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.motion-tip {
  margin: 18px 0 0;
  font-size: .78rem;
  letter-spacing: .08em;
  color: var(--gold-light);
  opacity: .85;
}

/* ---------- Chapter-to-chapter navigation ---------- */
.next-nav {
  display: flex;
  justify-content: center;
  margin-top: 40px;
}
.chapter--hero .next-nav { margin-top: 28px; }

.next-chapter {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 220px;
  min-height: 56px;
  padding: 12px 28px 8px;
  border-radius: 28px;
  text-decoration: none;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(212, 175, 55, .2), rgba(244, 182, 194, .1));
  border: 1px solid rgba(245, 215, 142, .45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, .3), 0 0 22px rgba(212, 175, 55, .18);
  transition: transform .2s ease, box-shadow .2s ease;
}
.next-chapter:active { transform: scale(.97); }
.next-chapter:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }

.next-label {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--gold-light);
}
.next-title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
}
.next-arrow {
  width: 22px;
  height: 22px;
  color: var(--gold-light);
  animation: bob 2s ease-in-out infinite;
}
.next-chapter--top .next-arrow { transform: rotate(180deg); animation: none; }

/* =========================================================
   SECTION 2 · Dual Leadership (tabs + flip card)
   ========================================================= */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.tab {
  min-height: 48px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: 600 .84rem/1.2 var(--font-body);
  cursor: pointer;
  transition: background .35s ease, color .35s ease, box-shadow .35s ease;
}
.tab[aria-selected="true"] {
  background: linear-gradient(135deg, #f5d78e, #d4af37);
  color: var(--plum-900);
  box-shadow: 0 4px 18px rgba(212, 175, 55, .4);
}
.tab:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

.flip {
  perspective: 1200px;
  -webkit-perspective: 1200px;
  cursor: pointer;
  border-radius: var(--radius);
  outline: none;
}
.flip:focus-visible { box-shadow: 0 0 0 2px var(--gold-light); }

.flip-inner {
  display: grid;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform .9s var(--ease-out);
}
.flip.is-flipped .flip-inner { transform: rotateY(180deg); }

.flip-face {
  grid-area: 1 / 1;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.flip-front { transform: rotateY(0deg); }
.flip-back  { transform: rotateY(180deg); }

/* Flip faces use a non-backdrop glass – backdrop-filter breaks 3D flips in Safari */
.card-face {
  padding: 30px 24px 22px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(212, 175, 55, .18), transparent 60%),
    linear-gradient(160deg, rgba(64, 30, 88, .92), rgba(29, 12, 43, .94));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .12);
}

.card-icon {
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  display: block;
  filter: drop-shadow(0 0 14px rgba(245, 215, 142, .45));
}

.card-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-pale);
}

.card-text { margin: 0; color: var(--ink-soft); font-size: 1rem; }

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}
.chips li {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--gold-pale);
  background: rgba(212, 175, 55, .14);
  border: 1px solid rgba(245, 215, 142, .3);
}

.flip-hint {
  margin: 18px 0 0;
  font-size: .78rem;
  color: var(--ink-mute);
  letter-spacing: .04em;
}

/* =========================================================
   SECTION 3 · Nurturing heart
   ========================================================= */
.heart-stage {
  position: relative;
  width: 170px;
  height: 170px;
  margin: 0 auto 30px;
  display: grid;
  place-items: center;
}

.heart-svg {
  position: relative;
  z-index: 2;
  width: 150px;
  filter: drop-shadow(0 0 22px rgba(244, 182, 194, .75)) drop-shadow(0 0 50px rgba(217, 115, 138, .35));
  animation: heartbeat 2.6s ease-in-out infinite;
  transform-origin: 50% 55%;
}

.pulse-ring {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 2px solid rgba(244, 182, 194, .55);
  animation: ring 2.4s ease-out infinite;
}

.quote {
  margin: 0;
  padding: 26px 22px;
  position: relative;
}
.quote::before {
  content: "\201C";
  position: absolute;
  top: -8px;
  left: 16px;
  font-family: var(--font-display);
  font-size: 4.5rem;
  line-height: 1;
  color: var(--gold);
  opacity: .55;
}
.quote p {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.18rem;
  line-height: 1.6;
  color: var(--ink);
}

/* =========================================================
   SECTION 4 · Letter + typewriter
   ========================================================= */
.letter {
  position: relative;
  padding: 44px 24px 28px;
  margin-top: 26px;
  background:
    radial-gradient(100% 60% at 50% 0%, rgba(244, 182, 194, .14), transparent 70%),
    var(--glass-bg);
}

.letter-seal {
  position: absolute;
  top: -28px;
  left: 50%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  filter: drop-shadow(0 4px 14px rgba(217, 115, 138, .55));
}

.letter-greeting {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--gold-light);
}

.tw {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.16rem;
  line-height: 1.8;
  color: var(--ink);
}
.tw-ghost { visibility: hidden; }
.tw-live {
  position: absolute;
  inset: 0;
}
.tw-live::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: -.18em;
  background: var(--gold-light);
  animation: blink 1s steps(1) infinite;
}
.tw.is-done .tw-live::after { display: none; }

.signature {
  margin: 24px 0 0;
  text-align: right;
  font-size: .92rem;
  color: var(--ink-soft);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1s ease, transform 1s var(--ease-out);
}
.letter.is-done .signature { opacity: 1; transform: none; }
.signature-name {
  display: block;
  margin-top: 4px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--gold-light);
}

/* =========================================================
   SECTION 5 · Blessings
   ========================================================= */
.wish-star {
  display: block;
  width: min(260px, 80vw);
  margin: 0 auto 24px;
  overflow: visible;
}
.star-core {
  transform-origin: 140px 68px;
  animation: starPulse 3.2s ease-in-out infinite;
  filter: drop-shadow(0 0 10px rgba(255, 243, 196, .9));
}
.star-glow { transform-origin: 140px 70px; animation: glowPulse 3.2s ease-in-out infinite; }
.star-tail {
  stroke-dasharray: 160;
  stroke-dashoffset: 160;
  animation: tailDraw 4.5s ease-in-out infinite;
}

.blessing-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.blessing {
  padding: 22px 20px;
  text-align: center;
}
.blessing-icon { width: 34px; height: 34px; margin: 0 auto 8px; display: block; }
.blessing h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--gold-pale);
}
.blessing p { margin: 0; color: var(--ink-soft); font-size: .96rem; }

/* =========================================================
   SECTION 6 · Cake & candles
   ========================================================= */
.cake {
  width: min(100%, 360px);
  margin: 12px auto 0;
}

.candle-row {
  position: relative;
  z-index: 2;
  width: 76%;
  /* % margins resolve against width: pulls candles down onto the top tier (y=40 of a 320×200 viewBox) */
  margin: 0 auto -12.5%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.candle {
  position: relative;
  width: 48px;
  min-width: 48px;
  height: 104px;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
  border-radius: 12px;
}
.candle:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

.candle-stick {
  width: 12px;
  height: 56px;
  border-radius: 3px 3px 2px 2px;
  background: repeating-linear-gradient(135deg, #fff6e9 0 6px, #f4b6c2 6px 12px);
  box-shadow: inset -3px 0 0 rgba(0, 0, 0, .08), 0 0 10px rgba(255, 220, 160, .25);
}
.candle-wick {
  width: 2px;
  height: 7px;
  background: #3a2a1a;
  border-radius: 1px;
}

.flame {
  position: absolute;
  bottom: 60px;
  left: 50%;
  width: 16px;
  height: 26px;
  margin-left: -8px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 78%, #ffffff 0 16%, #ffe58a 34%, #ffb340 60%, rgba(255, 120, 40, 0) 76%);
  transform-origin: 50% 90%;
  animation: flicker 1.3s ease-in-out infinite alternate;
  transition: opacity .35s ease, transform .35s ease;
}
.flame::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  margin: -34px 0 0 -32px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 100, .45), rgba(255, 200, 100, 0) 65%);
  pointer-events: none;
}

.smoke {
  position: absolute;
  bottom: 62px;
  left: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: rgba(225, 222, 235, .6);
  filter: blur(3px);
  opacity: 0;
  pointer-events: none;
}

.candle.is-out .flame { opacity: 0; transform: scale(.15) translateY(8px); animation: none; }
.candle.is-out .smoke { animation: smoke 1.8s ease-out forwards; }

.cake-svg {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .4));
}

.candle-status {
  margin: 18px 0 0;
  min-height: 1.6em;
  font-size: .9rem;
  color: var(--ink-mute);
  letter-spacing: .03em;
}

.finale {
  margin-top: 26px;
  padding: 26px 22px 24px;
  opacity: 0;
  transform: translateY(16px) scale(.96);
  transition: opacity .8s ease, transform .8s var(--ease-out);
}
.finale.is-shown { opacity: 1; transform: none; }

.finale-crown {
  width: 92px;
  margin: 0 auto 8px;
  display: block;
  filter: drop-shadow(0 0 12px rgba(245, 215, 142, .7));
  animation: tiaraFloat 4s ease-in-out infinite;
}
.finale-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.7rem;
  line-height: 1.2;
}
.finale-amharic {
  margin: 10px 0 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--rose);
}
.finale-text { margin: 12px auto 0; max-width: 32ch; color: var(--ink-soft); }

.btn-gold {
  min-height: 48px;
  margin-top: 20px;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #f5d78e, #d4af37);
  color: var(--plum-900);
  font: 600 .92rem/1 var(--font-body);
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(212, 175, 55, .4);
  transition: transform .2s ease, box-shadow .2s ease;
}
.btn-gold:active { transform: scale(.96); }
.btn-gold:focus-visible { outline: 2px solid var(--gold-pale); outline-offset: 3px; }

/* ---------- Footer ---------- */
.site-footer {
  padding: 24px 16px calc(36px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: .82rem;
  color: var(--ink-mute);
}
.site-footer p { margin: 4px 0; }
.footer-date { color: var(--gold-light); opacity: .8; }

/* ---------- Sound toggle ---------- */
.sound-toggle {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  z-index: 50;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--gold-light);
  cursor: pointer;
}
.sound-toggle svg { width: 22px; height: 22px; grid-area: 1 / 1; }
.sound-toggle .icon-on { display: none; }
.sound-toggle.is-playing .icon-on { display: block; }
.sound-toggle.is-playing .icon-off { display: none; }
.sound-toggle::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 2px solid rgba(245, 215, 142, .55);
  opacity: 0;
  pointer-events: none;
}
/* transform/opacity only, so the pulse runs on the GPU without repainting */
.sound-toggle.is-playing::after { animation: softPulse 2.4s ease-out infinite; }
.sound-toggle:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }

.sound-hint {
  position: fixed;
  top: calc(24px + env(safe-area-inset-top));
  right: calc(70px + env(safe-area-inset-right));
  z-index: 50;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  color: var(--plum-900);
  background: var(--gold-light);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
  pointer-events: none;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity .5s ease, transform .5s var(--ease-out);
}
.sound-hint.is-shown { opacity: 1; transform: none; }

/* Twinkling sparkles in SVGs */
.twinkle {
  transform-box: fill-box;
  transform-origin: center;
  animation: twinkle 2.6s ease-in-out infinite;
}

/* =========================================================
   Keyframes
   ========================================================= */
@keyframes shimmer   { to { background-position: -220% center; } }
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes bob       { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }
@keyframes blink     { 50% { opacity: 0; } }

@keyframes tiaraFloat {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50%      { transform: translateY(-6px) rotate(1.5deg); }
}
@keyframes gemGlow {
  0%, 100% { opacity: 1; }
  50%      { opacity: .7; }
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14%      { transform: scale(1.08); }
  28%      { transform: scale(1); }
  42%      { transform: scale(1.07); }
  70%      { transform: scale(1); }
}
@keyframes ring {
  0%   { transform: scale(.7); opacity: .8; }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes twinkle {
  0%, 100% { opacity: .35; transform: scale(.7); }
  50%      { opacity: 1;   transform: scale(1.15); }
}
@keyframes starPulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.06) rotate(4deg); }
}
@keyframes glowPulse {
  0%, 100% { transform: scale(.92); opacity: .75; }
  50%      { transform: scale(1.08); opacity: 1; }
}
@keyframes tailDraw {
  0%   { stroke-dashoffset: 160; opacity: 0; }
  20%  { opacity: 1; }
  60%  { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes flicker {
  0%   { transform: rotate(-3deg) scaleY(1); }
  50%  { transform: rotate(2deg) scaleY(1.08) scaleX(.94); }
  100% { transform: rotate(-1deg) scaleY(.95) scaleX(1.04); }
}
@keyframes smoke {
  0%   { opacity: .7; transform: translateY(0) scale(.6); }
  100% { opacity: 0;  transform: translateY(-46px) translateX(6px) scale(2.6); }
}
@keyframes softPulse {
  0%   { transform: scale(1);    opacity: .8; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* =========================================================
   Responsive tweaks
   ========================================================= */
@media (max-width: 359px) {
  .chapter { padding-top: 72px; padding-bottom: 72px; }
  .portrait-stage, .portrait { width: 190px; }
  .portrait { height: 190px; }
  .tab { font-size: .76rem; }
  .candle-row { width: 82%; }
}

@media (min-width: 768px) {
  .wrap { max-width: 520px; }
  .chapter { padding-top: 110px; padding-bottom: 110px; }
  .portrait-stage, .portrait { width: 260px; }
  .portrait { height: 260px; }
  .tiara { width: 190px; margin-left: -95px; top: -84px; }
  .blessing-grid { grid-template-columns: 1fr 1fr; }
  .lede { max-width: 40ch; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { transition-duration: .01s; transform: none; }
  .hero-title .text-gold, .tiara, .tiara-gem, .portrait-halo, .heart-svg, .pulse-ring,
  .twinkle, .star-core, .star-glow, .next-arrow, .finale-crown,
  .sound-toggle.is-playing::after { animation: none; }
  .star-tail { animation: none; stroke-dashoffset: 0; }
  .flip-inner { transition-duration: .2s; }
}
