/* ==========================================================================
   THEME VARIABLES (Customizable from SITE_CONFIG.theme in script.js)
   ========================================================================== */
:root {
  --accent: #b0324e;
  --accent-soft: #e0476f;
  --accent-dark: #6e1f44;
  --ink: #4a1728;
  --ink-muted: #8a4a5c;
  --paper: #f7ebe9;
  --paper-deep: #ecd8d6;
  --letter-bg: #f6c7ca;
  --env-start: #84264e;
  --env-end: #5c1537;
  --env-flap: #9a3462;
  --plaid-bg: #fff3d2;
  --rose-bg: #cf8393;
  --gold-shadow: #e5b84f;
  --focus-ring: #9b2c48;
  --radius-card: 16px;
}

/* ==========================================================================
   BASE & ACCESSIBILITY
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
  height: 100%;
  overflow-x: hidden;
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--plaid-bg);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   BACKGROUNDS
   ========================================================================== */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  transition: opacity 0.65s ease;
  pointer-events: none;
}

.bg-plaid {
  background:
    repeating-linear-gradient(0deg, rgba(244, 162, 184, 0.38) 0 30px, transparent 30px 60px),
    repeating-linear-gradient(90deg, rgba(244, 162, 184, 0.38) 0 30px, transparent 30px 60px),
    repeating-linear-gradient(0deg, rgba(150, 200, 232, 0.26) 0 6px, transparent 6px 60px),
    repeating-linear-gradient(90deg, rgba(150, 200, 232, 0.26) 0 6px, transparent 6px 60px),
    var(--plaid-bg);
}

.bg-rose {
  opacity: 0;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(181, 84, 106, 0.85) 0 24%, transparent 45%),
    radial-gradient(ellipse at 85% 28%, rgba(232, 207, 208, 0.8) 0 20%, transparent 42%),
    radial-gradient(ellipse at 28% 85%, rgba(217, 138, 154, 0.85) 0 26%, transparent 48%),
    radial-gradient(ellipse at 90% 90%, rgba(181, 84, 106, 0.8) 0 22%, transparent 44%),
    var(--rose-bg);
}

.bg-rose::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(255, 246, 240, 0.55);
  border-radius: 18px;
  pointer-events: none;
}

.bg-rose::after,
.paperx::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .2 0 0 0 0 .25 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body.rose .bg-rose {
  opacity: 1;
}

/* ==========================================================================
   STAGE & RESPONSIVE SCROLLABLE PAGES
   ========================================================================== */
.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100dvh;
}

.page {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: none;
  padding:
    calc(3.6rem + env(safe-area-inset-top))
    1rem
    calc(2.8rem + env(safe-area-inset-bottom));
}

.page.is-active {
  display: block;
}

.page[hidden] {
  display: none;
}

.page-inner {
  min-height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   TYPOGRAPHY & TORN PAPER CARD
   ========================================================================== */
.script {
  font-family: "Homemade Apple", cursive;
  font-weight: 400;
  color: var(--accent);
  line-height: 1.65;
  overflow-wrap: break-word;
  max-width: 100%;
}

.serif-h {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  overflow-wrap: break-word;
}

.subtitle {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-muted);
  line-height: 1.45;
  max-width: 30ch;
}

.subtitle:empty,
.pill-badge:empty,
.board-hint:empty {
  display: none;
}

.pill-badge {
  display: inline-block;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(176, 50, 78, 0.18);
}

.card-wrap {
  width: min(92vw, 410px);
  margin: auto;
  filter: drop-shadow(0 14px 22px rgba(110, 40, 62, 0.24));
}

.card-wrap.wide {
  width: min(94vw, 480px);
}

.torn {
  position: relative;
  min-height: min(64dvh, 450px);
  padding: 2.5rem 1.5rem 2.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.95rem;
  text-align: center;
  background: linear-gradient(150deg, var(--paper), var(--paper-deep));
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.58),
    inset 0 0 42px rgba(210, 150, 160, 0.24);
}

.torn-board {
  min-height: auto;
  padding: 2.4rem 1.35rem 1.9rem;
}

.torn::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.26;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .3 0 0 0 0 .3 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.torn > * {
  position: relative;
  z-index: 1;
}

.flower {
  position: absolute !important;
  z-index: 2 !important;
  top: -6px;
  right: -6px;
  width: 84px;
  height: 84px;
  transform: rotate(12deg);
  filter: drop-shadow(0 4px 5px rgba(120, 50, 70, 0.28));
  animation: sway 5.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sway {
  50% {
    transform: rotate(2deg) scale(1.04);
  }
}

#cover-title {
  font-size: clamp(1.38rem, 6.2vw, 1.95rem);
}

