* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2b2016;
  font-family: 'Caveat', cursive;
  touch-action: none;
}

body {
  background: radial-gradient(ellipse at center, #3a2c1c 0%, #201509 100%);
}

.scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 0.5s ease;
}

.scene.hidden {
  opacity: 0;
  pointer-events: none;
}

.desk-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(255, 220, 160, 0.12), transparent 60%);
  pointer-events: none;
}

/* ============ ENVELOPE ============ */

.envelope-container {
  position: relative;
  width: min(320px, 80vw);
  height: min(220px, 55vw);
  perspective: 900px;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.8s, opacity 0.6s;
  animation: envelopeFloat 3s ease-in-out infinite;
}

@keyframes envelopeFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(-1deg); }
}

.envelope-container.flipped {
  animation: none;
}

.envelope-container.slide-away {
  transform: translateY(120vh) rotate(-6deg) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

.envelope-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s ease-in-out;
}

.envelope-container.flipped .envelope-inner {
  transform: rotateY(180deg);
}

.envelope-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 6px;
  overflow: hidden;
}

.envelope-front, .envelope-back {
  background: linear-gradient(160deg, #d9c19a 0%, #c9a876 30%, #b8925f 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.envelope-back {
  transform: rotateY(180deg);
}

.envelope-texture {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 8px,
    rgba(0,0,0,0.03) 8px, rgba(0,0,0,0.03) 9px
  );
  pointer-events: none;
}

.envelope-name {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 700;
  color: #2a1a0a;
  text-align: center;
  z-index: 2;
  padding: 10px 20px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.wax-seal {
  width: min(80px, 20vw);
  height: min(80px, 20vw);
  background: radial-gradient(circle at 40% 35%,
    #e85555 0%, #cc3333 30%, #8b1a1a 70%, #5a0a0a 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(255, 150, 150, 0.3),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3);
  z-index: 5;
  transition: transform 0.4s, opacity 0.4s;
}

.seal-inner {
  width: 62%;
  height: 62%;
  border: 2px solid rgba(255, 200, 200, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seal-glyph {
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  color: rgba(255, 220, 220, 0.85);
  line-height: 1;
}

.wax-seal.breaking {
  transform: scale(1.6);
  opacity: 0;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  transform-origin: top center;
  transition: transform 0.6s ease-in-out;
  z-index: 4;
}

.flap-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #c9a876 0%, #b8925f 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.envelope-flap.opened {
  transform: rotateX(180deg);
}

.prompt-text {
  margin-top: 2.2rem;
  color: #e8d9c0;
  font-size: clamp(1rem, 4vw, 1.3rem);
  text-align: center;
  padding: 0 1.5rem;
  transition: opacity 0.4s;
}

.prompt-text.hidden {
  opacity: 0;
}

/* ============ ALBUM ============ */

#album-scene {
  color: #e8d9c0;
}

.album-topbar {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 20;
}

.progress {
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

.deck-area {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.deck {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
}

.card {
  position: absolute;
  inset: 0;
  will-change: transform, opacity;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card.dragging {
  cursor: grabbing;
  transition: none !important;
}

.card img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(232, 217, 192, 0.12);
  color: #e8d9c0;
  font-size: 1.6rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 15;
  transition: background 0.2s, opacity 0.3s;
}

.nav-btn:active { background: rgba(232, 217, 192, 0.25); }
.nav-btn:disabled { opacity: 0.25; pointer-events: none; }
.nav-left { left: 4px; }
.nav-right { right: 4px; }

@media (min-width: 640px) {
  .nav-left { left: 16px; }
  .nav-right { right: 16px; }
}

.hint {
  margin-bottom: max(18px, env(safe-area-inset-bottom));
  font-size: 1.1rem;
  opacity: 0.65;
  text-align: center;
  padding: 0 1rem;
  transition: opacity 0.4s;
}

.hint.hidden { opacity: 0; }

/* ============ MODAL ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 7, 3, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s;
}

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

.modal {
  width: 100%;
  max-width: 420px;
  background: #f7f1e3;
  color: #2a1a0a;
  border-radius: 20px 20px 0 0;
  padding: 1.8rem 1.6rem max(1.8rem, env(safe-area-inset-bottom));
  text-align: center;
  transform: translateY(0);
  transition: transform 0.35s ease;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
}

.modal-overlay.hidden .modal {
  transform: translateY(100%);
}

.modal-seal {
  color: #8b1a1a;
  font-size: 1.6rem;
  margin-bottom: 0.2rem;
}

.modal h2 {
  font-family: 'Dancing Script', cursive;
  font-size: 2rem;
  margin: 0 0 0.3rem;
}

.modal p {
  font-family: Arial, sans-serif;
  font-size: 0.95rem;
  color: #5a4632;
  margin: 0 0 1.4rem;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.modal-btn {
  font-family: Arial, sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 2px solid #8b1a1a;
  background: transparent;
  color: #8b1a1a;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.modal-btn:active { transform: scale(0.97); }

.modal-btn-primary {
  background: #8b1a1a;
  color: #f7f1e3;
}

.modal-cancel {
  margin-top: 1rem;
  background: none;
  border: none;
  font-family: Arial, sans-serif;
  font-size: 0.9rem;
  color: #8a7a63;
  cursor: pointer;
  padding: 0.4rem;
}
