* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --pink: #ff4d9d;
  --purple: #7b2ff7;
  --yellow: #ffd93d;
  --cyan: #21e6c1;
}

html, body { min-height: 100%; }

html {
  background: #12002e;
}

body {
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  background-color: #12002e;
  background-image: linear-gradient(135deg, #12002e, #3a0ca3, #7209b7, #f72585);
  background-size: 400% 400%;
  animation: bgshift 14s ease infinite;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  padding: 24px;
  color: #fff;
}

@keyframes bgshift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

.card {
  position: relative;
  z-index: 10;
  margin: auto;
  width: min(640px, 100%);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 28px;
  padding: 40px 32px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

/* Balloons */
.balloons { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.balloon {
  position: absolute;
  bottom: -60px;
  font-size: 42px;
  animation: float 9s ease-in infinite;
  opacity: 0.85;
}
.b1 { left: 6%;  animation-delay: 0s;   filter: hue-rotate(0deg); }
.b2 { left: 28%; animation-delay: 2s;   filter: hue-rotate(80deg); }
.b3 { left: 50%; animation-delay: 4s;   filter: hue-rotate(160deg); }
.b4 { left: 72%; animation-delay: 1.2s; filter: hue-rotate(220deg); }
.b5 { left: 90%; animation-delay: 3s;   filter: hue-rotate(300deg); }

@keyframes float {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
  15%  { opacity: 0.9; }
  100% { transform: translateY(-120vh) rotate(20deg); opacity: 0; }
}

.pretitle {
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--yellow);
  margin-bottom: 8px;
}

.title {
  font-size: clamp(28px, 7vw, 52px);
  line-height: 1.15;
  margin-bottom: 18px;
  color: #fff;
  word-break: break-word;
  text-shadow:
    0 2px 0 rgba(0,0,0,0.35),
    0 0 14px rgba(0,0,0,0.55),
    0 6px 22px rgba(0,0,0,0.5);
}

.title .wobble {
  display: inline-block;
  color: #fff;
  -webkit-text-fill-color: #fff;
  animation: wobble 2.5s ease-in-out infinite;
}
.title .wobble:nth-child(2) { animation-delay: 0.3s; }
.title .wobble:nth-child(3) { animation-delay: 0.6s; }

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

.name {
  display: block;
  margin-top: 6px;
  font-size: clamp(40px, 10vw, 78px);
  font-weight: 900;
  background: linear-gradient(90deg, var(--yellow), var(--cyan), var(--pink), var(--yellow));
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine 4s linear infinite;
}

@keyframes shine {
  to { background-position: 300% center; }
}

.age {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 8px 0 20px;
}
.age-num {
  font-size: 64px;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(33, 230, 193, 0.6);
  animation: pop 1.8s ease-in-out infinite;
}
.age-label { font-size: 16px; opacity: 0.85; letter-spacing: 1px; }

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

/* Cake */
.cake {
  width: 140px;
  margin: 10px auto 6px;
  cursor: pointer;
  transition: transform 0.2s;
  user-select: none;
}
.cake:hover { transform: scale(1.05); }
.cake:active { transform: scale(0.97); }

.candles { display: flex; justify-content: center; gap: 22px; margin-bottom: 4px; }
.candle {
  position: relative;
  width: 6px;
  height: 26px;
  background: repeating-linear-gradient(45deg, #ff6ec7 0 5px, #fff 5px 10px);
  border-radius: 3px;
}
.flame {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 18px;
  background: radial-gradient(circle at 50% 70%, #fff 0%, var(--yellow) 40%, #ff7b00 90%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: 0 0 14px 4px rgba(255, 180, 0, 0.7);
  animation: flicker 0.5s ease-in-out infinite alternate;
  transform-origin: center bottom;
}
@keyframes flicker {
  from { transform: translateX(-50%) scale(1) rotate(-3deg); }
  to   { transform: translateX(-50%) scale(1.15) rotate(3deg); }
}
.cake.blown .flame { opacity: 0; transform: translateX(-50%) scale(0); transition: all 0.4s; box-shadow: none; }

.cake-top    { height: 22px; background: #ffb3c6; border-radius: 10px 10px 0 0; }
.cake-mid    { height: 30px; background: #ff85a1; }
.cake-bottom { height: 34px; background: #c9184a; border-radius: 0 0 12px 12px; }
.cake-top, .cake-mid, .cake-bottom { position: relative; }
.cake-mid::before {
  content: "•  •  •  •  •";
  position: absolute;
  top: 6px; left: 0; right: 0;
  text-align: center;
  color: var(--yellow);
  font-size: 10px;
  letter-spacing: 4px;
}

.hint {
  font-size: 14px;
  opacity: 0.75;
  margin-bottom: 22px;
  min-height: 20px;
}

/* ---------- Галерея ---------- */
.gallery { margin: 8px 0 26px; }

.gallery-title {
  font-size: 20px;
  margin-bottom: 16px;
  color: var(--yellow);
  text-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.slideshow {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frame {
  position: relative;
  width: min(340px, 80vw);
  background: #fff;
  padding: 10px 10px 12px;
  border-radius: 6px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.5);
  transform: rotate(-2deg);
  transition: transform 0.3s;
}
.frame:hover { transform: rotate(0deg) scale(1.02); }

.frame img {
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 3px;
  display: block;
  cursor: pointer;
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tape {
  position: absolute;
  width: 60px;
  height: 22px;
  background: rgba(255, 217, 61, 0.55);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  top: -10px;
}
.tape-l { left: 8px;  transform: rotate(-28deg); }
.tape-r { right: 8px; transform: rotate(28deg); }

.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.nav.prev { left: 4px; }
.nav.next { right: 4px; }
.nav:hover { background: var(--pink); }
.nav:active { transform: translateY(-50%) scale(0.9); }

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.thumbs img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.55;
  border: 2px solid transparent;
  transition: opacity 0.2s, transform 0.2s, border-color 0.2s;
}
.thumbs img:hover { opacity: 1; transform: translateY(-3px); }
.thumbs img.active {
  opacity: 1;
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(33,230,193,0.6);
}

.joke {
  font-size: 19px;
  font-style: italic;
  line-height: 1.5;
  margin: 0 auto 26px;
  max-width: 480px;
  min-height: 60px;
  padding: 16px 20px;
  border-left: 4px solid var(--yellow);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 14px 14px 0;
  transition: opacity 0.25s;
}

.buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.btn {
  border: none;
  border-radius: 50px;
  padding: 14px 26px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  color: #fff;
}
.btn:hover { transform: translateY(-3px) scale(1.03); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-primary {
  background: linear-gradient(90deg, var(--pink), var(--purple));
  box-shadow: 0 8px 20px rgba(255, 77, 157, 0.45);
}
.btn-secondary {
  background: linear-gradient(90deg, var(--cyan), #2196f3);
  box-shadow: 0 8px 20px rgba(33, 230, 193, 0.4);
}

.footer {
  margin-top: 26px;
  font-size: 13px;
  opacity: 0.7;
}

.shake { animation: shake 0.5s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-1deg); }
  40% { transform: translateX(10px) rotate(1deg); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

/* ---------- Адаптив ---------- */
@media (max-width: 560px) {
  body { padding: 12px; }
  .card { padding: 28px 18px 24px; border-radius: 22px; }
  .pretitle { font-size: 13px; letter-spacing: 1px; }
  .age-num { font-size: 52px; }
  .balloon { font-size: 34px; }
  .joke { font-size: 17px; padding: 14px 16px; }
  .buttons { flex-direction: column; }
  .btn { width: 100%; }
  .frame { width: 88vw; }
  .nav { width: 40px; height: 40px; font-size: 26px; }
  .thumbs img { width: 44px; height: 44px; }
}

/* Уважаем отключённые анимации */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
