/* ============================================================
   machine.css — 인형뽑기 캐비닛 / 인형 / 바닥 / 컨트롤 / 인트로
   ============================================================ */

/* ---------- 기계 본체 ---------- */
#machine {
  position: absolute;
  left: 140px;
  top: 262px;
  width: 800px;
  height: 1300px;
  border-radius: 30px;
  background: linear-gradient(180deg, #fdfdff 0%, #e4ecf5 45%, #cfd9e6 100%);
  box-shadow: 0 26px 70px rgba(0,0,0,.65);
  overflow: hidden;
}

/* 기계 상단 헤더 */
#cabinetHeader {
  position: absolute;
  left: 26px; right: 26px; top: 22px;
  height: 84px;
  border-radius: 18px;
  background: linear-gradient(180deg, #4b1d5e, #2a0b3d);
  display: flex; align-items: center; justify-content: center; gap: 22px;
  border: 3px solid rgba(255,255,255,.25);
  box-shadow: inset 0 0 22px rgba(255,91,208,.35);
}
#cabinetHeader .hdr-text {
  font-size: 46px;
  letter-spacing: 10px;
  color: #fff;
  text-shadow: 0 0 10px #ff5bd0, 0 0 26px #ff5bd0, 0 0 52px rgba(255,91,208,.7);
}
#cabinetHeader .hdr-star {
  font-size: 30px; color: var(--neon-yellow);
  text-shadow: 0 0 12px #ffd60a;
  animation: tubePulse 1.6s ease-in-out infinite;
}

/* ---------- 유리 캐비닛 ---------- */
#glass {
  position: absolute;
  left: 26px; right: 26px;
  top: 122px;
  height: 1020px;
  border-radius: 20px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #ffd28a 0%, #ff9a5c 38%, #ff6fa5 72%, #e0489a 100%);
  border: 6px solid rgba(255,255,255,.55);
  box-shadow: inset 0 0 60px rgba(0,0,0,.28);
}
/* 유리 반사 하이라이트 */
#glass::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(118deg,
      rgba(255,255,255,.30) 0%, rgba(255,255,255,.06) 26%,
      rgba(255,255,255,0)   46%, rgba(255,255,255,.16) 62%,
      rgba(255,255,255,0)   78%);
  pointer-events: none;
  z-index: 20;
}

/* 방사형 선버스트 */
#sunburst {
  position: absolute;
  left: 50%; top: 45%;
  width: 1600px; height: 1600px;
  margin: -800px 0 0 -800px;
  background: repeating-conic-gradient(
      from 0deg,
      rgba(255,255,255,.22) 0deg 9deg,
      rgba(255,255,255,0)   9deg 18deg);
  animation: spinSlow 42s linear infinite;
}
@keyframes spinSlow { to { transform: rotate(360deg); } }

/* 소용돌이 · 별 장식 */
#swirl {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(255,255,255,.65) 0 4px, transparent 5px),
    radial-gradient(circle at 82% 18%, rgba(255,255,255,.55) 0 5px, transparent 6px),
    radial-gradient(circle at 12% 74%, rgba(255,255,255,.5)  0 4px, transparent 5px),
    radial-gradient(circle at 88% 70%, rgba(255,255,255,.6)  0 5px, transparent 6px),
    radial-gradient(circle at 50% 88%, rgba(255,255,255,.4)  0 4px, transparent 5px);
  animation: spinSlow 60s linear infinite reverse;
}

/* 유리 안내 스티커 */
#doorSticker {
  position: absolute;
  left: 50%; top: 906px;
  transform: translateX(-50%);
  z-index: 22;
  font-size: 34px;
  color: #e00024;
  text-shadow: 0 2px 0 rgba(255,255,255,.85), 0 0 12px rgba(255,255,255,.7);
  white-space: nowrap;
}

/* 유리문 (PERFECT 시 좌우로 열림) */
.door {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  z-index: 21;
  background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,.06));
  border: 3px solid rgba(255,255,255,.45);
  transition: transform 1.1s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}
.door-l { left: 0;  border-radius: 16px 0 0 16px; }
.door-r { right: 0; border-radius: 0 16px 16px 0; }
#glass.open .door-l { transform: translateX(-102%); }
#glass.open .door-r { transform: translateX(102%); }

