*  {
margin: 0; 
padding: 0; 
box-sizing: border-box;
}
/* Candle container: floating at bottom right */
#candle-container {
  position: fixed;
  bottom: 0;               /* stick to bottom */
  right: 5%;
  z-index: 9999;
  display: flex;
  flex-direction: column;  
  align-items: center;
  justify-content: flex-end; /* push candle to bottom */
  
}

/* Candle itself */
#candle {
  width: 7.5rem;
  display: grid;
  position: relative;
  margin: 0;              /* remove top margin */
  box-shadow: 0 0 20px rgba(0,0,0,0.3); /* subtle glow/shadow */
}
#flame,
#thread,
#blue-part,
#glow,
#candle-bottom {
    position: absolute;
    justify-self: center;
    bottom: 0;
}
#flame,
#glow,
#blue-part,
#smoke {
  display: none;
}
#thread::after,
#blue-part::after,
#wax::before {
    content: '';
    display: block;
}
#flame {
    bottom: 104%;
    border-radius: 50% 50% 20% 20%;
    height: 30%;
    z-index: 3;
    background: linear-gradient(white 80%, transparent);
    width: 14.8%;
    box-shadow: 0px -5px 7px 0px orange;
    transform-origin: bottom;
    animation: flame_animation 4s linear infinite, grow_flame 4s linear infinite;
}
#thread {
    width: .35rem;
    height: 8%;
    margin: 0 auto;
    border-radius: 40% 40% 0% 0%;
    background: linear-gradient(#ff7800, black 40%);
    bottom: 100%;
    z-index: 2;
}
#thread::after {
    width: 100%;
    height: 30%;
    top: 71%;
    position: absolute;
    background: linear-gradient(0deg, #898989, #000000);
}
#blue-part {
    width: 16%;
    height: 13%;
    background: rgba(0, 133, 255, .7);
    z-index: 2;
    bottom: 101%;
    border-radius: 50% 50% 35% 35%;
} 
#blue-part::after {
    width: 75%;
    border-radius: 50%;
    background: rgb(0 0 0 / 39%);
    position: relative;
    height: 70%;
    margin: 0 auto;
    top: 30%;
}  
#wax {
    width: 100%;
    height: 70%;
    z-index: 1;
    position: absolute;
    background: linear-gradient(180deg, #a7a2a2, #212121);
    box-shadow: inset 20px -30px 50px 0 rgba(0, 0, 0, 0.4), inset -20px 0px 50px 0 rgba(0, 0, 0, 0.4);
}
#wax::before {
    width: 100%;
    height: 10%;
    bottom: 95%;
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(#d1c3ac, #6f6f6f 46%, #817e7c 67%); 
}
#candle-bottom {
    top: 67%;
    height: 8%;
    width: 115%;
    border-radius: 50%;
    background: radial-gradient(#212121, #101010);
}
#glow {
    border-radius: 100%;
    width: 5rem;
    filter: blur(2.25rem);
    background: #ff6000;
    height: 8rem;
    bottom: 100%;
    z-index: 2;
    animation: flicker_animation .1s infinite   
}
@keyframes flicker_animation {
    0% {
        opacity: 0.8;
    }
}
@keyframes flame_animation {
    0% {
        transform: rotate(-2deg);
    }
    50% {
        transform: rotate(2deg);
    }
}
@keyframes grow_flame {
    0%,
    100% {
        height: 30%;
    }   50% {
        height: 33%;
    }
}

/* CLICK TO LIGHT THE CANDLE */

#flame, #glow {
  display: none; /* start hidden */
}
#candle-text {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Dancing Script", cursive;
  font-size: 15px;
  color: #fff;
  pointer-events: none;
  text-align: center;
  text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
}
#candle {
  position: relative;
  width: 7.5rem;
  height: 20rem;
  display: grid;
  margin-top: 10rem;
}
#candle-container {
  position: fixed;
  top: 0%;
  right: 5%;
  z-index: 9999;
}

#candle-container, #candle {
  pointer-events: auto;  /* allow clicks on the candle */
}


/* Smoke effect */

#smoke {
  position: absolute;
  bottom: 105%;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  display: none;
}

#smoke span {
  position: absolute;
  width: 18px;
  height: 18px;
  background: radial-gradient(
    circle,
    rgba(220,220,220,0.6) 0%,
    rgba(200,200,200,0.35) 40%,
    rgba(180,180,180,0.15) 65%,
    transparent 70%
  );
  border-radius: 50%;
  filter: blur(6px);
  opacity: 0;
}

/* Each wisp behaves slightly differently */
#smoke span:nth-child(1) {
  animation: smokeDream 4.2s ease-out forwards;
}
#smoke span:nth-child(2) {
  animation: smokeDream 5s ease-out forwards;
  animation-delay: 0.4s;
}
#smoke span:nth-child(3) {
  animation: smokeDream 8s ease-out forwards;
  animation-delay: 0.8s;
}

/* Dreamy, slow, realistic smoke */
@keyframes smokeDream {
  0% {
    transform: translate(-50%, 0) scale(0.6);
    opacity: 0.7;
  }

  30% {
    opacity: 0.4;
  }

  60% {
    transform: translate(-45%, -50px) scale(1.2);
    opacity: 0.25;
  }

  100% {
    transform: translate(-55%, -100px) scale(1.6);
    opacity: 0;
  }
}

/* Spark effect */

.spark {
  position: absolute;
  width: 2px;
  height: 2px;
  background: radial-gradient(circle, #fff 0%, #ffd27d 40%, #ff9f1c 70%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  animation: sparkFly 600ms ease-out forwards;
  z-index: 5;
}

@keyframes sparkFly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), var(--y)) scale(0.2);
    opacity: 0;
  }
}

/* ==============================
   Mobile scaling for candle
============================== */

@media (max-width: 480px) {
  #candle-container {
    transform: scale(0.45);       /* shrink to ~45% size */
    transform-origin: bottom right;
    right: 0.5rem;               /* tuck it closer to edge */
    bottom: 0.5rem;
  }
}

@media (max-width: 360px) {
  #candle-container {
    transform: scale(0.35);      /* very small phones */
  }
}
