/* Doodle Arcade: a sketchbook look. Cream paper, ink outlines, marker colors.
   Shared by every game; a game adds its own pieces in its own stylesheet. */

:root {
  --paper: #fdf6e3;
  --card: #fffdf6;
  --ink: #1f1d2b;
  --muted: #6f6a80;
  --line: #d9cfb6;
  --yellow: #ffd23f;
  --orange: #ff9f5a;
  --pink: #ff7aa2;
  --red: #ff5d5d;
  --purple: #b79cff;
  --blue: #5bc0eb;
  --green: #7bd389;
  /* every outline and shadow, so they stay the same across the games */
  --stroke: 2.5px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-small: 2px 3px 0 var(--ink);
  --shadow-tiny: 1.5px 2px 0 var(--ink);
  /* uneven corners make boxes look hand-drawn */
  --sketch: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --sketch-2: 15px 225px 15px 255px / 255px 15px 225px 15px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(31, 29, 43, .09) 1.5px, transparent 1.6px);
  background-size: 26px 26px;
}

[hidden] { display: none !important; }

main { position: relative; z-index: 1; }

h2 { font-size: 22px; font-weight: 600; margin: 0 0 10px; }
h2 small { font-size: 15px; font-weight: 400; color: var(--muted); margin-left: 6px; }

input, textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: var(--sketch-2);
  padding: 10px 14px;
  width: 100%;
  outline: none;
}
textarea { display: block; resize: vertical; border-radius: 14px; }
input:focus, textarea:focus { box-shadow: 0 0 0 4px var(--yellow); }
input::placeholder, textarea::placeholder { color: #b3ad9c; }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px dashed var(--purple); outline-offset: 3px; }

kbd {
  font: inherit;
  font-size: 11px;
  color: var(--muted);
  border: 1.5px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
  background: #fff;
}

/* ---------- background scribbles ---------- */
.doodles { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.doodles svg {
  position: absolute;
  opacity: .4;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: drift var(--dur) ease-in-out infinite;
  animation-delay: var(--delay);
}
@keyframes drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

/* ---------- shared pieces ---------- */
.paper {
  background: var(--card);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--sketch);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.btn {
  font-weight: 600;
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: var(--sketch-2);
  box-shadow: var(--shadow-small);
  padding: 9px 18px;
  transition: transform .08s, box-shadow .08s, background .15s;
}
.btn:hover:not(:disabled) { transform: translate(-1px, -2px) rotate(-1deg); box-shadow: 3px 5px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-yellow { background: var(--yellow); }
.btn-big { font-size: 22px; padding: 14px 26px; }
.btn-small { font-size: 14px; padding: 5px 12px; box-shadow: var(--shadow-tiny); }

.brand { font-family: 'Gochi Hand', cursive; font-size: 26px; line-height: 1; white-space: nowrap; transform: rotate(-2deg); }

.sound-toggle {
  flex: none;
  width: 44px;
  height: 44px;
  font-size: 20px;
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: 50%;
  box-shadow: var(--shadow-tiny);
  padding: 0;
}
.sound-toggle:active { transform: translate(1px, 2px); box-shadow: none; }
.head-buttons { display: flex; align-items: center; gap: 10px; }
.leave-room { flex: none; }

/* "Rules": a button that folds open the game's rules */
details.rules { flex: none; }
details.rules > summary { list-style: none; }
details.rules > summary::-webkit-details-marker { display: none; }
details.rules[open] > summary { background: var(--yellow); }
.rules-panel {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 20;
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  font-size: 15px;
  text-align: left;
  animation: drop-in .3s cubic-bezier(.3, 1.6, .5, 1);
}
.rules-panel h3 { font-family: 'Gochi Hand', cursive; font-size: 30px; font-weight: 400; line-height: 1.1; margin: 0 0 8px; }
.rules-panel h4 { font-size: 17px; font-weight: 600; margin: 14px 0 4px; }
.rules-panel p, .rules-panel ul { margin: 0 0 6px; color: var(--muted); }
.rules-panel ul { padding-left: 20px; }
.rules-panel li { margin-bottom: 3px; }
.rules-panel b { color: var(--ink); font-weight: 600; }
.rules-panel .rules-goal { color: var(--ink); background: #fff7d6; border: 2px dashed var(--ink); border-radius: 12px; padding: 8px 12px; }
.rules-close { margin-top: 10px; }

/* avatars */
.avatar, .avatar-full, .avatar-stage { line-height: 0; }
.avatar svg, .avatar-full svg, .avatar-stage svg { width: 100%; height: 100%; display: block; overflow: visible; }
.avatar { flex: none; width: 42px; height: 46px; }
.avatar.mini { width: 24px; height: 26px; display: inline-block; vertical-align: -7px; margin-right: 4px; }

/* ---------- 1. home ---------- */
.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 16px 40px;
}

.logo {
  font-family: 'Gochi Hand', cursive;
  font-size: clamp(46px, 11vw, 104px);
  font-weight: 400;
  line-height: 1;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 .28em;
}
.logo-word { display: flex; }
.logo .letter {
  display: inline-block;
  color: var(--c);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: var(--shadow);
  animation: wobble 3.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.27s);
}
@keyframes wobble {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-7px) rotate(3deg); }
}