/* ---------- 경품 : 당근수영 수모 ---------- */
#dollWrap {
  position: absolute;
  left: 50%; top: 300px;
  width: 540px; height: 580px;
  margin-left: -270px;
  z-index: 15;
  animation: dollFloat 3.4s ease-in-out infinite;
}
@keyframes dollFloat {
  0%,100% { transform: translateY(0)     rotate(-2deg); }
  50%     { transform: translateY(-26px) rotate(2.5deg); }
}

/* 사진 자체 */
#dollPic { position: relative; z-index: 2; display: block; width: 100%; height: 100%; }
#doll {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 20px rgba(0,0,0,.42));
  -webkit-user-select: none; user-select: none; -webkit-user-drag: none;
}

/* 수모 위를 훑고 지나가는 광택 — 수모 모양으로 잘라낸다 */
#dollGleam {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: linear-gradient(115deg,
      rgba(255,255,255,0)   38%,
      rgba(255,255,255,.85) 48%,
      rgba(255,255,255,0)   58%);
  background-size: 260% 100%;
  -webkit-mask-image: url('../assets/img/prize-cap-mask.png?v=20260925a');
          mask-image: url('../assets/img/prize-cap-mask.png?v=20260925a');
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  animation: gleamSweep 4.2s ease-in-out infinite;
  opacity: .9;
}
@keyframes gleamSweep {
  0%, 62%  { background-position: 150% 0; }
  92%,100% { background-position: -60% 0; }
}

/* 바닥 그림자 — 떠오를 때 작아진다 */
#dollShadow {
  position: absolute; z-index: 0;
  left: 50%; bottom: 34px;
  width: 290px; height: 40px; margin-left: -145px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,.52) 0%, rgba(0,0,0,.24) 52%, rgba(0,0,0,0) 74%);
  animation: dollShadowPulse 3.4s ease-in-out infinite;
}
@keyframes dollShadowPulse {
  0%,100% { transform: scale(1);    opacity: .62; }
  50%     { transform: scale(.78);  opacity: .34; }
}

/* 뒤에서 도는 후광 */
#dollHalo {
  position: absolute;
  left: 50%; top: 50%;
  width: 470px; height: 470px;
  margin: -235px 0 0 -235px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255,255,255,.34) 0%, rgba(255,233,168,.28) 42%, rgba(255,233,168,0) 70%);
  opacity: .55;
  z-index: 0;
  transition: opacity .4s, transform .4s;
  animation: haloBreath 3.4s ease-in-out infinite;
}
@keyframes haloBreath {
  0%,100% { opacity: .45; }
  50%     { opacity: .72; }
}

/* 반짝이 */
#dollWrap .spark {
  position: absolute; z-index: 4; pointer-events: none;
  width: 16px; height: 16px; opacity: 0;
  background:
    linear-gradient(to right, transparent 46%, #fff 49%, #fff 51%, transparent 54%),
    linear-gradient(to bottom, transparent 46%, #fff 49%, #fff 51%, transparent 54%);
  filter: drop-shadow(0 0 6px #ffe98a);
  animation: sparkTwinkle 2.6s ease-in-out infinite;
}
#dollWrap .s1 { left: 16%; top: 22%; animation-delay: .0s;  }
#dollWrap .s2 { left: 82%; top: 30%; animation-delay: .55s; width: 22px; height: 22px; }
#dollWrap .s3 { left: 70%; top: 12%; animation-delay: 1.1s; width: 12px; height: 12px; }
#dollWrap .s4 { left: 10%; top: 58%; animation-delay: 1.6s; width: 13px; height: 13px; }
#dollWrap .s5 { left: 88%; top: 62%; animation-delay: 2.1s; }
@keyframes sparkTwinkle {
  0%, 70%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); }
  80%           { opacity: 1; transform: scale(1.15) rotate(90deg); }
  88%           { opacity: .5; transform: scale(.9) rotate(140deg); }
}

/* PERFECT : 점프 + 회전 + 발광 */
#dollWrap.win { animation: dollWin 1.15s cubic-bezier(.3,1.4,.4,1) 2; }
#dollWrap.win #doll { filter: drop-shadow(0 0 34px #fff) drop-shadow(0 0 70px #ffd60a); }
#dollWrap.win #dollGleam { animation-duration: 1.1s; }
#dollWrap.win .spark { animation-duration: .8s; }
#dollWrap.win + #doorSticker { opacity: .3; }
@keyframes dollWin {
  0%   { transform: translateY(0) rotate(0); }
  38%  { transform: translateY(-150px) rotate(200deg) scale(1.08); }
  70%  { transform: translateY(14px) rotate(360deg) scale(.96); }
  100% { transform: translateY(0) rotate(360deg) scale(1); }
}
#dollWrap.win ~ * #dollHalo, #dollWrap.win #dollHalo { opacity: 1; transform: scale(1.25); }

