/* base.css — tokens, reset, shell, shared components and keyframes.
   Browser floor: iOS Safari 15.4+. No CSS nesting, color-mix() or @container. */

:root {
  /* from the original page */
  --rose: #E91E63;
  --rose-600: #D81B60;
  --rose-700: #C2185B;
  --rose-800: #AD1457;
  --rose-900: #880E4F;
  --paper-1: #fff8f2;
  --paper-2: #ffe9d9;
  --paper-3: #ffd9c2;
  --flap-1: #ffe4d1;
  --flap-2: #ffd2b8;
  --seal-hi: #ef3b52;
  --seal-lo: #a10f1c;
  --shadow-card: 0 24px 55px rgba(120, 0, 40, .4);
  --shadow-btn: 0 10px 30px rgba(0, 0, 0, .25);
  --glow-lo: rgba(255, 90, 130, .45);
  --glow-hi: rgba(255, 90, 130, .85);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);
  --ease-flap: cubic-bezier(.6, -.1, .3, 1.2);
  --ease-in: cubic-bezier(.7, 0, .84, 0);
  --ease-pulse: cubic-bezier(.4, 0, .6, 1);
  /* new */
  --ink: #7A1233;
  --ink-soft: rgba(122, 18, 51, .72);
  --gold: #FFD36E;
  --gold-deep: #C9A13B;
  --gold-hi: #FFF1B8;
  --glass: rgba(90, 0, 30, .22);
  --glass-bd: rgba(255, 255, 255, .26);
  --text-shadow: 0 1px 2px rgba(0, 0, 0, .14), 0 1px 1px rgba(0, 0, 0, .08);
  --font-love: "Playfair Display", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --bg: #E91E63;
}
html.font-playfair { --font-love: "FA Playfair", "Playfair Display", Georgia, "Times New Roman", serif; }

