:root {
  --blue: #00338D;
  --navy: #0B1B4D;
  --gold: #FFC72C;
  --orange: #FF9E1B;
  --sky: #2F80ED;
  --white: #fff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Fredoka', system-ui, sans-serif;
  color: var(--white);
  background: var(--navy);
  overflow-x: hidden;
}
/* rotating sunburst backdrop */
body::before {
  content: '';
  position: fixed;
  top: 50%; left: 50%;
  width: 300vmax; height: 300vmax;
  margin: -150vmax 0 0 -150vmax;
  background: repeating-conic-gradient(#00338D 0 10deg, #0a44b0 10deg 20deg);
  animation: spin 90s linear infinite;
  z-index: -2;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(circle at 50% 40%, transparent 0, rgba(11,27,77,.75) 80%);
  z-index: -1;
}
body.party::before {
  background: repeating-conic-gradient(#00338D 0 10deg, #FFC72C 10deg 20deg);
  animation-duration: 6s;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- header ---------- */
header { text-align: center; padding: 14px 8px 0; }
h1 {
  font-family: 'Bungee', sans-serif;
  font-size: clamp(1.7rem, 5.6vw, 4.2rem);
  margin: 0;
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--navy), 6px 6px 0 var(--sky), 9px 9px 0 rgba(0,0,0,.35);
  letter-spacing: .02em;
}
h1 span { display: inline-block; animation: bop 1.2s ease-in-out infinite; }
h1 span.sp { width: .35em; }
@keyframes bop {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-.18em) rotate(5deg) scale(1.08); }
}
.marquee {
  margin: 10px auto 0;
  overflow: hidden;
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  border-block: 4px dashed var(--navy);
  transform: rotate(-1deg) scale(1.02);
  white-space: nowrap;
}
.marquee-inner { display: inline-block; animation: scroll 22s linear infinite; padding: 4px 0; }
@keyframes scroll { to { transform: translateX(-50%); } }

/* ---------- layout ---------- */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 28px;
  align-items: center;
  max-width: 1150px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}
.stage { display: flex; flex-direction: column; align-items: center; }
.wheel-wrap {
  position: relative;
  width: min(100%, 74vh, 680px);
  aspect-ratio: 1;
  filter: drop-shadow(0 18px 0 rgba(0,0,0,.3));
  animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.015) rotate(.6deg); } }
