/* === Atmospheric pulse / heartbeat === */
body.tense::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 998;
  background:
    radial-gradient(ellipse at center, transparent 25%, rgba(180, 30, 30, 0.30) 70%, rgba(0, 0, 0, var(--vignette-darkness, 0.4)) 100%);
  animation: tenseAmbient 3s ease-in-out infinite;
}
@keyframes tenseAmbient {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
body.pulse::after {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(255, 80, 80, var(--pulse-intensity, 0.3)) 100%);
  animation: pulseFlash 0.24s ease-out forwards;
}
@keyframes pulseFlash {
  0% { opacity: 0; transform: scale(0.96); }
  35% { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(1.04); }
}
body.tense .wheel-container {
  animation: tensePulse 0.5s ease-in-out infinite alternate;
}
@keyframes tensePulse {
  from { filter: drop-shadow(0 0 30px rgba(122,92,255,.3)); }
  to { filter: drop-shadow(0 0 50px rgba(255, 100, 100, .5)) drop-shadow(0 0 80px rgba(255, 80, 80, .25)); }
}
body.tense .btn-spin {
  animation: spinBtnTense 0.5s ease-in-out infinite alternate;
}
@keyframes spinBtnTense {
  from { box-shadow: 0 0 40px rgba(255,216,77,.6), inset 0 -6px 16px rgba(0,0,0,.2); }
  to { box-shadow: 0 0 70px rgba(255, 100, 100, .9), 0 0 100px rgba(255, 80, 80, .4), inset 0 -6px 16px rgba(0,0,0,.2); }
}

/* === Эпическая вспышка при объявлении победителя === */
.reveal-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 1500;
  background: radial-gradient(ellipse at center, #fff 0%, #ffd84d 30%, #ff9933 60%, transparent 90%);
  animation: revealFlash 1.2s ease-out forwards;
  mix-blend-mode: screen;
}
@keyframes revealFlash {
  0% { opacity: 0; transform: scale(0.3); }
  10% { opacity: 1; transform: scale(1.5); }
  100% { opacity: 0; transform: scale(2.5); }
}

