:root {
  --cream: #fff7ea;
  --ink: #3b2f4f;
  --ink-soft: #7a6c8c;
  --pink: #ff7aa8;
  --pink-d: #d9487f;
  --pink-l: #ffd9e7;
  --mint: #82e3c0;
  --mint-d: #2fae85;
  --butter: #ffe28a;
  --butter-d: #e0b52c;
  --sky: #aadcff;
  --sky-d: #4a9fd8;
  --card: #ffffff;
  --shadow: 0 4px 0 rgba(59, 47, 79, 0.08), 0 10px 22px rgba(59, 47, 79, 0.08);
  /* ~15px on a 1440px laptop, still readable when screen-shared */
  font-size: clamp(14px, 1.05vw, 18px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--cream);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next Rounded", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  line-height: 1.3;
}

/* cow-spot background */
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 260px 180px at 6% 14%, #f6e9d3 0 97%, transparent 100%),
    radial-gradient(ellipse 200px 260px at 94% 30%, #f6e9d3 0 97%, transparent 100%),
    radial-gradient(ellipse 320px 200px at 22% 92%, #f6e9d3 0 97%, transparent 100%),
    radial-gradient(ellipse 180px 150px at 80% 88%, #f6e9d3 0 97%, transparent 100%),
    radial-gradient(ellipse 140px 100px at 48% 6%, #f6e9d3 0 97%, transparent 100%);
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.45rem 1.1rem;
}
.logo { display: flex; align-items: center; gap: 0.45rem; font-weight: 900; font-size: 1.2rem; letter-spacing: -0.01em; }
.logo .cow { width: 2rem; height: 2rem; }
.logo b { color: var(--pink-d); }
.top-mid { font-weight: 800; color: var(--ink-soft); font-size: 0.95rem; }
.top-right { display: flex; align-items: center; gap: 0.45rem; }
.pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.15rem 0.65rem; border-radius: 999px; font-weight: 800; font-size: 0.78rem;
  background: #fff; box-shadow: 0 2px 0 rgba(59, 47, 79, 0.1);
}
.pill.host { background: var(--butter); }
.pill.warn { background: var(--pink-l); color: var(--pink-d); }

/* ---------- layout ---------- */
main { padding: 0 1.1rem 0.9rem; max-width: 1500px; margin: 0 auto; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 1rem; align-items: start; }
.stage { display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }
.card {
  background: var(--card); border-radius: 1.3rem; padding: 0.9rem 1.2rem; box-shadow: var(--shadow);
}
.center { text-align: center; }
.scroll { display: flex; flex-direction: column; gap: 0.6rem; }

/* On laptops and desktops the page itself never scrolls: the header, question and
   host bar stay put, and only the answer cards and the scoreboard scroll if they overflow. */
@media (min-width: 961px) {
  body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  main { flex: 1; min-height: 0; width: 100%; overflow-y: auto; }
  .layout { height: 100%; grid-template-rows: minmax(0, 1fr); }
  .stage { height: 100%; min-height: 0; }
  .scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 1.1rem 0.5rem 0.7rem; margin: -1.1rem -0.5rem 0; }
  .board { position: static; max-height: 100%; display: flex; flex-direction: column; }
  .board ol { flex: 1; min-height: 0; overflow-y: auto; padding: 0.1rem; }
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 900; color: #fff;
  background: var(--pink); box-shadow: 0 4px 0 var(--pink-d);
  padding: 0.45rem 1.05rem; border-radius: 0.9rem; font-size: 0.95rem;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pink-d); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.mint { background: var(--mint-d); box-shadow: 0 4px 0 #1f7e5f; }
.btn.mint:active { box-shadow: 0 1px 0 #1f7e5f; }
.btn.sky { background: var(--sky-d); box-shadow: 0 4px 0 #2f78ad; }
.btn.sky:active { box-shadow: 0 1px 0 #2f78ad; }
.btn.big { font-size: 1.05rem; padding: 0.55rem 1.3rem; }
.btn.ghost {
  background: #fff; color: var(--ink); box-shadow: 0 3px 0 rgba(59, 47, 79, 0.15);
  font-size: 0.8rem; padding: 0.3rem 0.7rem; border-radius: 0.75rem;
}
.btn.ghost:active { box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
.btn.pulse { animation: pulse 1.4s ease-in-out infinite; }

.field {
  font: inherit; font-size: 1.05rem; font-weight: 700; color: var(--ink);
  width: 100%; padding: 0.5rem 0.85rem; border-radius: 0.9rem;
  border: 3px solid #eadfcd; background: #fffdf8; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field:focus { border-color: var(--pink); box-shadow: 0 0 0 4px var(--pink-l); }
.field::placeholder { color: #c7bbb0; }

.row { display: flex; gap: 0.6rem; align-items: stretch; flex-wrap: wrap; }
.row .field { flex: 1 1 12rem; width: auto; }
.error { color: var(--pink-d); font-weight: 800; min-height: 1.3em; margin: 0.4rem 0 0; font-size: 0.9rem; }
.hint { color: var(--ink-soft); font-weight: 700; margin: 0.35rem 0 0; font-size: 0.85rem; }

/* ---------- join & lobby ---------- */
.hero { max-width: 28rem; margin: 2vh auto 0; }
.hero .cow-big { width: 5.5rem; height: 5.5rem; margin: 0 auto; animation: bob 3s ease-in-out infinite; }
.hero h1 { font-size: 1.9rem; margin: 0.2rem 0 0.1rem; letter-spacing: -0.02em; }
.hero p.lead { margin: 0 0 0.8rem; color: var(--ink-soft); font-weight: 700; font-size: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; margin: 0.7rem 0; }
.chip {
  background: var(--pink-l); border-radius: 999px; padding: 0.15rem 0.7rem; font-weight: 800; font-size: 0.9rem;
  animation: pop 0.45s both;
}
.chip:nth-child(3n) { background: #d3f5e7; }
.chip:nth-child(3n + 1) { background: #fff0bd; }
.dots span { display: inline-block; animation: hop 1.2s infinite; font-size: 1.5rem; line-height: 1; }
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }

/* ---------- question ---------- */
.q-label { font-weight: 900; color: var(--pink-d); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; }
.question { font-size: clamp(1.25rem, 2.2vw, 2rem); font-weight: 900; line-height: 1.2; margin: 0.2rem 0 0; letter-spacing: -0.01em; }
.question.small { font-size: clamp(1.05rem, 1.5vw, 1.4rem); }
.blank {
  display: inline-block; min-width: 2.6em; border-bottom: 0.12em dashed var(--pink); margin: 0 0.15em;
  transform: translateY(0.05em);
}
.status { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 0.9rem; margin-top: 0.6rem; min-height: 1.5rem; }
.status .tick {
  display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: var(--mint-d); color: #fff; font-size: 0.8rem; animation: pop 0.4s both;
}
.progress { height: 0.55rem; border-radius: 999px; background: #f3e8d6; overflow: hidden; margin-top: 0.5rem; }
.progress i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--pink), var(--butter)); transition: width 0.4s; }
.hostbar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.hostbar .grow { flex: 1; }
.hostbar-label { font-weight: 900; color: var(--ink-soft); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.hostcard { background: #fff6cf; padding: 0.6rem 1rem; }
.hostcard .hint { margin-top: 0.3rem; font-size: 0.78rem; }

/* ---------- reveal ---------- */
.banner {
  border-radius: 1rem; padding: 0.55rem 1rem; font-weight: 900; font-size: 1rem;
  background: var(--mint); color: #145b43; animation: pop 0.5s both;
}
.banner.tie { background: var(--butter); color: #6b5200; }
.banner.cow { background: var(--pink-l); color: var(--pink-d); margin-top: 0.45rem; animation-delay: 0.3s; }
.banner.plain { background: #efe6d6; color: var(--ink-soft); }
.banner.noanim { animation: none; }

.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: 0.7rem; }
.group {
  --c: var(--pink-l); --cd: var(--pink);
  position: relative; background: var(--c); border: 3px solid transparent; border-radius: 1.1rem;
  padding: 0.65rem 0.8rem 0.75rem; box-shadow: 0 4px 0 rgba(59, 47, 79, 0.1);
  animation: pop 0.6s cubic-bezier(0.3, 1.5, 0.5, 1) both; animation-delay: calc(var(--i) * 120ms);
  text-align: left; font: inherit; color: inherit; width: 100%;
}
.group:nth-child(4n + 2) { --c: #d3f5e7; --cd: var(--mint-d); }
.group:nth-child(4n + 3) { --c: #fff0bd; --cd: var(--butter-d); }
.group:nth-child(4n + 4) { --c: #d8eeff; --cd: var(--sky-d); }
.group.selectable { cursor: pointer; }
.group.selectable:hover { transform: translateY(-2px) rotate(-0.4deg); }
.group.selected { border-color: var(--ink); border-style: dashed; }
.group.winner { box-shadow: 0 0 0 4px var(--butter-d), 0 6px 0 rgba(59, 47, 79, 0.12); }
.group.winner .answer-label { font-size: 1.3rem; }
.group.cow { border-color: var(--pink); }
.group.noanim, .group.noanim .member { animation: none; }
.answer-label { font-size: 1.1rem; font-weight: 900; line-height: 1.15; word-break: break-word; padding-right: 2rem; }
.variants { font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); margin-top: 0.15rem; }
.count {
  position: absolute; top: 0.5rem; right: 0.55rem; min-width: 1.7rem; height: 1.7rem; padding: 0 0.4rem;
  display: grid; place-items: center; border-radius: 999px; background: var(--cd); color: #fff;
  font-weight: 900; font-size: 0.9rem;
}
.members { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.5rem; }
.member {
  background: #fff; border-radius: 999px; padding: 0.1rem 0.55rem; font-weight: 800; font-size: 0.78rem;
  display: inline-flex; align-items: center; gap: 0.25rem;
  animation: pop 0.5s both; animation-delay: calc(var(--i) * 120ms + var(--j) * 60ms + 250ms);
}
.member .cow { width: 1rem; height: 1rem; }
.award { margin-top: 0.45rem; font-weight: 900; font-size: 0.82rem; color: var(--cd); }
.crown { position: absolute; top: -0.95rem; left: 0.7rem; font-size: 1.4rem; transform: rotate(-12deg); animation: bob 2.4s ease-in-out infinite; }
.silent { color: var(--ink-soft); font-weight: 700; margin: 0; font-size: 0.85rem; }

/* ---------- finished ---------- */
.trophy { font-size: 3.2rem; animation: bob 2s ease-in-out infinite; line-height: 1.1; }
.finale h2 { font-size: 1.9rem; margin: 0.1rem 0; }
.confetti { position: fixed; top: -2rem; font-size: 1.5rem; pointer-events: none; z-index: 5; animation: fall linear forwards; }

/* ---------- scoreboard ---------- */
.board { position: sticky; top: 0.6rem; padding: 0.75rem 0.8rem; }
.board h2 { margin: 0 0 0.5rem; font-size: 1rem; display: flex; align-items: center; gap: 0.4rem; }
.board ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.row-p {
  display: flex; align-items: center; gap: 0.45rem; padding: 0.25rem 0.55rem; border-radius: 0.8rem;
  background: #fbf3e4; font-weight: 800; font-size: 0.88rem; transition: opacity 0.3s;
}
.row-p.me { background: var(--pink-l); }
.row-p.offline { opacity: 0.5; }
.row-p .rank { width: 1rem; text-align: center; color: var(--ink-soft); font-size: 0.72rem; }
.row-p .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-p .done {
  width: 1.15rem; height: 1.15rem; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 0.68rem; background: #efe3cf; color: transparent;
}
.row-p .done.yes { background: var(--mint-d); color: #fff; animation: pop 0.4s both; }
.row-p .score { min-width: 1.3rem; text-align: right; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.row-p .score.bump { animation: bump 0.7s; }
.row-p .cow-slot { width: 1.5rem; height: 1.5rem; flex: none; }
.row-p .cow-slot .cow { width: 100%; height: 100%; animation: wobble 3s ease-in-out infinite; }
.row-p .kick {
  appearance: none; border: 0; background: none; cursor: pointer; color: var(--ink-soft);
  font-size: 0.75rem; padding: 0; opacity: 0; transition: opacity 0.15s;
}
.row-p:hover .kick { opacity: 1; }
.legend { margin: 0.5rem 0 0; font-size: 0.72rem; color: var(--ink-soft); font-weight: 700; }
.flying-cow { position: fixed; z-index: 20; pointer-events: none; }
.flying-cow .cow { width: 100%; height: 100%; filter: drop-shadow(0 8px 6px rgba(59, 47, 79, 0.25)); }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 0.4rem; align-items: center; z-index: 30; }
.toast {
  background: var(--ink); color: #fff; font-weight: 800; font-size: 0.9rem; padding: 0.5rem 1rem; border-radius: 999px;
  box-shadow: 0 10px 24px rgba(59, 47, 79, 0.3); animation: toast 3.6s both;
}

/* ---------- cow svg ---------- */
.cow { display: block; }

/* ---------- animations ---------- */
@keyframes pop { 0% { transform: scale(0.3) rotate(-6deg); opacity: 0; } 70% { transform: scale(1.06) rotate(1deg); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-0.5rem); } }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.7); color: var(--pink-d); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes toast { 0% { opacity: 0; transform: translateY(20px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-10px); } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

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