/* ============================================================
   For you, Always. — Infinite Memoir (Beige Kelam)
   ============================================================ */

:root {
  --font-display: 'Cormorant Garamond', serif;
  --font-sans: 'DM Sans', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --noise-opacity: 0.08;
}

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

.hidden {
  display: none !important;
}

html,
body {
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* ── Mesh Gradient Background (Beige Kelam) ── */
body {
  background-color: var(--bg);
  color: var(--text);
  position: relative;
  transition: background 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--mesh);
}

/* Texture Overlay (Analog Grain) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: var(--noise-opacity);
  pointer-events: none;
}

/* ── Theme Definitions (Muted & Warm) ── */
[data-theme="rose"],
[data-theme="rosewood"] {
  --bg: #2a1b1b;
  --surface: rgba(234, 218, 202, 0.08);
  --primary: #c4867d;
  --accent: #8b5a53;
  --text: #e8dbcf;
  --text-muted: #b09c8d;
  --border: rgba(196, 134, 125, 0.2);
  --mesh: radial-gradient(at 0% 0%, #3d2b27 0px, transparent 50%),
    radial-gradient(at 100% 0%, #2a1b1b 0px, transparent 50%),
    radial-gradient(at 100% 100%, #1e1414 0px, transparent 50%),
    radial-gradient(at 0% 100%, #362823 0px, transparent 50%);
}

[data-theme="original"],
[data-theme="gold"],
[data-theme="brown"],
:root {
  --bg: #4a3c31;
  /* Lighter warm brown (Mocha) */
  --surface: rgba(230, 215, 180, 0.1);
  --primary: #d4ae6a;
  --accent: #9c7b45;
  --text: #e6d7b4;
  --text-muted: #b5a17e;
  --border: rgba(212, 174, 106, 0.2);
  --mesh: radial-gradient(at 0% 0%, #5e4b3e 0px, transparent 50%),
    radial-gradient(at 100% 0%, #4a3c31 0px, transparent 50%),
    radial-gradient(at 100% 100%, #362823 0px, transparent 50%),
    radial-gradient(at 0% 100%, #544438 0px, transparent 50%);
}

[data-theme="midnight"] {
  --bg: #1a1b26;
  --surface: rgba(160, 170, 200, 0.08);
  --primary: #8fa1c4;
  --accent: #5d6d8c;
  --text: #d0d7e6;
  --text-muted: #9ba6bf;
  --border: rgba(143, 161, 196, 0.2);
  --mesh: radial-gradient(at 0% 0%, #262a36 0px, transparent 50%),
    radial-gradient(at 100% 0%, #1a1b26 0px, transparent 50%),
    radial-gradient(at 100% 100%, #12121a 0px, transparent 50%),
    radial-gradient(at 0% 100%, #222431 0px, transparent 50%);
}

[data-theme="mossy"],
[data-theme="sage"] {
  --bg: #141c12;
  --surface: rgba(80, 100, 60, 0.08);
  --primary: #7a8a5a;
  --accent: #5a6a40;
  --text: #d4dcc8;
  --text-muted: #6a7a54;
  --border: rgba(80, 100, 60, 0.3);
  --mesh: radial-gradient(at 0% 0%, #1e2a1a 0px, transparent 50%),
    radial-gradient(at 100% 0%, #162014 0px, transparent 50%),
    radial-gradient(at 100% 100%, #101a0e 0px, transparent 50%),
    radial-gradient(at 0% 100%, #1a2618 0px, transparent 50%);
}

[data-theme="silver"],
[data-theme="camera"] {
  --bg: #c8c4c0;
  --surface: rgba(100, 95, 90, 0.1);
  --primary: #7a7673;
  --accent: #4a4744;
  --text: #2a2724;
  --text-muted: #7a7673;
  --border: rgba(100, 95, 90, 0.3);
  --mesh: radial-gradient(at 0% 0%, #ddd9d5 0px, transparent 55%),
    radial-gradient(at 100% 0%, #cdc8c3 0px, transparent 55%),
    radial-gradient(at 80% 80%, #bfbbb6 0px, transparent 55%),
    radial-gradient(at 20% 100%, #d4d0cb 0px, transparent 55%);
}

[data-theme="pinky"],
[data-theme="magenta"] {
  --bg: #2d1a22;
  --surface: rgba(255, 182, 210, 0.12);
  --primary: #f472b6;
  --accent: #ec4899;
  --text: #fce4ec;
  --text-muted: #e8a0b8;
  --border: rgba(244, 114, 182, 0.25);
  --mesh: radial-gradient(at 0% 0%, #3d1f2e 0px, transparent 50%),
    radial-gradient(at 100% 0%, #351828 0px, transparent 50%),
    radial-gradient(at 80% 80%, #2a1220 0px, transparent 50%),
    radial-gradient(at 20% 100%, #3a1e2d 0px, transparent 50%);
}

#state-gift {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
}

.bokeh-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.bokeh-particle {
  position: absolute;
  border-radius: 50%;
  background: var(--primary);
  filter: blur(40px);
  opacity: 0.05;
  transition: transform 2s ease, opacity 1s ease;
  will-change: transform, opacity;
}

.voice-section {
  width: 100%;
  max-width: 420px;
  /* Up-sized from 380 */
  perspective: 2500px;
}

/* ── The Memoir Station (V3 - Precision Edition) ── */
.music-box-container {
  position: relative;
  background:
    radial-gradient(circle at 50% 50%, rgba(70, 60, 50, 0.9), rgba(40, 32, 25, 0.95)),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='0.03'/%3E%3C/svg%3E");

  /* Optimized backdrop-filter for mobile performance */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  @media (min-width: 768px) {
    backdrop-filter: blur(50px);
    -webkit-backdrop-filter: blur(50px);
  }

  /* Double Trim Border */
  border: 1px solid rgba(255, 255, 255, 0.05);
  outline: 1px solid rgba(212, 174, 106, 0.15);
  outline-offset: -8px;

  border-radius: 56px;
  padding: 85px 24px 165px;
  /* Further increased bottom padding to 165px */
  box-shadow: 0 80px 160px -40px rgba(0, 0, 0, 0.9),
  inset 0 1px 2px rgba(255, 255, 255, 0.05);
  text-align: center;
  overflow: hidden;
  will-change: transform;
  /* Hint for jitter animation */
}

/* Metallic Nameplate Badge (Simplified) */
.console-plate {
  position: absolute;
  top: 45px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 6px;
  background: linear-gradient(135deg, #2a2825, #1a1815);
  border: 1px solid rgba(212, 174, 106, 0.4);
  border-radius: 20px;
  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

/* Console-plate glow when polaroid is ready */
.console-plate.slot-active {
  border-color: rgba(212, 174, 106, 0.55);
  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.08),
    0 0 10px rgba(212, 174, 106, 0.35),
    0 0 28px rgba(212, 174, 106, 0.2),
    0 0 50px rgba(212, 174, 106, 0.08);
  animation: plate-pulse 1.2s ease-in-out infinite;
  pointer-events: all;
  cursor: pointer;
}

@keyframes plate-pulse {

  0%,
  100% {
    box-shadow:
      0 2px 5px rgba(0, 0, 0, 0.5),
      inset 0 1px 1px rgba(255, 255, 255, 0.08),
      0 0 10px rgba(212, 174, 106, 0.35),
      0 0 28px rgba(212, 174, 106, 0.2);
  }

  50% {
    box-shadow:
      0 2px 5px rgba(0, 0, 0, 0.5),
      inset 0 1px 1px rgba(255, 255, 255, 0.08),
      0 0 18px rgba(212, 174, 106, 0.55),
      0 0 45px rgba(212, 174, 106, 0.35),
      0 0 70px rgba(212, 174, 106, 0.12);
  }
}

/* Reopen label below console-plate */
.slot-reopen-label {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 5.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: transparent;
  pointer-events: none;
  transition: color 0.6s ease;
  white-space: nowrap;
  user-select: none;
}

.slot-reopen-label.is-ready {
  color: rgba(212, 174, 106, 0.22);
}

.music-box-container:hover .slot-reopen-label.is-ready {
  color: rgba(212, 174, 106, 0.55);
}




/* Mechanical Corner Screws */
.console-screw {
  position: absolute;
  width: 14px;
  height: 14px;
  background: radial-gradient(circle at 30% 30%, #555, #222);
  border-radius: 50%;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.8),
    inset 0 1px 1px rgba(255, 255, 255, 0.2);
  z-index: 5;
}

.console-screw::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 2px;
  background: #111;
  border-radius: 1px;
}

.top-left {
  top: 25px;
  left: 25px;
  transform: rotate(45deg);
}

.top-right {
  top: 25px;
  right: 25px;
  transform: rotate(-45deg);
}

.bottom-left {
  bottom: 25px;
  left: 25px;
  transform: rotate(-15deg);
}

.bottom-right {
  bottom: 25px;
  right: 25px;
  transform: rotate(30deg);
}

/* Photo Styling (Clean Version) */
.printer-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
  filter: sepia(0.1) contrast(1.1);
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── The Lens Viewport (240px) ── */
.printer-viewport {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 0 auto 30px;
  background: #080706;
  border-radius: 32px;
  overflow: hidden;
  box-shadow:
    0 0 0 12px rgba(0, 0, 0, 0.5),
    inset 0 0 60px rgba(0, 0, 0, 1);
  display: flex;
  align-items: center;
}

.printer-viewport::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 30%, rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
  z-index: 10;
}

/* Glass Lens Reflection Effect */
.glass-lens-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  background:
    /* Primary Diagonal Reflection */
    linear-gradient(135deg,
      rgba(255, 255, 255, 0.15) 0%,
      rgba(255, 255, 255, 0.05) 15%,
      transparent 40%,
      transparent 100%),
    /* Convex Hotspot Highlight */
    radial-gradient(circle at 30% 25%,
      rgba(255, 255, 255, 0.08) 0%,
      transparent 30%),
    /* Anti-reflective Tint (Subtle Purple/Blue) */
    radial-gradient(circle at 70% 80%,
      rgba(100, 100, 255, 0.03) 0%,
      transparent 50%);
  opacity: 0.8;
  mix-blend-mode: screen;
}

/* Dynamic Light Leaks (Analog Flicker) */
.light-leak-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 30%,
      rgba(255, 120, 30, 0.15) 0%,
      rgba(255, 60, 0, 0.05) 50%,
      transparent 100%);
  mix-blend-mode: color-dodge;
  opacity: 0;
  pointer-events: none;
  z-index: 15;
  transition: opacity 0.3s ease;
}

.is-cranking .light-leak-overlay {
  opacity: 1;
  animation: light-leak-flicker 0.4s steps(4) infinite;
}

@keyframes light-leak-flicker {

  0%,
  100% {
    background-position: 0% 0%;
    filter: hue-rotate(0deg) brightness(1);
    opacity: 0.2;
  }

  25% {
    background-position: 10% 20%;
    filter: hue-rotate(15deg) brightness(1.2);
    opacity: 0.6;
  }

  50% {
    background-position: -5% 10%;
    filter: hue-rotate(-10deg) brightness(1.1);
    opacity: 1;
  }

  75% {
    background-position: 20% -10%;
    filter: hue-rotate(5deg) brightness(1.3);
    opacity: 0.8;
  }
}

/* Analog Scanlines & Noise */
.analog-noise {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0.03) 1px,
      transparent 2px);
  background-size: 100% 3px;
  pointer-events: none;
  z-index: 20;
  opacity: 0.4;
}

.is-cranking .analog-noise {
  animation: scanline-flicker 0.1s infinite;
}

@keyframes scanline-flicker {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(1px);
  }
}

/* Metallic Printer Slot (Right Side) */
.printer-slot {
  position: absolute;
  top: 0;
  right: 0;
  width: 12px;
  height: 100%;
  background: linear-gradient(to right,
      rgba(0, 0, 0, 0.9) 0%,
      #333 30%,
      #111 60%,
      rgba(0, 0, 0, 0.9) 100%);
  z-index: 20;
  box-shadow:
    -2px 0 10px rgba(0, 0, 0, 0.8),
    inset 2px 0 5px rgba(0, 0, 0, 0.5);
}

.printer-tray {
  display: flex;
  height: 100%;
  will-change: transform;
  transform: translateZ(0);
  /* Force GPU */
}

.printer-photo {
  flex-shrink: 0;
  width: 240px;
  height: 100%;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.printer-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.printer-photo.is-active img {
  transform: scale(1.05) rotate(0.4deg);
}

/* ── Auto-Play Button (Matches Timer Size) ── */
.auto-play-btn {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  font-family: var(--font-mono);
  font-size: 8px;
  /* Tiny, precise typography */
  color: var(--text-muted);
  letter-spacing: 0.15em;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  outline: none;
}

.auto-play-btn:hover {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.08);
}

.auto-play-btn:active {
  transform: translateY(1px);
}

.auto-play-btn.is-active {
  color: var(--primary);
  /* The active state has a subtle glowing text, just like the active time #v-current */
  text-shadow: 0 0 10px rgba(212, 174, 106, 0.2);
  border-color: rgba(212, 174, 106, 0.2);
  background: rgba(212, 174, 106, 0.05);
}

.auto-play-icon {
  font-size: 8px;
  line-height: 1;
  transition: all 0.3s ease;
}

.auto-play-btn.is-active .auto-play-icon {
  color: var(--primary);
  text-shadow: 0 0 5px var(--primary);
  animation: pulse-glow 2s infinite alternate;
}

@keyframes pulse-glow {
  0% {
    opacity: 0.7;
  }

  100% {
    opacity: 1;
    text-shadow: 0 0 8px var(--primary);
  }
}

/* ── Tutorial: Pulse of Life ── */
.tutorial-pulse {
  animation: tutorial-pulse-anim 2s infinite ease-in-out;
  position: relative;
  z-index: 50;
}

@keyframes tutorial-pulse-anim {
  0% {
    box-shadow: 0 0 0 0 rgba(212, 174, 106, 0.3);
    transform: scale(1);
    border-color: rgba(212, 174, 106, 0.3);
  }

  50% {
    box-shadow: 0 0 12px 4px rgba(212, 174, 106, 0);
    transform: scale(1.03);
    border-color: rgba(212, 174, 106, 0.6);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(212, 174, 106, 0);
    transform: scale(1);
    border-color: rgba(212, 174, 106, 0.3);
  }
}


/* ── Recessed Brass Crank (Mechanically Low) ── */
.music-box-crank-area {
  position: absolute;
  bottom: -20px;
  /* Moved up slightly for better visibility */
  left: 0;
  width: 100%;
  height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 30;
}

.crank-handle-wrapper {
  position: relative;
  width: 140px;
  /* Reduced from 180 */
  height: 90px;
  /* Reduced from 110 */
  cursor: grab;
  touch-action: none;
}

/* 3D Circular Recess Pit - Deep Set */
.crank-base {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  background: radial-gradient(circle at 50% 10%, #111 0%, #000 100%);
  border-radius: 50%;
  box-shadow:
    inset 0 4px 8px rgba(0, 0, 0, 0.9),
    0 0 0 3px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 174, 106, 0.2);
}

/* Antique Slender Arm - "Panjang & Mancung" */
.crank-arm {
  position: absolute;
  top: 23px;
  left: 50%;
  width: 4px;
  /* Very thin */
  height: 45px;
  /* Slender arm */
  background: linear-gradient(90deg, #8b7355 0%, #d4ae6a 50%, #8b7355 100%);
  border-radius: 20px;
  transform-origin: center 0px;
  box-shadow: -6px 12px 20px rgba(0, 0, 0, 0.5);
  z-index: 10;
  will-change: transform;
  transform: translateZ(0);
  /* Force GPU */
}

/* Mechanical Pivot */
.crank-arm::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: radial-gradient(circle at 30% 30%, #fff 0%, #d4ae6a 100%);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Pointy / Tapered Slender Knob */
.crank-knob {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 32px;
  /* Pointy handle */
  background: linear-gradient(135deg, #fffefc 0%, #f4eee0 40%, #d1c1a5 100%);
  border-radius: 40% 40% 50% 50% / 15% 15% 85% 85%;
  /* Tapered shape */
  box-shadow:
    0 15px 30px rgba(0, 0, 0, 0.6),
    inset -2px -10px 10px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Sharp Gloss Highlight for Knob */
.crank-knob::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 20%;
  width: 25%;
  height: 25%;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  filter: blur(1px);
}

.is-cranking .crank-knob {
  box-shadow:
    0 0 20px var(--primary),
    0 15px 40px rgba(0, 0, 0, 0.8);
  transition: box-shadow 0.3s ease;
}

/* Mechanical Jitter Animation */
@keyframes mechanical-jitter {
  0% {
    transform: translate3d(0, 0, 0) rotate(0);
  }

  25% {
    transform: translate3d(0.5px, -0.5px, 0) rotate(0.1deg);
  }

  50% {
    transform: translate3d(-0.5px, 0.5px, 0) rotate(-0.1deg);
  }

  75% {
    transform: translate3d(0.5px, 0.5px, 0) rotate(0.05deg);
  }

  100% {
    transform: translate3d(0, 0, 0) rotate(0);
  }
}

.is-cranking .printer-viewport {
  animation: mechanical-jitter 0.15s linear infinite;
}

/* ── Waveform (Tight) ── */
/* ── Redesigned Premium Waveform Visualizer ── */
.music-box-info {
  margin-bottom: 16px;
  position: relative;
}

.music-box-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 42px;
  margin-bottom: 16px;
  background: rgba(160, 134, 108, 0.15);
  /* Tinted background */
  border-radius: 100px;
  padding: 0 15px;
  border: 1px solid rgba(160, 134, 108, 0.4);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.5);
  position: relative;
  overflow: hidden;
  max-width: 200px;
  margin-left: auto;
  margin-right: auto;
}

/* Subtle Scanlines for Audio Display */
.music-box-waveform::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.05) 2px,
      rgba(0, 0, 0, 0.05) 4px);
  pointer-events: none;
  z-index: 10;
}

/* Glass Inner Glow */
.music-box-waveform::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
      rgba(255, 255, 255, 0.03) 0%,
      transparent 40%,
      transparent 60%,
      rgba(0, 0, 0, 0.1) 100%);
  pointer-events: none;
  z-index: 10;
}

.waveform-bar {
  width: 2px;
  height: 32px;
  background: var(--accent);
  border-radius: 4px;
  opacity: 0.15;
  will-change: transform, opacity;
  transform-origin: center;
  transform: scaleY(0.125);
  /* Initial scale for 4px height */
}

.waveform-bar.active {
  opacity: 1;
  background: linear-gradient(to bottom,
      rgba(212, 174, 106, 0.2) 0%,
      var(--primary) 30%,
      #fff 50%,
      var(--primary) 70%,
      rgba(212, 174, 106, 0.2) 100%);
  box-shadow:
    0 0 15px rgba(212, 174, 106, 0.5),
    0 0 30px rgba(212, 174, 106, 0.1);
}

/* Center-line decoration */
.music-box-waveform::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(255, 255, 255, 0.03);
  z-index: 1;
}

/* ── Brand Badge (Ultra-Premium Redesign) ── */
.watermark-badge {
  position: fixed;
  top: 35px;
  right: 35px;
  background: rgba(15, 12, 10, 0.3);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);

  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 100px;
  padding: 8px 20px 8px 14px;
  color: var(--primary);
  text-decoration: none;

  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  display: flex;
  align-items: center;

  box-shadow:
    0 10px 40px -10px rgba(0, 0, 0, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

.watermark-badge .flex {
  gap: 16px !important;
}

/* Icon Refinement */
.watermark-badge .material-symbols-outlined {
  font-size: 18px !important;
  color: var(--primary);
  filter: drop-shadow(0 0 8px rgba(212, 174, 106, 0.2));
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Text Refinement with Vertical Divider */
.watermark-badge span:last-child {
  font-family: var(--font-sans);
  font-size: 9px !important;
  font-weight: 500 !important;
  letter-spacing: 0.35em !important;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.7;

  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-block;
  line-height: 1;
  transition: all 0.4s ease;
}

.watermark-badge:hover {
  background: rgba(20, 16, 12, 0.7);
  border-color: rgba(212, 174, 106, 0.25);
  transform: translateY(-5px) scale(1.02);
  box-shadow:
    0 25px 60px -15px rgba(0, 0, 0, 0.8),
    0 0 30px rgba(212, 174, 106, 0.1);
}

.watermark-badge:hover .material-symbols-outlined {
  transform: rotate(15deg) scale(1.1);
}

.watermark-badge:hover span:last-child {
  opacity: 1;
  color: var(--primary);
  letter-spacing: 0.4em !important;
  border-left-color: rgba(212, 174, 106, 0.3);
}

/* ── Mobile Overrides ── */
@media (max-width: 768px) {
  #state-gift {
    padding: 20px 10px;
  }

  .voice-section {
    max-width: 340px;
  }

  .music-box-container {
    border-radius: 44px;
    padding: 40px 20px 145px;
  }

  .console-plate {
    top: 14px;
  }

  .slot-reopen-label {
    top: 25px;
  }

  .printer-viewport,
  .printer-photo {
    width: 200px;
    /* Scale down viewport for small phones */
    height: 200px;
  }

  .music-box-crank-area {
    height: 120px;
  }

  .crank-handle-wrapper {
    width: 140px;
  }

  .crank-arm {
    height: 45px;
  }

  .watermark-badge {
    display: none !important;
  }

  /* ── Performance: Disable heavy effects on mobile ── */
  .music-box-container {
    /* Fix 5: Remove backdrop-filter on mobile — use solid fallback */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background:
      radial-gradient(circle at 50% 50%, rgba(70, 60, 50, 0.95), rgba(40, 32, 25, 0.98));
  }

  .is-cranking .light-leak-overlay {
    animation: none;
    opacity: 0.5;
  }

  .is-cranking .analog-noise {
    animation: none;
  }

  .is-cranking .printer-viewport {
    animation: none;
  }

  /* Fix 4: Replace expensive blur filter with pre-blurred gradient */
  .bokeh-particle {
    filter: none;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    opacity: 0.04;
  }
}

/* ── Alignment Utilities (Restored) ── */
.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.gap-2 {
  gap: 0.5rem;
}

.uppercase {
  text-transform: uppercase;
}

.font-bold {
  font-weight: 700;
}

.text-xs {
  font-size: 0.65rem;
}

.music-box-timer {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  font-family: var(--font-mono);
  font-size: 8px;
  /* Tiny, precise typography */
  color: var(--text-muted);
  letter-spacing: 0.15em;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.music-box-timer span#v-current {
  color: var(--primary);
  font-weight: 500;
  text-shadow: 0 0 10px rgba(212, 174, 106, 0.2);
  min-width: 32px;
}

.time-divider {
  width: 1px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.music-box-timer span#v-total {
  opacity: 0.4;
  min-width: 32px;
}

/* ── Password Card (Minimalist Luxury Redesign) ── */
.password-card {
  background: rgba(10, 8, 6, 0.2);
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);

  padding: 80px 50px;
  border-radius: 2px;
  /* Bauhaus-inspired sharp edges */
  border: 1px solid rgba(255, 255, 255, 0.04);
  text-align: center;
  max-width: 440px;
  width: 90%;

  box-shadow:
    0 40px 100px -20px rgba(0, 0, 0, 0.6);

  animation: fade-in-up 1.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.password-title {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 400;
  font-style: italic;
  margin-bottom: 40px;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.password-field {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 15px 0;
  color: #fff;
  text-align: center;
  font-size: 16px;
  /* Prevent iOS auto-zoom */
  margin-bottom: 40px;
  outline: none;
  transition: all 0.5s ease;
  letter-spacing: 0.15em;
}

.password-field::placeholder {
  color: rgba(255, 255, 255, 0.15);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.password-field:focus {
  border-bottom-color: var(--primary);
  letter-spacing: 0.25em;
}

.unlock-btn {
  width: 100%;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 22px;
  border-radius: 0;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.unlock-btn:hover {
  background: var(--primary);
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 15px 40px rgba(212, 174, 106, 0.2);
}

.password-hint {
  margin-top: 50px;
  font-size: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.25em;
  opacity: 0.5;
}

.password-hint-box {
  position: relative;
  text-align: left;
  background: rgba(245, 235, 215, 0.06);
  border: 1px solid rgba(var(--primary-rgb, 196, 134, 125), 0.15);
  border-left: 2px solid var(--primary);
  border-radius: 0 4px 4px 0;
  padding: 18px 16px 14px 20px;
  margin-top: 28px;
  opacity: 0;
  animation: hint-appear 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.4s both;
}

.password-hint-box.hidden {
  display: none !important;
}

@keyframes hint-appear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.password-hint-label {
  position: absolute;
  top: -8px;
  left: 16px;
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--primary);
  opacity: 0.7;
}

.password-hint-text {
  font-family: var(--font-display);
  font-size: 17px;
  font-style: italic;
  color: var(--text);
  opacity: 0.75;
  line-height: 1.5;
  margin: 4px 0 0;
  letter-spacing: 0.01em;
}

.password-error {
  color: var(--primary);
  /* Subtle error */
  font-size: 9px;
  margin-top: -30px;
  margin-bottom: 30px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

.shake {
  animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

  10%,
  90% {
    transform: translateX(-1px);
  }

  20%,
  80% {
    transform: translateX(1px);
  }

  30%,
  50%,
  70% {
    transform: translateX(-2px);
  }

  40%,
  60% {
    transform: translateX(2px);
  }
}

/* ── Fullscreen Center ── */
.fullscreen-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.loading-spinner {
  width: 70px;
  height: 70px;
  border: 2px solid rgba(255, 255, 255, 0.03);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Preloading UI ── */
.preloading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  max-width: 280px;
}

.preload-text {
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  margin-top: 24px;
}

.preload-progress-bg {
  width: 100%;
  height: 2px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  overflow: hidden;
}

.preload-progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Idle Overlay (PRESS PLAY) ── */
.lcd-idle-overlay {
  position: absolute;
  inset: 0;
  background: #080706;
  /* Solid black to cover photos completely */
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: opacity 0.8s ease;
}

.lcd-idle-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.lcd-idle-line {
  width: 32px;
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.lcd-idle-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.32em;
  color: rgba(255, 255, 255, 0.22);
  text-transform: uppercase;
}



/* ============================================================
   POLAROID — ported from camera project (mossy reference)
   ============================================================ */



















/* ── Modal backdrop — soft vignette ── */
.polaroid-modal-backdrop {
  position: absolute;
  inset: 0;
  border-radius: 52px;
  z-index: 500;
  background: rgba(10, 8, 6, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.polaroid-modal-backdrop.visible {
  opacity: 1;
  pointer-events: all;
}

@media (max-width: 640px) {
  .polaroid-modal-backdrop {
    border-radius: 46px;
  }
}

/* ── Memory Card ── */
.polaroid-modal {
  position: relative;
  width: min(320px, 80vw);
  opacity: 0;
  transform: translateY(20px);
  transition: none;
  perspective: 1000px;
}

@media (max-width: 640px) {
  .polaroid-modal {
    width: min(280px, 72vw);
  }
}

@keyframes polaroid-eject {
  0% {
    transform: translateY(20px);
    opacity: 0;
  }

  60% {
    transform: translateY(-4px);
    opacity: 1;
  }

  80% {
    transform: translateY(2px);
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.polaroid-modal.entering {
  opacity: 1;
  transform: translateY(0);
  animation: polaroid-eject 0.65s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Flipper — opacity swap, no 3D (iOS safe) ── */
.polaroid-flipper {
  width: 100%;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.polaroid-flipper.flipped {
  transform: rotateY(180deg);
}

.polaroid-flipper.flipped .polaroid-front {
  opacity: 0;
  pointer-events: none;
}

.polaroid-flipper.flipped .polaroid-back {
  opacity: 1;
  pointer-events: all;
}

/* ── Shared card base ── */
.polaroid-front,
.polaroid-back {
  background: #1a1612;
  border-radius: 12px;
  border: 1px solid rgba(212, 174, 106, 0.12);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.8),
    0 4px 16px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ══════════════════════════════
   FRONT
   ══════════════════════════════ */
.polaroid-front {
  width: 100%;
  overflow: hidden;
  transition: opacity 0.25s ease;
}

.polaroid-front-photo-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #0a0806;
  border-radius: 12px 12px 0 0;
}

.polaroid-front-photo-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
      transparent 55%,
      rgba(10, 8, 6, 0.65) 100%);
  pointer-events: none;
  z-index: 2;
}

.polaroid-front-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.1) saturate(0);
  transition: filter 2.5s ease;
}

.polaroid-front-img.developed {
  filter: brightness(0.92) contrast(1.06) saturate(0.88);
}

.polaroid-front-bottom {
  padding: 12px 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.polaroid-flip-hint {
  font-family: var(--font-display), serif;
  font-size: 11px;
  font-style: italic;
  font-weight: 400;
  color: rgba(212, 174, 106, 0.6);
  letter-spacing: 0.05em;
  text-transform: lowercase;
  user-select: none;
  opacity: 0.8;
}

/* ── Close button ── */
.polaroid-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 20;
}

.polaroid-close:hover {
  background: rgba(212, 174, 106, 0.3);
  border-color: rgba(212, 174, 106, 0.5);
  color: #fff;
}

.polaroid-flipper.flipped .polaroid-close {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* ══════════════════════════════
   BACK
   ══════════════════════════════ */
.polaroid-back {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  transform: rotateY(180deg);
}

/* Subtle ruled lines */
.polaroid-back::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  border-radius: 12px;
}

.polaroid-back::after {
  display: none;
}

.polaroid-back-scroll-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  white-space: nowrap;
}

.polaroid-back-scroll-hint span {
  font-family: var(--font-mono, monospace);
  font-size: 5.5px;
  letter-spacing: 0.18em;
  color: rgba(212, 174, 106, 0.35);
  text-transform: uppercase;
}

.polaroid-back-scroll-hint::after {
  content: '∨';
  font-size: 10px;
  color: rgba(212, 174, 106, 0.3);
  animation: scroll-bounce 1.4s ease-in-out infinite;
  display: block;
  line-height: 1;
}

@keyframes scroll-bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(3px);
  }
}

.polaroid-back.has-scroll .polaroid-back-scroll-hint {
  opacity: 1;
}

.polaroid-back.scrolled-to-bottom .polaroid-back-scroll-hint {
  opacity: 0;
}

.polaroid-letter {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 19px;
  font-style: italic;
  line-height: 1.8;
  color: rgba(235, 220, 190, 0.88);
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  z-index: 2;
  padding: 18px 18px 32px 18px;
  width: 100%;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.polaroid-letter::-webkit-scrollbar {
  display: none;
}