#ask-title {
  font-size: clamp(1.35rem, 6vw, 1.85rem);
}

.yay {
  font-size: 1.05rem;
  margin-bottom: -0.45rem;
}

#ready-title {
  font-size: clamp(1.55rem, 6.8vw, 2.15rem);
}

#board-title {
  font-size: clamp(1.35rem, 6vw, 1.85rem);
}

.for {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-top: -0.35rem;
}

.board-hint {
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(138, 74, 92, 0.85);
}

/* ==========================================================================
   BUTTONS & INTERACTIVE CONTROLS
   ========================================================================== */
.btn {
  min-height: 44px;
  min-width: 112px;
  padding: 0.65rem 1.75rem;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1rem;
  color: #4a2a2e;
  background: linear-gradient(180deg, #fffcf5, #f1e1ce);
  border: 2px solid #6b5048;
  box-shadow:
    0 4px 0 var(--gold-shadow),
    0 7px 14px rgba(80, 40, 40, 0.2);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 0 var(--gold-shadow),
    0 10px 18px rgba(80, 40, 40, 0.24);
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--gold-shadow);
}

.btn-primary {
  background: linear-gradient(180deg, #fffdf8, #f8e3d4);
}

.btn-secondary {
  min-width: 96px;
}

.text-link {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  border-radius: 8px;
  min-height: 40px;
}

.text-link:hover {
  background: rgba(176, 50, 78, 0.08);
}

.replay-btn {
  margin-top: 0.35rem;
  opacity: 0.82;
}

/* Runaway "no" button arena */
.arena {
  position: relative;
  width: 100%;
  height: 104px;
  margin-top: 0.2rem;
}

.arena .btn {
  position: absolute;
  top: 50%;
  margin-top: -23px;
  white-space: nowrap;
}

#btn-yes {
  left: 10%;
}

#btn-no {
  right: 10%;
  transition:
    left 0.32s cubic-bezier(0.3, 1.35, 0.5, 1),
    top 0.32s cubic-bezier(0.3, 1.35, 0.5, 1),
    transform 0.14s ease;
}

/* ==========================================================================
   STICKERS & BUILT-IN CHARACTER ILLUSTRATIONS
   ========================================================================== */
.hero {
  width: 146px;
  height: 146px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.9), rgba(255, 214, 224, 0.55));
  box-shadow:
    inset 0 0 0 1px rgba(224, 71, 111, 0.16),
    0 10px 22px rgba(224, 71, 111, 0.18);
  flex: none;
}

.hero.small {
  width: 96px;
  height: 96px;
  margin: 0 auto 0.4rem;
}

.hero svg,
.hero img {
  width: 84%;
  height: auto;
  max-height: 84%;
  object-fit: contain;
}

.duo {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.duo svg,
.duo img {
  width: min(250px, 84%);
  height: auto;
  max-height: 165px;
  object-fit: contain;
}

.peek-slot {
  position: absolute !important;
  left: 8%;
  bottom: -6px;
  width: 112px;
  pointer-events: none;
  z-index: 2 !important;
}

.peek-slot svg,
.peek-slot img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.stkimg {
  border-radius: 12px;
}

/* Character micro-animations */
.duoart .eyes,
.heroart .eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 4s infinite;
}

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

.duoart .lean-l {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: leanl 3.2s ease-in-out infinite;
}

.duoart .lean-r {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: leanr 3.2s ease-in-out infinite;
}

@keyframes leanl {
  50% { transform: rotate(3deg) translateY(-2px); }
}

@keyframes leanr {
  50% { transform: rotate(-3deg) translateY(-2px); }
}

.duoart .hrt {
  transform-box: fill-box;
  transform-origin: center;
  animation: hrt 2.4s ease-in-out infinite;
}

@keyframes hrt {
  0% { transform: translateY(10px) scale(0.5); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: translateY(-14px) scale(1.15); opacity: 0; }
}

.duoart .bodyb {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: breathe 2.8s ease-in-out infinite;
}

@keyframes breathe {
  50% { transform: scale(1.04, 0.96); }
}

.heroart .bbob {
  animation: hbob 2.4s ease-in-out infinite;
}

@keyframes hbob {
  50% { transform: translateY(-4px); }
}

.heroart .hb {
  transform-box: fill-box;
  transform-origin: center;
  animation: hpulse 1.3s ease-in-out infinite;
}

@keyframes hpulse {
  50% { transform: scale(1.1); }
}

.heroart .mh {
  transform-box: fill-box;
  transform-origin: center;
  animation: mhf 2.2s ease-in-out infinite;
}