/* ---------- moods (colour + opacity only) ---------- */
html[data-mood="invite"]  { --bg: #E91E63; }
html[data-mood="hush"]    { --bg: #D81B60; }
html[data-mood="golden"]  { --bg: #D81B60; }
html[data-mood="sparkle"] { --bg: #E91E63; }
html[data-mood="play"]    { --bg: #D81B60; }
html[data-mood="velvet"]  { --bg: #880E4F; }
html[data-mood="joy"]     { --bg: #E91E63; }
html[data-mood="candle"]  { --bg: #AD1457; }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  background-color: var(--bg);
  transition: background-color 1.2s ease;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;           /* no double-tap zoom; pinch-zoom still works */
  color-scheme: only light;
}
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: #fff;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.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;
}
:focus { outline: none; }
:focus-visible { outline: 3px solid rgba(255, 255, 255, .9); outline-offset: 3px; border-radius: 12px; }

/* ---------- typography ---------- */
.font-love, .love { font-family: var(--font-love); }
.title {
  font-family: var(--font-love);
  font-weight: 600;
  font-size: clamp(28px, 8vw, 44px);
  line-height: 1.15;
  text-align: center;
  text-shadow: var(--text-shadow);
}
.kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .8);
  text-align: center;
}
.subtitle {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  text-align: center;
  text-shadow: var(--text-shadow);
}
.love-lg { font-size: 44px; text-align: center; }
.readable { color: #fff; font-size: 16px; font-weight: 500; text-shadow: var(--text-shadow); }

/* ---------- screen shell: every screen is its own fixed, scrollable layer ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.screen-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(64px + var(--sat)) calc(16px + var(--sar)) calc(104px + var(--sab)) calc(16px + var(--sal));
}
.screen-inner.is-bare { padding-top: calc(28px + var(--sat)); }
/* auto margins centre safely: when content is taller than the screen it scrolls instead of clipping */
.screen-center {
  margin: auto 0;
  width: 100%;
  max-width: 576px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.screen-head { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 20px; text-align: center; }

/* ---------- surfaces ---------- */
.paper-card {
  position: relative;
  width: min(92vw, 440px);
  padding: 28px 24px;
  border-radius: 20px;
  background: linear-gradient(var(--paper-1), var(--paper-2));
  box-shadow: var(--shadow-card);
  color: var(--ink);
}
.paper-card::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(161, 15, 28, .15);
  border-radius: 12px;
  pointer-events: none;
}
.glass-card {
  background: var(--glass);
  border: 1px solid var(--glass-bd);
  border-radius: 18px;
  color: #fff;
}
@media (hover: hover) and (min-width: 900px) {
  html:not(.lite) .glass-card { -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
}
.fallback-card { text-align: center; display: flex; flex-direction: column; gap: 10px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 14px 28px;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform .15s ease, opacity .2s ease;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: #fff; color: var(--rose); box-shadow: var(--shadow-btn); }
.btn-yes {
  background: linear-gradient(135deg, #ff5a82, #E91E63 60%, #C2185B);
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  animation: yesGlow 2.2s ease-in-out infinite;
}
.btn-ghost { background: transparent; color: #fff; border: 1.5px solid rgba(255, 255, 255, .7); }
.btn-small { min-height: 44px; padding: 10px 18px; font-size: 15px; }
.link-btn {
  background: none; border: 0; padding: 10px; min-height: 44px;
  color: #fff; font-size: 15px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- HUD (top row) ---------- */
.hud {
  position: fixed;
  z-index: 30;
  top: calc(10px + var(--sat));
  left: calc(10px + var(--sal));
  right: calc(64px + var(--sar));
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.hud-back {
  pointer-events: auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-bd);
  background: var(--glass);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.hud-progress {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  transform: translateX(26px);          /* visually centred on the screen (the toggle sits on the right) */
}
.hud-dot { position: relative; width: 18px; height: 16px; color: rgba(255, 255, 255, .35); transition: color .4s ease; }
.hud-dot .hud-heart { width: 18px; height: 16px; }
.hud-dot.is-done { color: #fff; }
.hud-dot.is-current { color: #fff; animation: heartbeat 1.6s ease-in-out infinite; }
.hud-dot.is-current .hud-heart { filter: drop-shadow(0 0 5px rgba(255, 255, 255, .85)); }
.hud-q { width: 22px; height: 20px; }
.hud-q .hud-heart { width: 22px; height: 20px; }
.hud-qmark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--rose); }

/* ---------- music toggle (top-right) ---------- */
.music-toggle {
  position: fixed;
  z-index: 35;
  top: calc(10px + var(--sat));
  right: calc(10px + var(--sar));
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--glass-bd);
  background: var(--glass);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.music-toggle.is-in { animation: fadeIn .6s var(--ease-out) both; }
.mt-bars { display: none; align-items: flex-end; gap: 3px; height: 16px; }
.mt-bars i { display: block; width: 3px; height: 100%; border-radius: 2px; background: #fff; transform-origin: bottom; animation: eq 1s ease-in-out infinite; }
.mt-bars i:nth-child(2) { animation-delay: .2s; }
.mt-bars i:nth-child(3) { animation-delay: .4s; }
.mt-off { width: 20px; height: 20px; }
.music-toggle[data-state="playing"] .mt-bars { display: flex; }
.music-toggle[data-state="playing"] .mt-off { display: none; }
.music-toggle[data-state="loading"] .mt-off { opacity: .6; }
.mt-label { font-size: 14px; font-weight: 600; white-space: nowrap; }
.mt-label:empty { display: none; }
.music-toggle[data-state="blocked"] { background: #fff; color: var(--rose); animation: pulseRing 1.6s ease-in-out infinite; }
.now-playing {
  position: fixed;
  z-index: 34;
  top: calc(62px + var(--sat));
  right: calc(10px + var(--sar));
  max-width: calc(100vw - 20px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(90, 0, 30, .38);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}
.now-playing.is-in { animation: slideDown .6s var(--ease-out) both; }
.now-playing.is-out { animation: fadeOut .6s ease forwards; }

/* ---------- shared Next button (bottom centre) ---------- */
.next-btn {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: calc(20px + var(--sab));
  min-width: 180px;
  transform: translateX(-50%);
}
.next-btn:active { transform: translateX(-50%) scale(.96); }
.next-btn.is-in { animation: nextIn .6s var(--ease-out) both; }

/* ---------- the shared effects canvas (confetti, heart bursts, fireworks) ----------
   Created by fx.js as a body child. Without this it would sit in normal flow behind #bg and nothing would show. */
#fx { position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; display: block; }

/* ---------- toast, flash, badge, fatal ---------- */
.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(88px + var(--sab));
  transform: translateX(-50%);
  max-width: min(90vw, 420px);
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(60, 0, 20, .8);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}
.toast.is-in { animation: fadeIn .3s ease both; }
.flash { position: fixed; inset: 0; z-index: 50; pointer-events: none; background: #fff; opacity: 0; }
.flash.is-on { animation: flash .55s ease-out both; }
.flash.is-soft { background: #ffd6e2; animation: flashSoft .5s ease both; }
.test-badge {
  position: fixed;
  z-index: 90;
  left: 8px;
  bottom: calc(4px + var(--sab));
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  max-width: calc(100vw - 16px);
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font: 500 11px/1.3 var(--font-ui);
}
.tb-btn { border: 1px solid rgba(255, 255, 255, .5); background: transparent; color: #fff; border-radius: 8px; padding: 2px 8px; font-size: 11px; cursor: pointer; }
.fatal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(136, 14, 79, .55);
}
.fatal-card {
  position: relative;
  width: min(92vw, 420px);
  padding: 28px 22px;
  border-radius: 20px;
  background: linear-gradient(var(--paper-1), var(--paper-2));
  color: var(--ink);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  box-shadow: var(--shadow-card);
}
.fatal-heart { font-size: 40px; }
.fatal-soft { font-family: var(--font-love); font-size: 20px; }
.fatal-dev { margin: 0; max-height: 40vh; overflow: auto; width: 100%; text-align: left; white-space: pre-wrap; font: 12px/1.45 ui-monospace, Menlo, monospace; color: #7a0000; background: #fff; border: 2px solid #d00; border-radius: 10px; padding: 10px; }
.fatal-close { position: absolute; top: 6px; right: 8px; width: 40px; height: 40px; border: 0; background: none; color: var(--ink); font-size: 26px; cursor: pointer; }
/* Pure-CSS failsafe: if even guard.js failed, offer a refresh after 6 s. */
html:not(.booted) #fatal[hidden] { display: flex !important; opacity: 0; pointer-events: none; animation: lateShow .01s 6s forwards; }
.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; font: 600 20px/1.4 var(--font-love); color: #fff; background: #E91E63; z-index: 200; }

/* ---------- shared keyframes ---------- */
@keyframes yesGlow { 0%, 100% { box-shadow: 0 8px 22px var(--glow-lo); } 50% { box-shadow: 0 12px 40px var(--glow-hi); } }
@keyframes cardIn { 0% { opacity: 0; transform: translateY(24px) scale(.94); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes bounceIn { 0% { transform: scale(.8); opacity: 0; } 50% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes fadeOut { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes slideUp { 0% { transform: translateY(30px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes slideDown { 0% { transform: translateY(-30px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes scaleIn { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }
@keyframes pulse { 50% { opacity: .5; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes slideFromCenter { 0% { transform: translateX(150px) translateY(0) rotate(0deg) scale(.9); opacity: 0; } 100% { transform: translateX(0) translateY(2rem) rotate(-6deg) scale(1); opacity: 1; } }
@keyframes slideFromCenterRight { 0% { transform: translateX(-150px) translateY(0) rotate(0deg) scale(.9); opacity: 0; } 100% { transform: translateX(0) translateY(3rem) rotate(6deg) scale(1); opacity: 1; } }
@keyframes heartbeat { 0%, 60%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 45% { transform: scale(1.18); } 30% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(0); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-48px); } }
@keyframes countPop { 0% { transform: scale(1.8); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.9); opacity: 0; } }
@keyframes sealStamp { 0% { transform: scale(1.6) rotate(-14deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes nextIn { 0% { opacity: 0; transform: translateX(-50%) translateY(24px); } 100% { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes eq { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
@keyframes pulseRing { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .7); } 50% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); } }
@keyframes flash { 0% { opacity: 0; } 30% { opacity: .85; } 100% { opacity: 0; } }
@keyframes flashSoft { 0% { opacity: 0; } 40% { opacity: .5; } 100% { opacity: 0; } }
@keyframes lateShow { to { opacity: 1; pointer-events: auto; } }
@keyframes develop { 0% { filter: sepia(1) brightness(1.7) contrast(.55) blur(2px); } 100% { filter: none; } }

.anim-card-in { animation: cardIn .7s var(--ease-out) both; }
.anim-bounce-in { animation: bounceIn .8s var(--ease-back) both; }
.anim-fade-in { animation: fadeIn .8s var(--ease-out) both; }
.anim-slide-up { animation: slideUp .8s var(--ease-out) both; }
.anim-slide-down { animation: slideDown .8s var(--ease-out) both; }
.anim-scale-in { animation: scaleIn .8s var(--ease-out) both; }
.anim-shake { animation: shake .42s ease-in-out; }
.anim-wiggle { animation: wiggle .3s ease-out; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .15s !important; }
  .anim-card-in, .anim-bounce-in, .anim-fade-in, .anim-slide-up, .anim-slide-down, .anim-scale-in { animation: fadeIn .3s ease both !important; animation-duration: .3s !important; }
  .btn-yes { animation: none; box-shadow: 0 10px 34px var(--glow-hi); }
  html { transition: none; }
}
