:root {
  --ink: #27213c;
  --muted: #695f86;
  --cream: #fff7df;
  --pink: #ff8fb8;
  --coral: #ff6f7f;
  --blue: #78c6ff;
  --mint: #8fe6c8;
  --gold: #ffd166;
  --violet: #8872ff;
  --shadow: 0 22px 70px rgba(54, 41, 92, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background: #f8fbff;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-screen,
.birthday-screen {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.login-screen {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 209, 102, 0.5), transparent 24%),
    radial-gradient(circle at 85% 18%, rgba(120, 198, 255, 0.45), transparent 24%),
    linear-gradient(135deg, #fff7df 0%, #e8f6ff 48%, #f8e8ff 100%);
}

.sky-layer,
.celebration-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-panel {
  width: min(430px, 100%);
  position: relative;
  z-index: 2;
  padding: 32px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 10px;
  color: #7651d8;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  line-height: 1.02;
  letter-spacing: 0;
}

h1 {
  font-size: 4.8rem;
}

h2 {
  font-size: 5.4rem;
}

.login-copy {
  margin: 12px 0 26px;
  color: var(--muted);
  line-height: 1.55;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--ink);
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 50px;
  border: 2px solid #dfd7f5;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 4px rgba(136, 114, 255, 0.18);
}

.form-error {
  min-height: 22px;
  margin: 12px 0;
  color: #c33149;
  font-weight: 800;
}

.primary-button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0 24px;
  color: #2c2141;
  font-weight: 900;
  cursor: pointer;
  background: linear-gradient(135deg, var(--gold), #ff9dbb 58%, #9debd3);
  box-shadow: 0 12px 24px rgba(255, 111, 127, 0.22);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(255, 111, 127, 0.28);
}

.primary-button:active {
  transform: translateY(1px);
}

.star,
.floating-star {
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--gold);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: twinkle 2.4s ease-in-out infinite;
}

.star-a {
  left: 12%;
  top: 14%;
}

.star-b {
  right: 14%;
  top: 32%;
  animation-delay: 0.5s;
}

.star-c {
  left: 22%;
  bottom: 18%;
  animation-delay: 1s;
}

.balloon {
  position: absolute;
  width: 58px;
  height: 72px;
  border-radius: 50% 50% 45% 45%;
  animation: float 6s ease-in-out infinite;
}

.balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 70px;
  width: 2px;
  height: 64px;
  background: rgba(39, 33, 60, 0.24);
}

.balloon-a {
  left: 8%;
  bottom: 12%;
  background: var(--pink);
}

.balloon-b {
  right: 9%;
  top: 14%;
  background: var(--blue);
  animation-delay: 1.2s;
}

.balloon-c {
  right: 18%;
  bottom: 9%;
  background: var(--mint);
  animation-delay: 2s;
}

.birthday-screen {
  padding: 28px 18px;
  background:
    radial-gradient(circle at 14% 70%, rgba(255, 209, 102, 0.42), transparent 22%),
    radial-gradient(circle at 82% 64%, rgba(143, 230, 200, 0.36), transparent 24%),
    linear-gradient(180deg, rgba(255, 247, 223, 0.94), rgba(232, 247, 255, 0.98)),
    repeating-linear-gradient(90deg, rgba(255, 143, 184, 0.18) 0 34px, rgba(120, 198, 255, 0.16) 34px 68px);
}

