:root {
  --ink: #2a1660;
  --yellow: #ffcb2b;
  --pink: #ff4f8b;
  --teal: #19c3b4;
  --orange: #ff7a3d;
  --purple: #7b5cff;
  --cream: #fff6e0;
  --night: #1e1150;
  --font: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--yellow);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: not-allowed; }
input { font-family: inherit; }
#app { min-height: 100vh; min-height: 100dvh; }

/* ---------- shared bits ---------- */
.logo { font-weight: 700; line-height: .9; margin: 0; letter-spacing: -.02em; }
.logo span { color: var(--pink); }
.btn {
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  padding: .7em 1.2em;
  box-shadow: 0 6px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn:disabled { opacity: .45; }
.btn.big { font-size: 1.4rem; width: 100%; }
.btn.pink { background: var(--pink); color: #fff; }
.btn.teal { background: var(--teal); color: #fff; }
.btn.yellow { background: var(--yellow); }
.err { color: #d1123f; font-weight: 600; min-height: 1.2em; margin: .4em 0; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .7em 1.2em; border-radius: 14px;
  font-weight: 600; z-index: 50; animation: up .25s ease-out;
}
.net {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--orange); color: #fff; font-weight: 700; padding: .4em 1em; border-radius: 99px;
  border: 3px solid var(--ink);
}
@keyframes up { from { transform: translate(-50%, 20px); opacity: 0; } }

/* ---------- home ---------- */
body.home {
  background:
    radial-gradient(circle at 12% 18%, #fff3 0 40px, transparent 41px),
    radial-gradient(circle at 88% 80%, #ff4f8b33 0 90px, transparent 91px),
    radial-gradient(circle at 80% 12%, #19c3b433 0 60px, transparent 61px),
    var(--yellow);
}
.home {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 16px;
}
.home .logo { font-size: clamp(4rem, 18vw, 9rem); transform: rotate(-4deg); text-shadow: 6px 6px 0 #fff; }
.tag { font-size: 1.35rem; font-weight: 500; margin: .8em 0 1.4em; }
.home-btns { display: grid; gap: 18px; width: min(420px, 100%); }
.home-btns .btn { font-size: 1.6rem; padding: .8em; }
.fine { max-width: 26em; opacity: .8; margin-top: 1.6em; }

/* ---------- phone ---------- */
body.phone { background: var(--cream); }
.card {
  max-width: 440px; margin: 0 auto; padding: 24px 16px; min-height: 100dvh;
}
.card.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.join { position: relative; padding-top: 56px; }
.join .logo.sm { font-size: 2.6rem; text-align: center; margin-bottom: 24px; }
.back { position: absolute; top: 10px; left: 8px; border: 0; background: none; font-size: 2.4rem; line-height: 1; padding: 4px 12px; }
.join label { display: block; font-weight: 600; font-size: 1.1rem; margin-bottom: 16px; }
.join input, .guess-form input {
  display: block; width: 100%; margin-top: 6px;
  font-size: 1.6rem; font-weight: 600; padding: .45em .6em;
  border: 4px solid var(--ink); border-radius: 16px; background: #fff; color: var(--ink);
  outline: none;
}
.join input:focus, .guess-form input:focus { box-shadow: 0 0 0 4px var(--yellow); }
#code { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-size: 2.2rem; }

.ph-top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--ink); color: #fff;
}
.ph-top .who { flex: 1; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-score { background: var(--yellow); color: var(--ink); font-weight: 700; padding: .15em .6em; border-radius: 99px; }
.ghost { border: 2px solid currentColor; background: transparent; border-radius: 12px; padding: .35em .8em; font-weight: 600; font-size: 1rem; opacity: .85; }
.ghost.sm { font-size: .85rem; }
.ph {
  max-width: 560px; margin: 0 auto; padding: 20px 16px 32px; text-align: center;
  min-height: calc(100dvh - 52px); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
}
.ph h2 { font-size: 1.9rem; margin: .1em 0; }
.ph p { font-size: 1.15rem; margin: .2em 0; }
.big-emoji { font-size: 4.5rem; line-height: 1.1; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
.muted { opacity: .7; }
.pts { color: #fff; background: var(--teal); border-radius: 99px; padding: .05em .55em; font-weight: 700; }
.pts.big { font-size: 2.2rem; margin: .3em 0; border: 4px solid var(--ink); }
.timer-pill {
  display: inline-block; min-width: 3.2em; background: var(--ink); color: #fff; font-weight: 700;
  border-radius: 99px; padding: .2em .7em; font-size: 1.1rem; margin-top: 10px;
}
.timer-pill .hurry { color: var(--yellow); }
.answer-sm { font-size: 1.8rem; background: var(--yellow); border: 4px solid var(--ink); border-radius: 16px; padding: .3em .6em; transform: rotate(-1.5deg); }

/* guess */
.guess-form { width: 100%; display: grid; gap: 14px; margin-top: 12px; }
.feedback { font-weight: 700; font-size: 1.3rem !important; min-height: 1.4em; }
.feedback.no { color: var(--pink); }
.feedback.close { color: var(--orange); }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* draw */
.ph:has(.pad-wrap) { justify-content: flex-start; padding-top: 10px; gap: 8px; }
.prompt-bar {
  width: 100%; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  background: var(--yellow); border: 4px solid var(--ink); border-radius: 16px; padding: .4em .7em; font-size: 1.15rem;
}
.prompt-bar b { font-size: 1.25rem; }
.prompt-bar .timer-pill { margin: 0 0 0 auto; }
.pad-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
#pad {
  width: 100%; max-width: calc((100dvh - 290px) * 4 / 3); min-width: 240px; aspect-ratio: 4 / 3; height: auto;
  background: #fff; border: 4px solid var(--ink); border-radius: 14px; touch-action: none; cursor: crosshair;
}
.tools { width: 100%; max-width: 480px; display: grid; gap: 10px; }
.swatches { display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; }
.sw { width: 32px; height: 32px; flex: none; border-radius: 50%; border: 3px solid var(--ink); background: var(--c); padding: 0; }
.sw.on { transform: scale(1.15); box-shadow: 0 0 0 3px var(--cream), 0 0 0 6px var(--ink); }
.tool-row { display: grid; grid-template-columns: 1fr 1fr 1.4fr 1.4fr; gap: 6px; }
.tool { border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 600; font-size: 1rem; height: 44px; display: grid; place-items: center; }
.tool.on { background: var(--ink); color: #fff; }
.tool i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }

@media (orientation: landscape) and (max-height: 560px) {
  .pad-wrap { flex-direction: row; align-items: flex-start; justify-content: center; }
  #pad { width: auto; height: calc(100dvh - 130px); max-width: none; min-width: 0; flex: none; }
  .tools { width: 230px; }
  .tool-row { grid-template-columns: 1fr 1fr; }
  .sw { width: 30px; height: 30px; }
  .ph { min-height: 0; }
}

/* ---------- TV ---------- */
body.tv {
  color: #fff;
  background:
    radial-gradient(circle, #ffffff10 2px, transparent 2.5px) 0 0 / 34px 34px,
    radial-gradient(circle at 10% 0%, #7b5cff55, transparent 50%),
    radial-gradient(circle at 100% 100%, #ff4f8b40, transparent 50%),
    var(--night);
  font-size: clamp(16px, 1.4vw, 28px);
}
.tv-wait { display: grid; place-items: center; min-height: 100dvh; font-size: 2rem; font-weight: 600; }
.tv-top { display: flex; align-items: center; gap: 1em; padding: .8em 1.4em; }
.tv-top .logo.xs { font-size: 1.6em; flex: 1; }
.tv-code { font-weight: 600; opacity: .85; }
.tv-code b { color: var(--yellow); letter-spacing: .1em; }
.tv .ghost { color: #fff; font-size: .8em; }
.tv-title { font-size: 3.2em; margin: .1em 0 .4em; text-align: center; }
.tv-sub { font-size: 2em; margin: .4em 0; }
.tv-sub small { font-size: .55em; font-weight: 500; opacity: .8; }
.round-tag {
  display: inline-block; background: var(--yellow); color: var(--ink); font-weight: 700;
  padding: .2em .8em; border-radius: 99px; font-size: 1.2em; transform: rotate(-2deg);
}

/* lobby */
.tv-lobby { display: grid; grid-template-columns: 1.1fr 1fr; gap: 3em; padding: 1em 3em 2em; align-items: center; min-height: calc(100dvh - 5em); }
.join-card {
  background: #fff; color: var(--ink); border-radius: 36px; padding: 1.4em 1.6em 1.2em; text-align: center;
  border: 8px solid var(--ink); box-shadow: 0 16px 0 var(--pink); transform: rotate(-2deg);
}
.joinline { font-size: 1.6em; font-weight: 500; }
.joinline b { color: var(--pink); }
.code { font-size: 9.5em; font-weight: 700; letter-spacing: .08em; line-height: 1; margin-top: .1em; color: var(--ink); }
.lobby-side h2 { font-size: 2.2em; margin: 0 0 .4em; }
.lobby-side h2 span { opacity: .6; font-size: .7em; }
.seats { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .6em; }
.seats.wide { grid-template-columns: repeat(4, 1fr); width: min(100%, 64em); }
.seat {
  background: var(--c, #ffffff1a); color: #fff; border-radius: 18px; padding: .55em .8em; font-size: 1.5em;
  display: flex; flex-direction: column; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); border: 4px solid #ffffff30;
  overflow: hidden;
}
.seat b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat i { font-style: normal; font-size: .6em; opacity: .9; }
.seat.empty { background: transparent; border: 4px dashed #ffffff40; color: #ffffff70; animation: none; }
.seat.off { opacity: .5; }
.seat.done { box-shadow: 0 0 0 4px var(--yellow); }
.seat .ok { color: var(--ink); background: var(--yellow); border-radius: 99px; padding: 0 .5em; align-self: flex-start; font-weight: 700; }
.dots::after { content: "…"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.controls { margin-top: 1.4em; display: grid; gap: .8em; justify-items: start; }
.rounds { display: flex; align-items: center; gap: .6em; font-size: 1.5em; font-weight: 600; }
.round-btn { width: 1.8em; height: 1.8em; border-radius: 50%; border: 4px solid #fff; background: transparent; color: #fff; font-size: 1em; font-weight: 700; line-height: 1; }
.rounds b { min-width: 1.2em; text-align: center; font-size: 1.3em; color: var(--yellow); }
.btn.huge { font-size: 2.2em; padding: .4em 1.6em; border-radius: 24px; box-shadow: 0 8px 0 #000a; border-color: var(--ink); color: var(--ink); }
.hint { font-size: 1.2em; opacity: .85; margin: 0; }

/* draw */
.tv-draw { display: flex; flex-direction: column; align-items: center; padding: 1em 2em 2em; gap: 1em; }
.ring {
  --p: 1;
  width: 13em; height: 13em; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--yellow) calc(var(--p) * 360deg), #ffffff20 0);
  position: relative; transition: background .2s linear;
}
.ring::before { content: ""; position: absolute; inset: 1.1em; border-radius: 50%; background: var(--night); }
.ring span { position: relative; font-size: 5em; font-weight: 700; }
.ring span.hurry { color: var(--pink); animation: throb 1s infinite; }
.ring.sm { width: 8em; height: 8em; }
.ring.sm::before { inset: .8em; }
.ring.sm span { font-size: 3.2em; }
@keyframes throb { 50% { transform: scale(1.12); } }

/* guess */
.tv-guess, .tv-reveal { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 2.4em; padding: .5em 2.4em 2em; align-items: center; position: relative; min-height: calc(100dvh - 5em); }
.frame { background: #fff; border-radius: 26px; padding: .8em; border: 8px solid var(--ink); box-shadow: 0 14px 0 var(--teal); }
.frame img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 14px; background: #fff; }
.frame.tilt { transform: rotate(-2deg); box-shadow: 0 14px 0 var(--yellow); }
.guess-side { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .6em; }
.got { list-style: none; padding: 0; margin: 0; display: grid; gap: .4em; width: 100%; }
.got li { background: var(--teal); border-radius: 16px; padding: .35em .8em; font-size: 1.5em; font-weight: 500; }
.got li.pop { animation: pop .4s cubic-bezier(.3, 1.6, .5, 1); }
.floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float {
  position: absolute; bottom: 10%; font-size: 2em; font-weight: 600; color: #fff; background: #ffffff22;
  padding: .1em .6em; border-radius: 99px; white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis;
  animation: drift 3.5s ease-out forwards; transform: rotate(var(--r));
}
.float.close { background: var(--orange); }
@keyframes drift {
  0% { opacity: 0; translate: 0 30px; }
  15% { opacity: 1; }
  100% { opacity: 0; translate: 0 -55vh; }
}

/* reveal */
.reveal-side { display: flex; flex-direction: column; gap: .5em; align-items: flex-start; }
.answer { font-size: 3.4em; line-height: 1.05; margin: .1em 0; color: var(--yellow); }
.by { font-size: 1.7em; margin: 0 0 .4em; }
.by .pts, .got .pts { font-size: .8em; background: var(--yellow); color: var(--ink); }
.reveal-side .got li { display: flex; justify-content: space-between; align-items: center; gap: .5em; }
.nobody { font-size: 1.8em; opacity: .85; margin: 0; }

/* scores & end */
.tv-scores, .tv-end { padding: .5em 3em 2em; display: flex; flex-direction: column; align-items: center; }
.board { list-style: none; padding: 0; margin: 0; width: min(100%, 52em); display: grid; gap: .5em; }
.board li { display: grid; grid-template-columns: 2em 1fr 4em; align-items: center; gap: .6em; font-size: 1.7em; animation: pop .4s backwards; }
.board li:nth-child(2) { animation-delay: .06s; } .board li:nth-child(3) { animation-delay: .12s; }
.board li:nth-child(4) { animation-delay: .18s; } .board li:nth-child(5) { animation-delay: .24s; }
.place { font-weight: 700; text-align: center; color: var(--yellow); }
.bar { display: block; width: var(--w); min-width: fit-content; background: var(--c); border-radius: 14px; padding: .2em .6em; white-space: nowrap; transition: width .6s; }
.score { font-weight: 700; text-align: right; }
.next { font-size: 1.6em; margin-top: 1.2em; }
.next b { color: var(--yellow); }
.winner { font-size: 4.4em; margin: .1em 0 .4em; color: var(--yellow); text-align: center; transform: rotate(-2deg); text-shadow: 0 6px 0 var(--pink); }
.end-grid { display: grid; grid-template-columns: 1fr auto; gap: 2em; width: min(100%, 70em); align-items: center; }
.end-btns { display: grid; gap: 1em; justify-items: center; }
.ghost-btn { background: transparent; color: #fff; border-color: #fff; box-shadow: none; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(14em, 1fr)); gap: 1.2em; width: 100%; margin-top: .6em; }
.gallery figure { margin: 0; background: #fff; color: var(--ink); border-radius: 18px; padding: .5em; border: 5px solid var(--ink); }
.gallery figure:nth-child(odd) { transform: rotate(-1.5deg); } .gallery figure:nth-child(even) { transform: rotate(1.2deg); }
.gallery img { width: 100%; aspect-ratio: 4 / 3; display: block; border-radius: 10px; }
.gallery figcaption { padding: .4em .2em .1em; display: grid; }
.gallery figcaption span { font-size: .8em; opacity: .7; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.confetti i {
  position: absolute; top: -5%; left: calc(var(--i) * 4.2%); width: .7em; height: 1.1em; border-radius: 3px;
  background: hsl(calc(var(--i) * 47deg) 90% 60%); animation: fall calc(3s + var(--i) * .13s) linear calc(var(--i) * -.37s) infinite;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.tv-end > *:not(.confetti) { position: relative; z-index: 1; }

/* TV views on a narrow screen (a laptop window or a phone hosting) */
@media (max-width: 820px) {
  body.tv { font-size: 15px; }
  .tv-lobby, .tv-guess, .tv-reveal, .end-grid { grid-template-columns: 1fr; padding-left: 16px; padding-right: 16px; gap: 1.6em; }
  .code { font-size: 6em; }
  .seats.wide { grid-template-columns: 1fr 1fr; }
  .tv-scores, .tv-end, .tv-draw { padding-left: 16px; padding-right: 16px; }
  .tv-top { padding: .6em 16px; flex-wrap: wrap; }
  .seat.open { display: none; }
  .seat { font-size: 1.25em; }
  .tv-lobby { gap: 1em; min-height: 0; }
  .controls .btn.huge { width: 100%; }
  .tv-guess .ring.sm, .tv-draw .ring { font-size: .8em; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- watch page (display only, 16:9) ---------- */
body.watch { font-size: clamp(14px, min(1.45vw, 2.6vh), 48px); overflow: hidden; }
body.watch .ctl { display: none !important; }
body.watch .tv-end { overflow: auto; max-height: 100dvh; }
body.watch .tv-lobby, body.watch .tv-guess, body.watch .tv-reveal { min-height: calc(100dvh - 4.2em); }
body.watch .code { font-size: 11em; }
.watch-chrome {
  position: fixed; right: 16px; bottom: 16px; z-index: 40; display: flex; align-items: center; gap: 12px;
  transition: opacity .4s; cursor: default;
}
.watch-chrome.hide { opacity: 0; pointer-events: none; }
.watch-chrome .fs {
  border: 3px solid #fff; background: #0006; color: #fff; border-radius: 14px; padding: .5em 1em;
  font-size: 18px; font-weight: 600;
}
.airplay { background: #0006; color: #fff; border-radius: 12px; padding: .45em .8em; font-size: 15px; }
.tvline { font-size: 1em; opacity: .9; display: flex; flex-wrap: wrap; align-items: center; gap: .4em; }
.tvline a { color: var(--yellow); font-weight: 600; word-break: break-all; }

/* prompt packs */
.packs { display: flex; flex-wrap: wrap; align-items: center; gap: .4em; }
.packs-label { font-size: 1.2em; font-weight: 600; margin-right: .2em; }
.chip {
  border: 3px solid #ffffff80; background: transparent; color: #fff; border-radius: 99px;
  padding: .3em .9em; font-size: 1.05em; font-weight: 600; display: inline-flex; align-items: center; gap: .4em;
}
.chip.on { background: var(--yellow); color: var(--ink); border-color: var(--yellow); }
.chip small { font-size: .6em; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--pink); color: #fff; border-radius: 99px; padding: .15em .5em; }
body.watch .chip:not(.on) { display: none; }
body.watch .chip { pointer-events: none; }

.mute { font-size: 1.1em; padding: .2em .5em; line-height: 1; }
.ph-top .mute { color: #fff; font-size: 1rem; }
