/* --- Elegant 3D Animated Envelope and Lyrical Letter Style --- */

/* 1. Design System & Variables */
:root {
  /* Curated Premium HSL Palette */
  --bg-dark-1: hsl(222, 47%, 11%);
  --bg-dark-2: hsl(244, 49%, 10%);
  --bg-dark-3: hsl(282, 61%, 8%);
  
  --envelope-navy: hsl(217, 33%, 17%);
  --envelope-navy-dark: hsl(217, 33%, 12%);
  --gold-foil: linear-gradient(135deg, #f3d082 0%, #cfa149 50%, #997022 100%);
  --gold-solid: #d6ac56;
  --gold-glow: rgba(214, 172, 86, 0.4);
  
  --wax-red: linear-gradient(135deg, #be1c3c 0%, #8b0c22 70%, #5d0312 100%);
  --wax-seal-shadow: rgba(0, 0, 0, 0.5);
  
  --parchment-cream: #faf6ee;
  --parchment-shadow: rgba(0, 0, 0, 0.35);
  --ink-color: #2b2520;
  --ink-muted: #5c554e;
  
  --font-serif: 'Playfair Display', 'Noto Serif TC', serif;
  --font-serif-body: 'Cormorant Garamond', 'Noto Serif TC', serif;
  --font-handwriting: 'Great Vibes', cursive;
  --font-sans: 'Inter', system-ui, sans-serif;
  
  --transition-smooth: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-elastic: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 2. Base Reset & Structure */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, var(--bg-dark-2) 0%, var(--bg-dark-1) 50%, var(--bg-dark-3) 100%);
  font-family: var(--font-sans);
  color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
}

/* Canvas Background Star Particles */
#ambient-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* Starry Sky Ambient Lights */
.sky-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}
.glow-1 {
  width: 40vw;
  height: 40vw;
  top: 10%;
  left: 15%;
  background: radial-gradient(circle, rgba(162, 89, 255, 0.4) 0%, transparent 70%);
}
.glow-2 {
  width: 35vw;
  height: 35vw;
  bottom: 10%;
  right: 15%;
  background: radial-gradient(circle, rgba(214, 172, 86, 0.3) 0%, transparent 70%);
}

#app-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1;
}

/* 3. Ambient Player Widget */
#player-widget {
  position: absolute;
  top: 25px;
  right: 25px;
  width: 76px;
  height: 76px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(214, 172, 86, 0.25);
  border-radius: 50%;
  cursor: pointer;
  z-index: 100;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.1);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

#player-widget:hover {
  transform: scale(1.05);
  border-color: var(--gold-solid);
  box-shadow: 0 10px 30px rgba(214, 172, 86, 0.15), inset 0 1px 2px rgba(255, 255, 255, 0.15);
}

.player-hidden {
  opacity: 0.8;
}

.turntable-body {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, #3a2e24 0%, #221a14 100%);
  border: 2px solid #5a4b3d;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.vinyl-disc {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, #181818, #181818 2px, #262626 3px, #181818 4px);
  border: 1px solid #111;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.5s linear;
}

/* Vinyl Spin */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.vinyl-disc.playing {
  animation: spin 3.5s linear infinite;
}

.vinyl-label {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold-foil);
  border: 1px solid #000;
}

.tonearm {
  position: absolute;
  top: 6px;
  right: -2px;
  width: 24px;
  height: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d6ac56' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 3v5m0 0l-5 4m5-4H10a6 6 0 0 0-6 6v3'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  transform-origin: 20px 4px;
  transform: rotate(-15deg);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

#player-widget.active .tonearm {
  transform: rotate(10deg);
}