@keyframes mhf {
  0% { transform: translateY(6px) scale(0.6); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: translateY(-12px) scale(1.1); opacity: 0; }
}

/* ==========================================================================
   ENVELOPE BOARD & 3D OPENING ANIMATION
   ========================================================================== */
.envs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.05rem 0.95rem;
  width: 100%;
  padding: 0.4rem 0.25rem 0.2rem;
}

.envs-empty {
  grid-column: 1 / -1;
  padding: 1.5rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.env {
  position: relative;
  aspect-ratio: 1.42;
  min-height: 112px;
  border-radius: 8px;
  background: linear-gradient(160deg, var(--env-start), var(--env-end));
  box-shadow:
    0 10px 18px rgba(80, 20, 50, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform 0.24s cubic-bezier(0.25, 1.3, 0.5, 1), box-shadow 0.24s ease;
  perspective: 700px;
  overflow: visible;
}

.env:nth-child(odd) {
  transform: rotate(-2.4deg);
}

.env:nth-child(even) {
  transform: rotate(2.2deg);
}

.env:hover,
.env:focus-visible {
  transform: rotate(0deg) translateY(-5px) scale(1.03);
  box-shadow:
    0 14px 24px rgba(80, 20, 50, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  z-index: 3;
}

.env:active {
  transform: rotate(0deg) scale(0.98);
}

/* Inner peeking paper slip (lifts up when opening) */
.env-slip {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 12%;
  bottom: 14%;
  background: #fff9f5;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(60, 15, 30, 0.2);
  transform: translateY(0);
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1;
  pointer-events: none;
}

/* Front pocket fold */
.env-pocket {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background:
    linear-gradient(to top right, transparent 49.2%, rgba(255, 255, 255, 0.14) 50%, transparent 50.8%),
    linear-gradient(to top left, transparent 49.2%, rgba(255, 255, 255, 0.14) 50%, transparent 50.8%),
    linear-gradient(180deg, var(--env-start), var(--env-end));
  clip-path: polygon(0 100%, 0 36%, 50% 74%, 100% 36%, 100% 100%);
  z-index: 2;
  pointer-events: none;
}

/* Top triangular flap */
.env-flap {
  position: absolute;
  inset: 0;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--env-flap), var(--env-start));
  clip-path: polygon(0 0, 100% 0, 50% 60%);
  transform-origin: top center;
  transition: transform 0.38s cubic-bezier(0.34, 1.2, 0.64, 1);
  z-index: 3;
  pointer-events: none;
}

/* Opening state */
.env.is-opening {
  transform: rotate(0deg) scale(1.04);
  z-index: 5;
}

.env.is-opening .env-flap {
  transform: rotateX(-155deg);
}

.env.is-opening .env-slip {
  transform: translateY(-28%);
}

/* Seal & label tag */
.tag {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  width: 82%;
  margin: 0 auto;
  padding: 0.42rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  background: rgba(70, 14, 38, 0.56);
  backdrop-filter: blur(2px);
  color: #fff;
  transform: translateY(8%);
}

.tag-title {
  font-weight: 800;
  font-size: 0.68rem;
  line-height: 1.25;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tag-desc {
  font-weight: 600;
  font-size: 0.62rem;
  line-height: 1.2;
  opacity: 0.9;
}

.env-check {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--accent-dark);
  background: #fff4d6;
  box-shadow: 0 2px 5px rgba(50, 10, 25, 0.35);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.env.is-opened .env-check {
  opacity: 1;
  transform: scale(1);
}

/* ==========================================================================
   SURPRISE VIEWER
   ========================================================================== */
.viewer {
  position: relative;
  z-index: 2;
  width: min(94vw, 450px);
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.95rem;
  padding-bottom: 72px;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.bar-title {
  flex: 1;
  text-align: right;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 250, 248, 0.92);
  text-shadow: 0 1px 4px rgba(80, 20, 40, 0.35);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arrow {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  background: radial-gradient(circle at 30% 25%, #c2e2ff, #4b8ff0 58%, #2d62c9);
  border: 2px solid #fff;
  box-shadow:
    0 4px 10px rgba(30, 60, 140, 0.42),
    inset 0 -3px 5px rgba(0, 30, 120, 0.28);
  transition: transform 0.15s ease;
}

.arrow:hover {
  transform: scale(1.06);
}

.arrow:active {
  transform: scale(0.92);
}

.arrow[hidden] {
  visibility: hidden;
  display: grid;
}

.paperx {
  position: relative;
  width: 100%;
  background: linear-gradient(160deg, #fae0e2, var(--letter-bg));
  border-radius: 6px;
  padding: 1.65rem 1.35rem;
  box-shadow:
    0 16px 30px rgba(90, 26, 46, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  overflow: hidden;
}

.paperx > * {
  position: relative;
  z-index: 1;
}

.paperx .scroll {
  max-height: min(52dvh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.25rem;
}

.paperx .scroll::-webkit-scrollbar {
  width: 5px;
}

.paperx .scroll::-webkit-scrollbar-thumb {
  background: rgba(138, 36, 64, 0.28);
  border-radius: 999px;
}

.lt {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 600;
  font-size: clamp(0.98rem, 4vw, 1.12rem);
  line-height: 1.65;
  text-align: center;
  color: var(--ink);
  white-space: pre-line;
  overflow-wrap: break-word;
}

.lt-sign {
  margin-top: 1.1rem;
  font-family: "Homemade Apple", cursive;
  font-size: 1.05rem;
  color: var(--accent);
  text-align: center;
}

.vstk {
  position: absolute;
  right: -4px;
  bottom: -2px;
  width: 118px;
  pointer-events: none;
  z-index: 3;
}

.vstk svg,
.vstk img {
  width: 100%;
  height: auto;
  display: block;
}

/* ==========================================================================
   TIMER FEATURE (Fixed: Days, Hours, Minutes, Seconds — no duplication)
   ========================================================================== */
.timer-card {
  text-align: center;
}

.timer-intro {
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.timer-headline {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.35rem, 6vw, 1.75rem);
  color: var(--accent);
  margin-bottom: 0.85rem;
}

.tgrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.5rem;
}

.tbox {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(176, 50, 78, 0.14);
  border-radius: 12px;
  padding: 0.75rem 0.25rem;
}

.big {
  display: block;
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.25rem, 5.5vw, 1.85rem);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1.15;
}

.tbox small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.timer-since {
  margin-top: 1rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

/* ==========================================================================
   MEMORIES / POLAROID SCRAPBOOK GALLERY
   ========================================================================== */
.scrap {
  position: relative;
  width: 100%;
  padding: 14px 10px 16px;
  filter: drop-shadow(0 10px 16px rgba(90, 26, 46, 0.3));
}

.sc {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  border-radius: 3px;
}

.sc1 {
  background:
    repeating-linear-gradient(0deg, rgba(244, 162, 184, 0.52) 0 14px, transparent 14px 28px),
    repeating-linear-gradient(90deg, rgba(244, 162, 184, 0.52) 0 14px, transparent 14px 28px),
    #fff3d2;
  transform: rotate(-3.5deg) scale(1.02);
}

.sc2 {
  background: linear-gradient(135deg, #e6c49a, #cfa575);
  transform: rotate(3deg) translate(4px, 6px);
}

.pol {
  position: relative;
  z-index: 2;
  background: #fffaf4;
  padding: 11px 11px 16px;
  border-radius: 3px;
  box-shadow: 0 5px 14px rgba(90, 26, 46, 0.24);
  transform: rotate(-1.5deg);
}

.pol-media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3.5;
  background: #ecdcdc;
  overflow: hidden;
  border-radius: 2px;
}

.pol-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 40%);
  pointer-events: none;
}

.pol img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pol-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1rem;
  text-align: center;
  color: var(--ink-muted);
  background: linear-gradient(135deg, #fae8ec, #f3d6dd);
  font-weight: 700;
  font-size: 0.85rem;
}

.pol-media.is-broken img {
  display: none;
}

.pol-media.is-broken .pol-fallback {
  display: flex;
}

.pol .script {
  font-size: 0.88rem;
  line-height: 1.55;
  margin-top: 0.65rem;
  text-align: center;
}

.pol .d {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-top: 0.35rem;
  text-align: center;
}

.tape {
  position: absolute;
  width: 74px;
  height: 22px;
  opacity: 0.92;
  box-shadow: 0 1px 3px rgba(60, 20, 30, 0.22);
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.62) 0 6px, rgba(244, 162, 184, 0.62) 6px 12px);
  pointer-events: none;
}

.pol .tape {
  z-index: 4;
}

.pol .t1 {
  left: -18px;
  top: -8px;
  transform: rotate(-34deg);
}

.pol .t2 {
  right: -18px;
  top: -8px;
  transform: rotate(32deg);
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.62) 0 6px, rgba(160, 210, 235, 0.65) 6px 12px);
}