.tagline { font-family: 'Gochi Hand', cursive; font-size: 24px; margin: 4px 0 20px; text-align: center; transform: rotate(-1deg); }

.home-grid {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 26px;
  align-items: stretch;
}
.builder { transform: rotate(-.6deg); }
.entry { transform: rotate(.7deg); display: flex; flex-direction: column; gap: 12px; }
.entry label { font-weight: 500; margin-bottom: -6px; }
.entry .btn-big { margin-top: 6px; }

.step {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font-size: 18px;
  background: var(--pink);
  border: var(--stroke) solid var(--ink);
  border-radius: 50%;
  margin-right: 6px;
  transform: rotate(-6deg);
}

.builder-body { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; align-items: center; }
.builder-preview { flex: none; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.avatar-stage {
  width: 170px;
  height: 240px;
  padding: 10px 14px 6px;
  background: repeating-linear-gradient(#fff, #fff 23px, #dbe9f6 23px, #dbe9f6 25px);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--sketch-2);
}
.builder-options { flex: 1; min-width: 250px; display: flex; flex-direction: column; gap: 10px; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button {
  width: 30px;
  height: 30px;
  border: var(--stroke) solid var(--ink);
  border-radius: 50%;
  padding: 0;
  transition: transform .1s;
}
.swatches button:hover { transform: scale(1.15) rotate(8deg); }
.swatches button.active { box-shadow: 0 0 0 3px var(--card), 0 0 0 6px var(--ink); }

.part-row { display: grid; grid-template-columns: 74px 40px 1fr 40px; align-items: center; gap: 6px; margin-top: 6px; }
.part-row .part-label { font-weight: 600; }
.part-row .part-value { text-align: center; background: #fff; border: 2px dashed var(--line); border-radius: 10px; padding: 5px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-row button {
  height: 38px;
  font-size: 18px;
  font-weight: 700;
  background: var(--blue);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--sketch-2);
  box-shadow: var(--shadow-tiny);
  padding: 0;
}
.part-row button:active { transform: translate(1px, 2px); box-shadow: none; }

/* your own reaction texts, under the doodle builder */
.say-box { margin-top: 16px; padding-top: 14px; border-top: 2px dashed var(--line); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.say-editor { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.say-help { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--muted); text-align: center; }
.say-row { display: flex; align-items: center; gap: 8px; }
.say-icon { flex: none; width: 34px; font-size: 22px; line-height: 1; text-align: center; }
.say-row input { flex: 1; min-width: 0; padding: 6px 10px; font-size: 15px; }
.say-count { flex: none; width: 22px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .say-editor { grid-template-columns: 1fr; } }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 15px; margin-top: 8px; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 2px dashed var(--line); }

.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 600; }

.status { min-height: 1.4em; margin: 0; color: #c2410c; text-align: center; font-weight: 500; }

/* an invite link: the entry card is all about joining that one room */
.invite {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fff7d6;
  border: var(--stroke) dashed var(--ink);
  border-radius: 14px;
  padding: 10px 14px;
}
.invite b { font-size: 18px; font-weight: 600; }
.invite small { color: var(--muted); font-size: 14px; }
.invite .invite-problem { color: #c2410c; font-weight: 500; }
.home.invited #create, .home.invited .divider { display: none; }
.home.invited .entry { order: -1; } /* the invitation comes first, the doodle builder second */
.home.invited .intro { display: none; } /* how to play is in the lobby's Rules too; the name box comes first */
@media (min-width: 761px) {
  .home.invited .home-grid { grid-template-columns: 1fr 1.25fr; } /* and the builder keeps its wide column */
}
.home.invited .join-row input { flex: 0 0 120px; }
.home.invited .join-row .btn { flex: 1; }
.link-btn { align-self: center; background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: 15px; }
.link-btn:hover { color: var(--ink); }

/* how the game works, on the entry screen before anyone joins */
.intro { width: 100%; max-width: 980px; display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 0 0 22px; }
.how {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.how li {
  background: var(--card);
  border: var(--stroke) dashed var(--ink);
  border-radius: var(--sketch-2);
  padding: 8px 12px 10px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--muted);
}
.how li:nth-child(odd) { transform: rotate(-.8deg); }
.how li:nth-child(even) { transform: rotate(.8deg); }
.how span { display: block; font-size: 24px; line-height: 1.2; }
.how b { color: var(--ink); font-weight: 600; }

/* back to the arcade, top left of a game's entry screen */
.back-link {
  position: absolute;
  top: 16px;
  left: 16px;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow-tiny);
  padding: 4px 14px;
  transform: rotate(-2deg);
  transition: transform .1s;
}
.back-link:hover { transform: rotate(-2deg) translateY(-2px); }
.back-link:focus-visible { outline: 3px dashed var(--purple); outline-offset: 3px; }

/* a feedback link, under a game's entry screen and its final scores */
.home-foot, .feedback-nudge { margin: 18px 0 0; font-size: 15px; color: var(--muted); text-align: center; }
.home-foot a, .feedback-nudge a { color: var(--ink); font-weight: 600; text-decoration-style: wavy; text-decoration-color: var(--pink); text-underline-offset: 3px; }
.home-foot a:hover, .feedback-nudge a:hover { background: var(--yellow); }
.overlay .feedback-nudge { margin: 0; font-size: 14px; }

/* ---------- 2. lobby ---------- */
.lobby { max-width: 1040px; margin: 0 auto; padding: 20px 16px 120px; display: flex; flex-direction: column; gap: 24px; }

.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.ticket {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--yellow);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--sketch);
  box-shadow: var(--shadow);
  padding: 6px 16px;
  transform: rotate(-1.2deg);
}
.ticket span { font-weight: 500; }
.ticket b { font-family: 'Gochi Hand', cursive; font-size: 40px; font-weight: 400; letter-spacing: .14em; line-height: 1; }

