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

body {
  background: #00d4f5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  font-family: "Noto Sans KR", sans-serif;
  overflow: hidden;
  user-select: none;
  cursor: pointer;
}

/* ── 처음엔 숨김, 터치 후 등장 ── */
#top-text {
  margin-top: 10vh;
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 700;
  color: #000;
  text-align: center;
  line-height: 1.5;
  min-height: 6vh;
  opacity: 0;
  transition: opacity 0.5s ease;
}

#top-text.show { opacity: 1; }

#timer {
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 700;
  color: #000;
  margin-top: 1vh;
  min-height: 3vh;
  opacity: 0;
  transition: opacity 0.5s ease;
}

#timer.show { opacity: 0.7; }

/* ── 마이크 레벨 바 ── */
#mic-bar-wrap {
  display: none;
  align-items: center;
  gap: 1vw;
  background: rgba(0,0,0,0.15);
  border-radius: 50px;
  padding: 1.5vh 5vw;
  width: 40vw;
  height: 5vh;
  margin-top: 3vh;
  opacity: 0;
  transition: opacity 0.5s ease;
}

#mic-bar-wrap.show {
  display: flex;
  opacity: 1;
}

#mic-label {
  font-size: 1.3rem;
  flex-shrink: 0;
}

#mic-bar-track {
  flex: 1;
  height: 1vh;
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
  overflow: hidden;
}

#mic-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00aa44, #ffcc00, #ff3300);
  border-radius: 3px;
  transition: width 0.06s linear;
}

/* ── 촛불 씬 — 항상 하단 고정 ── */
#candle-scene {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── 불꽃 ── */
#flame-wrap {
  position: relative;
  width: 10vw;
  height: 20vh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transform-origin: bottom center;
}

#flame {
  width: 10vw;
  height: 20vh;
  border-radius: 50% 50% 30% 30% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse at 50% 70%, #ffee00 0%, #ff8800 45%, #ff3300 100%);
  box-shadow:
    0 0 2vw 1vw rgba(255,120,0,0.5),
    0 0 4vw 2vw rgba(255,60,0,0.25);
  transform-origin: bottom center;
  animation: idleFlicker 1.8s ease-in-out infinite alternate;
  transition: opacity 0.3s;
}

@keyframes idleFlicker {
  0%   { transform: scaleX(1)    scaleY(1)    rotate(-2deg); }
  30%  { transform: scaleX(0.93) scaleY(1.04) rotate(1deg);  }
  60%  { transform: scaleX(1.05) scaleY(0.97) rotate(-1deg); }
  100% { transform: scaleX(0.97) scaleY(1.03) rotate(2deg);  }
}

#flame.blown { animation: none; }

/* ── 심지 ── */
#wick {
  width: 10px;
  height: 3vh;
  background: #222;
  border-radius: 2px 2px 0 0;
  position: relative;
}

/* ── 양초 몸통 ── */
#candle-body {
  width: 120px;
  height: 40vh;
  background: #fff;
  position: relative;
  box-shadow: inset -0.8vw 0 1.6vw rgba(0,0,0,0.06);
}

/* ── 파티클 캔버스 ── */
#particle-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  display: none;
}

/* ── 결과 화면 ── */
#result-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: #00d4f5;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  z-index: 20;
  animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── HAPPY BIRTHDAY 글자 ── */
#birthday-text {
  margin-top: 10vh;
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-align: center;
}

#birthday-text .char {
  display: inline-block;
  transition: color 0.8s ease;
}

#result-screen .record {
  margin-top: 2vh;
  font-size: clamp(1rem, 3vw, 2.5rem);
  font-weight: 700;
  color: #000;
  opacity: 0.65;
}

/* ── 결과 화면 꺼진 초 ── */
#result-screen .wick-art {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

#result-screen .wick-line {
  width: 10px;
  height: 3vh;
  background: #111;
  border-radius: 2px;
  position: relative;
}

#result-screen .smoke {
  width: 1.5vw;
  height: 15vh;
  background: linear-gradient(to top, rgba(0,0,0,0.45), transparent);
  border-radius: 2px;
  animation: smokeDrift 3s ease-out infinite;
  transform-origin: bottom center;
}

@keyframes smokeDrift {
  0%   { transform: scaleX(1)   translateY(0);    opacity: 0.5; }
  50%  { transform: scaleX(2.5) translateY(-1vh); opacity: 0.3; }
  100% { transform: scaleX(3)   translateY(-2vh); opacity: 0;   }
}

#result-screen .candle-stub {
  width: 120px;
  height: 40vh;
  background: #fff;
}

/* ── 태블릿 이상 ── */
@media (min-width: 768px) {
  #mic-bar-wrap { 
    width: 20vw; padding: 1.2vh 2vw; 
  }

  #candle-body, #result-screen .candle-stub { 
    width: 150px; 
  }

  #flame-wrap {
    width: 5vw;
    height: 20vh;
  }

  #birthday-text {
    font-size: clamp(2rem, 7vw, 4rem);
  }

  #result-screen .record {
    font-size: clamp(1rem, 3vw, 2rem);
    font-weight: 700;
    color: #000;
    opacity: 0.65;
  }

  #result-screen .smoke {
    width: 0.3vw;
  }
}
