:root {
  --mustard: #E1AD01;
  --mustard-dark: #B98C00;
  --cream: #FFF4CF;
  --ink: #2B1D0E;
  --shadow: #5C3D0A;
  --red: #D9412B;
  --blue: #2F6FDB;
  --green: #2E9E5B;
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--mustard);
  color: var(--ink);
  font-family: "Chewy", system-ui, sans-serif;
  font-size: 20px;
  letter-spacing: 0.3px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.shake { animation: shake 0.45s linear 2; }
@keyframes shake {
  0%,100% { transform: translate(0,0) rotate(0); }
  20% { transform: translate(-8px,4px) rotate(-1deg); }
  40% { transform: translate(7px,-5px) rotate(1deg); }
  60% { transform: translate(-6px,-3px) rotate(-0.5deg); }
  80% { transform: translate(5px,6px) rotate(0.5deg); }
}

#app { max-width: 1100px; margin: 0 auto; padding: 20px 16px 120px; }
h1, h2, h3, .bubble { font-family: "Bagel Fat One", "Chewy", system-ui, sans-serif; font-weight: 400; margin: 0; }

/* ---------- logo ---------- */
.logo { display: flex; justify-content: center; gap: 2px; font-size: clamp(52px, 13vw, 128px); line-height: 1; padding: 30px 0 6px; user-select: none; }
.logo span {
  display: inline-block; color: var(--cream);
  -webkit-text-stroke: 0.11em var(--ink); paint-order: stroke fill;
  text-shadow: 0.05em 0.07em 0 var(--shadow);
  animation: pop 0.55s cubic-bezier(.2,1.6,.4,1) both;
}
/* whole logo squeezes and bops as one image, like a tween */
.logo:not(.small) { transform-origin: 50% 85%; animation: logobop 1.6s ease-in-out 1.6s infinite; }
@keyframes logobop {
  0%, 60%, 100% { transform: translateY(0) scale(1, 1); }
  10% { transform: translateY(4px) scale(1.08, .88); }
  24% { transform: translateY(-14px) scale(.94, 1.08); }
  38% { transform: translateY(0) scale(1.06, .93); }
  48% { transform: translateY(0) scale(.99, 1.01); }
}
.logo.small { font-size: 40px; padding: 0; justify-content: flex-start; }
.logo.small span { animation: none; }
@keyframes pop { 0% { transform: scale(0) rotate(var(--r,0deg)); opacity: 0; } 55% { transform: scale(1.28) rotate(var(--r,0deg)); opacity: 1; } 72% { transform: scale(.88) rotate(var(--r,0deg)); } 100% { transform: scale(1) rotate(var(--r,0deg)); } }
.tagline { text-align: center; font-size: 26px; margin: 4px 0 30px; animation: fadeUp .5s ease 1.4s both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- cards & buttons ---------- */
.card {
  background: var(--cream); border: 4px solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 6px 0 var(--shadow); padding: 22px;
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.center { text-align: center; justify-content: center; }
.muted { opacity: .75; }

button, .btn {
  font: inherit; font-size: 22px; cursor: pointer;
  min-height: 52px; padding: 10px 24px;
  color: var(--ink); background: var(--cream);
  border: 4px solid var(--ink); border-radius: 999px;
  box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
button:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 0 5px 0 var(--ink); }
button.primary { background: var(--ink); color: var(--cream); box-shadow: 0 5px 0 var(--shadow); }
button.small { font-size: 17px; min-height: 44px; padding: 6px 16px; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

input[type=text] {
  font: inherit; font-size: 26px; width: 100%;
  padding: 14px 20px; border: 4px solid var(--ink); border-radius: 18px;
  background: #fff; color: var(--ink);
}
label.lbl { font-size: 18px; display: block; margin-bottom: 6px; }

/* ---------- home ---------- */
.home { max-width: 520px; margin: 0 auto; }
.join { display: flex; gap: 10px; }
.join input { text-transform: uppercase; letter-spacing: 6px; text-align: center; }
.how { font-size: 18px; line-height: 1.5; }
.how b { font-family: "Bagel Fat One"; font-weight: 400; }

/* ---------- room layout ---------- */
.room { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 20px; align-items: start; }
@media (max-width: 820px) { .room { grid-template-columns: minmax(0,1fr); } }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.code { font-family: "Bagel Fat One"; font-size: 26px; letter-spacing: 4px; background: var(--cream); border: 4px solid var(--ink); border-radius: 14px; padding: 2px 14px; }

.board h3 { font-size: 24px; margin-bottom: 10px; }
.board ol { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.board li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; font-size: 18px; }
.board li.me { background: #FFE58A; }
.board li.off { opacity: .45; }
.board .pts { font-family: "Bagel Fat One"; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); margin-right: 6px; vertical-align: middle; }
.dot.done { background: var(--green); }

.badge { display: inline-block; font-size: 16px; padding: 4px 12px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; }
.badge.chaos { background: var(--ink); color: var(--cream); animation: wobble 0.6s ease-in-out infinite; }
@keyframes wobble { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) scale(1.05); } }

.prompt { font-family: "Bagel Fat One"; font-size: clamp(30px, 5vw, 46px); line-height: 1.15; }
.timer { height: 18px; border: 4px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.timer > div { height: 100%; background: var(--ink); width: 100%; transition: width .25s linear; }
.timer.low > div { background: var(--red); }

.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.opts button { border-radius: 18px; text-align: left; min-height: 80px; font-size: 22px; }
.opts button.picked { background: var(--ink); color: var(--cream); }

/* ---------- reveal ---------- */
.reveal { display: flex; flex-direction: column; gap: 12px; }
.res {
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 14px; align-items: center;
  background: #fff; border: 4px solid var(--ink); border-radius: 18px; padding: 14px 18px;
  opacity: 0; transform: scale(.6);
}
.res.in { animation: pop .5s cubic-bezier(.2,1.6,.4,1) both; opacity: 1; }
.res .who { font-size: 16px; opacity: .7; }
.res .ans { font-family: "Bagel Fat One"; font-size: 28px; word-break: break-word; }
.res .lab { font-size: 19px; }
.res .plus { font-family: "Bagel Fat One"; font-size: 30px; grid-row: span 3; }
.res.unicorn, .res.top { background: var(--ink); color: var(--cream); }
.res.invalid, .res.none { opacity: .6; }
.res.invalid.in, .res.none.in { opacity: .6; }

/* ---------- end ---------- */
.winner { text-align: center; }
.winner .crown { font-size: 80px; display: block; animation: wobble 1s ease-in-out infinite; }
.winner h2 { font-size: clamp(36px, 7vw, 64px); color: var(--cream); -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; }

/* ---------- reactions ---------- */
.reacts { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 6px; padding: 10px; background: linear-gradient(transparent, rgba(225,173,1,.95) 40%); flex-wrap: nowrap; overflow-x: auto; justify-content: safe center; }
.reacts button { font-size: 24px; min-height: 46px; min-width: 46px; padding: 2px 8px; font-family: system-ui; flex: 0 0 auto; }
@media (max-width: 480px) { .reacts { gap: 4px; padding: 8px 4px; } .reacts button { font-size: 20px; min-width: 44px; min-height: 44px; padding: 0 4px; border-width: 3px; } }
.float { position: fixed; bottom: 70px; font-size: 44px; pointer-events: none; animation: floatUp 2.2s ease-out forwards; z-index: 50; }
@keyframes floatUp { 0% { transform: translateY(0) scale(.6); opacity: 0; } 10% { opacity: 1; transform: translateY(-20px) scale(1.2); } 100% { transform: translateY(-60vh) scale(1) rotate(20deg); opacity: 0; } }

#fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti { position: absolute; top: -20px; width: 12px; height: 18px; border: 2px solid var(--ink); animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%) translateY(-120px); background: var(--ink); color: var(--cream); padding: 12px 22px; border-radius: 999px; font-size: 19px; transition: transform .25s, opacity .25s; opacity: 0; z-index: 70; max-width: 90vw; text-align: center; }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- chaos & comedy ---------- */
.slam {
  position: fixed; left: 50%; top: 42%; z-index: 80;
  font-family: "Bagel Fat One", system-ui; font-size: clamp(48px, 11vw, 120px); white-space: nowrap;
  color: var(--cream); -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill;
  text-shadow: 6px 8px 0 var(--shadow);
  animation: slam 1.9s cubic-bezier(.2,1.4,.4,1) forwards;
}
@keyframes slam {
  0% { transform: translate(-50%,-50%) scale(4) rotate(-20deg); opacity: 0; }
  18% { transform: translate(-50%,-50%) scale(.9) rotate(-8deg); opacity: 1; }
  28% { transform: translate(-50%,-50%) scale(1.05) rotate(-6deg); }
  80% { transform: translate(-50%,-50%) scale(1) rotate(-6deg); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.3) rotate(-6deg); opacity: 0; }
}
body.chaos-mode { animation: chaosbg 0.9s steps(2) infinite; }
@keyframes chaosbg { 0% { background: var(--mustard); } 50% { background: #E8C547; } }
.chaos-card { transform: rotate(-1deg); }
.chaos-text { animation: wobble .5s ease-in-out infinite; display: inline-block; }
.warn { margin: 0; padding: 12px 16px; background: #fff; border: 3px dashed var(--ink); border-radius: 14px; font-size: 18px; }
.av { font-family: system-ui, "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }
.big-av { font-size: 44px; line-height: 1; font-family: system-ui, "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }
.drum { margin: 0; text-align: center; font-family: "Bagel Fat One"; font-size: 30px; animation: wobble .3s linear infinite; }
.res.top, .res.unicorn { background: var(--ink); color: var(--cream); }
.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; text-align: left; margin-top: 10px; }
.award { background: #fff; border: 4px solid var(--ink); border-radius: 18px; padding: 14px 16px; box-shadow: 0 4px 0 var(--shadow); }
.award h3 { font-size: 22px; margin-bottom: 4px; }
.award p { margin: 0; font-size: 18px; }
.botb { font-family: system-ui, sans-serif; font-size: 11px; font-weight: 700; letter-spacing: 1px; padding: 2px 6px; border-radius: 6px; background: var(--ink); color: var(--cream); vertical-align: middle; }
.res.top .botb, .res.unicorn .botb { background: var(--cream); color: var(--ink); }
.final { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.final li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 14px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; font-size: 20px; }
.final li.me { background: #FFE58A; }
.res.tied { background: #FFE58A; }
.credits { margin-top: 18px; font-family: system-ui, sans-serif; font-size: 13px; line-height: 1.5; text-align: center; opacity: .8; }
.credits a { color: var(--ink); }

/* ---------- leaderboard ---------- */
.lb-title { font-size: clamp(40px, 8vw, 72px); color: var(--cream); -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; text-shadow: 4px 6px 0 var(--shadow); }
.lb-sub { margin: 0; font-size: 26px; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; max-width: 560px; margin: 8px auto 0; width: 100%; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; animation: pop .6s cubic-bezier(.2,1.6,.4,1) both; }
.pod1 { animation-delay: .9s; } .pod2 { animation-delay: .5s; } .pod3 { animation-delay: .2s; }
.pod-name { font-size: 18px; text-align: center; word-break: break-word; }
.pod-score { font-family: "Bagel Fat One"; font-size: 26px; }
.pod-block { width: 100%; border: 4px solid var(--ink); border-radius: 14px 14px 0 0; background: #fff; display: flex; justify-content: center; align-items: flex-start; padding-top: 6px; box-shadow: 0 5px 0 var(--shadow); }
.pod-block span { font-family: "Bagel Fat One"; font-size: 34px; }
.pod1 .pod-block { height: 150px; background: var(--ink); color: var(--cream); }
.pod2 .pod-block { height: 110px; }
.pod3 .pod-block { height: 80px; }
.pod.me .pod-name { font-weight: 700; text-decoration: underline; }
.lb-wrap { overflow-x: auto; border: 4px solid var(--ink); border-radius: 16px; background: #fff; }
.lb { width: 100%; border-collapse: collapse; font-size: 18px; text-align: left; }
.lb th { font-family: "Bagel Fat One"; font-weight: 400; font-size: 16px; padding: 10px 12px; border-bottom: 3px solid var(--ink); white-space: nowrap; }
.lb td { padding: 8px 12px; border-bottom: 2px solid #eee2b8; }
.lb tr.me td { background: #FFE58A; }
.lb td.best { max-width: 220px; }
.room.ended { grid-template-columns: minmax(0, 1fr); max-width: 860px; margin: 0 auto; }
.room.ended #side { display: none; }
.pod-name { overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .pod-name { font-size: 14px; }
  .pod-score { font-size: 20px; }
  .lb { font-size: 15px; }
  .lb th:nth-child(4), .lb td:nth-child(4), .lb th:nth-child(6), .lb td:nth-child(6) { display: none; }
}
