:root {
  --bg: #f4f5fb;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

body {
  position: relative;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

html {
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

/* 修改：只将特定元素设置为绝对定位，而不是所有元素 */
.cake *,
.tier,
.filling,
.icing,
.candles,
.candle,
.flame,
.flame-in {
  position: absolute;
}

*:before,
*:after {
  content: "";
  position: absolute;
}

/* 控制蛋糕和倒计时的显示/隐藏 */
.container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 300px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s ease, visibility 1s ease;
}

.container.visible {
  opacity: 1;
  visibility: visible;
}

/* 倒计时页面样式 */
.countdown-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 2000;
  transition: opacity 1s ease, visibility 1s ease;
  opacity: 1;
  visibility: visible;
}

.countdown-page.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 倒计时容器样式 */
.countdown-container {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  z-index: 1000;
}

#countdown {
  display: flex;
  gap: 15px;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  text-align: center;
  position: relative;
  min-width: 300px;
}

.time-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  flex: 1;
  padding: 5px 10px;
}

#days, #hours, #minutes, #seconds {
  font-size: 36px;
  font-weight: bold;
  color: #f2abe7;
  position: relative;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.time-label {
  font-size: 16px;
  color: #666;
  margin-top: 8px;
  position: relative;
  font-weight: 500;
}

/* 蛋糕样式 */
.cake {
  width: 80%;
  height: 80%;
  left: 10%;
  bottom: 15%;
}

.filling {
  height: 10px;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.1);
  top: 50%;
}

.tier {
  left: 10%;
  width: 80%;
  height: 50px;
  border-radius: 5px;
}

.tier .icing-group {
  width: 100%;
  height: 30px;
  overflow: hidden;
}

.tier .icing-group .icing {
  border-radius: 0 0 20px 20px;
  width: 40px;
  height: 20px;
  background-color: var(--bg);
}

.tier:after {
  border-radius: 0 5px 5px 0;
  right: 0;
  width: 50%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.05);
}

.tier-1 {
  background-color: #f2abe7;
  bottom: 0;
}

.tier-1 .filling {
  background-color: #ec7fdb;
}

.tier-2 {
  bottom: 50px;
  width: 60%;
  height: 45px;
  left: 20%;
  background-color: #9fa3ec;
}

.tier-2 .filling {
  background-color: #7a80e5;
}

.tier-3 {
  bottom: 95px;
  width: 40%;
  height: 40px;
  left: 30%;
  background-color: #86d2e1;
}

.tier-3 .filling {
  background-color: #5dc2d6;
}

.icing:nth-child(1) {
  left: -20px;
}

.icing:nth-child(2) {
  left: 10px;
}

.icing:nth-child(3) {
  left: 40px;
}

.icing:nth-child(4) {
  left: 70px;
}

.icing:nth-child(5) {
  left: 100px;
}

.icing:nth-child(6) {
  left: 130px;
}

.icing:nth-child(7) {
  left: 160px;
}

.icing:nth-child(8) {
  left: 190px;
}

.icing:nth-child(9) {
  left: 220px;
}

.candles {
  width: 40%;
  left: 30%;
  height: 30px;
  bottom: 135px;
}

.candles .candle {
  background-color: #f2abe7;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 25px;
  bottom: 0;
}

.candles .candle:after {
  width: 50%;
  height: 100%;
  right: 0;
  background-color: rgba(0, 0, 0, 0.1);
}

.candles .candle .flame {
  width: 15px;
  height: 15px;
  bottom: 30px;
  left: -3px;
}

.candles .candle .flame .flame-in {
  width: 100%;
  height: 100%;
  background-color: #fec31e;
  border-radius: 0 50% 50%;
  transform: rotate(45deg);
  animation: flame 2s linear infinite;
}

@keyframes flame {
  50% {
    transform: scale(0.8) rotate(45deg);
  }
}

.confetti {
  position: absolute;
  z-index: 999;
}

.confetti .rotate {
  animation: driftRotate 1s infinite both ease-in-out;
  width: 100%;
  height: 100%;
}

.confetti .askew {
  width: 100%;
  height: 100%;
  animation: drift 1s infinite alternate both ease-in-out;
}

@keyframes drift {
  0% {
    transform: skewY(10deg) translate3d(-250%, 0, 0);
  }
  100% {
    transform: skewY(-10deg) translate3d(250%, 0, 0);
  }
}

@keyframes driftRotate {
  0% {
    transform: rotateX(0);
  }
  100% {
    transform: rotateX(360deg);
  }
}

/* 为所有confetti元素添加动画延迟和持续时间 */
@media (min-width: 0px) {
  .confetti:nth-child(1n) .askew, .confetti:nth-child(1n) .rotate { animation-duration: calc(1s + 0.01s * var(--i, 0)); animation-delay: calc(-1s * 0.01 * var(--i, 0)); }
  .confetti:nth-child(2n) .askew, .confetti:nth-child(2n) .rotate { animation-duration: calc(1s + 0.02s * var(--i, 0)); animation-delay: calc(-1s * 0.02 * var(--i, 0)); }
  .confetti:nth-child(3n) .askew, .confetti:nth-child(3n) .rotate { animation-duration: calc(1s + 0.03s * var(--i, 0)); animation-delay: calc(-1s * 0.03 * var(--i, 0)); }
  .confetti:nth-child(4n) .askew, .confetti:nth-child(4n) .rotate { animation-duration: calc(1s + 0.04s * var(--i, 0)); animation-delay: calc(-1s * 0.04 * var(--i, 0)); }
  .confetti:nth-child(5n) .askew, .confetti:nth-child(5n) .rotate { animation-duration: calc(1s + 0.05s * var(--i, 0)); animation-delay: calc(-1s * 0.05 * var(--i, 0)); }
}

/* 生日祝福艺术字样式 */
.birthday-text {
  position: absolute;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  font-size: 30px;
  font-weight: bold;
  font-family: 'Comic Sans MS', cursive, sans-serif;
  background: linear-gradient(45deg, #ff6ec4, #7873f5, #48c6ef, #6f86d6);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  animation: glow 3s ease-in-out infinite;
  white-space: nowrap;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s ease 0.5s, visibility 1s ease 0.5s;
  z-index: 9999;
}

.container.visible .birthday-text {
  opacity: 1;
  visibility: visible;
}

@keyframes glow {
  0%, 100% {
    text-shadow: 0 0 10px #ff6ec4, 0 0 20px #7873f5;
    transform: translateX(-50%) scale(1);
  }
  50% {
    text-shadow: 0 0 20px #48c6ef, 0 0 30px #6f86d6;
    transform: translateX(-50%) scale(1.05);
  }
} 