:root {
  --red: #f33d4c;
  --red-deep: #d92036;
  --ink: #34131a;
  --cream: #fff9f3;
  --gold: #ffd338;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--red);
}

body {
  color: white;
  font-family: "Avenir Next", Avenir, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 4px;
}

kbd {
  display: inline-grid;
  min-width: 1.8em;
  min-height: 1.65em;
  place-items: center;
  padding: 0.1em 0.45em;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 0.5em;
  background: rgba(0, 0, 0, 0.14);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
  color: inherit;
  font-family: inherit;
  font-size: 0.76em;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.game {
  position: relative;
  isolation: isolate;
  width: 100vw;
  height: 100vh;
  min-height: 480px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.12), transparent 43%),
    linear-gradient(145deg, #fa4c58 0%, var(--red) 52%, var(--red-deep) 125%);
}

.game::before {
  position: absolute;
  inset: 0;
  z-index: -3;
  background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 22px 22px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 78%);
  opacity: 0.42;
}

.ambient {
  position: absolute;
  z-index: -2;
  width: min(42vw, 620px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  pointer-events: none;
}

.ambient::after {
  position: absolute;
  inset: 13%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  content: "";
}

.ambient--one {
  top: -22vw;
  right: -10vw;
}

.ambient--two {
  bottom: -26vw;
  left: -9vw;
}

.round-badge {
  position: absolute;
  top: clamp(18px, 2.2vw, 36px);
  left: clamp(18px, 2.2vw, 36px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 116px;
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(94, 0, 17, 0.23);
  box-shadow: 0 12px 28px rgba(100, 0, 17, 0.14);
  backdrop-filter: blur(12px);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.round-badge strong {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: white;
  color: var(--red-deep);
  font-size: 1rem;
  letter-spacing: normal;
}

.help-button {
  position: absolute;
  top: clamp(18px, 2.2vw, 36px);
  right: clamp(18px, 2.2vw, 36px);
  z-index: 30;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(94, 0, 17, 0.2);
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  backdrop-filter: blur(12px);
}

.ready-screen,
.winner-screen {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: clamp(82px, 8vh, 110px) 7vw clamp(84px, 10vh, 124px);
  text-align: center;
}

.quiz-logo-wrap {
  position: relative;
  width: min(39vw, 470px);
  height: clamp(105px, 15vh, 158px);
  flex: 0 0 auto;
  margin: 0 auto 0.15rem;
  overflow: hidden;
  filter: drop-shadow(0 16px 24px rgba(72, 0, 12, 0.2));
}

.quiz-logo {
  position: absolute;
  top: 48%;
  left: 50%;
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  transform: translate(-50%, -50%);
  user-select: none;
}

.eyebrow,
.winner-kicker {
  margin-bottom: 0.65rem;
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(0.7rem, 0.95vw, 0.92rem);
  font-weight: 900;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.ready-screen h1,
.winner-screen h1,
.play-heading h1 {
  margin: 0;
  font-weight: 950;
  letter-spacing: -0.055em;
  line-height: 0.94;
  text-wrap: balance;
}

.ready-screen h1 {
  max-width: 1150px;
  font-size: clamp(2.7rem, 6.7vw, 7.2rem);
}

.ready-copy {
  margin: 0.75rem 0 clamp(1rem, 2vh, 1.5rem);
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(1rem, 1.55vw, 1.55rem);
  font-weight: 650;
}

.ready-cards {
  position: relative;
  width: min(58vw, 620px);
  height: min(41vh, 400px);
  margin: 0 auto 0.85rem;
}

.ready-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(17vw, 180px);
  aspect-ratio: 0.707;
  overflow: hidden;
  border: clamp(4px, 0.42vw, 7px) solid white;
  border-radius: clamp(11px, 1.3vw, 20px);
  box-shadow: 0 24px 42px rgba(109, 0, 20, 0.28);
  transform-origin: 50% 90%;
}

.ready-card img,
.gesture-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.ready-card--1 {
  z-index: 1;
  transform: translate(-118%, -46%) rotate(-13deg);
}

.ready-card--2 {
  z-index: 3;
  transform: translate(-50%, -51%) rotate(0deg);
}

.ready-card--3 {
  z-index: 2;
  transform: translate(18%, -46%) rotate(13deg);
}

.ready-screen:hover .ready-card--1 {
  animation: cardWaveLeft 1.8s ease-in-out infinite;
}

.ready-screen:hover .ready-card--2 {
  animation: cardWaveCenter 1.8s 0.12s ease-in-out infinite;
}

.ready-screen:hover .ready-card--3 {
  animation: cardWaveRight 1.8s 0.24s ease-in-out infinite;
}

.stage-button {
  display: inline-flex;
  min-width: min(285px, 80vw);
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 1rem 1rem 1.35rem;
  border: 0;
  border-radius: 999px;
  background: white;
  box-shadow: 0 18px 34px rgba(108, 0, 19, 0.25);
  color: var(--red-deep);
  cursor: pointer;
  font-size: clamp(1rem, 1.2vw, 1.18rem);
  font-weight: 900;
  letter-spacing: -0.015em;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.stage-button:hover {
  box-shadow: 0 22px 40px rgba(108, 0, 19, 0.31);
  transform: translateY(-3px);
}

.stage-button kbd {
  background: var(--red);
  color: white;
}

.play-screen {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  padding: clamp(72px, 7.3vh, 92px) 4vw clamp(84px, 9vh, 110px);
}

.play-heading {
  z-index: 3;
  text-align: center;
}

.play-heading p {
  margin: 0 0 0.2rem;
  color: rgba(255, 255, 255, 0.76);
  font-size: clamp(0.7rem, 0.9vw, 0.88rem);
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.play-heading h1 {
  font-size: clamp(2.1rem, 5vw, 5.6rem);
  text-transform: uppercase;
}

.stage {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  width: min(60vw, 820px);
}

.gesture-card {
  position: relative;
  z-index: 2;
  height: min(60vh, 690px);
  max-height: 100%;
  aspect-ratio: 0.707;
  overflow: hidden;
  border: clamp(5px, 0.5vw, 8px) solid white;
  border-radius: clamp(14px, 1.3vw, 22px);
  background: var(--red);
  box-shadow: 0 28px 58px rgba(94, 0, 17, 0.34);
  will-change: transform, opacity;
}

.gesture-card--shuffling {
  animation: shuffleCard 155ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.gesture-card--revealed {
  animation: revealCard 640ms cubic-bezier(0.16, 1.1, 0.3, 1) both;
}

.burst {
  position: absolute;
  z-index: 1;
  width: min(68vh, 760px);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 255, 255, 0.28) 0 7deg,
    transparent 7deg 18deg
  );
  transform: scale(0.65) rotate(-15deg);
}

.game--revealed .burst {
  animation: burstIn 900ms 110ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.shuffle-status {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.72rem 1.1rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: clamp(0.8rem, 1vw, 1rem);
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pulse-dot {
  width: 0.68rem;
  height: 0.68rem;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5);
  animation: pulse 900ms ease-out infinite;
}

.result-strip {
  display: grid;
  z-index: 3;
  width: min(780px, 88vw);
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 18px;
  background: rgba(87, 0, 14, 0.26);
  box-shadow: 0 18px 34px rgba(91, 0, 17, 0.18);
  backdrop-filter: blur(14px);
  animation: resultUp 520ms 260ms ease both;
}

.result-item {
  padding: clamp(0.7rem, 1.3vh, 1rem) clamp(1rem, 2.5vw, 2rem);
  text-align: center;
}

.result-item span {
  display: block;
  margin-bottom: 0.14rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: clamp(0.58rem, 0.68vw, 0.7rem);
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.result-item strong {
  display: block;
  font-size: clamp(1rem, 1.5vw, 1.38rem);
  font-weight: 950;
}

.result-item--stay strong {
  color: white;
}

.result-item--sit strong {
  color: var(--gold);
}

.result-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.22);
}

.winner-screen {
  background:
    radial-gradient(circle at 50% 43%, rgba(255, 223, 86, 0.37), transparent 27%),
    linear-gradient(145deg, #fa4c58 0%, var(--red) 55%, #bd152a 125%);
}

.winner-screen h1 {
  max-width: 1250px;
  font-size: clamp(4rem, 10vw, 10.5rem);
  text-transform: uppercase;
  animation: winnerIn 850ms cubic-bezier(0.16, 1.15, 0.3, 1) both;
}

.winner-screen p {
  margin: 0.7rem 0 clamp(2rem, 5vh, 4rem);
  color: var(--gold);
  font-size: clamp(1.4rem, 3vw, 3rem);
  font-weight: 900;
  letter-spacing: 0.02em;
}

.stage-button--gold {
  background: var(--gold);
  color: var(--ink);
}

.stage-button--gold kbd {
  background: var(--ink);
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  --x: 50%;
  --delay: 0s;
  --spin: 420deg;
  --scale: 1;
  --drift: 5vw;
  --duration: 4.2s;
  position: absolute;
  top: -14%;
  left: var(--x);
  width: clamp(34px, 3.5vw, 66px);
  aspect-ratio: 1178 / 915;
  background: url("assets/redkite-kite-white.png") center / contain no-repeat;
  filter: drop-shadow(0 7px 8px rgba(73, 0, 13, 0.2));
  opacity: 0;
  animation: confettiFall var(--duration) var(--delay) linear infinite;
}

.confetti i:nth-child(3n) { --scale: 0.72; opacity: 0.78; }
.confetti i:nth-child(4n) { --scale: 1.18; opacity: 0.96; }
.confetti i:nth-child(1) { --x: 2%; --delay: -1.2s; --spin: 520deg; --drift: 7vw; --duration: 4.4s; }
.confetti i:nth-child(2) { --x: 7%; --delay: -3.6s; --spin: -460deg; --drift: -4vw; --duration: 5.1s; }
.confetti i:nth-child(3) { --x: 12%; --delay: -0.3s; --spin: 660deg; --drift: 6vw; --duration: 4.8s; }
.confetti i:nth-child(4) { --x: 17%; --delay: -2.8s; --spin: -520deg; --drift: -5vw; --duration: 5.4s; }
.confetti i:nth-child(5) { --x: 22%; --delay: -4.2s; --spin: 450deg; --drift: 4vw; --duration: 5.7s; }
.confetti i:nth-child(6) { --x: 27%; --delay: -1.8s; --spin: -650deg; --drift: -7vw; --duration: 4.6s; }
.confetti i:nth-child(7) { --x: 31%; --delay: -4.9s; --spin: 560deg; --drift: 5vw; --duration: 5.3s; }
.confetti i:nth-child(8) { --x: 36%; --delay: -2.4s; --spin: -430deg; --drift: -3vw; --duration: 4.9s; }
.confetti i:nth-child(9) { --x: 40%; --delay: -0.1s; --spin: 720deg; --drift: 8vw; --duration: 5.6s; }
.confetti i:nth-child(10) { --x: 44%; --delay: -3.1s; --spin: -540deg; --drift: -6vw; --duration: 4.7s; }
.confetti i:nth-child(11) { --x: 48%; --delay: -1.1s; --spin: 490deg; --drift: 4vw; --duration: 5.2s; }
.confetti i:nth-child(12) { --x: 52%; --delay: -4.7s; --spin: -680deg; --drift: -8vw; --duration: 5.8s; }
.confetti i:nth-child(13) { --x: 56%; --delay: -0.5s; --spin: 550deg; --drift: 3vw; --duration: 4.5s; }
.confetti i:nth-child(14) { --x: 60%; --delay: -2.6s; --spin: -470deg; --drift: -5vw; --duration: 5s; }
.confetti i:nth-child(15) { --x: 64%; --delay: -4.4s; --spin: 620deg; --drift: 7vw; --duration: 5.5s; }
.confetti i:nth-child(16) { --x: 68%; --delay: -1.9s; --spin: -560deg; --drift: -4vw; --duration: 4.8s; }
.confetti i:nth-child(17) { --x: 72%; --delay: -3.9s; --spin: 440deg; --drift: 6vw; --duration: 5.1s; }
.confetti i:nth-child(18) { --x: 76%; --delay: -0.8s; --spin: -610deg; --drift: -7vw; --duration: 5.7s; }
.confetti i:nth-child(19) { --x: 80%; --delay: -2.2s; --spin: 680deg; --drift: 5vw; --duration: 4.6s; }
.confetti i:nth-child(20) { --x: 84%; --delay: -4.5s; --spin: -490deg; --drift: -6vw; --duration: 5.4s; }
.confetti i:nth-child(21) { --x: 88%; --delay: -1.3s; --spin: 570deg; --drift: 4vw; --duration: 5s; }
.confetti i:nth-child(22) { --x: 92%; --delay: -3.7s; --spin: -720deg; --drift: -5vw; --duration: 5.8s; }
.confetti i:nth-child(23) { --x: 96%; --delay: -0.7s; --spin: 510deg; --drift: 3vw; --duration: 4.9s; }
.confetti i:nth-child(24) { --x: 11%; --delay: -4.1s; --spin: -590deg; --drift: -6vw; --duration: 5.5s; }
.confetti i:nth-child(25) { --x: 58%; --delay: -2s; --spin: 640deg; --drift: 7vw; --duration: 4.7s; }
.confetti i:nth-child(26) { --x: 89%; --delay: -5s; --spin: -530deg; --drift: -4vw; --duration: 5.2s; }

.operator-bar {
  position: absolute;
  right: 50%;
  bottom: clamp(12px, 1.8vh, 20px);
  z-index: 25;
  display: flex;
  max-width: calc(100vw - 32px);
  gap: 0.45rem;
  padding: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(70, 0, 12, 0.24);
  box-shadow: 0 12px 30px rgba(74, 0, 13, 0.2);
  opacity: 0.72;
  transform: translateX(50%);
  transition: opacity 180ms ease, background 180ms ease;
  backdrop-filter: blur(14px);
}

.operator-bar:hover,
.operator-bar:focus-within {
  background: rgba(70, 0, 12, 0.58);
  opacity: 1;
}

.operator-bar button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  font-size: clamp(0.68rem, 0.78vw, 0.78rem);
  font-weight: 800;
  white-space: nowrap;
}

.operator-bar button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.operator-bar button:disabled {
  cursor: default;
  opacity: 0.4;
}

.operator-bar .operator-primary {
  background: white;
  color: var(--red-deep);
}

.operator-bar .operator-primary:hover {
  background: white;
  color: var(--red-deep);
}

.operator-bar .operator-primary kbd {
  background: var(--red);
  color: white;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(55, 0, 10, 0.78);
  backdrop-filter: blur(14px);
  animation: fadeIn 180ms ease both;
}

.help-dismiss {
  position: absolute;
  top: 24px;
  right: 28px;
  border: 0;
  background: transparent;
  color: white;
  cursor: pointer;
  font-size: 2.8rem;
  font-weight: 300;
  line-height: 1;
}

.help-card {
  width: min(600px, 94vw);
  padding: clamp(1.6rem, 4vw, 3rem);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 28px;
  background: #8d1428;
  box-shadow: 0 34px 80px rgba(43, 0, 8, 0.35);
}

.help-card h2 {
  margin: 0 0 1.5rem;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 950;
  letter-spacing: -0.04em;
  line-height: 1;
}

.help-card dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.help-card dl div {
  display: grid;
  grid-template-columns: 88px 1fr;
  align-items: center;
  padding: 0.8rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.help-card dt,
.help-card dd {
  margin: 0;
}

.help-card dd {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 650;
}

.help-card p {
  margin: 1.2rem 0 0;
  color: var(--gold);
  font-weight: 800;
}

@keyframes shuffleCard {
  0% { opacity: 0.1; transform: translateX(28%) rotate(8deg) scale(0.92); }
  100% { opacity: 1; transform: translateX(0) rotate(0) scale(1); }
}

@keyframes revealCard {
  0% { opacity: 0; transform: scale(0.62) rotate(-7deg); }
  58% { opacity: 1; transform: scale(1.08) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes burstIn {
  0% { opacity: 0; transform: scale(0.45) rotate(-24deg); }
  45% { opacity: 0.72; }
  100% { opacity: 0.18; transform: scale(1.08) rotate(3deg); }
}

@keyframes resultUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5); }
  70% { box-shadow: 0 0 0 11px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

@keyframes winnerIn {
  0% { opacity: 0; transform: scale(0.55) rotate(-3deg); }
  65% { opacity: 1; transform: scale(1.06) rotate(1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes confettiFall {
  0% { opacity: 0; transform: translate3d(0, -12vh, 0) rotate(0deg) scale(var(--scale)); }
  8% { opacity: 0.94; }
  88% { opacity: 0.88; }
  100% { opacity: 0; transform: translate3d(var(--drift), 122vh, 0) rotate(var(--spin)) scale(var(--scale)); }
}

@keyframes cardWaveLeft {
  0%, 100% { transform: translate(-118%, -46%) rotate(-13deg); }
  50% { transform: translate(-122%, -50%) rotate(-17deg); }
}

@keyframes cardWaveCenter {
  0%, 100% { transform: translate(-50%, -51%) rotate(0deg); }
  50% { transform: translate(-50%, -57%) rotate(0deg); }
}

@keyframes cardWaveRight {
  0%, 100% { transform: translate(18%, -46%) rotate(13deg); }
  50% { transform: translate(22%, -50%) rotate(17deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 760px) {
  .operator-bar {
    bottom: 10px;
  }

  .operator-bar button:not(.operator-primary) {
    display: none;
  }

  .ready-cards {
    width: 90vw;
  }

  .quiz-logo-wrap {
    width: min(72vw, 390px);
  }

  .ready-card {
    width: min(27vw, 150px);
  }

  .play-screen {
    padding-inline: 2vw;
  }

  .result-strip {
    width: 94vw;
  }
}

@media (max-height: 720px) {
  .ready-screen {
    padding-top: 62px;
  }

  .ready-copy {
    margin-block: 0.45rem 0.7rem;
  }

  .quiz-logo-wrap {
    width: min(32vw, 330px);
    height: 88px;
    margin-bottom: 0;
  }

  .ready-cards {
    height: 37vh;
  }

  .gesture-card {
    height: 55vh;
  }

  .play-screen {
    padding-top: 60px;
    padding-bottom: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