.scene {
  position: relative;
  z-index: 2;
  width: min(980px, 100%);
  margin: 0 auto;
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto minmax(380px, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
}

.birthday-header {
  text-align: center;
  padding-top: 4px;
}

.wish {
  max-width: 680px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.55;
}

.stage {
  position: relative;
  width: min(640px, 100%);
  min-height: 390px;
  margin: 0 auto;
  display: grid;
  place-items: center;
}

.gift-wrap,
.cake-area {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.gift-wrap {
  transition: opacity 500ms ease, transform 600ms ease;
}

.gift-wrap.open {
  opacity: 0;
  transform: translateY(-80px) scale(0.86);
  pointer-events: none;
}

.gift-box,
.gift-lid {
  position: absolute;
  border-radius: 8px;
  background: linear-gradient(135deg, #78c6ff, #8872ff);
  box-shadow: 0 18px 36px rgba(73, 79, 143, 0.24);
}

.gift-box {
  width: 220px;
  height: 150px;
  bottom: 64px;
}

.gift-lid {
  width: 250px;
  height: 50px;
  bottom: 206px;
  transform-origin: 18% 100%;
  z-index: 2;
}

.gift-wrap.open .gift-lid {
  animation: lidOpen 650ms ease forwards;
}

.gift-ribbon-v,
.gift-ribbon-h {
  position: absolute;
  z-index: 3;
  background: #ffd166;
  border-radius: 8px;
}

.gift-ribbon-v {
  width: 34px;
  height: 150px;
  bottom: 64px;
}

.gift-ribbon-h {
  width: 250px;
  height: 30px;
  bottom: 130px;
}

.gift-glow {
  position: absolute;
  bottom: 92px;
  width: 260px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255, 209, 102, 0.34);
  filter: blur(18px);
  animation: pulseGlow 2s ease-in-out infinite;
}

.cake-area {
  opacity: 0;
  transform: translateY(90px) scale(0.86);
  pointer-events: none;
}

.cake-area.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 550ms ease 180ms, transform 700ms cubic-bezier(0.2, 0.9, 0.2, 1.15) 180ms;
}

.cake {
  position: relative;
  width: min(360px, 86vw);
  height: 290px;
  --cake-scale: 1;
  animation: cakeHappyDance 2.6s ease-in-out infinite;
}

.cake-layer,
.frosting,
.cake-plate {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.cake-top {
  bottom: 108px;
  width: 235px;
  height: 80px;
  border-radius: 8px 8px 22px 22px;
  background: linear-gradient(180deg, #ffc2d5, #ff8fb8);
}

.cake-bottom {
  bottom: 36px;
  width: 315px;
  height: 98px;
  border-radius: 8px 8px 28px 28px;
  background: linear-gradient(180deg, #ffde8a, #ffb36d);
}

.cake-bottom::before,
.cake-top::before {
  content: "";
  position: absolute;
  top: 30px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff7df;
  box-shadow: 40px 12px 0 #ff6f7f, 82px -8px 0 #78c6ff, 130px 9px 0 #8fe6c8;
}

.cake-bottom::before {
  left: 34px;
}

.cake-top::before {
  left: 28px;
  transform: scale(0.8);
}

.frosting {
  z-index: 3;
  height: 28px;
  border-radius: 999px;
  background: #fff7df;
}

.frosting-top {
  bottom: 176px;
  width: 250px;
}

.frosting-mid {
  bottom: 121px;
  width: 330px;
}

.cake-plate {
  bottom: 22px;
  width: 350px;
  height: 22px;
  border-radius: 999px;
  background: #dbe9ff;
  box-shadow: 0 16px 28px rgba(39, 33, 60, 0.18);
}

.teddy {
  position: absolute;
  right: 46px;
  bottom: 56px;
  width: 120px;
  height: 174px;
  transform-origin: 50% 100%;
  animation: teddyWave 1.8s ease-in-out infinite;
  z-index: 7;
}

.teddy-ear,
.teddy-head,
.teddy-body,
.teddy-arm {
  position: absolute;
  background: #c68553;
  box-shadow: inset -8px -10px 0 rgba(111, 63, 38, 0.12);
}

.teddy-ear {
  top: 4px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.teddy-ear.left {
  left: 18px;
}

.teddy-ear.right {
  right: 18px;
}

.teddy-head {
  left: 22px;
  top: 18px;
  width: 76px;
  height: 70px;
  border-radius: 50%;
  z-index: 2;
}

.teddy-eye {
  position: absolute;
  top: 27px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2c2141;
}

.teddy-eye.left {
  left: 22px;
}

.teddy-eye.right {
  right: 22px;
}

.teddy-muzzle {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 34px;
  height: 24px;
  border-radius: 50%;
  background: #f8d6ad;
  transform: translateX(-50%);
}

.teddy-muzzle span {
  position: absolute;
  left: 50%;
  top: 7px;
  width: 8px;
  height: 6px;
  border-radius: 50%;
  background: #2c2141;
  transform: translateX(-50%);
}

.teddy-body {
  left: 24px;
  bottom: 10px;
  width: 72px;
  height: 92px;
  border-radius: 40px 40px 34px 34px;
}

.teddy-belly {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 42px;
  height: 50px;
  border-radius: 50%;
  background: #f8d6ad;
  transform: translateX(-50%);
}

.teddy-arm {
  top: 82px;
  width: 28px;
  height: 58px;
  border-radius: 999px;
  z-index: 1;
}

.teddy-arm.left {
  left: 12px;
  transform: rotate(24deg);
}

.teddy-arm.right {
  right: 10px;
  transform-origin: 50% 12%;
  animation: teddyArm 1.1s ease-in-out infinite;
}

.candles {
  position: absolute;
  left: 50%;
  bottom: 202px;
  z-index: 5;
  width: 170px;
  display: flex;
  justify-content: space-between;
  transform: translateX(-50%);
}

.candle {
  position: relative;
  width: 22px;
  height: 64px;
  border-radius: 6px;
  background: repeating-linear-gradient(45deg, #ffffff 0 8px, #78c6ff 8px 14px);
}

.flame {
  position: absolute;
  left: 50%;
  top: -28px;
  width: 20px;
  height: 30px;
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(circle at 50% 70%, #fff7df 0 24%, #ffd166 25% 52%, #ff7b54 53% 100%);
  filter: drop-shadow(0 0 12px rgba(255, 123, 84, 0.85));
  transform: translateX(-50%);
  animation: flameDance 650ms ease-in-out infinite alternate;
}

.candles.blown .flame {
  animation: flameOut 520ms ease forwards;
}

.smoke {
  position: absolute;
  bottom: 220px;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(105, 95, 134, 0.3);
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  opacity: 0;
}

.smoke-one {
  left: calc(50% - 80px);
}

.smoke-two {
  left: 50%;
}

.smoke-three {
  left: calc(50% + 70px);
}

.cake-area.blown .smoke {
  animation: smokeRise 1.8s ease-out forwards;
}

.cake-area.blown .smoke-two {
  animation-delay: 0.15s;
}

.cake-area.blown .smoke-three {
  animation-delay: 0.3s;
}

.final-message {
  max-width: 620px;
  margin: 0 auto;
  text-align: center;
  color: #4f426c;
  font-size: 1.28rem;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms ease, transform 500ms ease;
}

.final-message.show {
  opacity: 1;
  transform: translateY(0);
}

.action-row {
  display: flex;
  justify-content: center;
}

.music-frame {
  width: min(640px, 100%);
  height: 0;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(14px);
  transition: height 350ms ease, opacity 350ms ease, transform 350ms ease;
}

.music-frame.show {
  height: 112px;
  opacity: 1;
  transform: translateY(0);
}

.music-card {
  min-height: 112px;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 16px 36px rgba(54, 41, 92, 0.14);
  backdrop-filter: blur(16px);
}

.music-disc {
  width: 58px;
  height: 58px;
  position: relative;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff7df 0 16%, transparent 17%),
    conic-gradient(from 40deg, #ff8fb8, #ffd166, #78c6ff, #8fe6c8, #ff8fb8);
  animation: spinDisc 4s linear infinite;
}

.music-disc span {
  position: absolute;
  inset: 19px;
  border-radius: 50%;
  background: #2c2141;
}

.music-title {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
}

.music-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.music-button {
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  padding: 0 18px;
  color: #2c2141;
  font-weight: 900;
  text-decoration: none;
  background: linear-gradient(135deg, #ffd166, #ff9dbb 58%, #9debd3);
  box-shadow: 0 10px 22px rgba(255, 111, 127, 0.2);
}

.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  background: var(--confetti-color);
  animation: confettiPop 1.25s ease-out forwards;
}

.fs-one {
  left: 12%;
  top: 12%;
}

.fs-two {
  right: 15%;
  top: 12%;
  animation-delay: 0.6s;
}

.fs-three {
  right: 24%;
  bottom: 18%;
  animation-delay: 1.1s;
}

.mini-balloon {
  position: absolute;
  width: 42px;
  height: 54px;
  border-radius: 50% 50% 45% 45%;
  animation: drift 9s ease-in-out infinite;
}

.mini-balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 52px;
  width: 2px;
  height: 42px;
  background: rgba(39, 33, 60, 0.16);
}

.mb-one {
  left: 7%;
  top: 26%;
  background: #ff8fb8;
}

.mb-two {
  right: 8%;
  top: 22%;
  background: #78c6ff;
  animation-delay: 1.3s;
}

.mb-three {
  left: 14%;
  bottom: 14%;
  background: #8fe6c8;
  animation-delay: 2s;
}

@keyframes twinkle {
  0%,
  100% {
    transform: scale(0.75) rotate(0deg);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.18) rotate(14deg);
    opacity: 1;
  }
}

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

@keyframes lidOpen {
  to {
    transform: translate(-42px, -70px) rotate(-24deg);
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.94);
  }
  50% {
    opacity: 0.75;
    transform: scale(1.08);
  }
}

@keyframes flameDance {
  from {
    transform: translateX(-50%) scale(0.9) rotate(-5deg);
  }
  to {
    transform: translateX(-50%) scale(1.1) rotate(5deg);
  }
}

@keyframes cakeHappyDance {
  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(var(--cake-scale));
  }
  50% {
    transform: translateY(-8px) rotate(-1deg) scale(var(--cake-scale));
  }
}

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

@keyframes teddyArm {
  0%,
  100% {
    transform: rotate(-28deg);
  }
  50% {
    transform: rotate(-58deg);
  }
}

@keyframes flameOut {
  0% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.2);
  }
}

@keyframes smokeRise {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5) rotate(0deg);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-90px) scale(1.7) rotate(65deg);
  }
}

