/* ============================================
   Tokens
   ============================================ */
:root {
  --bg-0: #0b0b0e;
  --bg-1: #141418;
  --ivory: #f3f1ec;
  --ivory-dim: rgba(243, 241, 236, 0.62);
  --ivory-faint: rgba(243, 241, 236, 0.38);

  --accent: #c9a24b;
  --accent-soft: #e2c583;
  --accent-deep: #8a6a28;
  --accent-rgb: 201, 162, 75;

  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;

  --sp-xs: 0.5rem;
  --sp-sm: 1rem;
  --sp-md: 1.5rem;
  --sp-lg: 2.5rem;
  --sp-xl: 4rem;

  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  --shadow-card: 0 30px 60px -20px rgba(0, 0, 0, 0.6), 0 10px 20px -10px rgba(0, 0, 0, 0.4);
  --shadow-btn: 0 8px 20px -8px rgba(0, 0, 0, 0.5);
}

/* ============================================
   Theme variants — dark base + one metallic/jewel accent
   ============================================ */
body[data-theme="romantic"] { --accent: #d98a9a; --accent-soft: #eab7c1; --accent-deep: #93505d; --accent-rgb: 217, 138, 154; }
body[data-theme="cute"]     { --accent: #cbb9e0; --accent-soft: #e3d7f0; --accent-deep: #8a76ab; --accent-rgb: 203, 185, 224; }
body[data-theme="classy"]   { --accent: #b9902f; --accent-soft: #dcb75c; --accent-deep: #765d1c; --accent-rgb: 185, 144, 47; }
body[data-theme="neon"]     { --accent: #a06be0; --accent-soft: #c69bf0; --accent-deep: #5f3a8c; --accent-rgb: 160, 107, 224; }
body[data-theme="ocean"]    { --accent: #4d8fc4; --accent-soft: #7fb3dd; --accent-deep: #2c5878; --accent-rgb: 77, 143, 196; }
body[data-theme="sunset"]   { --accent: #c97a3f; --accent-soft: #e0a066; --accent-deep: #824d24; --accent-rgb: 201, 122, 63; }
body[data-theme="forest"]   { --accent: #4f9d74; --accent-soft: #7dc0a0; --accent-deep: #2f6248; --accent-rgb: 79, 157, 116; }
body[data-theme="royal"]    { --accent: #8b6bc4; --accent-soft: #ae94db; --accent-deep: #56417a; --accent-rgb: 139, 107, 196; }
body[data-theme="candy"]    { --accent: #c4587a; --accent-soft: #dd8aa3; --accent-deep: #7c344c; --accent-rgb: 196, 88, 122; }

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse 900px 600px at 15% 10%, rgba(var(--accent-rgb), 0.10) 0%, transparent 55%),
    radial-gradient(ellipse 800px 700px at 85% 90%, rgba(var(--accent-rgb), 0.07) 0%, transparent 55%),
    var(--bg-0);
  color: var(--ivory);
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: calc(var(--vh, 1vh) * 100);
  width: 100%;
  -webkit-font-smoothing: antialiased;
}

.icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ============================================
   Real glass — blur + transparency only
   ============================================ */
.glass-control,
.glass-panel {
  background: rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

/* ============================================
   Music control
   ============================================ */
.music-control {
  position: fixed;
  top: var(--sp-md);
  right: var(--sp-md);
  z-index: 1000;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: var(--ivory-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease-smooth);
}

.music-control:hover {
  color: var(--accent-soft);
  border-color: rgba(var(--accent-rgb), 0.4);
  box-shadow: 0 0 24px -6px rgba(var(--accent-rgb), 0.5);
}

.icon-sound-off { display: none; }
.music-control:not(.is-playing) .icon-sound-on { display: none; }
.music-control:not(.is-playing) .icon-sound-off { display: block; }

/* ============================================
   Customization Panel
   ============================================ */
.customization-panel {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: var(--sp-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: fadeIn 0.5s var(--ease-smooth);
}

.customization-panel.hidden { display: none; }

.panel-content {
  border-radius: var(--radius-lg);
  padding: var(--sp-lg) var(--sp-lg);
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-card);
  animation: riseIn 0.7s var(--ease-out);
  margin: auto;
}

.panel-eyebrow {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-soft);
  margin-bottom: var(--sp-xs);
  font-weight: 600;
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.1rem;
  color: var(--ivory);
  margin-bottom: var(--sp-lg);
  text-align: center;
  letter-spacing: -0.01em;
}

.form-group { margin-bottom: 1.1rem; }

.form-group label {
  display: block;
  margin-bottom: var(--sp-xs);
  color: var(--ivory-dim);
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.form-group input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ivory);
  font-size: 1rem;
  font-family: var(--font-body);
  transition: all 0.25s var(--ease-smooth);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.form-group input::placeholder { color: var(--ivory-faint); }

.select-wrap { position: relative; }

.select-wrap select {
  width: 100%;
  padding: 0.85rem 2.6rem 0.85rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ivory);
  font-size: 1rem;
  font-family: var(--font-body);
  appearance: none;
  cursor: pointer;
  transition: all 0.25s var(--ease-smooth);
}

.select-wrap select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.select-wrap select option { background: var(--bg-1); color: var(--ivory); }

.select-caret {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ivory-faint);
  pointer-events: none;
}

.start-btn {
  width: 100%;
  margin-top: var(--sp-sm);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--accent) 60%, var(--accent-deep) 100%);
  color: #14120a;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  box-shadow: var(--shadow-btn), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth);
}

.start-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px -10px rgba(var(--accent-rgb), 0.5), inset 0 1px 0 rgba(255,255,255,0.4); }
.start-btn:active { transform: translateY(0); }

/* ============================================
   Celebration scene
   ============================================ */
.celebration-content {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: calc(var(--vh, 1vh) * 100);
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.celebration-content.hidden { display: none; }

.scene-backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.light-sweep {
  position: absolute;
  top: -50%;
  left: -20%;
  width: 60%;
  height: 200%;
  background: linear-gradient(100deg, transparent 40%, rgba(var(--accent-rgb), 0.06) 50%, transparent 60%);
  animation: sweep 8s ease-in-out infinite;
}

.facet {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
}
.facet-1 { width: 420px; height: 420px; top: -10%; left: -8%; background: radial-gradient(circle, rgba(var(--accent-rgb), 0.18), transparent 70%); animation: drift 22s ease-in-out infinite; }
.facet-2 { width: 360px; height: 360px; bottom: -10%; right: -6%; background: radial-gradient(circle, rgba(var(--accent-rgb), 0.14), transparent 70%); animation: drift 18s ease-in-out infinite reverse; }
.facet-3 { width: 280px; height: 280px; top: 40%; left: 50%; background: radial-gradient(circle, rgba(var(--accent-rgb), 0.08), transparent 70%); animation: drift 26s ease-in-out infinite; }

#confetti-canvas { position: fixed; inset: 0; z-index: 20; pointer-events: none; }

/* Balloons — crisp 3D glossy render, random colors per balloon, attached string */
.balloons-container { position: fixed; inset: 0; z-index: 15; overflow: hidden; pointer-events: none; }

.balloon {
  position: absolute;
  bottom: -180px;
  width: 64px;
  height: 122px;
  cursor: pointer;
  pointer-events: auto;
  animation: floatUp 15s ease-in infinite;
  transition: transform 0.15s var(--ease-smooth);
  --balloon-color: var(--accent);
  --balloon-color-soft: var(--accent-soft);
  --balloon-color-deep: var(--accent-deep);
}

.balloon:hover { transform: scale(1.06); }
.balloon:active { transform: scale(0.94); }

.balloon-body {
  position: absolute;
  top: 0;
  left: 0;
  width: 64px;
  height: 78px;
  border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.8) 0%, transparent 32%),
    radial-gradient(circle at 68% 78%, rgba(0, 0, 0, 0.3) 0%, transparent 55%),
    radial-gradient(ellipse at 40% 35%, var(--balloon-color-soft) 0%, var(--balloon-color) 55%, var(--balloon-color-deep) 100%);
  box-shadow: inset -6px -8px 14px rgba(0, 0, 0, 0.22), inset 4px 6px 10px rgba(255, 255, 255, 0.25);
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35));
}