.gang { transform: rotate(.3deg); }
.gang-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: flex-end; min-height: 150px; }
.gang-member { width: 92px; text-align: center; animation: drop-in .45s cubic-bezier(.3, 1.6, .5, 1) backwards; }
.gang-member .avatar-full { width: 80px; height: 122px; margin: 0 auto; }
.gang-member .gname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gang-member .gtag { font-size: 12px; font-weight: 600; background: var(--purple); border: 2px solid var(--ink); border-radius: 999px; padding: 0 8px; display: inline-block; }
.gang-member .gtag.me { background: var(--green); }
.gang-empty {
  width: 92px;
  height: 122px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  border: var(--stroke) dashed var(--line);
  border-radius: var(--sketch-2);
  align-self: flex-start;
  margin-top: 4px;
}
@keyframes drop-in { from { transform: translateY(-40px) scale(.6); opacity: 0; } }

.setup { transform: rotate(-.25deg); }
.setup h2 { margin-top: 18px; }
/* a heading with its explanation on the left, buttons on the right (or below, when they don't fit) */
.setup-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 0 16px; flex-wrap: wrap; }
.setup-head > div:first-child { flex: 1 1 320px; }
.setup-head h2 { margin-top: 0; }
.setup-head > .btn, .setup-head > .head-buttons { flex: none; margin-bottom: 12px; }
.setup-head .head-buttons { flex-wrap: wrap; }
.sub { margin: -6px 0 12px; color: var(--muted); }
.host-note { margin: 0 0 16px; padding: 8px 14px; background: #eef8ff; border: 2px dashed var(--blue); border-radius: 12px; font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  font-weight: 500;
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--muted);
  transition: transform .1s, background .12s;
}
.chip::before { content: '+ '; font-weight: 700; }
.chip.on { background: var(--green); color: var(--ink); box-shadow: var(--shadow-tiny); transform: rotate(-1.5deg); }
.chip.on:nth-child(even) { transform: rotate(1.5deg); background: var(--blue); }
.chip.on:nth-child(3n) { background: var(--pink); }
.chip.on::before { content: '✓ '; }
.chip:hover:not(:disabled) { transform: scale(1.06); }
.chip:disabled { cursor: default; }
.chip:disabled:not(.on) { opacity: .45; }