.player-tooltip {
  position: absolute;
  right: 90px;
  top: 24px;
  background: rgba(13, 27, 42, 0.85);
  color: var(--gold-solid);
  font-size: 13px;
  font-family: var(--font-serif);
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid rgba(214, 172, 86, 0.3);
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#player-widget:hover .player-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* 4. 3D Envelope Container */
#envelope-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.envelope-fade-out {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.envelope {
  position: relative;
  width: 420px;
  height: 280px;
  background: var(--envelope-navy);
  border-radius: 8px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  transform-style: preserve-3d;
  cursor: pointer;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

/* Envelope floating animation when idle */
@keyframes float {
  0% { transform: translateY(0px) rotateX(10deg); }
  50% { transform: translateY(-8px) rotateX(12deg); }
  100% { transform: translateY(0px) rotateX(10deg); }
}

.envelope-floating {
  animation: float 4.5s ease-in-out infinite;
}

.envelope:hover {
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6), 0 0 30px rgba(214, 172, 86, 0.15);
}

/* Envelope Internal Layers */
.envelope-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--envelope-navy-dark);
  border-radius: 8px;
  z-index: 1;
  overflow: hidden;
}

/* Decorative background texture inside the envelope */
.envelope-back::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(214, 172, 86, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

/* Pocket Front Overlay (V-Shape Pocket) */
.envelope-front {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--envelope-navy);
  clip-path: polygon(0 110px, 50% 195px, 100% 110px, 100% 280px, 0 280px);
  z-index: 20;
  border-radius: 0 0 8px 8px;
  box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.08);
}

.envelope-front-border {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  clip-path: polygon(0 110px, 50% 195px, 100% 110px, 100% 280px, 0 280px);
  border-bottom: 2px solid rgba(214, 172, 86, 0.4);
}

/* Gold line details along the pocket V-cut */
.envelope-front::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 1px solid rgba(214, 172, 86, 0.2);
  clip-path: polygon(0 112px, 50% 197px, 100% 112px, 100% 280px, 0 280px);
  pointer-events: none;
}

/* Left & Right Internal Folds (realistic flaps visual overlap) */
.envelope-internal-left {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: hsl(217, 33%, 15%);
  clip-path: polygon(0 0, 100% 140px, 0 280px);
  z-index: 18;
  opacity: 0.95;
  border-radius: 8px 0 0 8px;
  border-right: 1px solid rgba(0, 0, 0, 0.2);
}

.envelope-internal-right {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  background: hsl(217, 33%, 15%);
  clip-path: polygon(100% 0, 0 140px, 100% 280px);
  z-index: 18;
  opacity: 0.95;
  border-radius: 0 8px 8px 0;
  border-left: 1px solid rgba(0, 0, 0, 0.2);
}

/* 5. The Top 3D Flap */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 140px;
  transform-origin: top center;
  transform-style: preserve-3d;
  z-index: 40;
  transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px 8px 0 0;
}

/* Exterior flap front */
.flap-front {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--envelope-navy);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  backface-visibility: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  border-radius: 8px 8px 0 0;
}

/* Subtle gold trim line for flap */
.flap-front::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(214, 172, 86, 0.25);
  clip-path: polygon(1px 0, calc(100% - 1px) 0, 50% calc(100% - 2px));
  pointer-events: none;
}

/* Interior flap back (revealed when flipped open) */
.flap-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #c59b48;
  background: var(--gold-foil);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  backface-visibility: hidden;
  transform: rotateX(180deg);
  overflow: hidden;
}

/* Elegant wallpaper pattern on inside flap */
.flap-pattern {
  position: absolute;
  top: -20px;
  left: -20px;
  width: calc(100% + 40px);
  height: calc(100% + 40px);
  opacity: 0.15;
  background-image: radial-gradient(circle, #000 20%, transparent 20%),
                    radial-gradient(circle, #000 20%, transparent 20%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}

.flap-back::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 2px solid var(--envelope-navy-dark);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  opacity: 0.3;
}

/* Opened flap animation class */
.envelope.open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 5; /* Sit behind the paper when fully unfolded */
}

/* 6. Wax Seal Layer */
.wax-seal {
  position: absolute;
  top: 110px;
  left: calc(50% - 30px);
  width: 60px;
  height: 60px;
  z-index: 50;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
}

.wax-seal-outer {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--wax-red);
  box-shadow: 0 4px 10px var(--wax-seal-shadow), inset 0 2px 4px rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transform: rotate(-10deg);
  transition: transform 0.3s ease;
}