.balloon-body::after {
  /* knot at base of balloon */
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: var(--balloon-color-deep);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.balloon-string {
  position: absolute;
  top: 78px;
  left: 50%;
  width: 1px;
  height: 44px;
  background: linear-gradient(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.08));
  transform-origin: top center;
  animation: stringSway 3s ease-in-out infinite;
}

.balloon-1 { left: 6%;  animation-delay: 0s;   animation-duration: 15s; }
.balloon-2 { left: 20%; animation-delay: 2.5s; animation-duration: 17s; }
.balloon-3 { left: 42%; animation-delay: 1s;   animation-duration: 13s; }
.balloon-4 { left: 62%; animation-delay: 3.5s; animation-duration: 16s; }
.balloon-5 { left: 80%; animation-delay: 0.8s; animation-duration: 14.5s; }
.balloon-6 { left: 92%; animation-delay: 4.5s; animation-duration: 18s; }

/* Pop interaction */
.balloon.popped {
  animation: none;
  pointer-events: none;
}

.balloon.popped .balloon-body {
  animation: balloonPop 0.35s var(--ease-out) forwards;
}

.balloon.popped .balloon-string {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.balloon.reset-position {
  bottom: -180px;
  opacity: 0;
}

/* ============================================
   Content
   ============================================ */
.content-wrapper {
  position: relative;
  z-index: 10;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(1.5rem, 6vh, 3rem) max(var(--sp-md), env(safe-area-inset-right)) clamp(1.5rem, 5vh, 2.5rem) max(var(--sp-md), env(safe-area-inset-left));
  padding-top: calc(clamp(1.5rem, 6vh, 3rem) + env(safe-area-inset-top));
  padding-bottom: calc(clamp(1.5rem, 5vh, 2.5rem) + env(safe-area-inset-bottom));
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(1rem, 3vh, 1.75rem);
}

.celebration-header { margin-bottom: 0; }

.kicker {
  font-family: var(--font-body);
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent-soft);
  opacity: 0;
  animation: fadeInUp 0.7s var(--ease-out) forwards;
  animation-delay: 0.2s;
}

