/* Cards Against ... — mobile first, black and white, Helvetica, flat cards.
   Everything is designed for a phone held in one hand; wider screens get a
   roomier layout from the media queries at the bottom. */

/* Free Helvetica clone (TeX Gyre Heros, GUST font licence, see fonts/). Apple
   devices use their built-in Helvetica Neue first. */
@font-face { font-family: 'CA Heros'; src: url('fonts/heros-bold.woff2') format('woff2'); font-weight: 600 900; font-display: swap; }
@font-face { font-family: 'CA Heros'; src: url('fonts/heros-regular.woff2') format('woff2'); font-weight: 100 500; font-display: swap; }

:root {
  --bg: #000;
  --text: #fff;
  --muted: #9a9a9a;
  --faint: #5c5c5c;
  --surface-2: #1c1c1c;
  --line: rgba(255, 255, 255, .16);
  --red: #fe2f2f;
  --accent: #ff3d6e;
  --accent-2: #ff7a45;
  --hot: linear-gradient(135deg, var(--accent), var(--accent-2));
  /* The shiny white-to-pink text from the original design. */
  --shine: linear-gradient(135deg, #fff 30%, #ffb3c6);
  --whatsapp: #25d366;
  --font: 'Helvetica Neue', 'CA Heros', Helvetica, Arial, sans-serif; /* not plain Helvetica first: Windows maps it to Arial */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.3, 1.35, .45, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  /* The little two-card mark printed in each card's corner. */
  --mark-ink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='5' width='10.5' height='14.5' rx='1.6' transform='rotate(-14 8.75 12.25)' fill='white' stroke='black' stroke-width='2'/%3E%3Crect x='10' y='3.5' width='10.5' height='14.5' rx='1.6' transform='rotate(9 15.25 10.75)' fill='black'/%3E%3C/svg%3E");
  --mark-paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='5' width='10.5' height='14.5' rx='1.6' transform='rotate(-14 8.75 12.25)' fill='black' stroke='white' stroke-width='2'/%3E%3Crect x='10' y='3.5' width='10.5' height='14.5' rx='1.6' transform='rotate(9 15.25 10.75)' fill='white'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
html, body { overflow-x: clip; } /* nothing may widen the layout viewport on phones (clip, not hidden, so sticky still works) */
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
b, strong { font-weight: 700; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

/* ---------------------------------------------------------------- screens */
.screen { display: none; width: 100%; max-width: 1180px; margin: 0 auto; }
.screen.on { display: block; }
/* App screens fill the viewport: bar on top, scrolling middle, tray + dock at the bottom. */
.screen.app.on { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 20px; -webkit-overflow-scrolling: touch; }

.bar {
  flex: none; display: flex; align-items: center; gap: 6px;
  min-height: 60px; padding: var(--safe-t) 10px 0;
  border-bottom: 1px solid var(--line);
}
.bar-title { font-weight: 700; font-size: 1.15rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: none; border: 0; font-size: 1.5rem; cursor: pointer;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface-2); }
.timer {
  font-weight: 700; font-variant-numeric: tabular-nums; font-size: .95rem;
  border: 2px solid var(--text); border-radius: 999px; padding: 4px 12px;
}
.timer.urgent { background: var(--accent); border-color: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* The dock: primary actions, always in thumb reach. */
.dock {
  flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: #000;
  border-top: 1px solid var(--line);
}
.dock:empty { display: none; }
.dock .grow { flex: 1 1 auto; }
.dock .waiting { flex: 1 1 100%; margin: 0; text-align: center; color: var(--muted); font-size: .95rem; }
.dock .waiting:empty { display: none; }

/* ---------------------------------------------------------------- buttons: black pills, white type */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 50px; padding: 10px 22px;
  background: #000; color: #fff; border: 2px solid #fff; border-radius: 999px;
  font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s, transform .12s var(--ease), opacity .15s;
  user-select: none;
}
.btn:hover { background: #fff; color: #000; }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .3; cursor: not-allowed; transform: none; background: #000; color: #fff; }
.btn.primary { background: #fff; color: #000; }
.btn.primary:hover { background: #e6e6e6; }
.btn.primary:disabled { background: #fff; color: #000; }
.btn.hot { background: var(--hot); border-color: transparent; color: #fff; box-shadow: 0 8px 24px -8px rgba(255, 61, 110, .7); }
.btn.hot:hover { filter: brightness(1.08); background: var(--hot); color: #fff; }
.btn.hot:disabled { background: var(--hot); color: #fff; box-shadow: none; }
.btn.whatsapp { background: var(--whatsapp); border-color: var(--whatsapp); color: #000; }
.btn.ghost { border-color: var(--faint); }
.btn.ghost:hover { border-color: #fff; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.big { min-height: 58px; font-size: 1.2rem; padding: 12px 28px; }
.btn.small { min-height: 40px; padding: 6px 16px; font-size: .95rem; }
.btn.round { width: 58px; min-width: 58px; padding: 0; font-size: 1.3rem; }
.btn.copied { background: #fff; color: #000; }

/* ---------------------------------------------------------------- the cards */
/* Sizes come from --w (the card's width), so text and corners scale like print. */
.card {
  --w: 170px;
  position: relative; width: var(--w); aspect-ratio: 63 / 88;
  padding: calc(var(--w) * .085) calc(var(--w) * .085) calc(var(--w) * .22);
  border-radius: calc(var(--w) * .055);
  font-size: calc(var(--w) * .085); font-weight: 700; line-height: 1.22; letter-spacing: -.012em;
  text-align: left; overflow-wrap: break-word; hyphens: auto;
}
/* A whisper of shading, like light across real card stock. */
.card.white { background: linear-gradient(128deg, #fff 58%, #f0f0ee 100%); color: #000; }
.card.black { background: #000; color: #fff; box-shadow: inset 0 0 0 max(1.5px, calc(var(--w) * .008)) #fff; }
/* Printed footer: the mark plus "Cards Against <word>" (the word rotates, see app.js). */
.card::after {
  content: var(--card-footer, 'Cards Against ...');
  position: absolute; left: calc(var(--w) * .085); bottom: calc(var(--w) * .075);
  max-width: calc(100% - var(--w) * .17); overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  padding-left: 1.75em; min-height: 1.4em; line-height: 1.4em;
  font-size: max(7.5px, calc(var(--w) * .042)); font-weight: 700; letter-spacing: 0;
  background: var(--mark-ink) left center / 1.4em no-repeat;
}
.card.black::after { background-image: var(--mark-paper); }
.card.has-pick::after { max-width: 52%; }
html.word-tick .card::after { animation: footerWord .45s var(--ease); }
@keyframes footerWord { from { opacity: 0; transform: translateY(3px); } }
.card .blank {
  display: inline-block; min-width: 3.4em; color: transparent;
  border-bottom: max(1.5px, .08em) solid #000; line-height: 1;
}
.card.black .blank { border-bottom-color: #fff; }
.card .ans { color: var(--accent); }
.card.white .ans { color: inherit; text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .14em; }
.card .pick {
  position: absolute; right: calc(var(--w) * .085); bottom: calc(var(--w) * .07);
  font-size: max(8px, calc(var(--w) * .045)); font-weight: 700; letter-spacing: .04em;
  border: 1.5px solid currentColor; border-radius: 999px; padding: .1em .55em;
}

/* The black card on the play screen: as big as the phone allows, real proportions. */
.card.prompt { --w: clamp(170px, min(70vw, calc((100dvh - 520px) * .716)), 320px); font-size: calc(var(--w) * .08); }
.card.flash { animation: flash .35s var(--ease); }
@keyframes flash { 40% { transform: scale(1.025); } }

/* ---------------------------------------------------------------- home: the card pile */
#home.on {
  display: flex; flex-direction: column; gap: 18px;
  min-height: 100vh; min-height: 100dvh; max-width: none;
  padding: 0 0 calc(18px + var(--safe-b));
}
.pile {
  position: relative; flex: 1 1 auto; min-height: max(58dvh, 420px); overflow: clip;
  touch-action: manipulation; user-select: none;
}
.pile-title { position: absolute; left: 20px; top: calc(20px + var(--safe-t)); z-index: 0; pointer-events: none; }
.logo { font-weight: 700; font-size: clamp(2.6rem, 11.5vw, 4.8rem); line-height: .95; letter-spacing: -.035em; margin: 0; color: #fff; }
.shiny, #word, .room-code:not(.small) { background: var(--shine); -webkit-background-clip: text; background-clip: text; color: transparent; }
/* The gradient is only painted inside the element's box, so give descenders (the tail of a y) room below. */
#word { display: inline-block; white-space: nowrap; transition: opacity .25s, transform .25s var(--ease); padding: 0 .04em .18em 0; margin-bottom: -.18em; }
.room-code:not(.small) { padding-bottom: .1em; margin-bottom: calc(4px - .1em); }
#word.out { opacity: 0; transform: translateY(.2em); }
.tagline { margin: 12px 0 0; font-size: 1rem; font-weight: 700; color: var(--muted); }
.pile-hint { margin: -10px 0 0; min-height: 1.2em; text-align: center; font-size: .9rem; font-weight: 700; color: var(--muted); }

.pcard {
  /* Set from the pile's size in app.js, so the whole table scales with the window. */
  --w: var(--pile-card, clamp(108px, 30vw, 200px));
  position: absolute; left: 0; top: 0; width: var(--w); aspect-ratio: 63 / 88;
  transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(var(--s, 1));
  transition: transform .8s var(--ease), opacity .45s;
  perspective: 1000px; z-index: var(--z, 1);
  border: 0; padding: 0; background: none; font: inherit; color: inherit; cursor: pointer;
}
.pcard .flip { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .75s var(--ease); }
.pcard.down .flip { transform: rotateY(180deg); }
.pcard .face { position: absolute; inset: 0; margin: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 14px 30px -8px rgba(0, 0, 0, .8); }
.pcard .face.card { --w: inherit; width: 100%; }
.pcard .face.card.black { box-shadow: inset 0 0 0 max(1.5px, calc(var(--w) * .008)) #fff, 0 14px 30px -8px rgba(0, 0, 0, .8); }
.pcard .back {
  transform: rotateY(180deg);
  font-size: calc(var(--w) * .15); line-height: .98; letter-spacing: -.03em;
}
.pcard .back::after { content: none; }
.pcard.gone { opacity: 0; pointer-events: none; }
/* While the window is being resized the cards follow it exactly instead of gliding. */
.pile.resizing .pcard, .pile.resizing .pcard .flip { transition: none !important; }
.pcard.prompt-card { cursor: default; }
.pcard:focus-visible { outline: none; }
.pcard:focus-visible .front { outline: 3px solid #fff; outline-offset: 4px; }
@media (hover: hover) and (pointer: fine) {
  .pile.dealt .pcard.white-card:hover { transform: translate(var(--x), calc(var(--y) - 22px)) rotate(calc(var(--r) * .3)) scale(1.12); z-index: 35; transition-duration: .25s; }
}

.home-actions { display: grid; gap: 10px; width: 100%; max-width: 440px; margin: 0 auto; padding: 0 20px; }
.home-actions > .btn { width: 100%; }
.join-inline { display: flex; gap: 8px; }
.join-inline input {
  flex: 1; min-width: 0; min-height: 58px; padding: 0 22px; border-radius: 999px;
  background: #000; border: 2px solid var(--faint);
  text-transform: uppercase; letter-spacing: .12em; font-weight: 700; font-size: 1.15rem;
}
.join-inline input:focus { border-color: #fff; }
.join-inline input::placeholder { letter-spacing: normal; text-transform: none; font-weight: 400; color: var(--muted); }
.join-inline .btn { flex: none; min-height: 58px; padding: 0 26px; }
.classic-btn { flex-direction: column; gap: 0; border-radius: 22px; padding: 10px 16px; min-height: 64px; border-color: var(--faint); }
.classic-btn small { font-weight: 400; font-size: .85rem; color: var(--muted); white-space: normal; }
.classic-btn:hover small { color: #444; }
.home-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 16px; margin-top: 6px; }
.home-links button { background: none; border: 0; color: #fff; cursor: pointer; padding: 10px 2px; font-size: .95rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.home-links button:hover { text-decoration: none; }
.fineprint { text-align: center; color: var(--faint); font-size: .78rem; margin: 0; }

/* ---------------------------------------------------------------- forms */
input, textarea, select {
  width: 100%; background: #000; border: 2px solid var(--faint); border-radius: 14px;
  padding: 13px 15px; font-size: 17px; /* 16px+ stops iOS zooming in */
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #fff; }
.center-form { display: grid; gap: 16px; max-width: 440px; margin: 9vh auto 0; }
.center-form label { font-weight: 700; font-size: clamp(2rem, 9vw, 2.8rem); letter-spacing: -.03em; line-height: 1; }
.center-form input { font-size: 1.35rem; font-weight: 700; min-height: 62px; border-radius: 999px; padding: 0 22px; }
.room-hint { margin: 0; color: var(--muted); font-weight: 700; }
.room-hint b { color: #fff; letter-spacing: .08em; }

/* ---------------------------------------------------------------- lobby */
.panel { border: 2px solid var(--line); border-radius: 24px; }
.lobby { display: grid; gap: 26px; padding-top: 12px; }
.lobby-share { text-align: center; padding: 20px 16px; }
.label { margin: 0; color: var(--muted); font-weight: 700; font-size: .85rem; }
.section-title { margin: 0 4px 10px; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.section-title span { color: var(--muted); }
.room-code { font-weight: 700; font-size: clamp(3rem, 16vw, 4.4rem); letter-spacing: .02em; margin: 0 0 4px; font-variant-numeric: tabular-nums; user-select: all; line-height: 1; }
.room-code.small { font-size: 1.8rem; margin: 10px 0 0; text-align: center; }
.invite-url { margin: 0 0 16px; color: var(--muted); font-size: .9rem; word-break: break-all; }
.qr { display: none; justify-content: center; margin: 0 auto 16px; }
.qr.show, .qr.big { display: flex; }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 12px; border-radius: 12px; }
.qr.big svg { width: min(300px, 72vw); height: auto; aspect-ratio: 1; }
.invite { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.invite .wide { grid-column: 1 / -1; }
.invite .btn { width: 100%; }
.player-list { list-style: none; margin: 0 0 26px; padding: 0; border-top: 1px solid var(--line); }
.player-list li {
  display: flex; align-items: center; gap: 12px; min-height: 58px;
  border-bottom: 1px solid var(--line); padding: 8px 4px;
  font-weight: 700; font-size: 1.1rem; animation: slideIn .35s var(--ease) both;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } }
.player-list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list li.away { opacity: .4; }
.tag { font-size: .68rem; font-weight: 700; letter-spacing: .06em; color: #000; background: #fff; border-radius: 999px; padding: 2px 7px; margin-left: 8px; vertical-align: 3px; }
.kick { background: none; border: 0; color: var(--muted); cursor: pointer; width: 40px; height: 40px; border-radius: 50%; font-size: 1rem; }
.kick:hover { background: var(--red); color: #fff; }
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .95rem;
  background: #fff; color: #000; position: relative;
}
.settings { display: grid; gap: 20px; padding: 18px 16px; }
.setting > span { display: block; font-weight: 700; margin-bottom: 8px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 6px 10px; border-radius: 999px;
  background: #000; border: 2px solid var(--faint); cursor: pointer; font-weight: 700; font-size: .95rem; line-height: 1.1;
  transition: background .15s, color .15s, border-color .15s;
}
.seg button.on { background: #fff; color: #000; border-color: #fff; }
.seg button small { display: block; font-weight: 400; font-size: .7rem; opacity: .75; margin-top: 1px; }
#base-seg button, [data-key="judge"] .seg button { border-radius: 18px; }
/* Expansion and pack chips: tap to add or remove. */
.packs { display: flex; flex-wrap: wrap; gap: 6px; }
.pack-group { flex: 1 0 100%; margin: 6px 2px 0; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.pack-group:first-child { margin-top: 0; }
.pack-chip {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 40px; padding: 7px 14px;
  border-radius: 999px; border: 2px solid var(--faint); background: #000; cursor: pointer;
  font-weight: 700; font-size: .9rem; transition: background .15s, border-color .15s, color .15s;
}
.pack-chip small { font-weight: 400; font-size: .72rem; opacity: .7; }
.pack-chip.box { border-color: #888; }
.pack-chip.on { background: var(--hot); border-color: transparent; color: #fff; }
.pack-chip:disabled { cursor: default; }

.deck-size { font-weight: 400; color: var(--muted); margin-left: 6px; }
.licence a, .fineprint a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
/* Setup wizard: one question at a time. */
.setup { padding: 18px 16px 16px; }
.setup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.setup-count { font-size: .85rem; font-weight: 700; color: var(--muted); }
.setup-dots { display: flex; gap: 5px; }
.setup-dots span { width: 22px; height: 5px; border-radius: 3px; background: var(--faint); transition: background .3s; }
.setup-dots span.on { background: var(--hot); }
.setup-step { display: none; }
.setup-step.on { display: block; animation: stepIn .35s var(--ease) both; }
@keyframes stepIn { from { opacity: 0; transform: translateX(24px); } }
.setup-step h3 { margin: 0 0 6px; font-size: clamp(1.6rem, 7vw, 2.1rem); letter-spacing: -.03em; line-height: 1.05; }
.setup-hint { margin: 0 0 14px; color: var(--muted); }
.setup-step h3 + .seg, .setup-step h3 + .packs { margin-top: 14px; }
.choices button { min-height: 54px; font-size: 1.1rem; }
.choices.stack { flex-direction: column; }
.choices.stack button { flex: none; text-align: left; padding: 12px 18px; border-radius: 18px; }
.choices.stack button small { font-size: .82rem; margin-top: 3px; }
.setup-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 20px; }
.setup-nav .btn { flex: 1; max-width: 200px; }
.setup-nav .btn.primary { margin-left: auto; }

/* The rules in a nutshell, for everyone. */
.summary { padding: 16px; }
.summary-by { margin: 0 0 10px; font-weight: 700; }
.summary-list { margin: 0; }
.summary-row { display: flex; align-items: baseline; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.summary-row dt { flex: none; width: 118px; color: var(--muted); font-size: .9rem; }
.summary-row dd { flex: 1; margin: 0; font-weight: 700; }
.summary-row .link-btn { flex: none; font-size: .85rem; color: var(--muted); }
.summary-row.total dd { font-weight: 400; color: var(--muted); }

/* ---------------------------------------------------------------- game: players */
.players-strip {
  flex: none; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 12px 16px 10px;
}
.players-strip::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; align-items: center; gap: 8px;
  border: 2px solid var(--line); border-radius: 999px;
  padding: 2px 12px 2px 2px; font-size: .9rem; font-weight: 700; white-space: nowrap;
  transition: opacity .2s, border-color .2s;
}
.chip .avatar { width: 28px; height: 28px; font-size: .8rem; }
.chip .score { font-variant-numeric: tabular-nums; color: var(--muted); }
.chip.me { border-color: #fff; }
.chip.away { opacity: .35; }
.chip.done .avatar { background: #000; color: #fff; box-shadow: inset 0 0 0 2px #fff; }
.chip.done .avatar::after {
  content: '✓'; position: absolute; right: -5px; bottom: -5px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; color: #000; font-size: .6rem; display: grid; place-items: center; border: 2px solid #000;
}
.chip.czar .avatar::before { content: '👑'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%); font-size: .8rem; }

/* ---------------------------------------------------------------- game: stage */
/* Short content (one black card) sits in the middle of the free space;
   long content (a list of answers) just scrolls from the top. */
#g-main, #c-main { display: flex; flex-direction: column; }
#g-main > .status, #c-main > .status { margin-top: auto; }
#g-main > .stage, #c-main > .stage { margin-bottom: auto; }
#c-main > .banner { flex: none; }
.status { text-align: center; font-weight: 700; margin: 4px 0 16px; min-height: 1.3em; letter-spacing: -.02em; font-size: 1.45rem; line-height: 1.1; }
.status .sub { display: block; color: var(--muted); font-weight: 400; font-size: .95rem; margin-top: 4px; letter-spacing: 0; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* ---------------------------------------------------------------- the hand tray */
/* Cards look dealt, not gridded: each gets its own small tilt and nudge (--tilt, --dx, --dy,
   set per card in app.js so they stay put between re-renders). */
.tray {
  flex: none; display: flex; gap: 10px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-padding: 0 16px;
  padding: 20px 16px 14px; scrollbar-width: none;
  border-top: 1px solid var(--line);
}
.tray::-webkit-scrollbar { display: none; }
.tray:empty { display: none; }
.tray .card {
  --w: min(34vw, 150px);
  flex: none; cursor: pointer; scroll-snap-align: start; user-select: none;
  transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--tilt, 0deg));
  transition: transform .28s var(--ease), box-shadow .28s var(--ease), outline-color .2s, opacity .2s;
  outline: 3px solid transparent; outline-offset: 4px;
}
.tray .card.sel { transform: translateY(-12px) rotate(-1.5deg); outline-color: var(--accent); z-index: 3; }
.tray .card .num {
  position: absolute; top: calc(var(--w) * .06); right: calc(var(--w) * .06); width: 1.6em; height: 1.6em; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center; font-size: calc(var(--w) * .075);
}
.tray .card.writein {
  background: #000; color: #fff; box-shadow: none; border: 2px dashed rgba(255, 255, 255, .5);
  display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; text-align: center;
  padding-bottom: calc(var(--w) * .085);
}
.tray .card.writein::after { content: none; }
.tray .card.writein small { color: var(--muted); font-weight: 400; font-size: .8em; }
.tray.dim { opacity: .3; pointer-events: none; }
.tray .card { font-size: max(10.5px, calc(var(--w) * .085)); }

/* "Fit" mode (set by app.js when there's room): every card on show at once, wrapped into
   1-3 rows and sized to fit, instead of a sideways-scrolling strip. */
.tray.fit {
  flex-wrap: wrap; justify-content: center; align-content: center; gap: 14px;
  overflow: visible; scroll-snap-type: none; padding: 18px 20px;
}
.tray.fit .card { --w: var(--fit-w); scroll-snap-align: none; }

/* Wide, short windows (laptops): black card on the left, the whole hand on the right,
   so everything fits without scrolling. Switched on by app.js. */
.screen.app.on.side {
  display: grid; max-width: 1440px;
  grid-template-columns: minmax(0, 42fr) minmax(0, 58fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "bar bar" "strip strip" "main hand" "dock dock";
}
.screen.side > .bar { grid-area: bar; }
.screen.side > .players-strip { grid-area: strip; }
.screen.side > .scroll { grid-area: main; }
.screen.side > .tray-wrap { grid-area: hand; align-self: center; }
.screen.side > .dock { grid-area: dock; }
.screen.side .tray { border-top: 0; }

/* Scroll mode: arrows show which way there are more cards. */
.tray-wrap { position: relative; flex: none; }
.tray-arrow {
  position: absolute; top: calc(50% + 4px); transform: translateY(-50%); z-index: 8;
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; padding: 0 0 4px;
  background: var(--hot); color: #fff; border: 0; cursor: pointer;
  font-size: 2rem; font-weight: 700; line-height: 1;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .7); animation: arrowIn .3s var(--ease) both;
}
.tray-arrow.left { left: 8px; }
.tray-arrow.right { right: 8px; animation: arrowIn .3s var(--ease) both, nudge 1.6s 1s ease-in-out 2; }
.tray-arrow:active { transform: translateY(-50%) scale(.92); }
@keyframes arrowIn { from { opacity: 0; } }
@keyframes nudge { 50% { transform: translate(5px, -50%); } }
.tray .card.deal { animation: deal .65s var(--ease) backwards; }
@keyframes deal {
  0% { transform: translateY(70%) rotate(12deg); opacity: 0; }
  100% { transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--tilt, 0deg)); opacity: 1; }
}

/* ---------------------------------------------------------------- judging and reveal */
.answers { display: grid; gap: 14px; width: 100%; }
/* Answers are black cards with the white cards' words filled in. They grow to fit instead of keeping print proportions. */
.card.answer {
  --w: 340px; width: 100%; max-width: none; aspect-ratio: auto; min-height: 150px;
  font-size: 1.25rem; padding: 20px 20px 52px;
  transition: transform .2s var(--ease), box-shadow .2s, opacity .2s;
}
.card.answer::after { font-size: 11px; left: 20px; bottom: 16px; max-width: 55%; }
.card.answer.pickable { cursor: pointer; }
.card.answer.pickable:active { transform: scale(.98); }
.card.answer.sel { box-shadow: 0 0 0 3px var(--accent), 0 16px 34px -12px rgba(255, 61, 110, .55); }
.card.answer.sel::before { content: 'Your pick'; position: absolute; top: -12px; right: 16px; background: var(--hot); color: #fff; border: 0; font-size: .75rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; }
.card.answer.mine { opacity: .4; }
.answer .meta { position: absolute; right: 20px; bottom: 16px; font-size: .78rem; font-weight: 700; color: var(--muted); }

/* The winning card: one black card with the answers filled in, glowing a little. */
.card.prompt.winner-card {
  --w: 360px; width: 100%; max-width: 520px; aspect-ratio: auto; min-height: 220px;
  font-size: clamp(1.35rem, 6vw, 1.9rem); padding: 24px 24px 60px;
  box-shadow: inset 0 0 0 2px rgba(255, 61, 110, .7), 0 30px 60px -20px rgba(255, 61, 110, .45);
  animation: comboIn .7s var(--spring) both;
}
.card.prompt.winner-card::after { font-size: 11px; left: 24px; bottom: 20px; }
@keyframes comboIn { from { opacity: 0; transform: translateY(40%) rotate(-20deg) scale(.7); } }
.winner-name { font-size: clamp(1.8rem, 8vw, 2.6rem); font-weight: 700; text-align: center; margin: 0; letter-spacing: -.03em; line-height: 1; }
.winner-name small { display: block; font-size: 1rem; color: var(--muted); font-weight: 400; letter-spacing: 0; margin-top: 6px; }
.also { width: 100%; }
.also h3 { font-size: 1.6rem; letter-spacing: -.02em; margin: 24px 0 12px; }
.scores { list-style: none; padding: 0; margin: 0; width: 100%; max-width: 460px; border-top: 1px solid var(--line); }
.scores li { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 12px 4px; font-weight: 700; font-size: 1.1rem; }
.scores li .grow { flex: 1; }
.scores li b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.scores li.top .grow::after { content: ' 🏆'; }
.trophy { font-size: 4.4rem; line-height: 1; animation: comboIn .8s var(--spring) both; }
/* Confetti is tiny playing cards. */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -40px; width: 20px; height: 28px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(115vh) rotate(540deg); } }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--hot); color: #fff; font-weight: 700;
  border-radius: 18px; padding: 10px 10px 10px 18px; margin: 0 0 14px;
  animation: comboIn .5s var(--spring) both;
}
.banner .btn { background: #fff; color: #000; border-color: #fff; }

/* ---------------------------------------------------------------- dialogs: bottom sheets on phones */
dialog {
  background: #000; color: #fff; border: 2px solid #fff; border-bottom: 0;
  width: 100%; max-width: 100%; max-height: 88dvh; overflow: auto;
  margin: auto 0 0; border-radius: 28px 28px 0 0;
  padding: 26px 20px calc(20px + var(--safe-b));
}
dialog[open] { animation: sheetUp .32s var(--ease); }
@keyframes sheetUp { from { transform: translateY(40%); opacity: 0; } }
dialog::backdrop { background: rgba(0, 0, 0, .7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog h3 { margin: 0 0 14px; font-size: 1.9rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.05; }
dialog h4 { margin: 20px 0 6px; font-size: 1.15rem; }
dialog p, dialog li { line-height: 1.45; }
dialog ol, dialog ul { padding-left: 1.2em; }
dialog li { margin-bottom: 8px; }
dialog label { display: block; font-weight: 700; margin: 12px 0 6px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dlg-actions .btn { flex: 1; }
.menu-list { display: grid; gap: 8px; }
.menu-list .btn { width: 100%; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; cursor: pointer; border-bottom: 1px solid var(--line); margin: 0; font-weight: 700; }
.check input { width: 22px; height: 22px; flex: none; accent-color: #fff; margin-top: 1px; }

.toast {
  position: fixed; left: 50%; top: calc(12px + var(--safe-t)); transform: translateX(-50%);
  background: var(--hot); color: #fff; font-weight: 700; padding: 12px 20px; border-radius: 999px;
  z-index: 70; width: max-content; max-width: calc(100vw - 32px); text-align: center;
  box-shadow: 0 10px 30px -6px rgba(255, 61, 110, .55); animation: toastIn .3s var(--ease) both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -12px); } }
.offline { position: fixed; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); background: #c98a00; color: #fff; font-weight: 700; padding: 6px 14px; border-radius: 999px; z-index: 70; font-size: .85rem; }

/* ---------------------------------------------------------------- bigger screens */
@media (min-width: 600px) {
  dialog { margin: auto; width: min(560px, calc(100vw - 32px)); border-radius: 28px; border-bottom: 2px solid #fff; padding: 28px; }
  dialog[open] { animation: comboIn .3s var(--ease); }
  .dlg-actions .btn { flex: none; }
  .answers { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
}
@media (min-width: 820px) {
  .lobby { grid-template-columns: 1fr 1fr; align-items: start; }
  .lobby-share { position: sticky; top: 0; padding: 30px; }
  .qr { display: flex; }
  #btn-qr-toggle { display: none; }
  .scroll { padding: 8px 24px 24px; }
  .dock { justify-content: center; }
  .dock .grow { flex: 0 1 380px; }
  .players-strip { justify-content: center; }
  /* The table keeps its shape as the window is resized, so the cards scale with the width. */
  .pile { flex: none; min-height: 0; height: clamp(320px, 40vw, 72dvh); }
  /* The title scales with the table too, so the whole scene resizes like one picture. */
  .pile-title { left: 2.8vw; top: 2.2vw; }
  .logo { font-size: 5.3vw; }
  .tagline { font-size: max(12px, 1.15vw); margin-top: .8vw; }
}
@media (hover: hover) and (pointer: fine) {
  /* Pick a card up off the table: it rises, straightens up and grows over its neighbours. */
  .tray.fit .card:hover {
    transform: translate(var(--dx, 0), calc(var(--dy, 0px) - 26px)) rotate(0deg) scale(1.16);
    z-index: 5; box-shadow: 0 30px 50px -12px rgba(0, 0, 0, .95);
    transition-duration: .22s;
  }
  .tray.fit .card.sel:hover { transform: translateY(-26px) rotate(0deg) scale(1.16); }
  .card.answer.pickable:hover { transform: translateY(-4px) rotate(-.6deg); }
}
@media (max-height: 640px) {
  .status { font-size: 1.2rem; margin-bottom: 10px; }
  .tray .card { --w: min(34vw, 140px); }
}

/* ---------------------------------------------------------------- TV mode */
body.tv { font-size: 20px; }
body.tv .screen { max-width: 1600px; }
body.tv .bar .icon-btn, body.tv .dock, body.tv .tray, body.tv .invite, body.tv .invite-url { display: none; }
body.tv .card.prompt { --w: clamp(300px, 34vw, 520px); }
body.tv .answers { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
body.tv .card.answer { font-size: 1.6rem; }
body.tv .card.prompt.winner-card { max-width: 900px; font-size: clamp(2rem, 4vw, 3.2rem); }
body.tv .tv-join { position: fixed; right: 20px; bottom: 20px; background: #fff; color: #000; border-radius: 22px; padding: 12px 20px; font-weight: 700; text-align: center; z-index: 10; }
body.tv .tv-join b { display: block; font-size: 1.9rem; letter-spacing: .04em; }
body.tv #lobby .qr { display: flex; }
body.tv #lobby .qr svg { width: 340px; height: 340px; }
body.tv .kick, body.tv #lobby-setup { display: none; }
body.tv .lobby-share::after { content: 'Scan to join, or type the code on your phone.'; display: block; color: var(--muted); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* A button that looks like an inline link (e.g. "Send us feedback" in About). */
.link-btn { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { text-decoration: none; }
