/* Mushroom Quiz. Base and 8-bit layer lifted from getmushroom.app's site.css; needs tokens.css first.
   Never hardcode a hex value here: every color is a token. */

/* Terminus and Press Start 2P, both SIL Open Font License 1.1 (fonts/OFL-*.txt), original files. */
@font-face { font-family: "Terminus"; src: url("/fonts/TerminusTTF-4.49.3.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Terminus"; src: url("/fonts/TerminusTTF-Bold-4.49.3.ttf") format("truetype"); font-weight: 700 900; font-display: swap; }
@font-face { font-family: "Press Start 2P"; src: url("/fonts/PressStart2P-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }

:root {
  --px-line: light-dark(var(--ink), color-mix(in srgb, var(--ink) 55%, var(--bg)));
  --px-shadow: light-dark(color-mix(in srgb, var(--ink) 85%, transparent), color-mix(in srgb, var(--ink) 24%, var(--bg)));
}
* { box-sizing: border-box; border-radius: 0 !important; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 16px/1.6 "Terminus", ui-monospace, "SF Mono", Menlo, monospace;
  -webkit-font-smoothing: antialiased;
}
/* Press Start 2P is drawn on an 8px grid: whole multiples of 8 only, and it has one weight. */
h1, h2, .brand { font-family: "Press Start 2P", "Terminus", monospace; font-weight: 400; line-height: 1.5; margin: 0 0 12px; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { margin: 0 0 12px; text-wrap: pretty; }
a { color: inherit; }
b { font-weight: 700; }
:where(a, button, input, summary):focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }

.wrap { width: min(100% - 32px, 72rem); margin-inline: auto; }
.muted { color: var(--ink2); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 13px; font-weight: 700; color: var(--red); margin: 0 0 8px; }
.eyebrow::before { content: "+ "; }
.lede { color: var(--ink2); font-size: 17px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1 1 12rem; min-width: 0; }

/* ---------- header / footer ---------- */
.top { border-bottom: 2px solid var(--px-line); background: var(--bg2); margin-bottom: 24px; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-size: 16px; margin: 0; }
.foot { margin-top: auto; padding: 24px 0; color: var(--ink2); font-size: 14px; text-align: center; }

/* ---------- the sprite: 48x48 frames, nearest neighbour, integer scale only ---------- */
.shroom {
  display: inline-block; flex: none; width: 48px; height: 48px;
  background: url("/mushroom-idle.png") 0 0 / 432px 48px no-repeat;
  image-rendering: pixelated; animation: idle 1.4s steps(9) infinite;
}
.shroom--2x { width: 96px; height: 96px; background-size: 864px 96px; animation-name: idle2; }
@keyframes idle { to { background-position: -432px 0; } }
@keyframes idle2 { to { background-position: -864px 0; } }
@media (prefers-reduced-motion: reduce) { .shroom { animation: none; } }

/* ---------- cards, buttons, inputs: square corners, 2px pixel borders, hard shadows ---------- */
.card {
  background: var(--card); border: 2px solid var(--px-line); box-shadow: 5px 5px 0 var(--px-shadow);
  padding: 20px; margin-bottom: 24px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--red); color: var(--red-ink); border: 2px solid var(--px-line);
  padding: 10px 18px; font: inherit; font-weight: 700; line-height: 1.15; cursor: pointer; text-decoration: none;
  box-shadow: 3px 3px 0 var(--px-shadow); transition: transform .06s steps(2), box-shadow .06s steps(2);
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--px-shadow); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--px-shadow); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 3px 3px 0 var(--px-shadow); }
.btn--ghost { background: var(--card); color: var(--ink); }
.btn--sm { padding: 6px 12px; font-size: 14px; }
.x { background: none; border: 0; color: var(--ink2); font: inherit; cursor: pointer; padding: 0 4px; }
.x:hover { color: var(--red); }
input {
  font: inherit; color: var(--ink); background: var(--bg); border: 2px solid var(--px-line);
  padding: 9px 12px; min-width: 0;
}
input[type="number"] { width: 5em; }
label { display: block; font-weight: 700; margin: 12px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.chip { display: inline-block; border: 2px solid var(--px-line); background: var(--bg2); padding: 0 8px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip--red { background: var(--red); color: var(--red-ink); }
.chip--ok { background: var(--tint); }
.note { background: var(--tint); border: 2px solid var(--px-line); padding: 8px 12px; }
.small { font-size: 14px; }

/* ---------- landing / join ---------- */
.hero { max-width: 40rem; margin: 32px auto; text-align: center; }
.hero .shroom { margin-bottom: 16px; }
.hero .row { justify-content: center; }
@media (min-width: 700px) { .hero h1 { font-size: 32px; } }

/* ---------- game layout ---------- */
.game { display: grid; gap: 0 24px; align-items: start; }
@media (min-width: 900px) { .game { grid-template-columns: minmax(0, 1fr) 340px; } }
.q { font-size: 16px; line-height: 1.75; margin: 16px 0 20px; }
@media (min-width: 700px) { .q { font-size: 24px; } }
.stagehead { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.timer { font-family: "Press Start 2P", monospace; font-size: 16px; color: var(--red); }
.think { display: flex; align-items: center; gap: 16px; }
.answer { font-size: 20px; border: 2px solid var(--px-line); background: var(--bg2); padding: 8px 12px; }

.list { list-style: none; padding: 0; margin: 16px 0 0; }
.list li { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; padding: 6px 0; border-top: 2px dashed var(--line2); }
.list li:first-child { border-top: 0; }
.list .who { font-weight: 700; }
.list .what { flex: 1; overflow-wrap: anywhere; }
.list .off { opacity: .5; }
.list .done { text-decoration: line-through; color: var(--ink2); }
.list .cur { font-weight: 700; color: var(--red); }
.score { font-family: "Press Start 2P", monospace; font-size: 16px; }
ol.list { counter-reset: n; }
ol.list li::before { counter-increment: n; content: counter(n) "."; color: var(--ink2); min-width: 1.5em; }

.yt { aspect-ratio: 16 / 9; background: var(--bg3); border: 2px solid var(--px-line); margin-bottom: 12px; }
.yt iframe { display: block; width: 100%; height: 100%; }

.chat-log { max-height: 16rem; overflow-y: auto; margin-bottom: 12px; overflow-wrap: anywhere; }
.chat-log p { margin: 0 0 4px; }
.chat-log .mine b { color: var(--red); }
/* Off screen rather than display:none, which stops YouTube's player from ever loading the playlist. */
#yt-tmp { position: fixed; left: -9999px; top: 0; width: 200px; height: 200px; }

.promo { display: flex; gap: 16px; align-items: center; background: var(--bg2); }
.promo-line { min-height: 3.2em; }
.promo--big { flex-direction: column; text-align: center; margin: 24px 0 0; box-shadow: none; }
.promo--big ul { text-align: left; margin: 0 0 16px; padding-left: 1.2em; }
.chat-log .ad { background: var(--tint); border: 2px dashed var(--line2); padding: 4px 8px; margin: 6px 0; }
.chat-log .ad a { color: var(--red); font-weight: 700; }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; image-rendering: pixelated; }
.slide-in { animation: slidein .4s steps(6); }
.slide-in .bar i { animation: grow .8s steps(8); }
@keyframes slidein { from { transform: translateX(48px); opacity: 0; } }
@keyframes grow { from { width: 0; } }
@media (prefers-reduced-motion: reduce) { .slide-in, .slide-in .bar i { animation: none; } }
.slide { margin-top: 24px; }
.slide h2 { margin-top: 4px; }
.stat-name { min-width: 6em; }
.bar { flex: 1; height: 16px; background: var(--bg3); border: 2px solid var(--px-line); align-self: center; }
.bar i { display: block; height: 100%; background: var(--red); }
.dots { display: flex; gap: 6px; margin: 16px 0 0; }
.dots span { width: 10px; height: 10px; border: 2px solid var(--px-line); }
.dots .on { background: var(--red); }

/* ---------- the mushroom quizmaster ---------- */
.qm { display: flex; gap: 16px; align-items: center; margin: 8px 0 16px; }
.bubble {
  position: relative; flex: 1; min-width: 0; background: var(--bg); border: 2px solid var(--px-line);
  box-shadow: 3px 3px 0 var(--px-shadow); padding: 12px 16px; overflow-wrap: anywhere;
}
/* The tail: two stacked squares pointing at the mushroom, drawn like pixels. */
.bubble::before, .bubble::after { content: ""; position: absolute; background: var(--bg); border: 2px solid var(--px-line); }
.bubble::before { left: -12px; top: 22px; width: 10px; height: 10px; border-right: 0; }
.bubble::after { left: -20px; top: 28px; width: 6px; height: 6px; }
.bubble .q { margin: 0; }
.qm.enter .shroom {
  background-image: url("/mushroom-walk.png"); background-size: 384px 96px;
  animation: walk2 .6s steps(4) 2, walkin 1.2s steps(12) both;
}
.qm.enter .bubble { animation: pop .3s steps(3) 1.1s both; }
@keyframes walk2 { to { background-position: -384px 0; } }
@keyframes walkin { from { transform: translateX(-160px); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.qm.cheer .shroom { animation: idle2 1.4s steps(9) infinite, hop .5s steps(4) 3; }
@keyframes hop { 50% { transform: translateY(-16px); } }
/* Gentle: a little lower and a little greyer, never sad for long. */
.qm.droop .shroom { transform: translateY(6px); filter: saturate(.6); }
@media (prefers-reduced-motion: reduce) { .qm .shroom, .qm .bubble { animation: none !important; } }
.list li.rv { flex-wrap: wrap; }
.appeal { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.q-small { font-weight: 700; margin: 0 0 12px; }
.fact { border-left: 4px solid var(--red); padding: 4px 12px; background: var(--bg2); }

/* ---------- lobby settings and teams ---------- */
.setting { margin-top: 12px; }
.setting-label { min-width: 7em; font-weight: 700; }
.teams { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); margin-top: 8px; }
.team { border: 2px solid var(--px-line); padding: 10px 12px; background: var(--bg); }
.team.mine { background: var(--tint); }
.team p { margin: 4px 0 8px; }
.list .team-row { border-top: 2px solid var(--px-line); }
.list .member { padding-left: 16px; border-top: 0; font-size: 14px; }

/* ---------- reactions ---------- */
.reactions { margin-top: 12px; gap: 6px; }
.react { font-size: 20px; line-height: 1; padding: 6px 8px; background: var(--bg); border: 2px solid var(--px-line); cursor: pointer; }
.react:active { transform: translate(2px, 2px); }
.float { position: fixed; bottom: 0; z-index: 21; font-size: 32px; pointer-events: none; animation: rise 2.4s steps(24) forwards; }
@keyframes rise { to { transform: translateY(-70vh); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .float { animation: fade 1.5s forwards; bottom: 40%; } @keyframes fade { to { opacity: 0; } } }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 32rem; margin-inline: auto; z-index: 10;
  background: var(--card); border: 2px solid var(--px-line); box-shadow: 5px 5px 0 var(--px-shadow); padding: 12px 16px;
}