.main-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 9vw, 4.4rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ivory);
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) forwards;
  animation-delay: 0.4s;
}

/* 3D reveal card */
.reveal-card-section {
  perspective: 1200px;
  width: 100%;
  opacity: 0;
  animation: fadeIn 0.6s var(--ease-out) forwards;
  animation-delay: 1s;
}

.reveal-card {
  position: relative;
  padding: clamp(1.25rem, 4vh, 2.5rem) clamp(1.5rem, 6vw, 4rem);
  border-radius: var(--radius-lg);
  background: linear-gradient(155deg, rgba(255,255,255,0.06), rgba(255,255,255,0.015));
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow-card);
  transform: rotateX(6deg);
  transform-style: preserve-3d;
  animation: cardSettle 1.4s var(--ease-out) forwards;
  animation-delay: 1.1s;
  overflow: hidden;
}

.reveal-card-inner { position: relative; z-index: 2; }

.reveal-card-sheen {
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.08), transparent);
  animation: sheenSlide 4s ease-in-out 2.2s infinite;
}

.birthday-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 7vw, 3.2rem);
  word-break: break-word;
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: var(--sp-sm);
  letter-spacing: -0.01em;
}

.age-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.age-label { font-size: 1rem; color: var(--ivory-dim); }

.age-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.4rem;
  color: var(--ivory);
}

/* Wishes */
.wishes-section {
  width: 100%;
  opacity: 0;
  animation: fadeInUp 0.7s var(--ease-out) forwards;
  animation-delay: 1.8s;
}

.wish-container {
  position: relative;
  border-radius: var(--radius-md);
  padding: var(--sp-md) var(--sp-lg);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quote-mark {
  position: absolute;
  top: 0.6rem;
  left: 1rem;
  width: 20px;
  height: 20px;
  color: rgba(var(--accent-rgb), 0.4);
}

.rotating-wish {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-style: italic;
  font-weight: 400;
  color: var(--ivory);
  line-height: 1.5;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Actions */
.action-section {
  display: flex;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  justify-content: center;
  opacity: 0;
  animation: fadeInUp 0.7s var(--ease-out) forwards;
  animation-delay: 2.2s;
}

.action-btn {
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ivory);
  font-size: 0.92rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  transition: all 0.25s var(--ease-smooth);
}

.action-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.5);
  color: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow-btn);
}

.action-btn:active { transform: translateY(0); }

/* Toast */
.toast {
  position: fixed;
  bottom: var(--sp-lg);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 20, 24, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--ivory);
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-smooth), transform 0.3s var(--ease-smooth);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes cardSettle {
  0% { opacity: 0; transform: rotateX(20deg) translateY(30px) scale(0.95); }
  100% { opacity: 1; transform: rotateX(6deg) translateY(0) scale(1); }
}

@keyframes sheenSlide {
  0% { left: -60%; }
  100% { left: 130%; }
}

@keyframes sweep {
  0%, 100% { transform: translateX(0) translateY(0); }
  50% { transform: translateX(15%) translateY(10%); }
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, -25px); }
}

@keyframes balloonPop {
  0% { transform: scale(1); opacity: 1; }
  35% { transform: scale(1.25, 0.8); opacity: 1; }
  70% { transform: scale(0.3, 1.4); opacity: 0.6; }
  100% { transform: scale(0); opacity: 0; }
}

@keyframes floatUp {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 0.85; }
  90% { opacity: 0.85; }
  100% { transform: translateY(-115vh) translateX(20px); opacity: 0; }
}

@keyframes stringSway {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 640px) {
  .panel-content { padding: var(--sp-md); }
  .panel-title { font-size: 1.6rem; margin-bottom: var(--sp-md); }
  .action-section { flex-direction: column; width: 100%; max-width: 280px; }
  .action-btn { width: 100%; justify-content: center; }
}

@media (max-width: 400px) {
  .age-display { flex-direction: column; gap: 0.2rem; }
  .age-number { font-size: 2rem; }
}

@media (max-height: 700px) {
  .content-wrapper { justify-content: flex-start; }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[dir="rtl"] .quote-mark { left: auto; right: 1rem; }
