*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --accent: #e94560;
  --accent2: #ff6b35;
  --gold: #ffd700;
  --text: #eaeaea;
  --text-muted: #a0a0b0;
  --radius: 20px;
  --font: 'Fredoka', sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  touch-action: manipulation;
}

/* Screens */
.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ===== SPLASH ===== */
#splash {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.splash-content {
  text-align: center;
  padding: 2rem;
  animation: fadeInUp 0.8s ease;
}

.gift-box {
  font-size: 5rem;
  margin-bottom: 1.5rem;
  position: relative;
  animation: bounce 2s infinite;
}

.gift-box.open .gift-lid {
  transform: translateY(-60px) rotate(-20deg);
  opacity: 0;
}

.gift-lid {
  transition: all 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.splash-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, var(--gold), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.splash-sub {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.tap-hint {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  background: rgba(233, 69, 96, 0.2);
  border: 2px dashed var(--accent);
  border-radius: 50px;
  font-size: 0.9rem;
  animation: pulse 1.5s infinite;
}

/* ===== MAIN ===== */
#main {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
  position: relative;
  padding-bottom: 2rem;
}

#confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

.header {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.2rem 0;
}

.icon-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.icon-btn:active {
  transform: scale(0.9);
}

/* Hero */
.hero {
  text-align: center;
  padding: 1rem 1.5rem 2rem;
}

.avatar-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 1rem;
}

.avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  border: 4px solid var(--gold);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
  animation: float 3s ease-in-out infinite;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

.avatar.has-photo {
  background-color: #222;
}

.crown {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%) rotate(-10deg);
  font-size: 2rem;
  animation: wiggle 2s ease-in-out infinite;
}