@keyframes confettiPop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(540deg);
  }
}

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

@keyframes spinDisc {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 680px) {
  h1 {
    font-size: 3.2rem;
  }

  h2 {
    font-size: 3.1rem;
  }

  .wish {
    font-size: 1rem;
  }

  .final-message {
    font-size: 1.05rem;
  }

  .login-screen {
    padding: 18px;
  }

  .login-panel {
    padding: 24px;
  }

  .birthday-screen {
    padding: 18px 12px;
  }

  .scene {
    min-height: calc(100vh - 36px);
    grid-template-rows: auto minmax(330px, 1fr) auto auto auto;
    gap: 10px;
  }

  .stage {
    min-height: 330px;
  }

  .gift-box {
    width: 170px;
    height: 118px;
    bottom: 60px;
  }

  .gift-lid,
  .gift-ribbon-h {
    width: 198px;
  }

  .gift-lid {
    bottom: 176px;
  }

  .gift-ribbon-v {
    height: 118px;
    bottom: 60px;
  }

  .gift-ribbon-h {
    bottom: 112px;
  }

  .cake {
    --cake-scale: 0.86;
  }

  .teddy {
    right: 10px;
    bottom: 46px;
    transform: scale(0.72);
  }

  .primary-button {
    width: min(310px, 100%);
  }

  .music-frame.show {
    height: 184px;
  }

  .music-card {
    min-height: 184px;
    grid-template-columns: 54px 1fr;
  }

  .music-disc {
    width: 50px;
    height: 50px;
  }

  .music-disc span {
    inset: 17px;
  }

  .music-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .balloon {
    transform: scale(0.82);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