.stkh {
  position: absolute;
  z-index: 4;
  right: -10px;
  bottom: -14px;
  font-size: 2.15rem;
  line-height: 1;
  color: var(--accent-soft);
  filter: drop-shadow(0 3px 3px rgba(90, 26, 46, 0.35));
  transform: rotate(12deg);
  pointer-events: none;
}

.mem-nav {
  margin-top: 0.4rem;
}

.mem-count {
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  text-shadow: 0 1px 4px rgba(80, 20, 40, 0.4);
}

/* ==========================================================================
   PLAYFUL LOCKED LETTER
   ========================================================================== */
.locked-card {
  text-align: center;
}

.locked-prompt {
  font-size: 1rem;
  margin-bottom: 0.65rem;
}

.pw {
  width: 100%;
  min-height: 46px;
  padding: 0.68rem 0.9rem;
  border-radius: 12px;
  border: 2px solid #c98a96;
  background: #fff9f7;
  text-align: center;
  font: 700 1.05rem "Playfair Display", Georgia, serif;
  color: var(--ink);
}

.pw:focus {
  border-color: var(--accent);
}

.msg {
  min-height: 1.5em;
  margin: 0.6rem 0 0.75rem;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--accent);
}

.locked-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

/* ==========================================================================
   MUSIC BUTTON, WATERMARK & VIEWER DECORATIONS
   ========================================================================== */