.wax-seal-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px dashed rgba(214, 172, 86, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
}

.wax-seal-svg {
  width: 32px;
  height: 32px;
  filter: drop-shadow(1px 2px 1px rgba(0,0,0,0.5));
  transition: transform 0.3s ease;
}

.seal-glow {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-solid) 0%, transparent 60%);
  opacity: 0.3;
  z-index: -1;
  pointer-events: none;
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.25; }
  50% { transform: scale(1.15); opacity: 0.5; }
  100% { transform: scale(0.9); opacity: 0.25; }
}

.wax-seal:hover {
  transform: scale(1.1) rotate(5deg);
}

.wax-seal:hover .wax-seal-outer {
  box-shadow: 0 8px 20px var(--wax-seal-shadow), 0 0 15px rgba(214,172,86,0.3), inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.wax-seal:hover .wax-seal-svg {
  transform: scale(1.05);
}

/* Melt / Dissolve Wax animation when clicked */
.envelope.open .wax-seal {
  transform: scale(0.1) rotate(45deg);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.6s cubic-bezier(0.6, -0.28, 0.735, 0.045), opacity 0.5s ease;
}

/* 7. Dummy Paper Inside */
.dummy-paper {
  position: absolute;
  top: 15px;
  left: calc(50% - 190px);
  width: 380px;
  height: 250px;
  background: var(--parchment-cream);
  border-radius: 4px;
  z-index: 2;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), inset 0 0 40px rgba(197, 155, 72, 0.08);
  border: 1px solid #eadecd;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  transition: transform 1.2s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.4s ease;
}

.dummy-paper-top {
  width: 100%;
  height: 100%;
  border: 1px double #cfa149;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gold-seal-emboss {
  font-size: 24px;
  color: var(--gold-solid);
  opacity: 0.4;
  filter: drop-shadow(1px 1px 1px #fff);
}

/* Slide Dummy Paper Out When Envelope Open */
.envelope.open .dummy-paper {
  transform: translateY(-160px);
  z-index: 25; /* Rises in front of the flap but behind pocket */
  transition-delay: 1.1s;
}

/* Fade dummy paper out when real letter shows */
.envelope-open-complete .dummy-paper {
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* Interaction Hint Box */
#interaction-hint {
  margin-top: 30px;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--gold-solid);
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  opacity: 0.85;
  transition: opacity 0.4s ease;
}

@keyframes hint-breath {
  0% { opacity: 0.4; transform: translateY(0); }
  50% { opacity: 0.9; transform: translateY(-3px); }
  100% { opacity: 0.4; transform: translateY(0); }
}

.hint-pulse {
  animation: hint-breath 2.5s ease-in-out infinite;
}

.envelope.open + #interaction-hint {
  opacity: 0;
  pointer-events: none;
}

/* 8. Blur Backdrop Glassmorphism Overlay */
#backdrop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(13, 27, 42, 0.4);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#backdrop-overlay.overlay-visible {
  opacity: 1;
  pointer-events: all;
}

/* 9. The Real Lyrical Letter Paper Panel */
#real-letter-paper {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 90vw;
  max-width: 650px;
  height: auto;
  max-height: 88vh;
  background-color: var(--parchment-cream);
  background-image: radial-gradient(rgba(197, 155, 72, 0.04) 1px, transparent 0),
                    radial-gradient(rgba(197, 155, 72, 0.04) 1px, transparent 0);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  border-radius: 8px;
  box-shadow: 0 25px 65px var(--parchment-shadow), inset 0 0 50px rgba(197, 155, 72, 0.08);
  border: 1px solid #e3d2be;
  z-index: 90;
  padding: 35px 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  pointer-events: none;
  transition: transform 1.2s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 1s ease;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(214, 172, 86, 0.3) transparent;
}

