* { box-sizing: border-box; }

:root {
  --ink: #2d1b4e;
  --pink: #ff4fa3;
  --yellow: #ffe94d;
  --green: #3ddc84;
  --blue: #3fa9ff;
  --purple: #9b5cff;
  --orange: #ff8a3d;
  font-family: 'Fredoka', 'Arial Rounded MT Bold', 'Comic Sans MS', system-ui, sans-serif;
}

html, body { margin: 0; min-height: 100%; }

body {
  color: var(--ink);
  background: linear-gradient(135deg, #ff9a9e, #fad0c4, #fbc2eb, #a6c1ee, #84fab0, #fdfd96, #ff9a9e);
  background-size: 400% 400%;
  animation: rainbow 18s ease infinite;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}
@keyframes rainbow { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

button { font-family: inherit; cursor: pointer; }

/* ---------- screens ---------- */

.screen {
  display: none;
  min-height: 100vh;
  padding: 24px 16px 40px;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.screen.active { display: flex; }

.title {
  font-size: clamp(40px, 8vw, 88px);
  margin: 8px 0 0;
  color: #fff;
  text-align: center;
  text-shadow: 0 4px 0 var(--pink), 0 8px 0 var(--purple), 0 12px 20px rgba(0,0,0,.25);
  letter-spacing: 1px;
}
#setup .title { margin-top: 0.45em; }  /* room for the ball's bounce */
.title.small { font-size: clamp(32px, 6vw, 64px); }
.silly-ball { display: inline-block; width: 1.35em; height: 1.35em; vertical-align: -0.25em; margin: 0 0.05em; cursor: pointer; }
.silly-ball-body {
  position: relative; display: block; width: 100%; height: 100%;
  transform-origin: 50% 100%;
  animation: silly-bounce 1s cubic-bezier(.5,0,.5,1) infinite;
  filter: drop-shadow(0 6px 4px rgba(0,0,0,.25));
}
.silly-stripes { transform-origin: 50px 50px; animation: spin 2.5s linear infinite; }
.silly-ball .googly { border-width: 1.5px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes silly-bounce {
  0%   { transform: translateY(0) scale(1.25, 0.75); }
  12%  { transform: translateY(-8%) scale(0.9, 1.1); }
  50%  { transform: translateY(-38%) scale(1, 1); }
  88%  { transform: translateY(-6%) scale(0.95, 1.05); }
  100% { transform: translateY(0) scale(1.25, 0.75); }
}

.btn-help { background: var(--blue); font-size: 22px; }
.credits-link { font-size: 18px; font-weight: 700; color: var(--ink); opacity: .75; text-decoration: none; }
.credits-link:hover { opacity: 1; text-decoration: underline; }
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(45, 27, 78, .55);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(640px, 100%); max-height: 100%; overflow-y: auto;
  background: #fff; border: 6px solid var(--yellow); border-radius: 32px;
  padding: 22px 26px; text-align: center;
  box-shadow: 0 14px 0 rgba(0,0,0,.2);
  animation: pop .45s cubic-bezier(.3,1.6,.5,1) both;
}
.modal-card h2 { margin: 0 0 10px; font-size: clamp(32px, 6vw, 48px); color: var(--pink); }
.steps { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.steps li {
  display: flex; align-items: center; gap: 14px;
  font-size: clamp(18px, 2.6vw, 22px); line-height: 1.3;
  background: hsl(calc(var(--i, 0) * 50), 95%, 92%);
  border-radius: 18px; padding: 10px 14px;
}
.steps li:nth-child(1) { --i: 0; } .steps li:nth-child(2) { --i: 1; } .steps li:nth-child(3) { --i: 2; }
.steps li:nth-child(4) { --i: 3; } .steps li:nth-child(5) { --i: 4; } .steps li:nth-child(6) { --i: 5; }
.step-icon { font-size: 36px; flex: none; }
.tip { font-size: 18px; margin: 4px 0 16px; }

.hint { font-size: 22px; margin: 0; text-align: center; font-weight: 500; }

.row { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

.btn {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 700;
  border: 4px solid #fff;
  border-radius: 999px;
  padding: 14px 32px;
  color: #fff;
  box-shadow: 0 8px 0 rgba(0,0,0,.25);
  transition: transform .08s, box-shadow .08s;
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.btn:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-play { background: var(--green); font-size: clamp(30px, 5vw, 52px); padding: 18px 56px; animation: throb 1.2s ease-in-out infinite; }
.btn-play:disabled { animation: none; }
@keyframes throb { 50% { transform: scale(1.06); } }
.btn-studio { background: var(--purple); }
.btn-add { background: var(--blue); }
.btn-quiet { background: var(--orange); font-size: 22px; }

/* ---------- avatars + googly eyes ---------- */

.avatar {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 28%;
  border: 5px solid #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
}
.avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }

.googly {
  position: absolute;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 55%, #e6e6e6 100%);
  border: 2px solid #222;
  box-shadow: 0 2px 4px rgba(0,0,0,.4), inset 0 -2px 3px rgba(0,0,0,.15);
  container-type: inline-size;
  pointer-events: none;
}
.pupil {
  position: absolute;
  left: 50%; top: 50%;
  width: 46%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #111;
  transform: translate(-50%, -50%);
}
.pupil::after {
  content: '';
  position: absolute;
  width: 28%; height: 28%;
  left: 20%; top: 18%;
  border-radius: 50%;
  background: rgba(255,255,255,.8);
}

/* ---------- setup ---------- */

.player-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  width: min(100%, 1000px);
}
.player-list .player-card { width: 170px; }
.player-card {
  position: relative;
  background: hsl(var(--hue), 95%, 65%);
  border: 4px solid #fff;
  border-radius: 28px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 6px 0 rgba(0,0,0,.15);
}
.player-name { font-size: 26px; font-weight: 700; margin-top: 8px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.3); overflow-wrap: anywhere; }
.remove {
  position: absolute; top: -12px; right: -12px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #ff1744;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}
.pop-in { animation: pop .45s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

.add-form { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.add-form input {
  font-family: inherit;
  font-size: 28px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 4px solid #fff;
  width: min(80vw, 340px);
  outline: none;
  color: var(--ink);
}
.add-form input:focus { border-color: var(--yellow); box-shadow: 0 0 0 4px var(--pink); }

/* ---------- round ---------- */

#round {
  position: relative;
  --beat: 1000ms;
  justify-content: center;
  animation: pulse var(--beat) ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { background: rgba(255, 233, 77, .0); }
  50% { background: rgba(255, 79, 163, .45); }
}
#round.stopped { animation: none; background: rgba(255, 23, 68, .55); }
#round.stopped .pass-text, #round.stopped .clock { animation: none; opacity: .25; }
.stop-sign {
  position: absolute; left: 50%; top: 42%;
  font-size: clamp(80px, 20vmin, 240px); font-weight: 700;
  color: #fff; white-space: nowrap;
  -webkit-text-stroke: 6px #b71c1c; paint-order: stroke fill;
  text-shadow: 0 10px 0 rgba(0,0,0,.25);
  z-index: 20;
}
.clock { font-size: clamp(120px, 25vw, 260px); line-height: 1; filter: drop-shadow(0 10px 10px rgba(0,0,0,.25)); }
.pass-text {
  margin: 0;
  font-size: clamp(48px, 10vw, 120px);
  color: #fff;
  text-align: center;
  text-shadow: 0 5px 0 var(--blue), 0 10px 0 var(--purple), 0 14px 24px rgba(0,0,0,.3);
  animation: wobble var(--beat) ease-in-out infinite;
}
@keyframes wobble { 0%, 100% { transform: rotate(-3deg) scale(1); } 50% { transform: rotate(3deg) scale(1.08); } }

.scoreboard { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 10px; }
.mini-player { width: 90px; text-align: center; }
.mini-player .avatar { border-width: 3px; cursor: default; }
.mini-hearts { font-size: 16px; margin-top: 4px; font-weight: 700; }
.mini-player.is-out { filter: grayscale(1); opacity: .5; }

.corner-btn {
  position: fixed; top: 14px; right: 14px;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(0,0,0,.25);
  color: #fff;
  font-size: 22px;
  z-index: 10;
}

/* ---------- who had the ball ---------- */

.who-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 220px));
  justify-content: center;
  gap: 22px;
  width: min(100%, 1100px);
}
.who-btn {
  position: relative;
  background: #fff;
  border: 5px solid var(--yellow);
  border-radius: 30px;
  padding: 14px;
  box-shadow: 0 8px 0 rgba(0,0,0,.2);
  transition: opacity .3s, transform .15s;
}
.who-btn:hover { transform: scale(1.04) rotate(-1deg); }
.who-btn .player-name { color: var(--ink); text-shadow: none; }
.who-btn .hearts { font-size: 24px; margin-top: 4px; }
.who-btn.dim { opacity: .35; pointer-events: none; }
.who-btn.chosen { border-color: #ff1744; pointer-events: none; }
.who-btn.is-out .avatar { filter: grayscale(1); }
.out-stamp {
  position: absolute; left: 50%; top: 42%;
  font-size: 64px; font-weight: 700;
  color: #ff1744;
  border: 6px solid #ff1744;
  border-radius: 16px;
  padding: 0 14px;
  background: rgba(255,255,255,.85);
  pointer-events: none;
}

/* ---------- winner ---------- */

#winner { justify-content: center; overflow: hidden; }
.winner-spot { width: min(60vw, 340px); position: relative; z-index: 2; }
.dancing { animation: dance .6s ease-in-out infinite alternate; }
@keyframes dance {
  0% { transform: rotate(-12deg) translateY(0) scale(1); }
  100% { transform: rotate(12deg) translateY(-30px) scale(1.08); }
}
.winner-name { z-index: 2; position: relative; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.confetti { position: absolute; top: 0; border-radius: 3px; }

/* ---------- sound studio ---------- */

.studio-top { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; }
.studio-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  width: min(100%, 1200px);
}
.studio-card {
  background: hsl(var(--hue), 90%, 92%);
  border: 4px solid hsl(var(--hue), 85%, 60%);
  border-radius: 24px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.studio-head { display: flex; align-items: center; gap: 10px; }
.studio-emoji { font-size: 40px; }
.studio-title { font-size: 26px; font-weight: 700; flex: 1; }
.small-btn {
  font-size: 18px; font-weight: 700;
  border: 3px solid #fff; border-radius: 999px;
  padding: 6px 14px;
  background: hsl(var(--hue), 85%, 55%);
  color: #fff;
}
.sound-rows { display: flex; flex-direction: column; gap: 6px; }
.sound-row {
  display: flex; align-items: center; gap: 10px;
  background: #fff;
  border-radius: 14px;
  padding: 6px 10px;
  transition: opacity .2s;
}
.sound-row.off .sound-label { opacity: .4; text-decoration: line-through; }
.sound-row.playing { outline: 3px solid var(--green); }
.sound-label { flex: 1; font-size: 20px; }
.icon-btn { font-size: 22px; background: none; border: none; padding: 4px; }
.record-btn {
  font-size: 24px; font-weight: 700;
  border: 4px solid #fff;
  border-radius: 999px;
  padding: 10px;
  background: #ff1744;
  color: #fff;
  box-shadow: 0 5px 0 rgba(0,0,0,.2);
}
.record-btn.recording { animation: throb .6s ease-in-out infinite; background: #d50000; }
.studio-msg { font-size: 18px; font-weight: 700; color: #d50000; text-align: center; }
.studio-msg:empty { display: none; }

.switch { position: relative; width: 56px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #ccc; border-radius: 999px; transition: .2s; cursor: pointer; }
.slider::before { content: ''; position: absolute; width: 24px; height: 24px; left: 4px; top: 4px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(24px); }

/* ---------- surprise stage (shared) ---------- */

.stage { position: fixed; inset: 0; z-index: 100; overflow: hidden; }
.big-word {
  position: absolute; left: 50%; top: 22%;
  font-size: clamp(60px, 16vmin, 200px);
  font-weight: 700;
  white-space: nowrap;
  -webkit-text-stroke: 4px #fff;
  paint-order: stroke fill;
  text-shadow: 0 8px 0 rgba(0,0,0,.25);
  z-index: 10;
}

/* bomb */
.stage-bomb { background: radial-gradient(circle, #3d2a6b, #150b2e); }
.bomb { position: absolute; left: 50%; top: 50%; width: min(50vmin, 420px); aspect-ratio: 200 / 220; }
.flash { position: absolute; inset: 0; background: #fff; z-index: 5; }
.boom-burst { position: absolute; left: 50%; top: 50%; width: 130vmin; height: 130vmin; }
.debris { position: absolute; left: 50%; top: 50%; }
.smoke {
  position: absolute; left: 50%; top: 50%;
  width: 30vmin; height: 30vmin;
  border-radius: 50%;
  background: radial-gradient(circle, #bdbdbd, #757575 70%);
}

/* fart */
.stage-fart { background: rgba(255, 250, 200, .6); }
.green-tint { position: absolute; inset: 0; background: rgba(139, 195, 74, .4); }
.fart-cloud { position: absolute; left: 50%; top: 55%; width: 95vmin; height: 70vmin; }
.puff { position: absolute; border-radius: 50%; }
.stink-lines { position: absolute; left: 50%; top: 6%; width: 50vmin; height: 20vmin; }
.fly { position: absolute; font-size: 7vmin; z-index: 3; }
.peg {
  position: absolute; left: 50%; bottom: 5%;
  font-size: clamp(36px, 8vmin, 90px); font-weight: 700;
  background: #fff; color: #33691e;
  border-radius: 999px; padding: 8px 30px;
  border: 5px solid #33691e;
  z-index: 11;
}

/* cow */
.sky { position: absolute; inset: 0; background: linear-gradient(#4fc3f7 0%, #b3e5fc 72%, #7cb342 72%, #558b2f 100%); }
.cow { position: absolute; left: 50%; bottom: 22%; width: min(55vmin, 520px); aspect-ratio: 240 / 200; }
.dust { position: absolute; left: 50%; bottom: 16%; width: 60vmin; height: 16vmin; border-radius: 50%; background: #d7ccc8; }
.stars-halo {
  position: absolute;
  left: calc(50% - min(55vmin, 520px) * 0.31);
  bottom: calc(22% + min(55vmin, 520px) * 0.72);
}
.dizzy-star { position: absolute; font-size: 6vmin; transform-origin: center; margin: -3vmin 0 0 -3vmin; }

/* pie */
.stage-pie { background: repeating-linear-gradient(45deg, #ffcdd2 0 40px, #f8bbd0 40px 80px); }
.pie { position: absolute; left: 50%; top: 50%; width: 30vmin; height: 30vmin; z-index: 2; }
.splat { position: absolute; left: 50%; top: 50%; width: 95vmin; height: 95vmin; z-index: 3; filter: drop-shadow(0 8px 10px rgba(0,0,0,.25)); }
.drip {
  position: absolute;
  background: #fffef5;
  border-radius: 0 0 999px 999px;
  box-shadow: 2px 4px 6px rgba(0,0,0,.15);
  z-index: 4;
}
.cherry { position: absolute; width: 7vmin; height: 7vmin; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff8a80, #c62828); z-index: 4; }

@media (max-width: 600px) {
  .player-list .player-card { width: calc(50% - 9px); }
  .who-list { grid-template-columns: repeat(2, 1fr); }
}

/* banana */
.stage-banana { background: radial-gradient(circle, #fff59d, #ffca28 70%, #ff8f00); }
.banana { position: absolute; left: 50%; top: 50%; width: min(60vmin, 520px); aspect-ratio: 240 / 200; }
.banana-flash { background: #fffde7; }
.banana-bit { position: absolute; left: 50%; top: 50%; line-height: 1; z-index: 2; }
.banana-bit.slice { width: 6vmin; height: 6vmin; border-radius: 50%; background: radial-gradient(circle, #fff8e1 30%, #ffecb3 60%, #ffe082); border: 3px solid #f9d56e; }
.peel { position: absolute; width: 22vmin; height: 22vmin; z-index: 3; filter: drop-shadow(0 6px 6px rgba(0,0,0,.25)); }

/* cartwheel cow */
.meadow { position: absolute; inset: 0; background: linear-gradient(#81d4fa 0%, #e1f5fe 62%, #9ccc65 62%, #689f38 100%); }
.cartwheel-cow { position: absolute; left: 0; top: 50%; width: min(42vmin, 400px); aspect-ratio: 1; }
.dust-puff { position: absolute; top: 68%; width: 12vmin; height: 7vmin; border-radius: 50%; background: #d7ccc8; }
.sparkle { position: absolute; font-size: 7vmin; z-index: 4; }
.oops {
  position: absolute; left: 60vw; top: 70vh;
  font-size: clamp(36px, 9vmin, 100px); font-weight: 700; color: #e91e63;
  -webkit-text-stroke: 3px #fff; paint-order: stroke fill;
  z-index: 11;
}

/* dancing pineapple */
.disco { position: absolute; inset: 0; background: radial-gradient(circle at 50% 30%, #4a148c, #12002b 75%); overflow: hidden; }
.disco::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 22%; background: repeating-linear-gradient(90deg, #ff4081 0 12.5%, #7c4dff 12.5% 25%, #00e5ff 25% 37.5%, #ffea00 37.5% 50%); opacity: .55; }
.beam { position: absolute; top: -5%; width: 16vmin; height: 110%; transform-origin: 50% 0; filter: blur(6px); mix-blend-mode: screen; }
.disco-ball { position: absolute; left: 50%; top: 2%; width: 12vmin; height: 12vmin; border-radius: 50%; background: repeating-conic-gradient(#eee 0 10deg, #9e9e9e 10deg 20deg); box-shadow: 0 0 30px #fff; }
.pineapple { position: absolute; left: 50%; bottom: 8%; width: min(38vmin, 360px); aspect-ratio: 200 / 300; z-index: 2; }
.note { position: absolute; bottom: 10%; font-size: 9vmin; font-weight: 700; z-index: 3; text-shadow: 0 0 12px currentColor; }

/* tap dancing hippo */
.theatre { position: absolute; inset: 0; background: linear-gradient(#1a0d2e 0%, #2d1b4e 70%, #6d4c41 70%, #4e342e 100%); }
.spotlight { position: absolute; left: 50%; top: 0; width: 70vmin; height: 100%; transform: translateX(-50%); background: radial-gradient(ellipse at 50% 88%, rgba(255,245,200,.55), transparent 55%), linear-gradient(rgba(255,245,200,.12), rgba(255,245,200,.25)); clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%); }
.hippo { position: absolute; left: 50%; bottom: 12%; width: min(55vmin, 520px); aspect-ratio: 260 / 280; transform: translate(-50%, 0); z-index: 2; }
.curtain { position: absolute; top: 0; bottom: 0; width: 52%; z-index: 5; background: repeating-linear-gradient(90deg, #b71c1c 0 30px, #d32f2f 30px 60px); box-shadow: inset 0 -20px 40px rgba(0,0,0,.4); }
.curtain-l { left: 0; transform-origin: 0 0; }
.curtain-r { right: 0; transform-origin: 100% 0; }
.tap-word { position: absolute; bottom: 10%; font-size: 8vmin; -webkit-text-stroke: 2px #6d4c41; paint-order: stroke fill; font-weight: 700; color: #ffea00; z-index: 4; }
.burp-ring { position: absolute; left: 50%; bottom: calc(12% + min(55vmin, 520px) * 0.59); width: 40vmin; height: 25vmin; border-radius: 50%; border: 1.5vmin solid rgba(186, 255, 120, .8); z-index: 3; }
.speech {
  position: absolute; right: 10%; top: 30%;
  background: #fff; color: var(--ink);
  font-size: clamp(28px, 6vmin, 70px); font-weight: 700;
  padding: 14px 28px; border-radius: 40px; border: 5px solid var(--ink);
  z-index: 11;
}