.birthday-title {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.birthday-title .label {
  font-size: 0.85rem;
  letter-spacing: 4px;
  color: var(--gold);
  font-weight: 600;
}

.birthday-title .name {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.age-badge {
  display: inline-block;
  margin-top: 0.8rem;
  padding: 0.4rem 1.2rem;
  background: rgba(233, 69, 96, 0.25);
  border-radius: 50px;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}

/* Cake */
.cake-section {
  text-align: center;
  padding: 1rem 1.5rem 2rem;
}

.section-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.cake-section.locked .cake-container {
  opacity: 0.45;
  cursor: not-allowed;
}

.cake-section.locked .cake-container.shake-hint {
  animation: shake 0.4s ease;
}

.cake-section:not(.locked) .cake-container {
  cursor: pointer;
}

.wish-game.locked .btn-yes,
.wish-game.locked .btn-no {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.wish-lock-hint {
  color: var(--gold);
  min-height: 1.2rem;
}

.wish-game:not(.locked) .wish-lock-hint {
  display: none;
}

#msgProgress {
  font-size: 0.8rem;
  opacity: 0.8;
}

.next-msg-btn.done {
  opacity: 0.5;
  cursor: default;
}

.candles {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 4px;
}

.candle {
  width: 8px;
  height: 35px;
  background: linear-gradient(180deg, #fff 0%, #ffd700 100%);
  border-radius: 3px;
  position: relative;
  transition: opacity 0.5s;
}

.candle.out {
  opacity: 0.3;
}

.flame {
  width: 14px;
  height: 20px;
  background: radial-gradient(ellipse, #ff6b35 30%, #ffd700 70%, transparent);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  animation: flicker 0.3s infinite alternate;
}

.candle.out .flame {
  display: none;
}

.cake {
  position: relative;
}

.frosting {
  width: 140px;
  height: 30px;
  background: #ffb6c1;
  border-radius: 10px 10px 0 0;
  margin: 0 auto;
  position: relative;
}

.frosting::before,
.frosting::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: #ffb6c1;
  border-radius: 50%;
  bottom: -5px;
}

.frosting::before { left: 10px; }
.frosting::after { right: 10px; }

.cake-body {
  width: 140px;
  height: 60px;
  background: linear-gradient(180deg, #8B4513, #654321);
  margin: 0 auto;
  border-radius: 0 0 8px 8px;
}

.plate {
  width: 170px;
  height: 12px;
  background: linear-gradient(180deg, #ddd, #aaa);
  border-radius: 50%;
  margin: 0 auto;
}

.cake-status {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1.4em;
}

/* Messages */
.messages-section {
  padding: 0 1.5rem 2rem;
}

.message-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.08);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s, opacity 0.3s;
}

.message-card.flip {
  transform: scale(0.95);
  opacity: 0;
}

.msg-emoji {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.msg-text {
  font-size: 1.05rem;
  line-height: 1.5;
}

.next-msg-btn {
  display: block;
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.8rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
}

.next-msg-btn:active {
  background: rgba(255,255,255,0.15);
}

.section-title {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  text-align: center;
}

/* Wish Game */
.wish-game {
  padding: 0 1.5rem 2rem;
  text-align: center;
  position: relative;
}

.btn-group {
  position: relative;
  height: 260px;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.btn-yes {
  padding: 1rem 2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 50px;
  color: white;
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
  transition: left 0.12s cubic-bezier(0.34, 1.56, 0.64, 1),
              top 0.12s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 2;
  white-space: nowrap;
}

.btn-yes.dodging {
  position: absolute;
  animation: dodgePop 0.15s ease;
}

.btn-yes.ready {
  animation: pulse 1s infinite;
  transform: none !important;
}

.btn-yes:active:not(.dodging) {
  transform: scale(0.95);
}

.btn-no {
  padding: 0.7rem 1.2rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
  z-index: 1;
  margin-right: 0.8rem;
  transition: transform 0.2s;
}

.btn-no:active {
  transform: scale(0.95);
}

.wish-hint {
  min-height: 1.5rem;
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
  transition: opacity 0.3s;
}

.wish-hint.hidden {
  opacity: 0;
}

.wish-hint.shake {
  animation: shake 0.4s ease;
}

/* Gift Picker */
.gift-picker {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.5s ease;
}

.gift-picker.hidden {
  display: none;
}

.gift-picker-inner {
  width: 100%;
  max-width: 380px;
  text-align: center;
  animation: popIn 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.gift-picker-sparkles {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  animation: bounce 1.2s infinite;
}

.gift-picker-title {
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 0.3rem;
}

.gift-picker-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.gift-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gift-card {
  background: linear-gradient(145deg, var(--bg-card), #1a2744);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 1.3rem 1rem;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
  transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
  animation: slideInCard 0.5s ease backwards;
  position: relative;
  overflow: hidden;
}

.gift-card:nth-child(1) { animation-delay: 0.1s; }
.gift-card:nth-child(2) { animation-delay: 0.25s; }

.gift-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255, 215, 0, 0.08));
  opacity: 0;
  transition: opacity 0.3s;
}

.gift-card:active {
  transform: scale(0.97);
}

.gift-card:hover::before,
.gift-card.selected::before {
  opacity: 1;
}

.gift-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.35);
  transform: scale(1.05);
  animation: giftGlow 0.6s ease;
}

.gift-card.dimmed {
  opacity: 0.25;
  transform: scale(0.92);
  pointer-events: none;
}

.gift-card-emoji {
  display: block;
  font-size: 2.5rem;
  margin-bottom: 0.4rem;
}

.gift-card-title {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.gift-card-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Gift Sending */
.gift-sending {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 280;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.gift-sending.hidden {
  display: none;
}

.sending-box {
  text-align: center;
  animation: popIn 0.5s ease;
}

.sending-spinner {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

.sending-spinner.done {
  animation: none;
  border: none;
  width: auto;
  height: auto;
}

.sending-text {
  font-size: 1rem;
  color: var(--text);
}

.sending-check {
  font-size: 4rem;
  animation: checkPop 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.sending-check.hidden {
  display: none;
}

/* Photo Slideshow */
.photo-slideshow {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.4s ease;
}

.photo-slideshow.hidden {
  display: none;
}

.slideshow-inner {
  width: 100%;
  max-width: 400px;
  position: relative;
}

.slideshow-close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 2;
}

.slideshow-track {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  border: 3px solid var(--gold);
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.2);
}

.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.slide.active {
  opacity: 1;
  pointer-events: auto;
}

.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slideshow-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.slideshow-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.slideshow-dot.active {
  background: var(--gold);
  transform: scale(1.2);
}

.slideshow-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
}

.slideshow-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s;
}

.slideshow-btn:active {
  background: rgba(255, 255, 255, 0.25);
}

.slide-counter {
  font-size: 0.9rem;
  color: var(--text-muted);
  min-width: 3rem;
  text-align: center;
}

/* Surprise Overlay */
.surprise-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 2rem;
  animation: fadeIn 0.5s ease;
}

.surprise-overlay.hidden {
  display: none;
}

.surprise-content {
  text-align: center;
  animation: popIn 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.surprise-emoji {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: bounce 1s infinite;
}

.surprise-content h2 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
  color: var(--gold);
}

.surprise-content p {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.btn-replay {
  padding: 0.8rem 2rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  cursor: pointer;
}

.footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes wiggle {
  0%, 100% { transform: translateX(-50%) rotate(-10deg); }
  50% { transform: translateX(-50%) rotate(10deg); }
}

@keyframes flicker {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-50%) scale(1.1) translateY(-2px); }
}

@keyframes dodgePop {
  0% { filter: brightness(1.4); }
  100% { filter: brightness(1); }
}

@keyframes slideInCard {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes giftGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.3); }
  50% { box-shadow: 0 0 40px rgba(255, 215, 0, 0.6); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes checkPop {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.4s ease;
}
