:root {
  --bg-deep: #050714;
  --bg-mid: #0b1026;
  --bg-plum: #160e29;
  --glass-bg: rgba(16, 22, 48, 0.58);
  --glass-border: rgba(255, 224, 165, 0.18);
  --glass-highlight: rgba(255, 255, 255, 0.08);
  --gold: #f5c96a;
  --gold-soft: #fde6a8;
  --rose: #fb7185;
  --rose-soft: #fda4af;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --shadow-glow: 0 12px 42px rgba(0, 0, 0, 0.55), 0 0 36px rgba(245, 201, 106, 0.09);
  --radius-lg: 24px;
  --radius-md: 16px;
  --font-sans: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 10%, #19143a 0%, var(--bg-mid) 42%, var(--bg-deep) 100%);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: hidden;
  direction: rtl;
  line-height: 1.7;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* Sky canvases & moon */
#sky-canvas,
#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#sky-canvas {
  z-index: 0;
}

#fx-canvas {
  z-index: 60;
}

.moon-wrap {
  position: fixed;
  top: 22px;
  left: 22px;
  width: 72px;
  height: 72px;
  pointer-events: none;
  z-index: 1;
}

.moon-halo {
  position: absolute;
  inset: -26px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(253, 230, 168, 0.28) 0%, rgba(253, 230, 168, 0.05) 55%, transparent 72%);
  animation: moonPulse 6s ease-in-out infinite;
}

.moon {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffbeb 0%, #fde6a8 52%, #e8be6b 100%);
  box-shadow: 0 0 28px rgba(253, 230, 168, 0.55), inset -8px -8px 16px rgba(173, 126, 44, 0.25);
}

.nebula-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(75px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.nebula-1 {
  width: 280px;
  height: 280px;
  bottom: -60px;
  right: -60px;
  background: radial-gradient(circle, rgba(251, 113, 133, 0.35), transparent 70%);
}

.nebula-2 {
  width: 320px;
  height: 320px;
  top: 30%;
  left: -100px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.28), transparent 70%);
}

@keyframes moonPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.1); opacity: 1; }
}

/* Top HUD */
.top-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(to bottom, rgba(5, 7, 20, 0.88) 0%, rgba(5, 7, 20, 0) 100%);
}

.constellation {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(12, 17, 38, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  overflow-x: auto;
  max-width: calc(100% - 92px);
  scrollbar-width: none;
}

.constellation::-webkit-scrollbar {
  display: none;
}

.star-node {
  position: relative;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.star-node.unlocked {
  border-color: rgba(245, 201, 106, 0.55);
  background: rgba(245, 201, 106, 0.14);
  color: var(--gold-soft);
}

.star-node.completed {
  border-color: rgba(251, 113, 133, 0.65);
  background: linear-gradient(135deg, rgba(251, 113, 133, 0.26), rgba(245, 201, 106, 0.24));
  color: #fff;
}

.star-node.active {
  transform: scale(1.16);
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--gold), var(--rose));
  color: #120d1d;
  box-shadow: 0 0 16px rgba(245, 201, 106, 0.7);
}

.star-node.locked {
  opacity: 0.48;
}

