* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, #2a1a4a 0%, transparent 50%),
    radial-gradient(circle at 80% 90%, #0a3a5e 0%, transparent 50%),
    linear-gradient(135deg, #0f0f1e 0%, #1a1a2e 50%, #0a1a2e 100%);
  color: #fff;
  overflow-x: hidden;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 60px;
  min-height: 100vh;
}

.title {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 800;
  margin: 0 0 28px;
  letter-spacing: 3px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffd60a, #ff8c00, #ff3d7f);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 24px rgba(255, 200, 0, 0.35));
}

.wheel-wrap {
  position: relative;
  display: inline-block;
}

#wheel {
  display: block;
  filter: drop-shadow(0 14px 40px rgba(0, 0, 0, 0.55));
  cursor: grab;
  width: min(90vmin, 700px);
  height: auto;
  touch-action: none;
  user-select: none;
}
#wheel:active { cursor: grabbing; }

.pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 24px solid transparent;
  border-right: 24px solid transparent;
  border-top: 44px solid #ffd60a;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
  z-index: 10;
  pointer-events: none;
}

.spin-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 5px solid #ffd60a;
  background: radial-gradient(circle at 30% 30%, #ffffff, #e8e8f0);
  color: #1a1a2e;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.4),
    inset 0 -4px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.1s;
  z-index: 5;
}
.spin-btn:hover  { transform: translate(-50%, -50%) scale(1.06); }
.spin-btn:active { transform: translate(-50%, -50%) scale(0.94); }
.spin-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: translate(-50%, -50%) scale(1);
}

.hint {
  margin-top: 24px;
  opacity: 0.65;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

.mute-btn {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.mute-btn:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.35); }
.mute-btn[aria-pressed="true"] { opacity: 0.55; }

/* Winner overlay */
.winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.25s ease;
}
.winner-overlay.hidden { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.winner-card {
  position: relative;
  background: linear-gradient(135deg, #ffd60a 0%, #ff8c00 60%, #ff3d7f 100%);
  color: #1a1a2e;
  padding: 40px 48px 36px;
  border-radius: 28px;
  text-align: center;
  max-width: 90vw;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: pop 0.55s cubic-bezier(0.17, 0.67, 0.4, 1.35);
}

@keyframes pop {
  0%   { transform: scale(0.4) rotate(-6deg); opacity: 0; }
  60%  { transform: scale(1.06) rotate(2deg);             }
  100% { transform: scale(1) rotate(0);       opacity: 1; }
}

.winner-photo-wrap {
  position: relative;
  width: clamp(240px, 36vmin, 360px);
  height: clamp(240px, 36vmin, 360px);
  border-radius: 50%;
  margin: 40px auto 22px;
  border: 8px solid #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  background: #fff;
}
.winner-photo-wrap > img,
.winner-photo-wrap > .winner-fallback {
  border-radius: 50%;
  overflow: hidden;
}
.winner-photo-wrap > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.winner-crown {
  position: absolute;
  width: 46%;
  left: 50%;
  top: 0;
  transform: translate(-50%, -130%) rotate(-8deg);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45));
  z-index: 3;
  pointer-events: none;
  opacity: 0;
}
.winner-crown.drop {
  animation: crown-drop 0.95s cubic-bezier(0.34, 1.56, 0.64, 1) 0.25s both;
}
@keyframes crown-drop {
  0%   { transform: translate(-50%, -160%) rotate(-25deg); opacity: 0; }
  55%  { transform: translate(-50%, -78%)  rotate(6deg);   opacity: 1; }
  72%  { transform: translate(-50%, -88%)  rotate(-3deg);  }
  100% { transform: translate(-50%, -78%)  rotate(0);      opacity: 1; }
}
.winner-photo-wrap img.hidden { display: none; }

.winner-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(5rem, 18vmin, 9rem);
  font-weight: 900;
  color: #fff;
  background: #1a1a2e;
}
.winner-fallback.hidden { display: none; }

.winner-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 4px;
}

.winner-name {
  margin: 0 0 14px;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.1;
}

.winner-verdict {
  margin: 0 0 26px;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  font-weight: 600;
  font-style: italic;
  opacity: 0.85;
  max-width: 32ch;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.35;
}

.close-btn {
  background: #1a1a2e;
  color: #ffd60a;
  border: none;
  padding: 13px 34px;
  border-radius: 32px;
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.close-btn:hover  { transform: scale(1.05); background: #2a2a4e; }
.close-btn:active { transform: scale(0.97); }

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}
