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

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "Pretendard", "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, sans-serif;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

/* hidden source video for webcam frames (drawn manually onto canvas) */
#webcamVideo {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Start overlay ---------- */
#startOverlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #1a2440 0%, #050810 75%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  z-index: 50;
  transition: opacity 0.6s ease;
}

#startOverlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#startOverlay h1 {
  color: #eaf2ff;
  font-size: clamp(28px, 5vw, 52px);
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(90, 170, 255, 0.9), 0 0 60px rgba(90, 170, 255, 0.5);
  text-align: center;
}

#startOverlay p {
  color: #9fb4d8;
  font-size: clamp(13px, 2vw, 16px);
  text-align: center;
  max-width: 520px;
  line-height: 1.6;
  padding: 0 20px;
}

#startBtn {
  padding: 16px 48px;
  font-size: 20px;
  font-weight: 700;
  color: #071018;
  background: linear-gradient(180deg, #ffe27a, #ffb020);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(255, 190, 60, 0.7), 0 4px 0 rgba(140, 90, 0, 0.6);
  letter-spacing: 1px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#startBtn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 0 42px rgba(255, 200, 80, 0.9), 0 6px 0 rgba(140, 90, 0, 0.6); }
#startBtn:active { transform: translateY(1px) scale(0.98); }

#permHint {
  color: #6f88b3;
  font-size: 12px;
  min-height: 16px;
}

/* ---------- SUPER SAVE text ---------- */
/* Sits near the bottom, not over the hand, so the God Hand holding the
   ball stays fully visible above it instead of being covered by text. */
#superSaveText {
  position: absolute;
  left: 50%;
  top: 86%;
  transform: translate(-50%, -50%) scale(0.3);
  font-size: clamp(32px, 7vw, 92px);
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff8dd;
  -webkit-text-stroke: 3px #1c3a6e;
  text-shadow:
    0 0 10px #fff6cf,
    0 0 30px #ffd35c,
    0 0 60px #ff9d2e,
    0 0 110px #3aa9ff,
    0 0 8px #ffffff;
  opacity: 0;
  z-index: 30;
  white-space: nowrap;
  pointer-events: none;
  font-family: "Arial Black", "Pretendard", sans-serif;
  font-style: italic;
}

#superSaveText.show {
  animation: superSavePunch 0.9s cubic-bezier(.2, 1.4, .4, 1) forwards;
}

@keyframes superSavePunch {
  0%   { opacity: 0;   transform: translate(-50%, -50%) scale(0.2) rotate(-4deg); }
  35%  { opacity: 1;   transform: translate(-50%, -50%) scale(1.18) rotate(2deg); }
  55%  { opacity: 1;   transform: translate(-50%, -50%) scale(0.96) rotate(-1deg); }
  75%  { opacity: 1;   transform: translate(-50%, -50%) scale(1.05) rotate(0deg); }
  100% { opacity: 1;   transform: translate(-50%, -50%) scale(1.0) rotate(0deg); }
}

/* ---------- Flash overlay ---------- */
#flashOverlay {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
}

#stateTag {
  position: absolute;
  top: 10px;
  left: 12px;
  color: rgba(160, 190, 255, 0.5);
  font-size: 11px;
  letter-spacing: 1px;
  z-index: 25;
  pointer-events: none;
}

/* ---------- 결과 화면 (승부차기 5번) ---------- */
#resultOverlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vh;
  background: rgba(3, 6, 16, 0.82);
  z-index: 45;
  color: #eaf2ff;
  text-align: center;
}
#resultOverlay.hidden { display: none; }
.result-label { font-size: clamp(24px, 4vw, 48px); font-weight: 800; color: #9fc2ff; }
.result-score {
  font-size: clamp(90px, 20vw, 240px);
  font-weight: 900;
  line-height: 1;
  color: #fff3c4;
  text-shadow: 0 0 30px rgba(255, 200, 60, 0.8);
  font-family: "Arial Black", "Pretendard", sans-serif;
}
.result-best { font-size: clamp(22px, 3.5vw, 42px); font-weight: 700; color: #ffd23c; }
#retryBtn {
  margin-top: 2vh;
  padding: 3vh 10vw;
  font-size: clamp(32px, 5vw, 64px);
  font-weight: 900;
  color: #071018;
  background: linear-gradient(180deg, #ffe27a, #ffb020);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 40px rgba(255, 190, 60, 0.8), 0 6px 0 rgba(140, 90, 0, 0.6);
}
#retryBtn:hover { transform: scale(1.04); }
.result-new { font-size: clamp(26px, 4vw, 52px); font-weight: 900; color: #ff5a8a; }
.result-new.hidden { display: none; }
.result-avg { font-size: clamp(18px, 2.6vw, 32px); font-weight: 700; color: #cfe0ff; }