.music-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(245, 201, 106, 0.35);
  background: rgba(16, 22, 48, 0.78);
  backdrop-filter: blur(12px);
  color: var(--gold-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.music-btn:active {
  transform: scale(0.95);
}

.music-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.music-bars i {
  display: block;
  width: 2.5px;
  height: 4px;
  background: var(--gold);
  border-radius: 2px;
  transition: height 0.2s ease;
}

.music-btn.playing .music-bars i:nth-child(1) { animation: barBounce 0.8s ease-in-out infinite; }
.music-btn.playing .music-bars i:nth-child(2) { animation: barBounce 0.6s ease-in-out 0.15s infinite; }
.music-btn.playing .music-bars i:nth-child(3) { animation: barBounce 0.9s ease-in-out 0.3s infinite; }
.music-btn.muted { opacity: 0.65; border-color: rgba(255, 255, 255, 0.2); }

@keyframes barBounce {
  0%, 100% { height: 4px; }
  50% { height: 12px; }
}

/* Preview banner & Toast */
.preview-banner {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(245, 201, 106, 0.94);
  color: #111827;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.45);
}

.preview-banner button {
  border: none;
  background: #111827;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.toast {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translate(-50%, -14px);
  z-index: 80;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 52, 0.94);
  border: 1px solid rgba(245, 201, 106, 0.45);
  color: var(--gold-soft);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Main App Container */
.app-shell {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 540px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 84px 16px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stage-view {
  animation: stageIn 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes stageIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.glass-card {
  position: relative;
  background: linear-gradient(155deg, rgba(24, 31, 66, 0.72) 0%, rgba(12, 16, 36, 0.78) 100%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 26px 20px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-glow);
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(253, 230, 168, 0.28), rgba(251, 113, 133, 0.16), transparent 60%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.center-card {
  text-align: center;
  padding: 40px 24px;
}

.spinner-star {
  font-size: 36px;
  color: var(--gold);
  animation: spinStar 3s linear infinite;
  margin-bottom: 10px;
}

@keyframes spinStar {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(245, 201, 106, 0.12);
  border: 1px solid rgba(245, 201, 106, 0.34);
  color: var(--gold-soft);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

.stage-header-block {
  text-align: center;
  margin-bottom: 18px;
}

.stage-title {
  margin: 0 0 8px;
  font-size: 1.55rem;
  font-weight: 800;
  background: linear-gradient(120deg, #fff 15%, var(--gold-soft) 55%, var(--rose-soft) 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.4;
}

.stage-subtitle {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.muted-text {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.big-emoji {
  font-size: 46px;
  margin-bottom: 10px;
}

/* Buttons */
.stage-actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 28px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--gold) 0%, #f59e0b 45%, var(--rose) 100%);
  color: #160c1f;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(251, 113, 133, 0.3), 0 0 24px rgba(245, 201, 106, 0.35);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: scale(0.95);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 24px;
  border-radius: 999px;
  border: 1px solid rgba(245, 201, 106, 0.45);
  background: rgba(245, 201, 106, 0.1);
  color: var(--gold-soft);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.btn-secondary:active {
  transform: scale(0.96);
}

/* Stage 1: Welcome */
.welcome-card {
  text-align: center;
  padding: 34px 22px;
}

.hero-star-emblem {
  font-size: 38px;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(245, 201, 106, 0.8);
  margin: 4px 0 14px;
  animation: floatGentle 4s ease-in-out infinite;
}

@keyframes floatGentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.typed-box {
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  font-size: 1.18rem;
  font-weight: 600;
  color: #fff;
}

.typed-line {
  margin: 0;
}

.typed-line.lead {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--gold-soft);
}

.typed-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--rose-soft);
  margin-right: 4px;
  vertical-align: middle;
  animation: blinkCursor 0.8s steps(2) infinite;
}

@keyframes blinkCursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Stage 2: Counter */
#stage-2 .stage-card {
  text-align: center;
}

.counter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 22px 0 18px;
}

.counter-tile {
  padding: 14px 6px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(245, 201, 106, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.counter-num {
  display: block;
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--gold-soft);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.counter-lbl {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--rose-soft);
  font-weight: 600;
}

.milestone-line {
  margin: 10px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(251, 113, 133, 0.09);
  border: 1px dashed rgba(251, 113, 133, 0.35);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Stage 3: Memories Timeline */
.timeline-wrap {
  position: relative;
  padding-right: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.timeline-wrap::before {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  right: 7px;
  width: 2px;
  background: linear-gradient(to bottom, var(--gold), var(--rose), rgba(245, 201, 106, 0.15));
  border-radius: 2px;
}

.timeline-card {
  position: relative;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.timeline-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.timeline-dot {
  position: absolute;
  right: -23px;
  top: 22px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--rose));
  box-shadow: 0 0 14px rgba(245, 201, 106, 0.85);
  border: 2px solid #090e22;
}

.timeline-date {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 6px;
}

.timeline-title {
  margin: 0 0 8px;
  font-size: 1.12rem;
  font-weight: 800;
  color: #fff;
}

.timeline-photo-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 10px;
  cursor: zoom-in;
}

.timeline-photo-btn img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.timeline-photo-btn:hover img {
  transform: scale(1.02);
}

.timeline-caption {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Stage 4: Scratch Cards */
.scratch-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scratch-card-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 122px;
  border: 1px solid rgba(245, 201, 106, 0.3);
  background: linear-gradient(135deg, rgba(251, 113, 133, 0.14), rgba(245, 201, 106, 0.12));
  box-shadow: var(--shadow-glow);
}

.scratch-under {
  min-height: 122px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.scratch-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

.scratch-secret-text {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 700;
  color: #fff;
}

.scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  transition: opacity 0.45s ease;
}

.scratch-card-wrap.revealed .scratch-canvas {
  opacity: 0;
  pointer-events: none;
}

.scratch-progress-pill {
  margin: 16px auto 0;
  width: fit-content;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--gold-soft);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* Stage 5: Quiz */
.quiz-progress-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.quiz-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: transform 0.25s ease, background 0.25s ease;
}

.quiz-dot.current {
  transform: scale(1.25);
  background: var(--gold);
}

.quiz-dot.done-right {
  background: #34d399;
}

.quiz-dot.done-wrong {
  background: var(--rose);
}

.quiz-question {
  font-size: 1.12rem;
  font-weight: 800;
  margin: 0 0 16px;
  color: #fff;
  text-align: center;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-opt-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 0.96rem;
  font-weight: 600;
  text-align: right;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.2s ease, background 0.2s ease;
}

.quiz-opt-btn:hover:not(:disabled) {
  border-color: rgba(245, 201, 106, 0.5);
  background: rgba(245, 201, 106, 0.08);
}

.quiz-opt-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.quiz-opt-btn.correct {
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.18);
  color: #ecfdf5;
}

.quiz-opt-btn.wrong {
  border-color: var(--rose);
  background: rgba(251, 113, 133, 0.18);
  animation: gentleShake 0.35s ease;
}

.quiz-reaction {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 14px;
  background: rgba(245, 201, 106, 0.11);
  border: 1px solid rgba(245, 201, 106, 0.32);
  color: var(--gold-soft);
  font-weight: 600;
  text-align: center;
  animation: stageIn 0.3s ease;
}

.quiz-score-box {
  text-align: center;
  padding: 10px 4px;
}

.quiz-score-num {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 6px;
}

/* Stage 6: Open-When Envelopes */
.envelopes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.envelope-card {
  position: relative;
  padding: 0;
  border: 1px solid rgba(245, 201, 106, 0.3);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(30, 38, 78, 0.85), rgba(16, 20, 46, 0.92));
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.envelope-card:active {
  transform: scale(0.97);
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 58px;
  background: linear-gradient(180deg, rgba(245, 201, 106, 0.22), rgba(251, 113, 133, 0.1));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.envelope-card.opened .envelope-flap {
  transform: rotateX(160deg);
  opacity: 0.45;
}

.envelope-seal {
  position: relative;
  z-index: 2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fb7185, #be123c);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 4px 14px rgba(190, 18, 60, 0.5);
  margin-bottom: 10px;
  transition: transform 0.35s ease;
}

.envelope-card.opened .envelope-seal {
  background: radial-gradient(circle at 30% 30%, var(--gold-soft), #d97706);
  transform: scale(0.9);
}

.envelope-label {
  position: relative;
  z-index: 2;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0 16px;
}

.envelope-status {
  position: relative;
  z-index: 2;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--gold-soft);
}

/* Stage 7: Voice Note */
.voice-card {
  text-align: center;
}

.voice-player-box {
  margin-top: 12px;
  padding: 20px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(245, 201, 106, 0.24);
}

.voice-orb {
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  border-radius: 50%;
  padding: 6px;
  background: radial-gradient(circle, rgba(251, 113, 133, 0.35), rgba(245, 201, 106, 0.14));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s ease;
}

.voice-orb.playing {
  box-shadow: 0 0 32px rgba(251, 113, 133, 0.55);
  animation: orbPulse 1.6s ease-in-out infinite;
}

@keyframes orbPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.voice-play-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--gold), var(--rose));
  color: #140c1f;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(251, 113, 133, 0.4);
}