:root {
  --bg: #070710;
  --bg-soft: #0f0f1c;
  --bg-card: #13132a;
  --bg-card-2: #1a1a35;
  --line: #252548;
  --text: #f4f4ff;
  --muted: #8d8db5;
  --brand: #ffd84d;
  --brand-2: #ffae00;
  --good: #4dffae;
  --bad: #ff5577;
  --accent: #7a5cff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1400px 700px at 20% -10%, rgba(122,92,255,.18), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(255,216,77,.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}
#app { max-width: 1400px; margin: 0 auto; padding: 30px 20px 60px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 30px; flex-wrap: wrap;
  padding: 14px 0 22px; border-bottom: 1px solid var(--line);
  margin-bottom: 30px;
}
.brand__title {
  font-weight: 900; font-size: 28px; letter-spacing: .3px;
  background: linear-gradient(180deg, #fff, #bfbfff 80%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand__sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 4px; }
.stages { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.stage {
  appearance: none; background: var(--bg-card); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 18px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: .15s;
}
.stage:hover { color: var(--text); }
.stage.active { background: linear-gradient(180deg, var(--accent), #4d2fff); color: #fff; border-color: transparent; }

/* Views */
.view { display: none; animation: fadeIn .3s ease-out; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* Champion (1st place) */
.champion-card {
  max-width: 720px; margin: 30px auto;
  background: linear-gradient(180deg, #2a2008, #1a1505);
  border: 2px solid #b88520;
  border-radius: 28px;
  padding: 50px 40px 40px;
  text-align: center;
  box-shadow: 0 0 60px rgba(255,180,60,.25);
  position: relative;
}
/* Photo with crown — used on champion, winner overlays, podium */
.photo-with-crown {
  position: relative;
  width: 200px; height: 200px;
  margin: 0 auto 24px;
}
.photo-with-crown.big { width: 220px; height: 220px; margin-top: 30px; }
.photo-with-crown.small { width: 130px; height: 130px; margin: 0 auto 14px; }

.photo-with-crown .photo-wrap,
.photo-with-crown .podium-photo {
  width: 100%; height: 100%;
  border-radius: 50%; overflow: hidden;
  border: 4px solid var(--brand);
  box-shadow: 0 0 40px rgba(255,216,77,.5);
  background: var(--bg-card-2);
}
.photo-with-crown .photo-wrap img,
.photo-with-crown .podium-photo img { width: 100%; height: 100%; object-fit: cover; }

.photo-with-crown .crown {
  position: absolute;
  top: -45%;
  left: 50%;
  font-size: 120px;
  z-index: 3;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.5));
  animation: crownDrop 1s cubic-bezier(.34, 1.56, .64, 1) 0.4s both;
  transform-origin: center bottom;
}
.photo-with-crown.big .crown { font-size: 130px; top: -50%; }
.photo-with-crown.small .crown { font-size: 75px; top: -42%; }

@keyframes crownDrop {
  0% {
    transform: translateX(-50%) translateY(-100vh) rotate(-25deg);
    opacity: 0;
  }
  60% {
    transform: translateX(-50%) translateY(15px) rotate(8deg);
    opacity: 1;
  }
  78% {
    transform: translateX(-50%) translateY(-10px) rotate(-4deg);
  }
  100% {
    transform: translateX(-50%) translateY(0) rotate(-6deg);
    opacity: 1;
  }
}
.champion-card__title {
  font-size: 12px; color: var(--brand); letter-spacing: 2px; font-weight: 800;
  text-transform: uppercase; margin-bottom: 10px;
}
.champion-card__name {
  font-size: 42px; font-weight: 900; line-height: 1.1; margin-bottom: 8px;
  background: linear-gradient(180deg, #fff, var(--brand) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.champion-card__team { font-size: 16px; color: #cfcff0; margin-bottom: 14px; }
.champion-card__stats { font-size: 14px; color: var(--muted); margin-bottom: 30px; }
.champion-card__prize {
  background: rgba(0,0,0,.4); border: 1px solid #5a4118; border-radius: 14px;
  padding: 18px; margin-bottom: 30px;
}
.prize-label { font-size: 11px; color: var(--brand); letter-spacing: 1.5px; text-transform: uppercase; font-weight: 800; margin-bottom: 6px; }
.prize-name { font-size: 22px; font-weight: 800; color: #fff; }
.prize-or { font-size: 13px; color: var(--muted); margin-top: 4px; }

.btn-cta {
  background: linear-gradient(180deg, var(--accent), #4d2fff);
  color: #fff; border: 0; border-radius: 999px;
  padding: 14px 28px; font: inherit; font-size: 15px; font-weight: 800;
  cursor: pointer; box-shadow: 0 8px 24px rgba(122,92,255,.4);
  transition: .15s;
}
.btn-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(122,92,255,.5); }

.btn-secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 14px 24px; font: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: .15s;
}
.btn-secondary:hover { border-color: var(--accent); background: rgba(122,92,255,.1); }

/* Stage header (2nd, 3rd) */
.stage-header { text-align: center; margin-bottom: 20px; }
.stage-title { font-size: 32px; font-weight: 900; margin-bottom: 8px; }
.stage-prize { font-size: 16px; color: var(--brand); font-weight: 700; margin-bottom: 4px; }
.stage-info { font-size: 13px; color: var(--muted); }

/* Wheel */
.wheel-container {
  position: relative; width: 100%; max-width: 800px; margin: 0 auto;
  aspect-ratio: 1;
}
.wheel-container canvas {
  width: 100%; height: 100%; display: block;
  filter: drop-shadow(0 0 30px rgba(122,92,255,.3));
}
.wheel-pointer {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  font-size: 56px; color: var(--brand); z-index: 5;
  text-shadow: 0 0 20px rgba(255,216,77,.8);
  animation: pulsePointer 1.8s ease-in-out infinite;
}
@keyframes pulsePointer { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-6px); } }
.wheel-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); z-index: 4;
}
.btn-spin {
  width: 130px; height: 130px; border-radius: 50%;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: #1a1100;
  border: 4px solid #fff;
  font: inherit; font-weight: 900; font-size: 18px; letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 0 40px rgba(255,216,77,.6), inset 0 -6px 16px rgba(0,0,0,.2);
  transition: .15s;
}
.btn-spin:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 0 60px rgba(255,216,77,.9), inset 0 -6px 16px rgba(0,0,0,.2);
}
.btn-spin:disabled { opacity: .55; cursor: not-allowed; }

/* Winner overlay */
.winner-overlay {
  position: fixed; inset: 0;
  background: rgba(2,2,12,.85); backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  animation: fadeIn .3s ease-out;
}
.winner-card {
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border: 2px solid var(--brand);
  border-radius: 28px;
  padding: 60px 40px 40px;
  text-align: center;
  max-width: 600px; width: 100%;
  box-shadow: 0 0 100px rgba(255,216,77,.6), 0 0 200px rgba(255,180,60,.3);
  animation: epicReveal 1.4s cubic-bezier(.34, 1.56, .64, 1);
  position: relative;
}
@keyframes epicReveal {
  0% { transform: scale(0.2) rotate(-8deg); opacity: 0; filter: blur(20px); }
  40% { transform: scale(1.18) rotate(3deg); opacity: 1; filter: blur(0); }
  60% { transform: scale(0.96) rotate(-1.5deg); }
  80% { transform: scale(1.04) rotate(0.5deg); }
  100% { transform: scale(1) rotate(0); }
}
.winner-card__close {
  position: absolute;
  top: 12px; right: 18px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 32px;
  font-weight: 300;
  cursor: pointer;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: .15s;
  line-height: 1;
}
.winner-card__close:hover {
  color: var(--text);
  background: rgba(255,255,255,.1);
}
@keyframes zoomIn { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.winner-overlay { animation: overlayFadeIn .4s ease-out; }
@keyframes overlayFadeIn { from { background: rgba(2,2,12,0); } to { background: rgba(2,2,12,.85); } }
.winner-card__crown { font-size: 70px; margin-bottom: 12px; }
.winner-card__photo {
  width: 200px; height: 200px; margin: 0 auto 20px;
  border-radius: 50%; overflow: hidden;
  border: 4px solid var(--brand);
  box-shadow: 0 0 30px rgba(255,216,77,.4);
  background: var(--bg-card-2);
}
.winner-card__photo img { width: 100%; height: 100%; object-fit: cover; }
.winner-card__name {
  font-size: 36px; font-weight: 900; line-height: 1.1; margin-bottom: 8px;
  background: linear-gradient(180deg, #fff, var(--brand) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.winner-card__team { font-size: 16px; color: #cfcff0; margin-bottom: 10px; }
.winner-card__stats { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.winner-card__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Summary */
.summary-card { max-width: 1100px; margin: 30px auto; text-align: center; }
.summary-card h1 { font-size: 36px; font-weight: 900; margin-bottom: 30px; }
.podium {
  display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 20px;
  align-items: end; margin-bottom: 40px;
}
.podium-place {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 18px; text-align: center;
}
.podium-1 {
  border-color: #b88520; background: linear-gradient(180deg, #2a2008, var(--bg-card));
  transform: scale(1.05);
}
.podium-2 { border-color: #888; }
.podium-3 { border-color: #b76; }
.podium-rank {
  font-size: 60px; font-weight: 900; line-height: 1;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 14px;
}
.podium-2 .podium-rank { background: linear-gradient(180deg, #ddd, #999); -webkit-background-clip: text; }
.podium-3 .podium-rank { background: linear-gradient(180deg, #c97, #864); -webkit-background-clip: text; }
.podium-photo {
  width: 130px; height: 130px; margin: 0 auto 14px;
  border-radius: 50%; overflow: hidden;
  border: 3px solid var(--brand); background: var(--bg-card-2);
}
.podium-2 .podium-photo { border-color: #999; }
.podium-3 .podium-photo { border-color: #864; }
.podium-photo img { width: 100%; height: 100%; object-fit: cover; }
.podium-name { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.podium-prize { font-size: 12px; color: var(--muted); }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1100; overflow: hidden; }
.confetti-piece {
  position: absolute; top: -20px; width: 10px; height: 14px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
.confetti-piece.burst {
  animation: confettiBurst cubic-bezier(.15,.85,.4,1) forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
@keyframes confettiBurst {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx, 0), var(--dy, 0)) rotate(900deg); opacity: 0; }
}

/* Responsive */
@media (max-width: 720px) {
  #app { padding: 16px 12px 40px; }
  .stages { width: 100%; }
  .stage { padding: 7px 12px; font-size: 12px; }
  .champion-card { padding: 30px 22px; }
  .champion-card__name { font-size: 28px; }
  .stage-title { font-size: 22px; }
  .btn-spin { width: 100px; height: 100px; font-size: 14px; }
  .podium { grid-template-columns: 1fr; gap: 14px; }
  .podium-1 { transform: none; order: -1; }
  .podium-photo { width: 100px; height: 100px; }
}