.music {
  position: fixed;
  z-index: 60;
  top: max(0.75rem, env(safe-area-inset-top));
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: min(64vw, 240px);
  min-height: 38px;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.76rem;
  color: var(--ink);
  background: rgba(255, 252, 248, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(231, 181, 192, 0.9);
  box-shadow: 0 5px 14px rgba(120, 50, 70, 0.18);
  transition: transform 0.15s ease, background 0.2s ease;
}

.music:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.96);
}

.music #song {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.music .note {
  color: var(--accent);
  font-size: 0.95rem;
}

.music.is-playing .note {
  animation: bob 1.4s ease-in-out infinite;
}

@keyframes bob {
  50% { transform: translateY(-3px) rotate(6deg); }
}

.music.is-unavailable {
  opacity: 0.72;
}

.wm {
  position: fixed;
  z-index: 15;
  bottom: calc(8px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(110, 31, 68, 0.62);
  pointer-events: none;
}

body.rose .wm {
  color: rgba(255, 246, 244, 0.82);
  text-shadow: 0 1px 3px rgba(80, 20, 40, 0.35);
}

.heart {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  color: var(--accent-soft);
  font-size: 1.25rem;
  user-select: none;
}

/* Scrapbook floating details behind viewer */
.vdeco {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.vf {
  position: absolute;
  transform: rotate(var(--r));
  filter: drop-shadow(0 5px 6px rgba(90, 26, 46, 0.3));
  animation: sway 5.4s ease-in-out infinite;
}

.vs {
  position: absolute;
  font-style: normal;
  color: #fff3f0;
  text-shadow: 0 0 10px rgba(255, 200, 215, 0.9);
  animation: twk 3.2s ease-in-out infinite;
}

.vs:nth-of-type(odd) {
  color: #ffd6e0;
}

@keyframes twk {
  50% { transform: scale(1.4) rotate(18deg); opacity: 0.5; }
}

.pt {
  position: absolute;
  top: -20px;
  width: 11px;
  height: 15px;
  border-radius: 75% 0 75% 0;
  background: radial-gradient(circle at 30% 30%, #ffd3de, #f08aa6 75%);
  opacity: 0.78;
  animation: fall var(--d) linear infinite;
}

@keyframes fall {
  0% { transform: translate(0, -30px) rotate(0); }
  50% { transform: translate(var(--w), 55vh) rotate(180deg); }
  100% { transform: translate(calc(var(--w) * -0.6), 108vh) rotate(380deg); }
}

.wt1 {
  left: -16px;
  top: 9%;
  transform: rotate(-40deg);
}

.wt2 {
  right: -18px;
  bottom: 11%;
  transform: rotate(-38deg);
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 0 6px, rgba(160, 210, 235, 0.65) 6px 12px);
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (Small Phones, Tablets, Landscape)
   ========================================================================== */
@media (max-width: 380px) {
  .torn {
    padding: 2.1rem 1.05rem 1.85rem;
  }

  .flower {
    width: 68px;
    height: 68px;
  }

  .peek-slot {
    width: 88px;
    left: 4%;
  }

  .envs {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .tgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vstk {
    width: 96px;
  }
}

@media (max-height: 620px) {
  .torn {
    min-height: auto;
    padding: 1.75rem 1.25rem;
    gap: 0.75rem;
  }

  .hero {
    width: 116px;
    height: 116px;
  }

  .duo svg,
  .duo img {
    max-height: 120px;
  }
}

/* ==========================================================================
   REDUCED MOTION SUPPORT
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .pt {
    display: none;
  }
}