.voice-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  margin-bottom: 14px;
}

.voice-wave span {
  display: block;
  width: 4px;
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(to top, var(--rose), var(--gold-soft));
  opacity: 0.5;
  transition: height 0.15s ease, opacity 0.2s ease;
}

.voice-wave.playing span {
  opacity: 1;
  animation: wavePulse 0.9s ease-in-out infinite;
}

@keyframes wavePulse {
  0%, 100% { height: 8px; }
  50% { height: 32px; }
}

.voice-scrubber-row {
  display: flex;
  align-items: center;
  gap: 10px;
  direction: ltr;
}

.voice-seek {
  flex: 1;
  accent-color: var(--gold);
  cursor: pointer;
}

.time-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}

.voice-caption {
  margin: 12px 0 0;
  color: var(--gold-soft);
  font-size: 0.92rem;
  font-weight: 600;
}

/* Stage 8: Final Secret */
.secret-card,
.final-reveal-card {
  text-align: center;
}

.locked-heart-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 6px auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heart-pulse-ring {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid rgba(251, 113, 133, 0.45);
  animation: ringExpand 2.2s ease-out infinite;
}

@keyframes ringExpand {
  0% { transform: scale(0.85); opacity: 0.85; }
  100% { transform: scale(1.35); opacity: 0; }
}