body.spinning .wheel-wrap { animation: rumble .12s linear infinite; }
@keyframes rumble {
  0% { transform: translate(1px, -1px) rotate(-.3deg); }
  50% { transform: translate(-1px, 1px) rotate(.3deg); }
  100% { transform: translate(1px, 1px) rotate(0); }
}
#wheel { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; border-radius: 50%; }
.hub {
  position: absolute; top: 50%; left: 50%;
  width: 24%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 6px solid var(--navy);
  background: radial-gradient(circle at 35% 30%, #fff6c9, var(--gold) 45%, var(--orange));
  color: var(--navy);
  font-family: 'Bungee', sans-serif;
  font-size: clamp(.9rem, 2.6vw, 1.7rem);
  cursor: pointer;
  box-shadow: 0 6px 0 var(--navy), 0 0 30px rgba(255,199,44,.8);
  animation: pulse 1s ease-in-out infinite;
}
.hub:active { box-shadow: 0 2px 0 var(--navy); margin-top: 4px; }
body.spinning .hub { animation: none; filter: grayscale(.4); cursor: wait; }
@keyframes pulse { 50% { transform: translate(-50%, -50%) scale(1.1) rotate(-6deg); } }
.pointer {
  position: absolute; top: 50%; right: -7%;
  width: 13%; aspect-ratio: 1.25;
  margin-top: -5.2%;
  transform-origin: 85% 50%;
  background: var(--gold);
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
  filter: drop-shadow(0 0 0 var(--navy));
}
.pointer::after {
  content: ''; position: absolute; inset: 12% 6% 12% 22%;
  background: var(--navy);
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
  opacity: .9;
}
.hint { margin: 22px 0 0; font-weight: 700; text-shadow: 2px 2px 0 var(--navy); animation: wiggle 2s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
kbd { background: var(--gold); color: var(--navy); padding: 1px 8px; border-radius: 6px; border-bottom: 3px solid var(--orange); font-family: inherit; }

/* ---------- panel ---------- */
.panel {
  background: var(--white);
  color: var(--navy);
  border: 6px solid var(--navy);
  border-radius: 26px;
  padding: 16px 18px 18px;
  box-shadow: 10px 10px 0 var(--gold), 10px 10px 0 4px var(--navy);
  transform: rotate(1.5deg);
}
.panel h2 { font-family: 'Bungee', sans-serif; font-size: 1.25rem; margin: 0; color: var(--blue); }
.count { margin: 2px 0 8px; font-weight: 700; color: var(--orange); }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 4px; }
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 10px;
  border-radius: 14px;
  font-size: 1.15rem; font-weight: 700;
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.row:hover { background: #fff3c4; transform: scale(1.04) rotate(-1deg); }
.row input {
  appearance: none; -webkit-appearance: none;
  width: 26px; height: 26px; margin: 0; flex: none;
  border: 3px solid var(--navy); border-radius: 8px;
  background: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.row input:checked { background: var(--gold); }
.row input:checked::after { content: '✔'; font-size: 16px; color: var(--navy); }
.row input:focus-visible, button:focus-visible { outline: 4px solid var(--sky); outline-offset: 2px; }
.row.done .name { text-decoration: line-through wavy var(--orange); opacity: .55; }
.row .badge { margin-left: auto; font-size: .8rem; background: var(--blue); color: #fff; padding: 2px 8px; border-radius: 99px; }
.buttons { display: grid; gap: 8px; margin-top: 14px; }
.buttons button, .card button {
  font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 1rem;
  padding: 9px 12px;
  border: 3px solid var(--navy); border-radius: 14px;
  background: var(--blue); color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--navy);
  transition: transform .1s;
}
.buttons button:nth-child(even) { background: var(--gold); color: var(--navy); }
.buttons button:hover, .card button:hover { transform: translateY(-2px) rotate(-1.5deg) scale(1.03); }
.buttons button:active, .card button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy); }

/* ---------- winner modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: rgba(11,27,77,.72);
  padding: 16px;
  overflow: hidden;
}
.burst {
  position: absolute; top: 50%; left: 50%;
  width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(rgba(255,199,44,.55) 0 8deg, transparent 8deg 16deg);
  animation: spin 9s linear infinite;
}
.card {
  position: relative;
  width: min(680px, 100%);
  text-align: center;
  background: var(--white); color: var(--navy);
  border: 8px solid var(--navy); border-radius: 34px;
  padding: 22px 20px 24px;
  box-shadow: 0 0 0 8px var(--gold), 0 0 0 14px var(--blue), 0 30px 60px rgba(0,0,0,.5);
  animation: pop .7s cubic-bezier(.2, 1.9, .4, 1) both, sway 1.1s ease-in-out .7s infinite;
}
@keyframes pop { from { transform: scale(0) rotate(-200deg); } }
@keyframes sway { 0%,100% { transform: rotate(-2deg) scale(1); } 50% { transform: rotate(2deg) scale(1.03); } }
.hype { font-family: 'Bungee', sans-serif; font-size: clamp(1rem, 3.5vw, 1.6rem); margin: 0; color: var(--blue); }
.winner-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.winner {
  font-family: 'Bungee Shade', 'Bungee', sans-serif;
  font-size: clamp(2.6rem, 13vw, 7rem);
  line-height: 1.1; margin: 6px 0;
  color: var(--blue);
  text-shadow: 4px 4px 0 var(--gold);
  animation: flash .5s steps(2) infinite;
  white-space: nowrap;
}
@keyframes flash { 50% { color: var(--orange); text-shadow: 4px 4px 0 var(--blue); } }
.clap { font-size: clamp(2rem, 8vw, 4.5rem); animation: clap .28s ease-in-out infinite alternate; }
.clap.flip { animation-delay: .14s; }
@keyframes clap { from { transform: rotate(-25deg) scale(.85); } to { transform: rotate(20deg) scale(1.25); } }
.sub { font-size: 1.2rem; font-weight: 700; margin: 0 0 16px; }
.card button { display: block; width: 100%; margin-top: 10px; }
.card .primary { font-size: 1.3rem; background: var(--gold); color: var(--navy); padding: 14px; }
.card .ghost { background: #fff; color: var(--blue); box-shadow: none; border-style: dashed; font-size: .9rem; }

/* ---------- confetti + emoji rain ---------- */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
#rain { position: fixed; inset: 0; pointer-events: none; z-index: 21; overflow: hidden; }
#rain span { position: absolute; top: -12vh; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(125vh) rotate(720deg); } }

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; padding-top: 18px; }
  .wheel-wrap { width: min(92vw, 62vh); }
  .panel { transform: none; max-width: 480px; width: 100%; margin: 0 auto; }
  fieldset { grid-template-columns: 1fr 1fr; }
}

