.stage-shell {
  --stage-bg: #000;
  --stage-panel: #100e12;
  --stage-edge: #302833;
  --stage-text: #fff;
  --stage-muted: #c6bbc9;
  --stage-accent: #ead1ff;
  --stage-peach: #ffcbaa;
  --stage-magenta: #e15bb9;
  --stage-highlight: linear-gradient(125deg, #f8d4ff 0%, #ffc9ad 100%);
  --stage-gutter: clamp(20px, 3.35vw, 72px);
  --stage-indent: clamp(0px, 4.7vw, 96px);
  position: relative;
  isolation: isolate;
  overflow: clip;
  color: var(--stage-text);
  background: var(--stage-bg);
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.stage-shell::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  width: clamp(30px, 8.6vw, 170px);
  background: repeating-linear-gradient(24deg, #303030 0 26px, transparent 26px 72px);
  mask-image: linear-gradient(90deg, #000 2%, rgb(0 0 0 / .8) 65%, transparent);
  pointer-events: none;
}

.stage-shell [hidden] { display: none; }
.stage-live { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; white-space: nowrap; clip-path: inset(50%); }
.stage-shell button { font: inherit; }
.stage-shell h1, .stage-shell h2, .stage-shell p { margin: 0; }
.stage-shell h1, .stage-shell h2 { overflow-wrap: anywhere; }
.stage-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: clamp(68px, 8.6vh, 108px);
  margin: 0 var(--stage-gutter);
  padding-left: var(--stage-indent);
}

.stage-header-brand {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.2vw, 40px);
  min-width: 0;
}

.stage-header-brand img {
  display: block;
  width: clamp(133px, 18vw, 342px);
  height: auto;
}

.stage-header-brand > span {
  padding-left: clamp(10px, 1.65vw, 32px);
  border-left: 1px solid var(--stage-edge);
  color: var(--stage-muted);
  font-size: clamp(12px, 1vw, 20px);
  text-wrap: balance;
}
.stage-header-actions { display: flex; align-items: center; gap: clamp(8px, .7vw, 14px); }
.stage-phase, .stage-link-state {
  display: inline-flex;
  align-items: center;
  gap: .55em;
  border: 1px solid var(--stage-edge);
  background: var(--stage-panel);
  border-radius: 100px;
  padding: .55em .86em;
  font-size: clamp(13px, 1.1vw, 20px);
  line-height: 1.15;
  color: var(--stage-muted);
  white-space: nowrap;
}

.stage-phase::before, .stage-link-state::before {
  content: '';
  width: .44em;
  height: .44em;
  border-radius: 50%;
  background: var(--stage-peach);
  flex: none;
}

.stage-phase.is-playing::before { background: var(--stage-accent); }
.stage-icon-button {
  display: inline-grid;
  place-items: center;
  width: clamp(44px, 3.35vw, 62px);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 13px;
  border: 1px solid var(--stage-edge);
  background: var(--stage-panel);
  color: var(--stage-text);
  cursor: pointer;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out;
}

.stage-icon-button[aria-pressed='true'] { color: var(--stage-accent); border-color: #816287; }
.stage-icon-button:hover { border-color: var(--stage-muted); background: #251e29; }
.stage-icon-button:active { background: #3a2840; }
.stage-icon-button:focus-visible { outline: 2px solid var(--stage-accent); outline-offset: 3px; }

.stage-main {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: clamp(14px, 1.6vw, 30px);
  width: auto;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: clamp(16px, 2.45vh, 36px) var(--stage-gutter) clamp(22px, 3.4vh, 48px);
}

.stage-lobby, .stage-game {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(0, 1fr);
  gap: clamp(16px, 2vw, 38px);
  align-items: stretch;
  min-width: 0;
}

.stage-lobby {
  position: relative;
  isolation: isolate;
  grid-template-columns: minmax(0, 1fr) minmax(0, .56fr) minmax(0, .36fr);
}

.stage-lobby::before {
  content: '';
  position: absolute;
  z-index: -1;
  right: calc(-1 * var(--stage-gutter));
  bottom: -3vh;
  width: clamp(580px, 66vw, 1300px);
  aspect-ratio: 1260 / 1080;
  max-height: 100vh;
  background: url('/assets/event/lounge.webp') right bottom / contain no-repeat;
  mask-image: linear-gradient(90deg, transparent, #000 29%);
  pointer-events: none;
}

.stage-lobby-copy {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  padding: clamp(6px, 1.45vw, 28px) 0 clamp(6px, 1.45vw, 28px) var(--stage-indent);
  min-width: 0;
}

.stage-kicker {
  display: inline-flex;
  align-items: center;
  gap: .7em;
  color: var(--stage-text);
  padding: .32em 0;
  font-size: clamp(13px, 1.1vw, 21px);
  font-weight: 600;
}

.stage-kicker > i {
  width: .53em;
  height: .53em;
  border-radius: 50%;
  background: var(--stage-accent);
  box-shadow: 0 0 0 .24em rgb(234 209 255 / .14);
}

.stage-shell .stage-lobby-title {
  font-size: clamp(54px, min(7.45vw, 14vh), 145px);
  line-height: .94;
  letter-spacing: -.042em;
  font-weight: 830;
  text-transform: uppercase;
}

.stage-shell .stage-lobby-title.is-custom { font-size: clamp(48px, min(6.6vw, 11.6vh), 122px); }
.stage-lobby-title em { font-style: normal; }
.stage-shell .stage-instruction {
  max-width: 23ch;
  margin-top: clamp(18px, 3vh, 42px);
  color: var(--stage-muted);
  font-size: clamp(19px, min(2.15vw, 3.8vh), 43px);
  line-height: 1.27;
  letter-spacing: -.026em;
}

.stage-lobby-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(10px, 1.5vw, 28px);
  margin-top: clamp(20px, 3.9vh, 54px);
}

.stage-lobby-count {
  display: flex;
  align-items: center;
  gap: .62em;
  padding: .5em .76em;
  border: 1px solid var(--stage-edge);
  border-radius: 13px;
  background: var(--stage-panel);
  color: var(--stage-muted);
  font-size: clamp(15px, 1.46vw, 28px);
  line-height: 1;
}

.stage-lobby-count svg { color: var(--stage-accent); }
.stage-lobby-count strong { color: var(--stage-text); font-size: 1.3em; font-variant-numeric: tabular-nums; }
.stage-qr-area {
  display: grid;
  place-items: center;
  align-self: center;
  min-width: 0;
  padding: 14px 0;
  transform: translateY(-4vh);
}

.stage-pattern {
  --pattern-line: rgb(241 192 251 / .17);
  --pattern-fill: rgb(241 192 251 / .08);
  position: absolute;
  z-index: -1;
  display: grid;
  grid-template: repeat(4, 1fr) / repeat(4, 1fr);
  gap: clamp(6px, 1vw, 18px);
  width: clamp(270px, 37vw, 700px);
  aspect-ratio: 1;
  top: -32%;
  right: -15%;
  transform: rotate(12deg);
  pointer-events: none;
}

.stage-pattern i { min-width: 0; border: 1px solid var(--pattern-line); border-radius: 12%; }
.stage-pattern i:nth-child(5n + 1), .stage-pattern i:nth-child(4), .stage-pattern i:nth-child(13) { background: var(--pattern-fill); }
.stage-qr-card {
  display: grid;
  place-items: center;
  width: min(94%, 46vh, 450px);
  padding: clamp(4px, .7vw, 12px);
  aspect-ratio: 1;
  border-radius: clamp(9px, 1.35vw, 24px);
  background: #fff;
  box-shadow: 0 10px 40px #000b;
}

.stage-qr-card img { display: block; width: 100%; height: auto; aspect-ratio: 1; }

.stage-prizes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1vw, 19px);
  list-style: none;
  margin: 0;
  padding: 0;
}

.stage-prize {
  min-width: 0;
  min-height: clamp(52px, 6.4vh, 76px);
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 16px);
  padding: clamp(8px, .78vw, 15px);
  border: 1px solid var(--stage-edge);
  border-radius: clamp(10px, 1vw, 18px);
  color: var(--stage-muted);
  background: var(--stage-panel);
}

.stage-prize-number {
  width: clamp(30px, 2.65vw, 50px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--stage-edge);
  border-radius: 9px;
  background: #25232f;
  font-size: clamp(12px, 1.1vw, 20px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stage-prize-name { font-size: clamp(14px, 1.24vw, 24px); font-weight: 750; line-height: 1.13; overflow-wrap: anywhere; }
.stage-prize-status { margin-left: auto; font-size: clamp(11px, .9vw, 16px); line-height: 1.13; }
.stage-prize.is-active { border-color: #a47dac; color: var(--stage-accent); }
.stage-prize.is-active .stage-prize-number { background: var(--stage-highlight); color: var(--stage-bg); border-color: transparent; }
.stage-prize.is-awarded .stage-prize-number { color: var(--stage-accent); }

.stage-game { grid-template-columns: minmax(0, 2.28fr) minmax(0, 1fr); }
.stage-draw, .stage-history {
  min-width: 0;
  border: 1px solid var(--stage-edge);
  border-radius: clamp(18px, 2vw, 38px);
}

.stage-draw {
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: min(46vh, 430px);
  padding: clamp(16px, 3vw, 56px);
  border-color: #432d4b;
  background: radial-gradient(ellipse at 100% 0, #30172e, transparent 59%), #100a12;
}

.stage-draw::before, .stage-final::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: 0;
  right: 0;
  width: min(45%, 450px);
  height: 100%;
  background: url('/assets/event/chrome.webp') right top / contain no-repeat;
  mask-image: radial-gradient(ellipse at 100% 0, #000 29%, transparent 76%);
  opacity: .7;
  pointer-events: none;
}

.stage-draw-top {
  color: var(--stage-accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: clamp(12px, 1.2vw, 22px);
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.stage-draw-content {
  margin-block: auto;
  padding-block: clamp(16px, 3vh, 48px);
}

.stage-draw-index {
  display: inline-flex;
  align-items: baseline;
  gap: .35em;
  margin-bottom: clamp(10px, 2vh, 28px);
  color: var(--stage-accent);
  font-size: clamp(25px, min(3vw, 6.5vh), 64px);
  line-height: 1;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.06em;
}

.stage-draw-index span { color: var(--stage-muted); font-size: .55em; letter-spacing: -.015em; }
.stage-shell .stage-draw-title {
  max-width: 20ch;
  color: var(--stage-text);
  font-size: clamp(29px, min(4.4vw, 8.2vh), 86px);
  line-height: 1.035;
  font-weight: 850;
  letter-spacing: -.027em;
  text-wrap: balance;
}

.stage-shell .stage-draw-title.is-long { max-width: 24ch; font-size: clamp(24px, min(3.65vw, 6.8vh), 70px); }

.stage-draw-pause {
  display: inline-flex;
  align-items: center;
  gap: .55em;
  align-self: flex-start;
  font-size: clamp(13px, 1.15vw, 20px);
  font-weight: 700;
  padding: .55em .77em;
  color: #ffe4d5;
  background: #432637;
  border-radius: 100px;
}

.stage-history {
  display: flex;
  flex-direction: column;
  padding: clamp(16px, 2.15vw, 42px);
  background: var(--stage-panel);
}

.stage-shell .stage-history h2 { font-size: clamp(20px, 1.85vw, 34px); line-height: 1.09; letter-spacing: -.035em; }
.stage-shell .stage-history p { color: var(--stage-muted); margin-top: .9em; font-size: clamp(14px, 1.17vw, 22px); }
.stage-history ol { display: grid; list-style: none; margin: clamp(11px, 2vh, 26px) 0 0; padding: 0; }
.stage-history li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(8px, 1vw, 16px);
  align-items: start;
  padding: clamp(8px, 1.36vh, 18px) 0;
  border-top: 1px solid var(--stage-edge);
}

.stage-history li > span {
  margin-top: .06em;
  color: #b8b2c5;
  font-size: clamp(12px, 1.03vw, 20px);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.stage-history li:first-child > span { color: var(--stage-accent); }
.stage-history li strong {
  color: var(--stage-text);
  font-size: clamp(14px, 1.23vw, 25px);
  line-height: 1.25;
  font-weight: 600;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stage-draw.is-rolling .stage-pattern i { animation: stage-reel .72s ease-in-out infinite alternate; }
.stage-draw.is-rolling .stage-pattern i:nth-child(3n) { animation-delay: -.55s; }
.stage-draw.is-rolling .stage-pattern i:nth-child(3n + 1) { animation-delay: -.25s; }
.stage-draw.is-rolling .stage-pattern i:nth-child(7n) { animation-delay: -.83s; }
.stage-draw.is-rolling .stage-draw-title { color: var(--stage-accent); }
.stage-draw.is-revealed .stage-draw-content { animation: stage-reveal 320ms cubic-bezier(.15, .81, .3, 1) both; }

.stage-overlay {
  position: fixed;
  z-index: 10;
  inset: clamp(68px, 8.6vh, 108px) 0 0;
  display: grid;
  place-items: center;
  padding: var(--stage-gutter);
  background: rgb(0 0 0 / .73);
  pointer-events: none;
}

.stage-win {
  position: relative;
  isolation: isolate;
  width: min(100%, 1120px);
  overflow: hidden;
  padding: clamp(28px, 5vw, 94px) clamp(18px, 5vw, 94px);
  border-radius: clamp(20px, 3vw, 54px);
  background: var(--stage-highlight);
  color: var(--stage-bg);
  text-align: center;
  box-shadow: 0 16px 70px rgb(0 0 0 / .36);
  animation: stage-reveal 460ms cubic-bezier(.15, .81, .3, 1) both;
}

.stage-win-badge, .stage-win-category {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .5em;
  font-size: clamp(14px, 1.45vw, 29px);
  font-weight: 800;
}

.stage-win-badge { border: 1px solid rgb(30 12 33 / .35); border-radius: 100px; padding: .42em .66em; }
.stage-shell .stage-win h2 {
  margin-top: .1em;
  font-size: clamp(62px, min(11vw, 18vh), 170px);
  line-height: .95;
  text-transform: uppercase;
  letter-spacing: -.047em;
  font-weight: 900;
}

.stage-shell .stage-win p {
  margin-top: .4em;
  font-size: clamp(27px, 4vw, 76px);
  line-height: 1;
  letter-spacing: -.04em;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.stage-win-category { margin-top: 1.1em; }
.stage-final, .stage-empty {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  grid-row: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: clamp(14px, 2.7vh, 34px);
  padding: clamp(22px, 3.5vw, 75px);
  text-align: center;
}

.stage-final { border: 1px solid var(--stage-edge); border-radius: clamp(20px, 2.6vw, 52px); background: radial-gradient(ellipse at 86% 0, #2d172c, transparent 64%), var(--stage-panel); }
.stage-final::before { width: min(37%, 580px); opacity: .59; }
.stage-final-emblem {
  display: grid;
  place-items: center;
  width: clamp(61px, min(6vw, 12vh), 112px);
  aspect-ratio: 1;
  border-radius: 24%;
  background: var(--stage-highlight);
  color: var(--stage-bg);
  transform: rotate(-8deg);
}

.stage-final-emblem svg { width: 48%; height: 48%; }
.stage-shell .stage-final h1, .stage-shell .stage-empty h1 {
  max-width: 15ch;
  font-size: clamp(42px, min(6.8vw, 11vh), 134px);
  line-height: .97;
  font-weight: 900;
  letter-spacing: -.037em;
  text-wrap: balance;
}

.stage-final h1 em { color: var(--stage-accent); font-style: normal; }
.stage-podium {
  display: grid;
  gap: clamp(10px, 1.25vw, 24px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  list-style: none;
  margin: clamp(5px, 1.65vh, 24px) 0 0;
  padding: 0;
  text-align: left;
}

.stage-podium-place {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1vw, 18px);
  min-width: 0;
  border: 1px solid #494558;
  border-radius: clamp(12px, 1.35vw, 24px);
  padding: clamp(12px, 1.7vw, 32px);
  color: var(--stage-text);
  background: var(--stage-bg);
}

.stage-podium-place > span { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: var(--stage-muted); font-weight: 750; font-size: clamp(12px, 1.1vw, 21px); }
.stage-podium-place strong { font-size: clamp(18px, 2.35vw, 46px); line-height: 1; letter-spacing: -.042em; overflow-wrap: anywhere; }
.stage-podium-place div { display: flex; flex-wrap: wrap; align-items: center; gap: .5em; color: var(--stage-muted); font-size: clamp(12px, 1.22vw, 22px); }
.stage-podium-place small { padding: .26em .4em; border: 1px solid currentColor; border-radius: 5px; }
.stage-podium-place.is-main-prize { color: var(--stage-bg); background: var(--stage-highlight); border-color: transparent; }
.stage-podium-place.is-main-prize > span, .stage-podium-place.is-main-prize div { color: #452947; }
.stage-shell .stage-empty p { font-size: clamp(16px, 1.5vw, 28px); color: var(--stage-muted); }

.stage-confetti { position: absolute; z-index: -1; inset: 0; overflow: hidden; pointer-events: none; }
.stage-confetti i {
  --fall-delay: 0ms;
  --fall-turn: 214deg;
  position: absolute;
  top: -11%;
  left: calc(4.16% * var(--i));
  width: clamp(7px, 1.2vw, 20px);
  height: clamp(10px, 1.7vw, 29px);
  background: var(--stage-magenta);
  border-radius: 2px;
  animation: stage-fall 2.65s var(--fall-delay) ease-out both;
}

.stage-confetti i:nth-child(4n + 2) { border-radius: 50%; background: #a462d9; --fall-delay: 175ms; --fall-turn: -193deg; }
.stage-confetti i:nth-child(4n + 3) { border-radius: 50%; background: var(--stage-text); --fall-delay: 330ms; --fall-turn: 257deg; }
.stage-confetti i:nth-child(4n + 4) { background: #8b563f; --fall-delay: 490ms; --fall-turn: -86deg; }
.stage-confetti i:nth-child(1) { --i: 0; }
.stage-confetti i:nth-child(2) { --i: 1; }
.stage-confetti i:nth-child(3) { --i: 2; }
.stage-confetti i:nth-child(4) { --i: 3; }
.stage-confetti i:nth-child(5) { --i: 4; }
.stage-confetti i:nth-child(6) { --i: 5; }
.stage-confetti i:nth-child(7) { --i: 6; }
.stage-confetti i:nth-child(8) { --i: 7; }
.stage-confetti i:nth-child(9) { --i: 8; }
.stage-confetti i:nth-child(10) { --i: 9; }
.stage-confetti i:nth-child(11) { --i: 10; }
.stage-confetti i:nth-child(12) { --i: 11; }
.stage-confetti i:nth-child(13) { --i: 12; }
.stage-confetti i:nth-child(14) { --i: 13; }
.stage-confetti i:nth-child(15) { --i: 14; }
.stage-confetti i:nth-child(16) { --i: 15; }
.stage-confetti i:nth-child(17) { --i: 16; }
.stage-confetti i:nth-child(18) { --i: 17; }
.stage-confetti i:nth-child(19) { --i: 18; }
.stage-confetti i:nth-child(20) { --i: 19; }
.stage-confetti i:nth-child(21) { --i: 20; }
.stage-confetti i:nth-child(22) { --i: 21; }
.stage-confetti i:nth-child(23) { --i: 22; }
.stage-confetti i:nth-child(24) { --i: 23; }

@keyframes stage-reveal {
  from { opacity: .15; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes stage-reel {
  from { background-color: rgb(234 209 255 / .04); }
  to { background-color: rgb(231 129 211 / .46); }
}

@keyframes stage-fall {
  from { opacity: 0; transform: translateY(0) rotate(0); }
  18%, 72% { opacity: .7; }
  to { opacity: 0; transform: translateY(min(85vh, 650px)) rotate(var(--fall-turn)); }
}

@media (max-width: 1120px) {
  .stage-prize-status { display: none; }
}

@media (max-width: 760px) and (orientation: portrait), (max-width: 550px) {
  .stage-shell { --stage-indent: 0px; }
  .stage-shell::before { opacity: .5; }
  .stage-header { gap: 6px; }
  .stage-header-brand { gap: 8px; }
  .stage-header-brand > span { display: none; }
  .stage-header-actions { gap: 6px; }
  .stage-phase, .stage-link-state { display: none; }
  .stage-lobby, .stage-game { grid-template-columns: minmax(0, 1fr); }
  .stage-lobby::before { width: min(90vw, 550px); bottom: -1.6vh; }
  .stage-lobby-copy { padding: 18px 0 4px; }
  .stage-shell .stage-lobby-title { font-size: clamp(46px, 12vw, 100px); }
  .stage-lobby-status { margin-top: 21px; }
  .stage-qr-area { transform: none; place-items: center start; }
  .stage-qr-card { width: min(58%, 320px); }
  .stage-prize { align-items: flex-start; flex-direction: column; }
  .stage-podium { grid-template-columns: minmax(0, 1fr); }
  .stage-overlay { inset: 0; }
}

@media (orientation: landscape) and (max-height: 550px) and (min-width: 551px) {
  .stage-header { min-height: 56px; }
  .stage-brand-tagline { display: none; }
  .stage-overlay { top: 56px; }
  .stage-main { padding-top: 10px; padding-bottom: 10px; gap: 9px; }
  .stage-lobby-copy { padding-block: 4px; }
  .stage-shell .stage-lobby-title { font-size: clamp(38px, 11.4vh, 63px); }
  .stage-shell .stage-instruction { margin-top: 11px; font-size: clamp(15px, 4.1vh, 24px); }
  .stage-lobby-status { margin-top: 10px; }
  .stage-qr-area { padding: 10px 0; transform: none; }
  .stage-qr-card { width: min(98%, 54vh); }
  .stage-draw, .stage-history { padding: 14px; }
  .stage-history li { padding-block: 5px; }
  .stage-prize { min-height: 44px; padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-shell *, .stage-shell *::before { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .stage-confetti { display: none; }
}