#real-letter-paper::-webkit-scrollbar {
  width: 6px;
}
#real-letter-paper::-webkit-scrollbar-track {
  background: transparent;
  margin: 15px 0;
}
#real-letter-paper::-webkit-scrollbar-thumb {
  background-color: rgba(197, 155, 72, 0.3);
  border-radius: 10px;
}

#real-letter-paper.letter-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: all;
}

/* Custom Letter Border styling */
.letter-frame {
  width: 100%;
  height: auto;
  min-height: auto;
  flex: 0 0 auto;
  border: 1px solid rgba(214, 172, 86, 0.3);
  position: relative;
  padding: 40px 30px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: visible;
}

/* Double gold border trim */
.letter-double-border {
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border: 2px solid var(--gold-solid);
  pointer-events: none;
}

.letter-frame::before {
  content: '';
  position: absolute;
  top: 9px;
  left: 9px;
  right: 9px;
  bottom: 9px;
  border: 1px dashed var(--gold-solid);
  opacity: 0.5;
  pointer-events: none;
}

/* Scrollbar styling inside frame */
.letter-frame::-webkit-scrollbar {
  width: 5px;
}
.letter-frame::-webkit-scrollbar-track {
  background: transparent;
}
.letter-frame::-webkit-scrollbar-thumb {
  background-color: rgba(197, 155, 72, 0.3);
  border-radius: 10px;
}

/* Letter Headers & Footer elements */
.letter-header {
  text-align: center;
  margin-bottom: 25px;
}

.letter-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 24px;
  color: var(--ink-color);
  letter-spacing: 4px;
  margin-bottom: 8px;
  text-shadow: 0.5px 0.5px 0.5px #fff;
}

.letter-date {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--ink-muted);
  letter-spacing: 2px;
}

.header-flourish {
  width: 80px;
  height: 12px;
  margin: 0 auto 15px auto;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.7;
}

.top-flourish {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' fill='none' stroke='%23d6ac56' stroke-width='2'%3E%3Cpath d='M10 10 C30 -5, 40 25, 50 10 C60 -5, 70 25, 90 10'/%3E%3Ccircle cx='50' cy='10' r='2' fill='%23d6ac56'/%3E%3C/svg%3E");
}

.bottom-flourish {
  margin-top: 15px;
  margin-bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' fill='none' stroke='%23d6ac56' stroke-width='2'%3E%3Cpath d='M10 10 Q50 25 90 10'/%3E%3Ccircle cx='50' cy='15' r='1.5' fill='%23d6ac56'/%3E%3C/svg%3E");
}

/* Lyrical lines fading in */
.letter-body {
  text-align: center;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  margin: 15px 0;
}

.lyrics-verse {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 1.5s cubic-bezier(0.25, 1, 0.5, 1), transform 1.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.lyrics-verse.lyrics-reveal {
  opacity: 1;
  transform: translateY(0);
}

.lyrics-line {
  font-family: var(--font-serif-body);
  font-size: 17px;
  color: var(--ink-color);
  line-height: 1.8;
  letter-spacing: 2.5px;
  font-weight: 500;
}

/* Decorative Divider */
.lyrics-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 10px 0;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 2s cubic-bezier(0.25, 1, 0.5, 1), transform 2s cubic-bezier(0.25, 1, 0.5, 1);
  transition-delay: 7.5s;
}

.lyrics-divider.divider-reveal {
  opacity: 0.6;
  transform: scale(1);
}

.divider-dot {
  color: var(--gold-solid);
  font-size: 11px;
}

.divider-line {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-solid), transparent);
}

/* Letter Footer & Sign */
.letter-footer {
  text-align: center;
  margin-top: 25px;
}

.signature-intro {
  font-size: 14px;
  font-style: italic;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

.signature-name {
  font-family: var(--font-handwriting);
  font-size: 32px;
  color: var(--gold-solid);
  margin-bottom: 5px;
  letter-spacing: 1px;
}

/* Close Button (Floating in top-right of paper) */
.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(250, 246, 238, 0.85);
  border: 1px solid rgba(214, 172, 86, 0.4);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--gold-solid);
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.4s ease;
  opacity: 0;
  transform: scale(0.8);
}