.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: var(--sketch-2);
  padding: 12px 16px;
  flex-wrap: wrap;
}
/* the text takes the room it needs; buttons that do not fit go on the next line */
.option .otext { flex: 1 1 180px; min-width: 0; }
.option h3 { margin: 0; font-size: 18px; font-weight: 600; }
.option p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
button.option { transition: transform .1s, background .15s; }
button.option:hover:not(:disabled) { transform: translateY(-2px) rotate(-.5deg); }
button.option.on { background: #fff7d6; box-shadow: var(--shadow-small); }
button.option:disabled { cursor: default; }

.switch { flex: none; width: 58px; height: 32px; border: var(--stroke) solid var(--ink); border-radius: 999px; background: #e7e1d0; position: relative; transition: background .15s; }
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: 50%;
  transition: transform .18s cubic-bezier(.3, 1.6, .5, 1);
}
.on > .switch { background: var(--green); }
.on > .switch::after { transform: translateX(26px); }

.stepper, .segments { flex: none; display: flex; align-items: center; gap: 6px; }
.stepper b { min-width: 30px; text-align: center; font-size: 22px; }
.stepper button, .segments button {
  min-width: 38px;
  height: 38px;
  font-weight: 600;
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: 12px;
  padding: 0 8px;
}
.stepper button { font-size: 20px; background: var(--blue); }
.segments button.active { background: var(--yellow); box-shadow: var(--shadow-tiny); transform: rotate(-2deg); }
.stepper button:disabled, .segments button:disabled { cursor: default; }
.stepper button:disabled { opacity: .35; }
.segments button:disabled:not(.active) { opacity: .4; }

.lobby-foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: linear-gradient(transparent, var(--paper) 35%);
}
.start-hint { margin: 0; font-family: 'Gochi Hand', cursive; font-size: 22px; }
#start:not(:disabled) { animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge {
  0%, 86%, 100% { transform: rotate(0); }
  90% { transform: rotate(-2.5deg) scale(1.04); }
  95% { transform: rotate(2.5deg) scale(1.04); }
}

/* ---------- 3. game ---------- */
.game { padding: 14px 16px 24px; max-width: 1440px; margin: 0 auto; }