/* 실패 : 고개 갸웃 */
#dollWrap.sad { animation: dollSad 1s ease-in-out; }
@keyframes dollSad {
  0%,100% { transform: rotate(0); }
  30%     { transform: rotate(-13deg) translateY(10px); }
  65%     { transform: rotate(9deg)  translateY(10px); }
}

/* 움직임을 줄여달라는 설정이면 조용히 떠 있기만 한다 */
@media (prefers-reduced-motion: reduce) {
  #dollWrap, #dollShadow, #dollHalo { animation: none; }
  #dollGleam, #dollWrap .spark { display: none; }
}

/* ---------- 경품 배출구 ---------- */
#prizeChute {
  position: absolute;
  left: 26px; right: 26px; bottom: 24px;
  height: 118px;
  border-radius: 16px;
  background: linear-gradient(180deg, #2b3244, #10131c);
  border: 4px solid rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 12px 26px rgba(0,0,0,.75);
}
#prizeChute span {
  font-size: 30px; letter-spacing: 12px;
  color: rgba(255,255,255,.35);
}

/* ---------- 체크무늬 바닥 ---------- */
#floor {
  position: absolute;
  left: -20%; right: -20%;
  top: 1520px;
  height: 420px;
  background:
    repeating-conic-gradient(#ffd7e8 0 25%, #fff6fb 0 50%) 0 0 / 120px 120px;
  transform: perspective(420px) rotateX(62deg);
  transform-origin: top center;
  opacity: .5;
  z-index: -1;
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.95), rgba(0,0,0,0) 86%);
  mask-image: linear-gradient(180deg, rgba(0,0,0,.95), rgba(0,0,0,0) 86%);
}

/* ---------- 하단 컨트롤 ---------- */
#controls {
  position: absolute;
  left: 0; right: 0;
  top: 1600px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  z-index: 30;
}
#turnBadge {
  display: flex; align-items: center; gap: 12px;
  font-size: 36px;
  padding: 10px 30px;
  border-radius: 999px;
  background: rgba(8,2,24,.72);
  border: 3px solid var(--neon-cyan);
  color: #fff;
  box-shadow: 0 0 18px rgba(0,229,255,.6);
  text-shadow: 0 0 10px rgba(0,229,255,.8);
}
#turnBadge .dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 12px currentColor;
}

.btn-row { display: flex; align-items: stretch; gap: 40px; }

/* STOP / START — 같은 크기의 사각 버튼 */
#stopBtn, #startBtn {
  width: 300px;
  height: 140px;
  border-radius: 18px;
  font-size: 54px;
  letter-spacing: 3px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .08s, box-shadow .08s, filter .2s, opacity .2s;
}

#stopBtn {
  background: linear-gradient(180deg, #ff5a6e 0%, #ff2d55 52%, #c1122c 100%);
  border: 6px solid #fff;
  color: #fff;
  text-shadow: 0 4px 6px rgba(0,0,0,.45);
  box-shadow: 0 12px 0 #7c0a1f, 0 18px 34px rgba(0,0,0,.55), inset 0 -8px 18px rgba(0,0,0,.25);
}
#stopBtn:active:not(:disabled) {
  transform: translateY(10px);
  box-shadow: 0 2px 0 #7c0a1f, 0 6px 14px rgba(0,0,0,.5), inset 0 -6px 16px rgba(0,0,0,.3);
}
#stopBtn:disabled { filter: grayscale(.65) brightness(.6); cursor: default; }

#startBtn {
  background: linear-gradient(180deg, #9dff7a 0%, #56d62f 52%, #2f9415 100%);
  border: 6px solid #fff;
  color: #10330a;
  text-shadow: 0 3px 5px rgba(255,255,255,.35);
  box-shadow: 0 12px 0 #1d6b0d, 0 18px 34px rgba(0,0,0,.55), inset 0 -8px 18px rgba(0,0,0,.18);
}
#startBtn:active:not(:disabled) {
  transform: translateY(10px);
  box-shadow: 0 2px 0 #1d6b0d, 0 6px 14px rgba(0,0,0,.5), inset 0 -6px 16px rgba(0,0,0,.22);
}
#startBtn:disabled { filter: grayscale(.8) brightness(.62); cursor: default; }