#real-letter-paper.letter-visible .close-btn {
  opacity: 1;
  transform: scale(1);
  transition-delay: 1.5s; /* Show up after paper settled */
}

.close-btn:hover {
  background: var(--gold-solid);
  color: #fff;
  border-color: var(--gold-solid);
  box-shadow: 0 4px 12px rgba(214, 172, 86, 0.3);
  transform: scale(1.05) rotate(90deg);
}

.close-icon {
  font-size: 24px;
  line-height: 1;
}

.close-text {
  display: none; /* Hide the text, keep circular golden button */
}

.close-btn:hover {
  background: var(--gold-solid);
  color: var(--bg-dark-1);
  border-color: var(--gold-solid);
  box-shadow: 0 6px 20px rgba(214, 172, 86, 0.3);
}

.close-icon {
  font-size: 18px;
  line-height: 1;
}

/* Sparkles Floating on the paper (decorative) */
.letter-sparkle-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.letter-sparkle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--gold-solid);
  border-radius: 50%;
  filter: drop-shadow(0 0 2px var(--gold-solid));
  animation: float-sparkle 6s linear infinite;
  opacity: 0;
}

@keyframes float-sparkle {
  0% { transform: translateY(100px) scale(0); opacity: 0; }
  20% { opacity: 0.6; }
  80% { opacity: 0.6; }
  100% { transform: translateY(-500px) scale(1.2); opacity: 0; }
}

/* Typography styles based on Font Face */
.font-serif {
  font-family: var(--font-serif);
}

.font-serif-tc {
  font-family: var(--font-serif-body);
}

.font-handwriting {
  font-family: var(--font-handwriting);
}

/* 10. Responsive Adaptability */
@media (max-width: 480px) {
  .envelope {
    width: 310px;
    height: 210px;
  }
  
  .envelope-front {
    clip-path: polygon(0 80px, 50% 145px, 100% 80px, 100% 210px, 0 210px);
  }
  
  .envelope-front-border {
    clip-path: polygon(0 80px, 50% 145px, 100% 80px, 100% 210px, 0 210px);
  }
  
  .envelope-front::before {
    clip-path: polygon(0 82px, 50% 147px, 100% 82px, 100% 210px, 0 210px);
  }

  .envelope-internal-left {
    clip-path: polygon(0 0, 100% 105px, 0 210px);
  }

  .envelope-internal-right {
    clip-path: polygon(100% 0, 0 105px, 100% 210px);
  }
  
  .envelope-flap {
    height: 105px;
  }
  
  .flap-front, .flap-back {
    clip-path: polygon(0 0, 100% 0, 50% 100%);
  }
  
  .wax-seal {
    top: 80px;
    left: calc(50% - 25px);
    width: 50px;
    height: 50px;
  }
  
  .dummy-paper {
    width: 280px;
    height: 180px;
    left: calc(50% - 140px);
  }
  
  .envelope.open .dummy-paper {
    transform: translateY(-110px);
  }
  
  #interaction-hint {
    font-size: 14px;
  }
  
  #real-letter-paper {
    padding: 20px;
    height: 82vh;
  }
  
  .letter-frame {
    padding: 15px;
  }
  
  .letter-title {
    font-size: 19px;
    letter-spacing: 2px;
  }
  
  .lyrics-line {
    font-size: 14px;
    letter-spacing: 1.5px;
    line-height: 1.6;
  }
  
  .signature-name {
    font-size: 26px;
  }
  
  #player-widget {
    top: 15px;
    right: 15px;
    width: 60px;
    height: 60px;
  }
  
  .turntable-body {
    width: 48px;
    height: 48px;
  }
  
  .vinyl-disc {
    width: 34px;
    height: 34px;
  }
  
  .vinyl-label {
    width: 10px;
    height: 10px;
  }
  
  .tonearm {
    width: 20px;
    height: 20px;
    top: 4px;
  }
}