/* ---------- suspense banner ---------- */
#banner {
  position: fixed; top: 5vh; left: 0; right: 0; z-index: 9;
  text-align: center; pointer-events: none; padding: 0 10px;
}
#banner p { margin: 0; font-family: 'Bungee', sans-serif; }
#banner .big {
  font-size: clamp(1.8rem, 7vw, 5rem); line-height: 1.05;
  color: var(--gold);
  text-shadow: 4px 4px 0 var(--navy), 8px 8px 0 var(--sky);
  animation: thump .5s ease-in-out infinite;
}
#banner .vs {
  display: inline-block; margin-top: 10px;
  font-size: clamp(1.1rem, 3.6vw, 2.4rem);
  background: var(--white); color: var(--blue);
  border: 5px solid var(--navy); border-radius: 99px; padding: 4px 22px;
  box-shadow: 6px 6px 0 var(--gold);
  animation: wiggle .4s ease-in-out infinite;
}
@keyframes thump { 0%, 100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.12) rotate(2deg); } }

/* ---------- photo finish (close call) ---------- */
.stage { position: relative; }
.wheel-wrap { transition: transform .7s cubic-bezier(.3, 1.4, .5, 1); }
header, .panel, .hint { transition: opacity .5s; }
body.closecall .stage, body.finale .stage { z-index: 5; }
body.closecall .wheel-wrap { animation: none; transform: scale(1.5); transform-origin: 100% 50%; }
body.closecall header, body.closecall .panel, body.closecall .hint { opacity: .12; }
body.closecall::after { background: radial-gradient(circle at 60% 50%, rgba(11,27,77,.3) 0, rgba(5,10,35,.95) 70%); animation: pulseDark .6s ease-in-out infinite; }
body.closecall .hub { animation: none; }
body.closecall .pointer { background: #fff; filter: drop-shadow(0 0 14px var(--gold)); }
@keyframes pulseDark { 50% { opacity: .75; } }

/* ---------- the grand (pointless) finale ---------- */
body.finale::before { background: repeating-conic-gradient(#00338D 0 10deg, #FFC72C 10deg 20deg); animation-duration: 3s; }
body.finale header, body.finale .panel, body.finale .hint { opacity: .25; }
body.finale .wheel-wrap { animation: loopy 7.6s ease-in-out both; }
body.finale .hub { animation: pulse .25s linear infinite; }
@keyframes loopy {
  0%   { transform: translate(0, 0) perspective(900px) rotateY(0) rotateX(0) scale(1); }
  10%  { transform: translate(-22vw, -8vh) perspective(900px) rotateY(0) rotateX(0) scale(.55); }
  22%  { transform: translate(16vw, 9vh) perspective(900px) rotateY(360deg) rotateX(0) scale(1.2); }
  35%  { transform: translate(-10vw, 12vh) perspective(900px) rotateY(360deg) rotateX(360deg) scale(.8); }
  48%  { transform: translate(0, -14vh) perspective(900px) rotateY(720deg) rotateX(360deg) scale(.35); }
  60%  { transform: translate(20vw, -6vh) perspective(900px) rotateY(720deg) rotateX(720deg) scale(1.25); }
  72%  { transform: translate(-18vw, 6vh) perspective(900px) rotateY(1080deg) rotateX(720deg) scale(.6); }
  86%  { transform: translate(0, 0) perspective(900px) rotateY(1440deg) rotateX(1080deg) scale(1.55); }
  93%  { transform: translate(0, 0) perspective(900px) rotateY(1440deg) rotateX(1080deg) scale(.9); }
  100% { transform: translate(0, 0) perspective(900px) rotateY(1440deg) rotateX(1080deg) scale(1); }
}