#hint { font-size: 26px; color: rgba(255,255,255,.55); letter-spacing: 1px; }

/* ---------- 인트로 / 닉네임 입력 ---------- */
#intro {
  position: fixed; inset: 0; z-index: 250;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,0,16,.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
  transition: opacity .45s;
}
#intro.hide { opacity: 0; pointer-events: none; }

.intro-box {
  width: min(92vw, 620px);
  max-height: 92vh;
  overflow-y: auto;
  padding: 34px 28px 30px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(26,11,46,.96), rgba(9,2,25,.98));
  border: 4px solid var(--neon-cyan);
  box-shadow: 0 0 30px rgba(0,229,255,.6), inset 0 0 40px rgba(177,74,237,.25);
  text-align: center;
}
.intro-title {
  font-size: clamp(28px, 7.2vw, 42px);
  color: #fff;
  text-shadow: 0 0 12px var(--neon-pink), 0 0 34px var(--neon-pink);
  margin-bottom: 8px;
}
.intro-sub { font-size: clamp(16px, 4.2vw, 20px); color: rgba(255,255,255,.72); margin-bottom: 14px; }
.intro-sub b { color: var(--neon-yellow); text-shadow: 0 0 10px var(--neon-yellow); }

/* 안내 목록 (경품 · 참여조건 · 랭킹 초기화) */
.intro-info {
  list-style: none;
  text-align: left;
  margin: 0 0 22px;
  display: flex; flex-direction: column; gap: 9px;
}
.intro-info li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.055);
  border: 2px solid rgba(0,229,255,.28);
  font-size: clamp(14px, 3.4vw, 18px);
  line-height: 1.5;
  color: rgba(255,255,255,.86);
}
.intro-info li .ico { flex: 0 0 auto; font-size: 1.15em; line-height: 1.35; }
.intro-info li b { color: var(--neon-yellow); text-shadow: 0 0 8px rgba(255,214,10,.55); }
.intro-info li b.hl { color: #ffa53d; text-shadow: 0 0 10px rgba(255,165,61,.7); }

.input-row { display: flex; gap: 10px; }
#nickInput {
  flex: 1;
  min-width: 0;
  height: 56px;
  padding: 0 16px;
  font-size: 22px;
  border-radius: 12px;
  background: rgba(255,255,255,.07);
  border: 2px solid rgba(0,229,255,.5);
  color: #fff;
}
#nickInput::placeholder { color: rgba(255,255,255,.35); }
#nickInput:focus { border-color: var(--neon-cyan); box-shadow: 0 0 14px rgba(0,229,255,.5); }
#addBtn {
  width: 132px; height: 56px;
  white-space: nowrap;
  border-radius: 12px;
  font-size: 22px;
  color: #06121a;
  background: linear-gradient(180deg, #5ef0ff, #00b8d4);
  box-shadow: 0 0 16px rgba(0,229,255,.6);
}
#addBtn:active { transform: scale(.95); }

#nickError { min-height: 26px; font-size: 18px; color: var(--neon-red); margin-top: 8px; }

#chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 52px; margin: 6px 0 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 14px 10px 18px;
  border-radius: 999px;
  font-size: 22px;
  color: #fff;
  border: 2px solid currentColor;
  background: rgba(8,2,24,.7);
  box-shadow: 0 0 14px currentColor;
  animation: chipIn .28s cubic-bezier(.2,1.5,.4,1);
}
.chip .nm { color: #fff; text-shadow: 0 0 8px currentColor; }
.chip .del {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,.14);
  font-size: 17px; line-height: 1; color: #fff;
}
.chip .del:hover { background: var(--neon-red); }
@keyframes chipIn { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.cap { font-size: 17px; color: rgba(255,255,255,.5); margin-bottom: 22px; }

#playBtn {
  width: 100%;
  height: 70px;
  border-radius: 16px;
  font-size: 30px;
  color: #0d2b06;
  background: linear-gradient(180deg, #9dff7a, #3fbf23);
  box-shadow: 0 0 26px rgba(57,255,20,.65);
  transition: transform .12s, filter .2s;
}
#playBtn:active:not(:disabled) { transform: scale(.97); }
#playBtn:disabled { filter: grayscale(1) brightness(.55); cursor: default; box-shadow: none; }