.topbar { display: flex; align-items: center; gap: 14px; }
.pill {
  font-size: 14px;
  font-weight: 600;
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}
.word-box { flex: 1; min-width: 0; overflow-wrap: anywhere; text-align: center; min-height: 56px; display: flex; flex-direction: column; justify-content: center; }
.word { font-size: clamp(18px, 2.6vw, 30px); font-weight: 700; letter-spacing: .28em; white-space: pre-wrap; }
.category { font-size: 14px; color: var(--muted); font-weight: 500; }
.timer {
  flex: none;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 22px;
  background: var(--yellow);
  border: var(--stroke) solid var(--ink);
  border-radius: 50%;
  box-shadow: var(--shadow-tiny);
  font-variant-numeric: tabular-nums;
}
.timer.low { background: var(--red); color: #fff; animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.12) rotate(4deg); } }

.progress { height: 12px; background: #fff; border: var(--stroke) solid var(--ink); border-radius: 999px; margin: 10px 0 16px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: repeating-linear-gradient(-45deg, var(--pink) 0 10px, var(--orange) 10px 20px); transition: width .25s linear; }

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}
.layout .paper { padding: 14px 16px; }

.players ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.players li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 2px solid transparent;
  border-radius: 14px;
}
.players li.drawing { background: #fff7d6; border-color: var(--ink); border-style: dashed; }
.players li.guessed { background: #dff6e4; border-color: var(--ink); }
.players li.guessed .avatar { animation: hop .5s ease-out; }
@keyframes hop { 40% { transform: translateY(-12px) rotate(-8deg); } }
.pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.pname small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.pscore { font-weight: 700; font-variant-numeric: tabular-nums; }

.canvas-wrap {
  position: relative;
  border: var(--stroke) solid var(--ink);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  background: #fff;
  line-height: 0;
}
canvas { width: 100%; height: auto; touch-action: none; cursor: crosshair; display: block; }

/* overlay on the canvas: word choice and results */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(253, 246, 227, .96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* "safe": when it does not fit (a phone), it starts at the top and scrolls,
     instead of spilling over the top edge where nobody can scroll to it */
  justify-content: safe center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  line-height: 1.4;
  overflow: auto;
}
.overlay h3 { font-family: 'Gochi Hand', cursive; font-size: clamp(26px, 3.6vw, 40px); font-weight: 400; margin: 0; }
.overlay p { margin: 0; color: var(--muted); }
.overlay .label { font-weight: 600; color: var(--muted); }
.overlay .big { font-size: clamp(26px, 5vw, 48px); font-weight: 700; letter-spacing: .1em; }
.overlay .row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: stretch; }
.overlay .avatar-full { width: 90px; height: 138px; }

.scores { list-style: none; margin: 0; padding: 0; min-width: 280px; }
.scores li { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 3px 0; font-weight: 500; }
.scores .gain { color: #1f9d55; font-weight: 700; }
.scores li.winner { font-weight: 700; font-size: 21px; }

.tip { margin: 0; font-size: 14px; color: var(--muted); }
.tip b { color: var(--ink); font-weight: 600; }

/* chat */
.chat { display: flex; flex-direction: column; height: min(72vh, 660px); }
.messages { flex: 1; overflow-y: auto; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 16px; }
.messages div { overflow-wrap: anywhere; }
.messages .msg, .messages .hidden {
  align-self: flex-start;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 4px 14px 14px 14px;
  padding: 3px 10px;
  animation: pop .2s ease-out;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.messages .msg b, .messages .hidden b { font-weight: 600; margin-right: 5px; }
.messages .hidden { background: #dff6e4; border-style: dashed; }
.messages .sys { color: var(--muted); font-size: 14px; }
.messages .good { color: #1f9d55; font-weight: 600; }

/* ---------- reactions: jump, angry, celebrate, laugh, mock, shocked ---------- */
.gang-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.gang-head h2 { margin: 0; }
.react-bar { display: flex; gap: 6px; flex-wrap: wrap; }
/* in the narrow chat the buttons share the width, so they always fit on one row */
.chat .react-bar { margin-bottom: 8px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.chat .react-bar button { width: 100%; max-width: 44px; justify-self: center; aspect-ratio: 1; height: auto; }
.react-bar button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 21px;
  line-height: 1;
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-tiny);
  transition: transform .1s;
}
.react-bar button:hover:not(:disabled) { transform: translateY(-3px) rotate(-6deg) scale(1.08); }
.react-bar button:active:not(:disabled) { transform: translate(1px, 2px); box-shadow: none; }
.react-bar button:disabled { opacity: .45; cursor: default; }

.bubble {
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--ink);
  background: #fff;
  border: var(--stroke) solid var(--ink);
  border-radius: 14px;
  box-shadow: var(--shadow-tiny);
  padding: 2px 9px;
  animation: pop .2s ease-out;
}

/* a doodle popping up at the bottom of the drawing */
.reaction-stage { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.reaction {
  position: absolute;
  bottom: 0;
  width: 116px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  animation: react-pop 2.6s ease-in-out forwards;
}
.reaction .avatar-full { width: 70px; height: 114px; }
/* long custom texts wrap, so the bubble never runs off the side of the drawing */
.reaction .bubble { font-size: 12px; padding: 1px 7px; white-space: normal; text-align: center; max-width: 100%; overflow-wrap: anywhere; }
@keyframes react-pop {
  0% { transform: translateY(105%); }
  12%, 86% { transform: translateY(6%); }
  100% { transform: translateY(105%); }
}

/* what each reaction does, on the canvas and in the player lists */
.reacting.r-jump .avatar { animation: react-jump .9s ease-in-out infinite; }
.reacting.r-angry .avatar { animation: react-shake .14s linear infinite; filter: drop-shadow(0 0 6px rgba(255, 93, 93, .9)); }
.reacting.r-celebrate .avatar { animation: react-party .5s ease-in-out infinite; }
.reacting.r-laugh .avatar { animation: react-laugh .22s ease-in-out infinite; }
.reacting.r-mock .avatar { animation: react-mock .6s ease-in-out infinite; }
.reacting.r-shocked .avatar { animation: react-shock 1.2s ease-out; }
.r-angry .bubble { background: #ffd6d6; }
.r-celebrate .bubble { background: var(--yellow); }
.r-laugh .bubble { background: #dff6e4; }
.r-mock .bubble { background: #efe8ff; }
@keyframes react-jump { 0%, 100% { transform: translateY(0) scaleY(1); } 15% { transform: translateY(0) scaleY(.88); } 45% { transform: translateY(-34%) scaleY(1.06); } 75% { transform: translateY(0) scaleY(.94); } }
@keyframes react-shake { 0%, 100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(-4px) rotate(-3deg); } 75% { transform: translateX(4px) rotate(3deg); } }
@keyframes react-party { 0%, 100% { transform: translateY(0) rotate(-10deg); } 50% { transform: translateY(-14%) rotate(10deg); } }
@keyframes react-laugh { 0%, 100% { transform: rotate(-6deg) translateY(0); } 50% { transform: rotate(6deg) translateY(-4%); } }
@keyframes react-mock { 0%, 100% { transform: translateX(-10%) skewX(-6deg); } 50% { transform: translateX(10%) skewX(6deg); } }
@keyframes react-shock { 0% { transform: scale(1); } 15% { transform: scale(1.25, .8) translateY(8%); } 35% { transform: scale(.9, 1.2) translateY(-18%); } 60%, 100% { transform: scale(1); } }

/* the other places a doodle reacts: the player list and the lobby */
.players li, .gang-member { position: relative; }
.players li > .bubble { position: absolute; left: 40px; top: -14px; z-index: 2; }
.gang-member > .bubble { position: absolute; left: 50%; top: -18px; transform: translateX(-50%); z-index: 2; }

/* ---------- small screens ---------- */
/* a small laptop or a projector: narrower sides, so the drawing stays big */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr) 250px; gap: 14px; }
  .layout .paper { padding: 12px 12px; }
}
@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; }
  .stage { order: -1; }
  .chat { height: 320px; }
  .game .brand { display: none; }
}
@media (max-width: 760px) {
  .home-grid { grid-template-columns: 1fr; }
  .option-grid { grid-template-columns: 1fr; }
  .builder-body { flex-direction: column; }
  .builder-options { width: 100%; }
  .lobby-head .brand { display: none; }
  .back-link { position: static; align-self: flex-start; margin-bottom: 6px; }
  /* a crowded top bar: the word gets its own row, buttons drop their text */
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar .head-buttons { gap: 6px; }
  .topbar .sound-toggle { width: 38px; height: 38px; font-size: 18px; }
  .topbar .timer { width: 48px; height: 48px; font-size: 19px; }
  .topbar .word-box { order: 5; flex-basis: 100%; min-height: 0; }
  .topbar #round { margin-right: auto; }
  .topbar .rules summary span { display: none; }
  .how { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* the overlay on a phone is small: everything a bit tighter */
  .overlay { gap: 8px; padding: 10px; }
  .overlay h3 { font-size: 24px; }
  .overlay .avatar-full { width: 64px; height: 98px; }
  .scores { min-width: 0; width: 100%; }
}

/* people who prefer less motion get a calm page */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