.locked-heart {
  font-size: 56px;
  filter: drop-shadow(0 0 18px rgba(251, 113, 133, 0.75));
}

.lock-icon {
  position: absolute;
  bottom: 4px;
  left: 8px;
  font-size: 22px;
  background: rgba(12, 16, 36, 0.9);
  border-radius: 50%;
  padding: 3px;
}

.secret-hint {
  display: inline-block;
  margin: 0 0 14px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(245, 201, 106, 0.12);
  color: var(--gold-soft);
  font-size: 0.84rem;
}

.secret-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.secret-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(245, 201, 106, 0.38);
  background: rgba(8, 11, 26, 0.75);
  color: #fff;
  font-size: 1.08rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.secret-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(245, 201, 106, 0.25);
}

.secret-error {
  margin: 12px 0 0;
  color: var(--rose-soft);
  font-weight: 700;
  font-size: 0.94rem;
}

.shake {
  animation: gentleShake 0.4s ease;
}

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-5px); }
}

.final-crown {
  font-size: 38px;
  margin-bottom: 8px;
}

.final-title {
  margin: 0 0 14px;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gold-soft);
}

.final-photo-wrap {
  margin: 0 auto 16px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(245, 201, 106, 0.35);
}

.final-photo-wrap img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}

.final-message {
  margin: 0 0 16px;
  font-size: 1.06rem;
  line-height: 1.9;
  color: #fff;
  white-space: pre-line;
}

.closing-line {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--rose-soft);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 6, 18, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  max-height: 82dvh;
  overflow-y: auto;
  padding: 28px 22px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.modal-wax {
  font-size: 38px;
  margin-bottom: 6px;
}

.modal-letter-title {
  margin: 0 0 12px;
  color: var(--gold-soft);
  font-size: 1.25rem;
}

.modal-letter-body {
  color: #f8fafc;
  font-size: 1.04rem;
  line-height: 1.95;
  white-space: pre-line;
}

.lightbox-inner {
  position: relative;
  max-width: 94vw;
  max-height: 90dvh;
  text-align: center;
}

.lightbox-inner img {
  max-width: 100%;
  max-height: 78dvh;
  border-radius: 16px;
  border: 1px solid rgba(245, 201, 106, 0.35);
}

.lightbox-caption {
  color: var(--text-muted);
  margin: 10px 0 0;
  font-size: 0.95rem;
}

@media (min-width: 520px) {
  .envelopes-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
