:root {
  --felt: #0f5132;
  --felt-dark: #0a3522;
  --panel: rgb(0 0 0 / 0.28);
  --panel-border: rgb(255 255 255 / 0.12);
  --ink: #f5f3ea;
  --muted: rgb(245 243 234 / 0.65);
  --accent: #f2c14e;
  --accent-ink: #2a2000;
  --danger: #ff8a80;
  --ok: #8be28b;
  /* The help for a new player (hints.js): the card winning the round and the dica. Blue,
     so it is never mistaken for the manilha (accent) or for who took the round (ok). */
  --hint: #8ecbff;
  --card-bg: #fffdf6;
  --card-ink: #1b1b1b;
  --card-red: #c0262d;
  --card-w: 64px;
  --card-h: 92px;
  /* How wide the page is: the header, the content and the footer all keep to it. The home
     page widens it on a desktop, where its panels sit side by side (see "home"). */
  --page-w: 920px;
}

* { box-sizing: border-box; }

/* `hidden` must win over component display rules (grid/flex). */
[hidden] { display: none !important; }

html { background: var(--felt-dark); }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, var(--felt), var(--felt-dark) 75%) no-repeat var(--felt-dark);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.site-header {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 14px 16px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* The links take a line of their own rather than making the page wider than the screen.
     A page wider than the screen carries everything anchored to its right edge out of
     sight with it — above all the 🔊/😀 column, which is fixed to the right and was out of
     reach on a 320px phone (no chat, and nothing a player could do about it). Letting the
     header wrap is what keeps that from happening on any phone, whatever its fonts measure:
     where the three links fit beside the logo nothing moves, and where they don't the top
     grows a line instead of the page growing sideways. */
  flex-wrap: wrap;
}
/* On its own line the nav keeps to the right, under the links it had beside the logo. */
.site-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-left: auto; }
.site-nav a { color: var(--ink); text-decoration: none; font-weight: 600; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--panel-border); white-space: nowrap; }
.site-nav a:hover { border-color: var(--accent); color: var(--accent); }
.logo { color: var(--ink); text-decoration: none; font-size: 1.8rem; font-weight: 800; letter-spacing: 0.01em; }
.logo span { color: var(--accent); }
/* Phones: smaller logo and links, so the three of them fit on one line next to the logo on
   a 360px screen. Narrower than that (or with wider fonts than these measure) they wrap. */
@media (max-width: 520px) {
  .site-header { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .site-nav { gap: 6px; }
  .site-nav a { padding: 5px 8px; font-size: 0.85rem; }
  .logo { font-size: 1.5rem; }
}

/* Bottom padding keeps the end of the page scrollable clear of the 😀 reactions button. */
main { max-width: var(--page-w); margin: 0 auto; padding: 8px 16px 24px; }

h2 { margin: 0 0 12px; font-size: 1.15rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
}
.panel.center { text-align: center; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); }

/* 404 / error page (views/error.pug). */
.error-page { max-width: 420px; margin: 48px auto; }

label { display: grid; gap: 4px; margin-bottom: 12px; font-size: 0.9rem; color: var(--muted); }
input {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgb(255 255 255 / 0.92);
  color: #111;
}
input[name="code"] { text-transform: uppercase; letter-spacing: 0.2em; font-weight: 700; }

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.small { padding: 6px 10px; font-size: 0.85rem; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--panel-border); }
.btn:focus-visible, .card.playable:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ---------- buy me a coffee ---------- */

/* Extra bottom room so the fixed 😀/🔊 buttons in games never cover the link. */
.site-footer { text-align: center; padding: 8px 16px 96px; }
.coffee-link { color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.coffee-link:hover { color: var(--accent); }
.pix { margin: 12px auto 0; display: grid; justify-items: center; gap: 6px; }
.pix img {
  display: block;
  width: 140px;
  height: 140px;
  padding: 10px;
  box-sizing: content-box;
  background: #fff;
  border-radius: 10px;
}
.pix figcaption { font-size: 0.85rem; font-weight: 700; color: var(--accent); }
/* The home page's two cards that are a whole link — the tutorial and the coffee — have the
   same shape: an icon, a title and a line explaining it. */
.home-card {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  border-color: rgb(242 193 78 / 0.4);
}
.home-card:hover { border-color: var(--accent); background: rgb(242 193 78 / 0.08); }
.home-card strong { display: block; }
.home-card .muted { display: block; font-size: 0.85rem; }
.home-card-icon { font-size: 2rem; line-height: 1; }

/* ---------- home ---------- */

.home { max-width: 420px; margin: 0 auto; }
.tagline { text-align: center; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.stat {
  display: grid;
  justify-items: center;
  padding: 10px 8px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  text-align: center;
}
.stat strong { font-size: 1.6rem; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { font-size: 0.85rem; color: var(--muted); }

/* Desktop: one 420px column in the middle of a wide screen looks cramped, so the panels go
   side by side and fill the page instead — the counters next to the tutorial card, the
   character picker next to the two forms. Below this width the wrappers in index.pug are
   plain blocks, so the page is the same single column as on a phone. The picker's sideways
   scroll is switched off up here too (see "characters"), because it has room to wrap. */
@media (min-width: 900px) {
  /* Wider than the rest of the site, header and all, so the two columns have room. Where
     :has() is missing the page keeps its usual width and the columns share that instead. */
  body:has(.home) { --page-w: 1120px; }
  .home { max-width: none; }
  .tagline { font-size: 1.1rem; margin: 4px 0 16px; }

  /* The counters keep a readable width; the tutorial card takes whatever is left. */
  .home-top { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
  .home-top .stats { flex: 1 1 280px; max-width: 420px; margin: 0; }
  .home-top .stat { align-content: center; }
  .home-top .home-card { flex: 2 1 380px; margin: 0; }

  /* The forms only need room for a name and a code; the picker gets the rest. */
  .home-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 340px); gap: 20px; align-items: start; }

  /* With a column to itself the picker shows bigger cards, so the art is readable and the
     two columns end up about the same height (see "characters" for the 76px phone row). */
  #character-panel .character-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
  #character-panel .character-option img, #character-panel .character-random { max-width: none; }
  #character-panel .character-random { font-size: 2.6rem; }
  #character-panel .character-name { font-size: 0.85rem; }
}

/* ---------- lobby ---------- */

.lobby { margin: 4px 0 0; }
/* The lobby's table: places to pick (game.js renderLobby). */
.lobby-center { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.lobby-center .tag { margin: 0; }
.lobby-hint { margin: 0 0 12px; font-size: 0.9rem; }
.seats .player.place.empty-seat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-height: 56px; }
.seats .player.place.empty-seat:hover { border-color: var(--accent); }
.place .sit { border: 0; background: none; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; padding: 6px 4px; width: 100%; }
.place .sit:hover, .place .sit:focus-visible { color: var(--accent); }
.place-host { justify-content: center; min-height: 0; margin: 0; }
.place-host .remove { margin-left: 0; }
.seats .player.place .remove { font-size: 1.1rem; }
.share { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code { font-size: 1.2rem; letter-spacing: 0.15em; color: var(--accent); }
.tag {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.15);
  color: var(--ink);
  margin-left: 4px;
}
.tag.watching { background: rgb(255 255 255 / 0.15); color: var(--ink); }
.tag.icon { background: none; padding: 0 1px; font-size: 1rem; line-height: 1; }
.tag.pe { background: rgb(139 226 139 / 0.2); color: var(--ok); }
.tag.bot { background: rgb(242 193 78 / 0.25); color: var(--accent); }
.lobby-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ready-panel { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: rgb(255 255 255 / 0.05); }
.ready-panel.starting { color: var(--ok); padding-bottom: 14px; }
.autoplay-toggle { display: flex; justify-content: center; align-items: center; gap: 6px; margin: -6px auto 14px; width: fit-content; padding: 4px 12px; border-radius: 999px; font-size: 0.9rem; color: var(--muted); cursor: pointer; user-select: none; }
.autoplay-toggle.on { color: var(--accent); background: rgb(242 193 78 / 0.12); }
/* The two switches under the table ("Jogar por mim", "Dicas") share a line and wrap on a
   phone, so neither of them pushes the other off the screen. */
.play-toggles { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 10px; }
.play-toggles .autoplay-toggle, .play-toggles .hints-toggle { margin: -6px 0 14px; }
.hints-toggle { display: flex; justify-content: center; align-items: center; gap: 6px; width: fit-content; padding: 4px 12px; border-radius: 999px; font-size: 0.9rem; color: var(--muted); cursor: pointer; user-select: none; }
.hints-toggle.on { color: var(--hint); background: rgb(142 203 255 / 0.12); }
.tag.auto { background: rgb(242 193 78 / 0.2); color: var(--accent); font-size: 0.7rem; padding: 0 5px; }
.tag.ready { background: rgb(139 226 139 / 0.18); color: var(--ok); }
.join-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
/* Empty seats (vagas): a dashed outline where someone can sit. */
.seats .player.empty-seat { background: rgb(8 30 20 / 0.55); border: 2px dashed rgb(255 255 255 / 0.28); color: var(--muted); }
.seat-kind { border: 0; background: none; color: var(--ink); font-size: 0.85rem; padding: 0 4px; cursor: pointer; opacity: 0.6; }
.seat-kind:hover { opacity: 1; }
.host-seat-bar { display: flex; justify-content: center; margin: -6px 0 12px; }
.remove {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}
.remove:hover { color: var(--danger); }
.replace-bot, .make-host {
  margin-left: auto;
  border: 0;
  background: none;
  font-size: 0.95rem;
  padding: 0 4px;
  cursor: pointer;
  opacity: 0.55;
}
.replace-bot:hover, .make-host:hover { opacity: 1; }
.make-host + .remove, .make-host + .replace-bot, .player-tags .make-host { margin-left: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: rgb(255 255 255 / 0.25); flex: none; }
.dot.on { background: var(--ok); }

/* ---------- table ---------- */

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.hand-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bid-counter {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  border: 1px solid var(--panel-border);
  background: rgb(255 255 255 / 0.08);
  white-space: nowrap;
}
.bid-counter.match { color: var(--ok); border-color: var(--ok); background: rgb(139 226 139 / 0.15); }
.bid-counter.differ { color: var(--danger); border-color: var(--danger); background: rgb(255 138 128 / 0.15); }

.players {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.player {
  position: relative; /* for the bid pop */
  background: var(--panel);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
}
.player.me { background: rgb(255 255 255 / 0.08); }

/* A bid just made: the number grows and fades over the card. */
.bid-pop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 2px 10px rgb(0 0 0 / 0.6);
  pointer-events: none;
  z-index: 2;
  animation: bid-pop 1.2s ease-out both;
}
@keyframes bid-pop {
  0% { transform: scale(0.4); opacity: 0; }
  20% { transform: scale(1.15); opacity: 1; }
  45% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.9); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bid-pop { animation-name: fade-reaction; }
}
.player.turn { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(242 193 78 / 0.2); }
.player.out { opacity: 0.45; }
/* Already played this round: faded, so who is still to play stands out. */
.player.played { opacity: 0.55; filter: saturate(0.6); transition: opacity 0.25s, filter 0.25s; }
.played-tag { color: var(--ok); font-weight: 700; }
.player-name { display: flex; align-items: baseline; gap: 6px; font-weight: 700; min-width: 0; }
.player-name .dot { flex: none; align-self: center; }
.player-name .name { min-width: 0; overflow-wrap: normal; word-break: normal; }
/* Words never break; one too long for the card is cut with "…" (full name on hover). */
.player-name .word { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.player-tags { display: flex; flex-wrap: wrap; gap: 4px; min-height: 1.35rem; margin: 2px 0 2px 14px; }
.player-tags .tag { margin-left: 0; }
.player-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.lives { position: relative; display: inline-flex; gap: 2px; color: #ff6b6b; letter-spacing: 1px; }
.life { display: inline-block; }
.life.lost { color: rgb(255 255 255 / 0.2); }

/* A life just lost: the heart pops red, shakes and fades to grey… */
.life.breaking { animation: heart-break 1.8s ease-out both; }
@keyframes heart-break {
  0% { color: #ff6b6b; transform: scale(1); }
  15% { color: #ff3b3b; transform: scale(1.7); }
  25% { transform: scale(1.4) rotate(-14deg); }
  35% { transform: scale(1.4) rotate(14deg); }
  45% { transform: scale(1.2) rotate(-8deg); }
  60% { color: #ff6b6b; transform: scale(1) rotate(0); }
  100% { color: rgb(255 255 255 / 0.2); transform: scale(1); }
}
/* …and a "−1 ♥" floats up beside the hearts, clear of the name and tags (positioned, so
   the card doesn't move). */
.life-loss {
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 6px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #ff6b6b;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgb(0 0 0 / 0.6);
  pointer-events: none;
  animation: life-loss-float 1.8s ease-out both;
}
@keyframes life-loss-float {
  0% { transform: translateY(4px) scale(0.6); opacity: 0; }
  15% { transform: translateY(0) scale(1.25); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translateY(-22px) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .life.breaking { animation: none; }
  .life-loss { animation-name: fade-reaction; }
}

/* ---------- the round table ----------
   Players sit on the rim, each card lands on the felt in front of whoever played it, and
   the vira and the round sit in the middle. Places come from --x/--y (unit circle, set by
   seatSpot() in game.js), scaled by the radii below. */
.round-table {
  --seat-rx: 41%;
  --seat-ry: 39%;
  --play-rx: 21%;
  --play-ry: 19%;
  --seat-w: 150px;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  /* The box is the felt and the cards on it; the places lean outwards from its rim, so the
     page leaves a place's height for them above and below (see .seats .player).
     A place's height is the room the lean can need, so this covers every table shape and
     screen. Don't trade it for a smaller fixed margin: one that doesn't cover the lean puts
     the top place inside the bar with the code and the hand's number, over its text — which
     is how it broke once. tests/ui/checks.mjs assertSeatsClearOfBar watches it. */
  margin: var(--seat-h) 0;
}
/* Up to four: a lower table, cards further from the middle. Six: the side cards need room. */
.round-table.n2, .round-table.n3, .round-table.n4 { aspect-ratio: 16 / 9; --play-ry: 23%; }
.round-table.n6 { --play-ry: 21%; }
/* Seven or eight: a rectangle, the players down the sides, each card just inside its seat. */
.round-table.rect { aspect-ratio: 16 / 11; --seat-rx: 41%; --seat-ry: 40%; --play-rx: 25%; --play-ry: 30%; }
.round-table.rect .felt { inset: 7% 13%; border-radius: 28px; }
.round-table.rect .table-center { max-width: 26%; }
.felt {
  position: absolute;
  inset: 10% 11%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, #1b7a4f, #0d4d30 72%);
  border: 10px solid #6b4423;
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / 0.25), inset 0 0 46px rgb(0 0 0 / 0.45), 0 10px 28px rgb(0 0 0 / 0.45);
}
.table-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 6px;
  max-width: 30%;
  text-align: center;
  font-size: 0.85rem;
}
.vira { display: flex; align-items: center; gap: 8px; }
.center-label { display: grid; gap: 2px; }
.round-table .trick { position: absolute; inset: 0; pointer-events: none; }
.round-table .trick .play {
  position: absolute;
  left: calc(50% + var(--x) * var(--play-rx));
  top: calc(50% + var(--py, var(--y)) * var(--play-ry));
  transform: translate(-50%, -50%);
  z-index: 1;
}
.round-table .trick .play-name { text-shadow: 0 1px 3px rgb(0 0 0 / 0.6); }
/* The list covers the whole table; only the places in it take clicks. */
.seats { position: absolute; inset: 0; margin: 0; display: block; pointer-events: none; }
/* A place leans outwards: --seat-ry is its *inner* edge, not its middle, so the card that
   lands in front of it (--play-ry, always inside that) is never under it. --y scales the
   lean, so the places down the sides lean less than the ones at the top and the bottom.
   The table's margins (above) make room for the half that now hangs outside the box. */
.seats .player {
  position: absolute;
  width: var(--seat-w);
  left: clamp(calc(var(--seat-w) / 2), calc(50% + var(--x) * var(--seat-rx)), calc(100% - var(--seat-w) / 2));
  top: calc(50% + var(--y) * var(--seat-ry));
  transform: translate(-50%, calc(-50% + var(--y) * 50%));
  background: rgb(8 30 20 / 0.92);
  border-color: rgb(255 255 255 / 0.1);
  pointer-events: auto;
  z-index: 2;
}
.seats .player.me { background: rgb(30 60 45 / 0.95); }
.seat-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; min-height: 1.4rem; margin: 2px 0; }
.seat-row .player-tags { display: inline-flex; flex-wrap: wrap; gap: 2px; min-height: 0; margin: 0; }
.seats .player-stats { gap: 8px; font-size: 0.85em; }
.legend strong.ok { color: var(--ok); }
.legend strong.bad { color: var(--danger); }
.legend .bid-meter { display: inline-flex; margin: 0; }
/* Bid meter: won/bid in big type, a pip per round bid, and a note (falta 1 · feito · passou). */
.bid-meter { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; margin-top: 2px; }
.bid-score { font-size: 1.5em; line-height: 1; font-variant-numeric: tabular-nums; }
.bid-score strong { font-weight: 800; }
.bid-score .of { color: var(--muted); font-weight: 600; }
.bid-pips { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.pip { width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.55); }
.pip.won { background: var(--accent); box-shadow: none; }
.pip.extra { background: var(--danger); box-shadow: none; }
.bid-note { font-size: 0.85em; font-weight: 700; color: var(--accent); white-space: nowrap; }
.bid-meter.hit .bid-note, .bid-meter.hit .bid-score strong { color: var(--ok); }
.bid-meter.over .bid-note, .bid-meter.over .bid-score strong { color: var(--danger); }
.bid-meter.waiting .bid-score { color: var(--muted); }
.bid-meter.waiting .bid-note { color: var(--muted); font-weight: 400; }
.hand-count { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; color: var(--muted); font-size: 0.85em; font-variant-numeric: tabular-nums; }
.mini-back { width: 9px; height: 13px; border-radius: 2px; background: repeating-linear-gradient(45deg, #b3262d 0 2px, #8e1c22 2px 4px); box-shadow: 0 0 0 1px rgb(255 255 255 / 0.7); }
.seats .player.turn { border-color: var(--accent); }
/* Truco paulista: your side and the other side (spectators: the two teams). */
.seats .player.ally, .seats .player.team0 { box-shadow: inset 4px 0 0 rgb(120 190 255 / 0.85); }
.seats .player.foe, .seats .player.team1 { box-shadow: inset 4px 0 0 rgb(255 138 128 / 0.85); }
.seats .player.turn.ally, .seats .player.turn.foe, .seats .player.turn.team0, .seats .player.turn.team1 {
  box-shadow: 0 0 0 3px rgb(242 193 78 / 0.25);
}
.rounds { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 8px; }
.round { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; }
.round-label { color: var(--muted); font-size: 0.85rem; }
.round-cards { display: flex; flex-wrap: wrap; gap: 6px; }
.round-cards .play { opacity: 0.6; }
.round-cards .play.winner { opacity: 1; }
/* Cards cleaned from the table by an equal card: faded and struck through. */
.play.cancelled, .example-item.cleaned { opacity: 0.45 !important; }
.play.cancelled .card::after, .example-item.cleaned .card::after {
  content: '';
  position: absolute;
  left: -4px;
  right: -4px;
  top: 50%;
  height: 2px;
  background: var(--danger);
  transform: rotate(-35deg);
}
.cleaned-note { color: var(--accent); }

/* A round that just ended, held on the table with its result. */
.round-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); }
.round-banner strong { color: var(--ok); }
.round-banner strong.nobody { color: var(--accent); }
.round-banner strong.lost { color: var(--danger); }
/* Pinned to the bottom edge so it never takes a line (long results wrap on phones). */
.round-banner { position: relative; display: grid; justify-items: center; gap: 2px; padding-bottom: 6px; }
.countdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--ok);
  transform-origin: left;
  animation: countdown linear forwards;
}
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .countdown { animation: none; opacity: 0.5; } }
.round-result { font-size: 0.85rem; color: var(--ok); text-align: right; }
.round-result.cancelled { color: var(--muted); font-style: italic; }
.card.small { --card-w: 38px; --card-h: 54px; border-radius: 6px; }
.card.small .corner { font-size: 0.8rem; --rank-y: 2px; --rank-x: 4px; }
.card.small .suit { font-size: 1.2rem; }
.round-cards .play-name { font-size: 0.7rem; max-width: 48px; }
.play { display: grid; justify-items: center; gap: 4px; }
.play.winner .card { box-shadow: 0 0 0 3px var(--ok); }
/* Winning the round *so far* (hints.js): a blue ring while the round is still open. It
   gives way to the green one the moment the round is taken. */
.play.leading .card { box-shadow: 0 0 0 3px var(--hint); }

/* A card just played flies onto the table from its player's place (--x/--y, see the round
   table); your own comes up from your hand. --play-delay continues it across re-renders. */
.play.just-played .card {
  --from-x: calc(var(--x, 0) * 110px);
  --from-y: calc(var(--y, -0.8) * 110px);
  --from-rot: calc(var(--x, 0) * 14deg - 4deg);
  animation: card-in 420ms cubic-bezier(0.2, 0.8, 0.25, 1.15) both;
  animation-delay: var(--play-delay, 0ms);
}
.play.just-played.from-me .card { --from-x: 0px; --from-y: 160px; --from-rot: 10deg; }
.play.just-played .play-name { animation: fade-in 420ms ease-out both; animation-delay: var(--play-delay, 0ms); }
@keyframes card-in {
  0% { transform: translate(var(--from-x, 0px), var(--from-y)) rotate(var(--from-rot)) scale(0.85); opacity: 0; }
  60% { opacity: 1; }
  /* Lands already at its resting angle on the table (--rest-rot), no turn afterwards. */
  100% { transform: translateY(0) rotate(var(--rest-rot, 0deg)) scale(1); opacity: 1; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .play.just-played .card, .play.just-played .play-name { animation: none; }
}
.play-name { font-size: 0.8rem; color: var(--muted); max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The help for a new player, under the status: who is winning the round and the dica.
   Quieter than the status line — it is there to be read, not to be obeyed. */
.hint-bar { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 14px; margin: -4px 0 10px; font-size: 0.95rem; color: var(--muted); text-align: center; }
.hint-leading strong { color: var(--hint); }
.hint-tip strong { color: var(--hint); }
.status { text-align: center; font-size: 1.1rem; font-weight: 700; margin: 12px 0; }
.game-over-actions, .only-bots-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin: 0 0 12px; }
.game-over-actions p, .only-bots-actions p { margin: 0; width: 100%; text-align: center; }
.status.mine { color: var(--accent); }
/* Turn timer under the status: empties over turnTimeoutMs, turning red near the end. */
.turn-timer { height: 4px; max-width: 220px; margin: -6px auto 12px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.turn-timer span { --bar: var(--muted); display: block; height: 100%; transform-origin: left; animation: turn-timer linear both; }
.turn-timer.mine span { --bar: var(--accent); }
@keyframes turn-timer {
  0% { transform: scaleX(1); background: var(--bar); }
  65% { background: var(--bar); }
  100% { transform: scaleX(0); background: var(--danger); }
}
/* The bar still has to empty — it is the warning that a bot is about to play for you — so
   it isn't switched off like the rest; it drops in five steps instead of sliding for the
   whole turn, which says the same thing without the constant movement. */
@media (prefers-reduced-motion: reduce) {
  .turn-timer span { animation-timing-function: steps(5, end); }
}

.bids { text-align: center; }
.bid-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0 6px; }
.btn.bid { min-width: 48px; font-size: 1.1rem; }
/* The bid the dica points at, marked like the card it would play. */
.btn.bid.hinted { outline: 3px solid var(--hint); outline-offset: 2px; }

.hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px 0; }
.hand:not(.active) .card { filter: saturate(0.85); }
/* The card the dica points at: a blue ring, the same blue as the card winning the round.
   Nothing moves — it is a suggestion, and the player picks whichever card they want. */
.hand .card.hinted { outline: 3px solid var(--hint); outline-offset: 2px; }
/* Pré-seleção (preselect.js): it isn't your turn yet, but the cards already take a click
   that chooses one for the turn to come. They are not `playable` — that class means a
   click plays the card — so the pointer, the focus ring and the lift are asked for here.
   The chosen card keeps its colour and the fan lifts it out of the hand (further down),
   so a glance says which card goes down the moment the turn arrives. Its ring is dashed
   and neither gold nor blue: it isn't played yet (like the encoberta toggle), solid gold
   is the manilha and blue is the dica. */
.hand.choosing .card { cursor: pointer; transition: transform 0.12s ease; }
.hand.choosing .card:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.hand.choosing .card.chosen { filter: none; outline: 3px dashed var(--ink); outline-offset: 2px; }

.last-hand summary { cursor: pointer; font-weight: 700; }
.last-hand table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.9rem; }
.last-hand th, .last-hand td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--panel-border); }
.table-scroll { overflow-x: auto; }
.history td.missed .cost { color: var(--danger); font-weight: 700; }
.history td.hit .cost { color: var(--ok); }
.history th, .history td { white-space: nowrap; }
.history-legend { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.85rem; display: grid; gap: 2px; }
.history-legend li { display: grid; grid-template-columns: 3.4em 1fr; gap: 8px; }
.history-legend b.hit { color: var(--ok); }
.history-legend b.missed { color: var(--danger); }

/* ---------- cards ---------- */

.card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--card-ink);
  border: 0;
  padding: 0;
  font: inherit;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.4);
  display: grid;
  place-items: center;
  flex: none;
}
/* Each corner is the rank with its suit in small right under it — a real card's index, and
   what a card half covered by the one in front of it (the fan on a phone) has left to show.
   The bottom-right one is the same thing turned upside down. Sizes set the corner's own
   font-size and --rank-y / --rank-x, which move both corners together. */
.card .corner {
  position: absolute; top: var(--rank-y, 4px); left: var(--rank-x, 6px);
  display: grid; justify-items: center; line-height: 1;
  font-size: 1.05rem;
}
.card .corner.bottom {
  top: auto; left: auto; bottom: var(--rank-y, 4px); right: var(--rank-x, 6px);
  transform: rotate(180deg);
}
.card .corner .rank { font-weight: 800; font-size: 1em; line-height: 1; }
.card .corner .mini { font-size: 0.72em; line-height: 1; margin-top: 0.08em; }
.card .suit { font-size: 2rem; line-height: 1; }
.card.red { color: var(--card-red); }
.card.manilha { box-shadow: 0 0 0 3px var(--accent), 0 2px 6px rgb(0 0 0 / 0.4); }
.card.playable { cursor: pointer; transition: transform 0.12s ease; }
.card.playable:hover { transform: translateY(-8px); }

/* ---------- truco paulista ---------- */

.card.back {
  background: repeating-linear-gradient(45deg, #7a1f2b 0 6px, #8f2a37 6px 12px);
  border: 3px solid var(--card-bg);
}
.card.back.playable:hover { transform: translateY(-8px); }
.hand.face-down .card { filter: brightness(0.75); outline: 2px dashed var(--accent); outline-offset: 2px; }

.tag.mode { background: rgb(242 193 78 / 0.18); color: var(--accent); font-size: 0.75rem; }
.tag.team-0 { background: rgb(139 226 139 / 0.18); color: var(--ok); }
.tag.team-1 { background: rgb(255 138 128 / 0.18); color: var(--danger); }

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.team-box { background: var(--panel); border: 2px solid transparent; border-radius: 12px; padding: 10px 12px; }
.team-box.mine { border-color: rgb(242 193 78 / 0.5); }
.team-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.team-name { font-weight: 700; overflow-wrap: break-word; min-width: 0; }
.team-score { font-size: 2.2rem; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.team-players { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 0.85rem; color: var(--muted); }
.team-players li.me { color: var(--ink); font-weight: 700; }
.team-players .tag { margin-left: 0; }

.hand-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 0; }
.value-chip { padding: 3px 10px; border-radius: 999px; font-weight: 700; background: rgb(255 255 255 / 0.1); }
.value-chip.value-3, .value-chip.value-6 { background: rgb(242 193 78 / 0.25); color: var(--accent); }
.value-chip.value-9, .value-chip.value-12 { background: rgb(255 138 128 / 0.25); color: var(--danger); }
.round-chip { font-size: 0.8rem; padding: 2px 8px; border-radius: 999px; background: rgb(255 255 255 / 0.08); }
.round-chip.won { color: var(--ok); }
.round-chip.lost { color: var(--danger); }
.round-chip.tie { color: var(--muted); }
.tag.special { background: rgb(255 138 128 / 0.2); color: var(--danger); }
.hand-bar .muted { margin-left: auto; }

.decision { text-align: center; }
.decision p { margin: 6px 0; }
.decision-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.truco-call { border-color: var(--danger); }
.call-banner {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--danger);
  animation: call-pop 0.5s ease-out;
}
@keyframes call-pop { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
.btn.raise { background: var(--danger); color: #2a0000; }
.hand-tools { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 40px; }
.btn.truco-btn { background: var(--danger); color: #2a0000; font-size: 1.05rem; letter-spacing: 0.03em; }
.btn.active { border-color: var(--accent); color: var(--accent); }
.hand-log { padding-left: 20px; font-size: 0.9rem; }
.hand-log li { margin: 4px 0; }
.card-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0; }

.modes { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.modes legend { font-size: 0.9rem; color: var(--muted); margin-bottom: 4px; padding: 0; }
.mode-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  color: var(--ink);
  cursor: pointer;
}
.mode-option:has(input:checked) { border-color: var(--accent); background: rgb(242 193 78 / 0.08); }
.mode-option input { margin-top: 3px; accent-color: var(--accent); }
.mode-option .muted { display: block; font-size: 0.8rem; }

/* Sinais */
.signals { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 6px 0; }
.signal-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.signal-row button {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 64px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgb(255 255 255 / 0.06);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}
.signal-row button:hover { background: rgb(255 255 255 / 0.14); }
.signal-row.cooling button { opacity: 0.35; cursor: default; }
.signal-emoji { font-size: 1.5rem; line-height: 1.1; }
.signal-meaning { font-size: 0.7rem; color: var(--muted); }
.signal-bubble {
  position: absolute;
  z-index: 25;
  transform: translateY(-100%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  border: 2px solid var(--ok);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.5);
  pointer-events: none;
  animation: signal-flash var(--bubble-ms, 1200ms) ease-out both;
}
.signal-bubble .signal-emoji { font-size: 1.3rem; }
.signal-bubble.caught { border-color: var(--accent); }
.signal-bubble.hint {
  border-color: var(--danger);
  cursor: pointer;
  pointer-events: auto;
  /* Catchable: pops in, then holds still (a moving target is unfair to click), then fades. */
  animation-name: signal-hint;
}
@keyframes signal-hint {
  0% { opacity: 0; transform: translateY(-100%) scale(0.6); }
  10% { opacity: 1; transform: translateY(-100%) scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-100%) scale(1); }
}
button.signal-bubble.hint:hover { background: #2a0000; }
@keyframes signal-flash {
  0% { opacity: 0; transform: translateY(-80%) scale(0.6); }
  12% { opacity: 1; transform: translateY(-100%) scale(1.1); }
  20% { transform: translateY(-100%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-115%) scale(1); }
}

@media (prefers-reduced-motion: reduce) { .call-banner, .signal-bubble { animation: none; } }

/* ---------- emoji reactions ---------- */

/* The 🔊/😀 buttons are fixed to the right edge, above everything else at the bottom of the
   screen (the fanned hand and the bid bar under it) — see --bottom-furniture further down,
   which is what lifts them. */
:root {
  --reactions-inset: 16px;
  --reactions-size: 48px;
  /* The 🔊 button is the smaller of the two, and the gap is the one between them. Both are
     read back by --reactions-buttons below, so the room left for an open menu follows the
     buttons instead of being a number written down twice. */
  --reactions-mute: 40px;
  --reactions-buttons-gap: 8px;
  /* How tall the 🔊/😀 buttons are together: side by side they are one button tall, and on
     a phone (where they stack, see the media query) two plus the gap between them. */
  --reactions-buttons: var(--reactions-size);
  /* Between an open menu and the buttons under it. */
  --reactions-gap: 8px;
  /* How far the column's bottom edge is from the bottom of the screen. On a phone the hand
     and the bid bar lift it (--bottom-furniture). */
  --reactions-bottom: var(--reactions-inset);
}
.reactions {
  position: fixed;
  right: var(--reactions-inset);
  bottom: var(--reactions-bottom);
  /* Above the hand (24) and the bid bar (25): the buttons are lifted clear of both on a
     phone, and when a card does end up near one it must not be the thing the finger hits —
     a card painted over the 😀 button is a touch target swallowed by another. */
  z-index: 26; display: grid; justify-items: end; gap: var(--reactions-gap);
  /* The column is anchored at the bottom and grows upwards, so an open menu taller than the
     room above the buttons runs off the *top* of the screen — and nothing scrolls a fixed
     element back down. This is what is left for one: the screen, less everything under it
     (the buttons, the gap to them and the inset below them) and the same inset above it.
     Both menus set their max-height from it; they are never open at the same time. */
  --reactions-room: calc(100dvh - var(--reactions-bottom) - var(--reactions-buttons)
    - var(--reactions-gap) - var(--reactions-inset));
}
.reaction-toggle {
  width: var(--reactions-size);
  height: var(--reactions-size);
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--felt-dark);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.4);
}
.reaction-buttons { display: flex; gap: var(--reactions-buttons-gap); }
.reaction-toggle.mute {
  width: var(--reactions-mute); height: var(--reactions-mute); font-size: 1.15rem; align-self: end;
}
.mute-menu {
  display: grid; gap: 4px; width: min(260px, calc(100vw - 32px)); padding: 8px; border-radius: 12px;
  background: var(--felt-dark); border: 1px solid var(--panel-border); box-shadow: 0 4px 12px rgb(0 0 0 / 0.4);
  max-height: var(--reactions-room); overflow-y: auto;
}
.mute-menu button {
  border: 0; border-radius: 8px; padding: 8px 10px; text-align: left; font: inherit; font-size: 0.9rem;
  color: var(--ink); background: rgb(255 255 255 / 0.06); cursor: pointer;
}
.mute-menu button:hover { background: rgb(255 255 255 / 0.14); }
.mute-menu button.on { color: var(--danger); }
.reaction-panel {
  display: grid;
  gap: 6px;
  /* A width, not just a max-width: the emoji row below reflows to the room it is given, and
     a shrink-to-fit panel would give it its seven columns' worth however narrow the phone
     is — a 320px screen had to be scrolled sideways to read the sounds. 350px is the seven
     columns plus the padding, so nothing changes on a phone wide enough for them. */
  width: min(350px, calc(100vw - 32px));
  /* Many sounds: scroll inside the panel instead of running off the screen. */
  max-height: var(--reactions-room);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border-radius: 12px;
  background: var(--felt-dark);
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.4);
}
/* A row of the panel may be narrower than its contents want to be. Without this the message
   field's own idea of how wide a text input is (around 195px, plus the Enviar button) is a
   floor under the whole panel, and a 320px phone had to be scrolled sideways to read it. */
.reaction-panel > * { min-width: 0; }
/* Seven to a row where they fit, fewer on a narrower phone, rather than off the edge. */
.reaction-emojis { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: 4px; justify-content: space-between; }
.reaction-section { font-size: 0.75rem; color: var(--muted); padding: 2px 4px 0; }
.reaction-sounds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.reaction-sounds button {
  font-size: 0.8rem !important;
  height: auto !important;
  min-height: 36px;
  padding: 6px 8px;
  text-align: left;
  color: var(--ink);
  background: rgb(255 255 255 / 0.06) !important;
}
.reaction-sounds button:hover { background: rgb(255 255 255 / 0.14) !important; }
.reaction-panel button {
  font-size: 1.5rem;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.reaction-panel button:hover { background: rgb(255 255 255 / 0.1); }
.reaction-panel .cooling button, .reaction-panel button.cooling { opacity: 0.35; cursor: default; }
.flying-reaction {
  position: fixed;
  bottom: 0;
  z-index: 30;
  display: grid;
  justify-items: center;
  pointer-events: none;
  animation: fly-up 3s ease-out forwards;
}
.flying-reaction .emoji { font-size: 2.6rem; line-height: 1; }
.flying-reaction .who {
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  white-space: nowrap;
}
@keyframes fly-up {
  0% { transform: translate(-50%, 0); opacity: 0; }
  10% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -70vh); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .flying-reaction { animation-name: fade-reaction; bottom: 80px; transform: translateX(-50%); }
  @keyframes fade-reaction { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
}

/* ---------- misc ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.4);
}

#game.offline::before {
  content: 'Reconectando…';
  display: block;
  text-align: center;
  background: #7a4b00;
  border-radius: 8px;
  padding: 6px;
  margin-bottom: 8px;
}

/* ---------- your hand at the bottom of the screen, and the bid bar under it ----------

   Your cards — and, when it is your turn to bid, the bid bar — ride at the bottom edge of
   the screen, at every width. They used to be in the flow of the page, under the table. On
   a phone that put them below the fold: every turn began by scrolling down to them, and the
   moment you looked at the table again they were gone. On a desktop it put the bid bar far
   enough down that the page scrolled itself to it the instant your turn began — the table
   you were reading slid away under you, once a hand, with no way to ask it not to. Both are
   the same fix, so both get it: there is nothing left to scroll to, and the scroll that did
   it is gone from bids.js.

   Fixed, not sticky: sticky to the bottom only holds an element while you are scrolled
   *above* where it belongs, so scrolling down to the rounds or the history would take the
   hand away again — the thing being fixed. What it costs, a strip of screen the page can't
   use, is given back as room at the end of the page (#game's padding-bottom below), so
   everything can still be scrolled clear of the fan and nothing is ever permanently hidden
   under it.

   What is fixed is the hand itself in the bidding game and, in truco paulista, the block
   around it — the hand there comes with the Truco button and the 🤫 signals over it, and
   those have to ride along with the cards.

   The cards lean out of a pivot below the hand and overlap each other by --fan-overlap: as
   much as a hand of eight needs to fit the screen, never more than 60% of a card. That
   ceiling is not a matter of taste — the strip left out is what carries the rank and its
   suit (see .card .corner), and past 60% the corner goes under the next card too. On a
   screen with room to spare the overlap stops at the lower end instead, which is what makes
   it a fan rather than a row. */
#game > .hand, #game > .hand-fan {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--fan-bottom, calc(var(--card-h) * -0.12));
  z-index: 24;
  margin: 0;
}
/* The screen the fan takes — and the bid bar under it — given back at the end of the page. */
#game:has(> .hand), #game:has(> .hand-fan) { padding-bottom: calc(var(--card-h) * 1.2); }
#game:has(.panel.bids) { padding-bottom: calc(var(--card-h) * 1.2 + var(--bids-h, 124px)); }
#game .hand {
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0;
  padding: 0;
  margin: 0;
  min-height: calc(var(--card-h) * 1.1);
  /* The whole width, bar a margin at each edge: the 🔊/😀 buttons are above the hand, not
     beside it, so nothing at the bottom of the screen has to be kept clear of. */
  --fan-span: calc(100vw - 16px);
  --fan-overlap: clamp(
    calc(var(--card-w) * 0.34),
    calc((var(--card-w) * var(--n, 1) - var(--fan-span)) / (var(--n, 1) - 1)),
    calc(var(--card-w) * 0.6));
}
/* Your turn: the fan comes up, so the cards you are choosing between are whole. */
#game > .hand.active, #game > .hand-fan:has(.hand.active) { --fan-bottom: calc(var(--card-h) * -0.02); }
/* With the bid bar up the fan rides above it, never under its numbers. The bar is a
   different height every hand, so --bids-h is measured (measureBidBar in bids.js). */
body:has(#game .panel.bids) #game > .hand { --fan-bottom: calc(var(--bids-h, 124px) + 8px); }
#game .hand .card + .card { margin-left: calc(var(--fan-overlap) * -1); }
/* --i (which card) and --n (how many) come from the page (fanHand in cards-view.js). */
#game .hand .card {
  transform-origin: 50% 210%;
  transform: rotate(var(--fan-rot));
  --fan-rot: calc((var(--i, 0) - (var(--n, 1) - 1) / 2) * min(7deg, 34deg / var(--n, 1)));
}
/* The card under the pointer comes forward as well as up: in a fan the card to its right
   lies on top of it, so lifting it alone would raise a card that is still half covered. */
#game .hand .card.playable:hover,
#game .hand .card.playable:focus-visible {
  transform: rotate(var(--fan-rot)) translateY(-10px) scale(1.04);
  z-index: 2;
}
/* The pre-selected card — and the one under the pointer while choosing — stands out of
   the fan the same way, and for the same reason: it has to be whole to be recognised
   while the other players take their turns. */
#game .hand.choosing .card:hover,
#game .hand.choosing .card:focus-visible {
  transform: rotate(var(--fan-rot)) translateY(-10px) scale(1.04);
  z-index: 2;
}
#game .hand.choosing .card.chosen {
  transform: rotate(var(--fan-rot)) translateY(-10px);
  z-index: 2;
}

/* The bid buttons as a bar at the bottom, under the fan. On a wide screen it is a bar in
   the middle of it: the numbers are read together, and one stretched from edge to edge of a
   desktop window puts "0" and "8" a screen apart. */
.panel.bids {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 0;
  z-index: 25;
  max-width: 520px;
  margin: 0 auto;
  border-radius: 14px 14px 0 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgb(8 30 20 / 0.97);
  box-shadow: 0 -10px 24px rgb(0 0 0 / 0.45);
}
.panel.bids.opening { animation: bids-up 220ms ease-out var(--bids-delay, 0ms) both; }
.panel.bids .bid-buttons { margin: 8px 0 0; }

/* The 🔊/😀 buttons used to sit in the bottom-right corner, where the fanned hand ran over
   them. Two things at once: with five cards or more the cards themselves reach into that
   corner (the overlap stops at 60% of a card, so past four the hand is wider than any strip
   the corner could be kept clear of), and the hand's own box spans the screen and is
   painted above the buttons whatever is in it — so the finger hit the hand and the 😀 panel
   never opened. Keeping the hand narrow enough instead would cost a phone two cards.

   They ride above the hand instead: --bottom-furniture is how much of the bottom of the
   screen all that fixed furniture takes together — the fan, the block around it in truco
   paulista (the Truco button and the 🤫 signals come with the cards) and the bid bar under
   them. Measured after every render (bids.js) rather than written down here: each of those
   is a different height from hand to hand. It is 0 where there is no hand at the bottom of
   the screen (the lobby, the end of a match), and the buttons go back to the corner. */
.reactions { --reactions-bottom: calc(var(--reactions-inset) + var(--bottom-furniture, 0px)); }
/* The tutorial's guide card is at the bottom too: above the fan, never on the cards it is
   telling you about (and never between your finger and them). */
body.tutorial .coach:not(.top) { bottom: calc(var(--card-h) * 1.15 + 16px); }

@media (max-width: 520px) {
  .place .sit { padding: 2px; }
  :root { --card-w: 52px; --card-h: 76px; }
  /* A phone's card is 52px wide, and on one that size the index drawn for a desktop card
     was too big for it: a two-digit rank with a full-size suit under it crowded the corner,
     and the 10 of ouros read as a block of ink rather than as a card. The whole index is a
     size down here — the rank, the small suit under it and the big one in the middle — and
     sits closer in to the corner, which is also the part of a card the fan leaves out. */
  .card .corner { font-size: 0.8rem; --rank-y: 3px; --rank-x: 4px; }
  .card .corner .mini { font-size: 0.66em; }
  .card .suit { font-size: 1.35rem; }
  /* DOM order is mute then 😀, so a column leaves 😀 — the one used most — nearest the thumb. */
  .reaction-buttons { flex-direction: column; align-items: flex-end; }
  /* Stacked they are the 🔊 button, the gap and the 😀 one: that much less room for an open
     menu above them (--reactions-room). */
  :root {
    --reactions-buttons: calc(var(--reactions-mute) + var(--reactions-buttons-gap)
      + var(--reactions-size));
  }
  .players { grid-template-columns: repeat(2, 1fr); }
  /* Phones: the places lean outwards (see .seats .player), so the felt itself can be much
     shorter than the band of places around it — the cards land clear of them. */
  .round-table {
    --seat-rx: 40%;
    --seat-ry: 44%;
    --play-rx: 16%;
    --play-ry: 19%;
    --seat-w: 98px;
    aspect-ratio: 3 / 3.4;
  }
  .felt { inset: 11% 13%; border-width: 7px; }
  .table-center { font-size: 0.75rem; max-width: 34%; }
  .vira { flex-direction: column; gap: 2px; }
  /* A short middle, so the card you play (just below it) doesn't cover it: while a round's
     result is up, the status line under the table says who took it, so the middle keeps
     only the countdown bar. */
  .table-center { gap: 2px; }
  .round-banner { width: 72px; padding-bottom: 4px; }
  .round-banner > :not(.countdown) { display: none; }
  .seats .player { padding: 4px 6px; font-size: 0.72rem; }
  .seats .player .lives { font-size: 0.65rem; gap: 1px; letter-spacing: 0; }
  .seats .player .tag.icon { font-size: 0.8rem; }
  .seats .bid-meter { gap: 1px 5px; }
  .seats .bid-score { font-size: 1.3em; }
  .seats .pip { width: 7px; height: 7px; }
  .round-table .trick .card { --card-w: 42px; --card-h: 61px; }
  .round-table .trick .card .suit { font-size: 1.25rem; }
  .round-table .trick .card .corner { font-size: 0.85rem; --rank-y: 2px; --rank-x: 4px; }
  .round-table .trick .play { gap: 1px; }
  .round-table .trick .play-name { font-size: 0.65rem; max-width: 60px; }
  /* Five players or more on a phone: the cards land in rows, and the name under a card has
     to stay clear of the row below it. The card plus its name is about 70px, so the rows
     are pitched wider than that — the felt is taller and the cards a size smaller. Without
     this the names end up behind the next row of cards and can't be read. */
  .round-table.n5 .trick .card, .round-table.n6 .trick .card, .round-table.rect .trick .card {
    --card-w: 38px;
    --card-h: 55px;
  }
  .table-center .vira { font-size: 0.7rem; }
  .table-center { max-width: 30%; font-size: 0.7rem; }
  .round-table.n2, .round-table.n3, .round-table.n4 { aspect-ratio: 3 / 2.4; --play-ry: 22%; }
  .round-table.n5, .round-table.n6 { aspect-ratio: 3 / 3.05; --play-ry: 22%; }
  .round-table.rect {
    aspect-ratio: 3 / 3.45;
    --seat-w: 84px;
    --seat-rx: 50%;
    --seat-ry: 44%;
    --play-rx: 18%;
    --play-ry: 30%;
  }
  .round-table.rect .felt { inset: 6% 15%; border-width: 7px; border-radius: 20px; }
  .round-table.rect .table-center { max-width: 28%; }
  .teams { margin: 8px 0; }
  .team-box { padding: 6px 10px; }
  .team-score { font-size: 1.7rem; }

}
/* The bar slides up when it's your turn, so it isn't just suddenly there. It animates only
   while it is opening: the page is rebuilt on every message, and a bar that started its
   slide over again would drop off the bottom of the screen in the middle of a bid. A redraw
   during the slide carries on from where it was (--bids-delay, set in bids.js). */
@keyframes bids-up {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .panel.bids.opening { animation: none; }
}

/* ---------- rules page ---------- */

.rules { max-width: 760px; margin: 0 auto; }
.rules h1 { font-size: 1.6rem; margin: 8px 0 4px; }
.rules h3 { margin: 20px 0 8px; font-size: 1rem; color: var(--accent); }
.rules ul, .rules ol { padding-left: 20px; }
.rules li { margin: 4px 0; }
.rules .card { --card-w: 46px; --card-h: 66px; }
.rules .card .suit { font-size: 1.4rem; }
.rules .card .corner { font-size: 0.9rem; --rank-y: 3px; --rank-x: 5px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.9rem; }
.card-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.example { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.example-item { display: grid; justify-items: center; gap: 4px; }
.arrow { font-size: 1.5rem; color: var(--muted); }
.steps li { margin: 8px 0; }
.rules .example-players { max-width: 200px; padding: 0; grid-template-columns: 1fr; }
.legend { list-style: none; padding-left: 0 !important; }
.legend li > * { vertical-align: middle; }
.legend .dot { display: inline-block; margin: 0 2px 0 8px; }
.legend .dot:first-child { margin-left: 0; }
.legend .life { color: #ff6b6b; }
.legend-turn { display: inline-block; width: 18px; height: 12px; border: 2px solid var(--accent); border-radius: 4px; }
.center { text-align: center; }

/* Admin panel */
.admin { display: grid; gap: 16px; }
.admin > * { min-width: 0; } /* wide tables scroll inside their panel, not the page */
.admin-players { width: 100%; border-collapse: collapse; }
.admin-players th, .admin-players td { padding: 6px 8px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.admin-add { display: flex; gap: 6px; align-items: center; }
.admin-add input { width: 4.5em; }
.admin-add input:not([type]) { width: 9em; }
#admin-error:empty { display: none; }
.admin-games-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.admin-games-head h2 { margin: 0; }
#admin-games-list { overflow-x: auto; }
.admin-games td { white-space: nowrap; }
.admin-games .tag { margin-left: 6px; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 700; letter-spacing: 0.1em; cursor: pointer; text-decoration: underline; }

/* ---------- tutorial (/tutorial) ---------- */

/* Nothing to invite to or react with in a practice hand. */
body.tutorial .share, body.tutorial .reactions, body.tutorial .autoplay-toggle,
body.tutorial .host-seat-bar { display: none !important; }
/* The guide: a card at the bottom (or the top, when what it points at is down there). */
.coach {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 40;
  width: min(520px, calc(100vw - 24px));
  padding: 14px 16px;
  border-radius: 14px;
  background: #fffdf6;
  color: #1b1b1b;
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.5);
  animation: fade-in 200ms ease-out;
}
.coach.top { top: 12px; bottom: auto; }
.coach strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.coach p { margin: 0 0 10px; line-height: 1.45; }
.coach .muted { color: #6b6b6b; font-size: 0.9rem; }
.coach-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: flex-end; }
.coach .btn.ghost { color: #1b1b1b; border-color: rgb(0 0 0 / 0.25); }
/* The ring around what the guide is talking about; clicks go through to the table. */
.coach-ring {
  position: fixed;
  z-index: 39;
  border: 3px solid var(--accent);
  border-radius: 14px;
  box-shadow: 0 0 0 4px rgb(242 193 78 / 0.25), 0 0 24px rgb(242 193 78 / 0.45);
  pointer-events: none;
  transition: left 150ms, top 150ms, width 150ms, height 150ms;
}
@media (prefers-reduced-motion: reduce) { .coach { animation: none; } .coach-ring { transition: none; } }

/* "Instale o truco.vc no celular" (javascripts/install.js): a card at the bottom, above
   the table's floating buttons, once per browser. */
.install-banner {
  position: fixed; left: 12px; right: 12px; z-index: 50;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: 48px 1fr; gap: 10px 12px; align-items: center;
  padding: 12px 14px; border-radius: 14px;
  background: var(--card-bg); color: var(--card-ink);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.45);
  animation: install-in 250ms ease-out;
}
.install-banner img { width: 48px; height: 48px; border-radius: 11px; }
.install-text p { margin: 2px 0 0; font-size: 0.9rem; line-height: 1.35; }
.install-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.install-banner .btn.ghost { color: var(--card-ink); border-color: rgb(0 0 0 / 0.25); }
.share-icon { width: 0.85em; height: 1.05em; vertical-align: -0.15em; color: #0a66d6; }
@keyframes install-in { from { transform: translateY(20px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .install-banner { animation: none; } }

/* ---------- ranking (/ranking) ---------- */

.ranking { max-width: 640px; margin: 0 auto; }
.ranking h1 { font-size: 1.6rem; margin: 8px 0 4px; }
.ranking-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.ranking-tabs a {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--panel-border);
  color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600;
}
.ranking-tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ranking-table { width: 100%; border-collapse: collapse; padding: 4px 0; margin: 12px 0 16px; }
.ranking-table th, .ranking-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--panel-border); }
.ranking-table tr:last-child td { border-bottom: 0; }
.ranking-table th { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.ranking-table .pos { width: 2.5em; text-align: center; }
.ranking-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ranking-table .name { overflow-wrap: anywhere; }
.ranking-table .podium .name { font-weight: 700; }
.ranking-table .num strong { color: var(--accent); }
@media (max-width: 520px) {
  .ranking-table th, .ranking-table td { padding: 8px 6px; font-size: 0.9rem; }
}

/* ---------- conquistas (/conquistas, and the list at the end of a match) ---------- */

.achievements-search { margin: 12px 0 4px; }
.achievements-search-row { display: flex; gap: 8px; align-items: center; }
.achievements-search-row input { flex: 1 1 auto; min-width: 0; }
.achievements-count { margin: 12px 0 0; }
.achievement-list { list-style: none; margin: 12px 0 16px; padding: 0; display: grid; gap: 8px; }
.achievement {
  display: flex; align-items: center; gap: 12px; margin: 0; padding: 12px 14px;
}
/* Locked ones are still listed — knowing what is missing is half the fun — but dimmed. */
.achievement:not(.got) { opacity: 0.62; }
.achievement.got { border-color: var(--accent); }
.achievement-icon { font-size: 1.6rem; line-height: 1; flex: 0 0 auto; }
.achievement-text { flex: 1 1 auto; min-width: 0; }
.achievement-text h2 { margin: 0 0 2px; font-size: 1rem; }
.achievement-text p { margin: 0; }
.achievement-badge { flex: 0 0 auto; color: var(--ok); font-weight: 700; white-space: nowrap; }

/* The end of a match, on the table page (game/achievements.js). */
.achievements-earned ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.achievements-earned li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.achievements-earned strong { margin-right: 2px; }
.achievement-chip {
  padding: 3px 9px; border-radius: 999px; font-size: 0.85rem;
  background: rgb(242 193 78 / 0.18); border: 1px solid var(--accent); color: var(--ink);
}

/* ---------- feedback (💬 in the footer) and the mural (/mural) ---------- */

.feedback-links { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 14px 0 0; }
.feedback-links .mural-link { color: var(--muted); font-size: 0.85rem; }
.feedback-links .mural-link:hover { color: var(--accent); }

/* The dialog is the page's own panel, not the browser's white box. */
.feedback-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--felt-dark);
  color: var(--ink);
  padding: 20px;
}
.feedback-dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.feedback-dialog h2 { margin-bottom: 4px; }
.feedback-form input, .feedback-form textarea { width: 100%; }
.feedback-form textarea {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgb(255 255 255 / 0.92);
  color: #111;
  resize: vertical;
}
.feedback-note { margin: 0 0 8px; }
#feedback-error:empty { display: none; }
.feedback-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* The thank-you note outlives the dialog, so it floats over the page on its own. */
.feedback-thanks {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  z-index: 40;
  animation: fade-in 200ms ease-out;
}

.mural { max-width: 640px; margin: 0 auto; }
.mural h1 { font-size: 1.6rem; margin: 8px 0 4px; }
.mural-notes { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px; }
.mural-note { margin: 0; }
.mural-note blockquote { margin: 0 0 8px; font-size: 1.05rem; overflow-wrap: anywhere; }
.mural-note footer { color: var(--muted); font-size: 0.85rem; }
.mural-who { font-weight: 700; color: var(--accent); }

/* Admin: the triage queue. */
.admin-feedback-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-feedback-tabs .btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.admin-feedback-items { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 12px; }
.admin-feedback-item { border: 1px solid var(--panel-border); border-radius: 10px; padding: 12px; }
.admin-feedback-item blockquote { margin: 0 0 6px; overflow-wrap: anywhere; }
.admin-feedback-item p { margin: 0 0 8px; }
.admin-feedback-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.admin-feedback-actions input { flex: 1 1 12em; min-width: 8em; }

/* ---------- chat ---------- */

/* The message field at the top of the 😀 panel. */
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--panel-border); background: var(--ink); color: var(--card-ink); font: inherit; font-size: 0.95rem; }
.reaction-panel .chat-form button {
  height: auto; padding: 0 12px; font-size: 0.9rem; font-weight: 700; min-width: 64px;
  background: var(--accent); color: var(--accent-ink);
}
.reaction-panel .chat-form button:disabled { background: rgb(255 255 255 / 0.1); color: var(--muted); cursor: default; }
/* "Chat explícito", under the message field: the host's checkbox, a note for everyone else. */
.chat-explicit { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--muted); cursor: pointer; user-select: none; padding: 2px 4px; }
.chat-explicit input { accent-color: var(--accent); margin: 0; }
.chat-explicit-note { margin: 0; padding: 2px 4px; font-size: 0.75rem; color: var(--muted); }
/* A message over the sender's place: pops in, stays, fades out (showChat in game.js). */
.chat-bubble {
  position: absolute;
  z-index: 26;
  /* As wide as the message (up to 200px), wherever the place is: lines break at spaces,
     a word is only split when it doesn't fit on a line by itself. */
  width: max-content;
  max-width: 200px;
  padding: 6px 12px;
  border-radius: 14px;
  background: var(--card-bg);
  color: var(--card-ink);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: break-word;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.5);
  pointer-events: none;
  transform: translate(-50%, -100%);
  animation: chat-bubble 6s ease-out forwards;
}
.chat-bubble::after {
  content: '';
  position: absolute;
  left: calc(50% + var(--tail-shift, 0px)); /* still under the place when the bubble was moved to fit */
  bottom: -6px;
  border: 6px solid transparent;
  border-bottom: 0;
  border-top-color: var(--card-bg);
  transform: translateX(-50%);
}
@keyframes chat-bubble {
  0% { opacity: 0; transform: translate(-50%, -80%) scale(0.8); }
  5% { opacity: 1; transform: translate(-50%, -100%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -112%); }
}
@keyframes chat-fade { 75% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .chat-bubble { animation-name: chat-fade; } }
/* "Mensagens": every chat message since the page loaded, under the table (logChat). */
.chat-log { margin: 16px 0 0; }
.chat-log h2 { margin-bottom: 8px; }
.chat-log-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; display: grid; gap: 4px; overflow-wrap: break-word; }
.chat-log-list li { padding: 4px 8px; border-radius: 8px; background: rgb(255 255 255 / 0.04); }
.chat-log-list li.mine { background: rgb(242 193 78 / 0.1); }
.chat-log-list time { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.chat-log-note { margin: 8px 0 0; font-size: 0.8rem; }

/* ---------- poderes (v2) ---------- */

.powers-toggle { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 0 auto 12px; width: fit-content; padding: 6px 14px; border-radius: 999px; background: rgb(242 193 78 / 0.12); color: var(--accent); font-weight: 700; cursor: pointer; user-select: none; }
.powers-on { color: var(--accent); font-weight: 700; margin: 0 0 12px; }
/* Your power for the hand, above your cards. Border color by tier. */
.power-bar {
  --tier: #9aa5a0;
  display: grid; gap: 6px; justify-items: center; text-align: center;
  max-width: 460px; margin: 0 auto 10px; padding: 10px 14px; border-radius: 12px;
  background: rgb(0 0 0 / 0.3); border: 2px solid var(--tier);
}
.power-bar.rare { --tier: #5aa9ff; }
.power-bar.epic { --tier: #c77dff; box-shadow: 0 0 18px rgb(199 125 255 / 0.35); }
.power-bar.used > :not(.power-peek) { opacity: 0.55; }
.power-head { display: flex; align-items: center; gap: 6px; }
.power-icon { font-size: 1.3rem; }
.power-tier { background: color-mix(in srgb, var(--tier) 25%, transparent); color: var(--ink); }
.power-text { font-size: 0.85rem; }
.power-bids { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; }
.power-peek { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.hand.armed .card.playable { box-shadow: 0 0 0 3px #c77dff, 0 6px 16px rgb(0 0 0 / 0.4); }
/* A card played with a power: a label above it on the table. */
.play .power-badge { font-size: 0.65rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: #3b1f5c; color: #f1ddff; white-space: nowrap; }
/* Troca: the card that came in pops and glows, then keeps a small "nova" mark. */
.hand .card.swapped-in { position: relative; outline: 3px solid #c77dff; outline-offset: 2px; animation: swapped-in 2.4s ease-out; }
.card .new-tag { animation: new-tag-fade 4s linear both; position: absolute; top: -9px; right: -6px; padding: 0 5px; border-radius: 999px; background: #c77dff; color: #1b0030; font-size: 0.6rem; font-weight: 800; line-height: 1.5; pointer-events: none; }
@keyframes swapped-in {
  0% { transform: translateY(-18px) scale(1.15) rotate(-6deg); box-shadow: 0 0 0 0 rgb(199 125 255 / 0.9); }
  25% { transform: translateY(-6px) scale(1.08) rotate(2deg); box-shadow: 0 0 22px 8px rgb(199 125 255 / 0.75); }
  60% { box-shadow: 0 0 16px 4px rgb(199 125 255 / 0.5); }
  100% { transform: none; box-shadow: 0 0 8px 1px rgb(199 125 255 / 0.35); }
}
@media (prefers-reduced-motion: reduce) { .hand .card.swapped-in { animation: none; } }
.powers-option { display: grid; justify-items: center; gap: 6px; margin: 0 0 12px; }
.powers-option .powers-toggle { margin: 0; }
.bid-pop .bid-pop-icon { font-size: 0.4em; vertical-align: super; margin-right: 2px; }
/* Escudo used: a shield pops over the player's card, glows, and fades (shieldPop). */
.shield-pop {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 2.8rem; pointer-events: none; z-index: 3;
  filter: drop-shadow(0 0 12px rgb(120 190 255 / 0.9));
  animation: shield-pop 2.2s ease-out both;
}
@keyframes shield-pop {
  0% { transform: scale(0.3) rotate(-20deg); opacity: 0; }
  15% { transform: scale(1.25) rotate(6deg); opacity: 1; }
  30% { transform: scale(1) rotate(0); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .shield-pop { animation-name: fade-reaction; } }

/* ---------- characters ---------- */

/* Picking a character: the cards in a grid (home page, and the lobby's 🎭 Trocar). */
.character-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.character-option { display: grid; justify-items: center; gap: 4px; padding: 4px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; text-align: center; }
.character-option input { position: absolute; opacity: 0; pointer-events: none; }
.character-option img { width: 100%; max-width: 76px; height: auto; aspect-ratio: 76 / 120; border-radius: 6px; box-shadow: 0 3px 8px rgb(0 0 0 / 0.4); }
.character-option:has(input:checked), .character-option.chosen { border-color: var(--accent); background: rgb(242 193 78 / 0.12); }
.character-option:has(input:focus-visible) { outline: 3px solid #fff; outline-offset: 2px; }
.character-random { display: grid; place-items: center; width: 100%; max-width: 76px; aspect-ratio: 76 / 120; border-radius: 6px; background: rgb(255 255 255 / 0.08); font-size: 2rem; }
.character-name { font-size: 0.75rem; font-weight: 600; line-height: 1.2; }
.character-option { position: relative; font: inherit; color: var(--ink); background: none; }
.character-picker { margin: 0 0 12px; }
.character-picker h2 { font-size: 1rem; }
/* The character's face on each place at the table (avatar() / moodFor() in game.js). */
.player-name .avatar {
  flex: none; align-self: center; width: 40px; height: 40px; border-radius: 10px;
  object-fit: cover; background: #f3e6c8; box-shadow: 0 0 0 2px rgb(255 255 255 / 0.15);
}
.player.me .player-name .avatar { box-shadow: 0 0 0 2px var(--accent); }
.player-name .avatar.mood-gritando { box-shadow: 0 0 0 2px var(--danger); animation: shout 0.35s ease-in-out 3; }
.player-name .avatar.mood-morto { filter: grayscale(0.7); }
@keyframes shout { 50% { transform: scale(1.12) rotate(-3deg); } }
@media (prefers-reduced-motion: reduce) { .player-name .avatar.mood-gritando { animation: none; } }
@media (max-width: 520px) {
  .player-name .avatar { width: 28px; height: 28px; border-radius: 7px; }
}
/* Home page, narrow screens: one row of cards that scrolls sideways, so the forms stay
   close. On a desktop the picker has its own column and the cards wrap into rows (see
   the min-width: 900px block in "home"). */
@media (max-width: 899px) {
  #character-panel .character-grid { grid-auto-flow: column; grid-auto-columns: 76px; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px; }
  #character-panel .character-option { scroll-snap-align: start; }
}
@media (max-width: 520px) {
  /* 7–8 players on a phone: tiny places, so a smaller face leaves room for the name. */
  .round-table.rect .player-name { gap: 3px; }
  .round-table.rect .player-name .avatar { width: 20px; height: 20px; border-radius: 5px; }
}
@keyframes new-tag-fade { 75% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- places: one fixed size ---------- */
/* Every place at a table has the same size whatever it shows (tags coming and going, long
   names, the bid's note): each line is fixed and nothing wraps; extra text is cut with "…".
   The height depends on the kind of table and the screen (--seat-h). */
.round-table { --seat-h: 88px; }
.seats .player { height: var(--seat-h); overflow: hidden; display: flex; flex-direction: column; }
.seats .player-name { white-space: nowrap; align-items: center; }
.seats .player-name .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seats .seat-row { flex-wrap: nowrap; }
.seats .seat-tags { display: flex; flex-wrap: nowrap; gap: 2px; overflow: hidden; min-height: 1.35rem; margin: 0; align-items: center; }
.seats .seat-row .player-tags, .seats .seat-row .player-tags * { flex-wrap: nowrap; }
.seats .player-tags { flex-wrap: nowrap; overflow: hidden; }
/* The bid: score and pips on one line, the note under them. */
.seats .bid-meter { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 6px; row-gap: 0; }
.seats .bid-pips { display: flex; flex-wrap: nowrap; overflow: hidden; }
.seats .bid-note { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; }
.seats .seat-status { min-height: 2.6em; display: flex; align-items: center; font-size: 0.9em; }
.round-table.mode-bidding { --seat-h: 150px; }
.round-table.mode-paulista { --seat-h: 88px; }
.round-table.mode-lobby { --seat-h: 88px; }
@media (max-width: 520px) {
  .round-table.mode-bidding { --seat-h: 130px; }
  .round-table.mode-bidding.rect { --seat-h: 122px; }
  .round-table.mode-paulista, .round-table.mode-lobby { --seat-h: 68px; }
}
/* ---------- the lobby's table: one fixed size ---------- */
/* In the lobby the number of places changes under your hands (+ Lugar, + 🤖, ×), so the
   table keeps one size for two places and for eight: a height of its own instead of the
   aspect ratio the game tables use with each number of players (hence the place here, after
   those). Adding a place now only fills the rim — it never makes the table taller and pushes
   the buttons under it, which is where the mouse already is, down the page. The places keep
   the same size too (--seat-h above, with no exception for the eight-place rectangle), so the
   band of places around the table is as tall for one number of players as for another. */
.round-table.mode-lobby { aspect-ratio: auto; height: 460px; }
@media (max-width: 520px) {
  .round-table.mode-lobby { height: 300px; }
}
/* Your place hangs below the table's bottom edge: a little more room under it, so your
   hand doesn't start right against it. */
.round-table { margin-bottom: calc(var(--seat-h) + 12px); }
.seats .seat-tags > * { flex: none; white-space: nowrap; }

/* ---------- 3D table ---------- */
/* Depth with CSS only; nothing moves: places and cards keep their positions. The felt is
   tilted back a little (seen from a bit above), the wooden rim is lit from the top and has
   a visible side under it, and the table casts a shadow on the floor. */
.felt {
  transform: perspective(1100px) rotateX(14deg);
  transform-origin: 50% 55%;
  /* A spotlight over the middle and a faint cloth weave. */
  background:
    radial-gradient(ellipse 60% 50% at 50% 42%, rgb(255 255 255 / 0.10), transparent 70%),
    repeating-linear-gradient(45deg, rgb(255 255 255 / 0.018) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 50% 40%, #1f8a59, #0b4329 75%);
  /* Rim: lighter on top, darker at the bottom. */
  border-color: #9a6635 #7a4c26 #4e2f15 #7a4c26;
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 0.12),
    inset 0 0 0 2px rgb(0 0 0 / 0.25),
    inset 0 10px 30px rgb(0 0 0 / 0.35),
    inset 0 -18px 46px rgb(0 0 0 / 0.5),
    /* the side of the table, then its shadow on the floor */
    0 6px 0 #4a2c13,
    0 11px 0 #331e0c,
    0 26px 34px rgb(0 0 0 / 0.55);
}
/* Cards on the table: lying on the cloth, a little turned toward whoever played them. */
.round-table .trick .play .card {
  --rest-rot: calc(var(--x, 0) * 7deg);
  transform: rotate(var(--rest-rot));
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.15), 0 8px 14px rgb(0 0 0 / 0.45);
}
.round-table .vira .card { box-shadow: 0 1px 0 rgb(0 0 0 / 0.15), 0 6px 12px rgb(0 0 0 / 0.45); }
/* Places float over the table. */
.seats .player { box-shadow: 0 10px 22px rgb(0 0 0 / 0.45), inset 0 1px 0 rgb(255 255 255 / 0.06); }
/* Your hand: cards with some thickness, lifting toward you on hover. */
.hand .card { box-shadow: 0 1px 0 rgb(0 0 0 / 0.2), 0 6px 14px rgb(0 0 0 / 0.45); }
.hand .card.playable:hover { transform: translateY(-10px) scale(1.04); box-shadow: 0 1px 0 rgb(0 0 0 / 0.2), 0 16px 24px rgb(0 0 0 / 0.5); }
@media (max-width: 520px) {
  .felt { transform: perspective(700px) rotateX(10deg); }
}
/* The 3D shadows above must not hide the card rings: manilha (yellow) and the card that
   won the round (green) keep them, on top of the depth shadow. */
.round-table .trick .play .card.manilha { box-shadow: 0 0 0 3px var(--accent), 0 0 14px rgb(242 193 78 / 0.55), 0 8px 14px rgb(0 0 0 / 0.45); }
.round-table .trick .play.winner .card { box-shadow: 0 0 0 3px var(--ok), 0 0 16px rgb(139 226 139 / 0.55), 0 8px 14px rgb(0 0 0 / 0.45); }
/* The card in front while the round is open (blue), under the same rule: the ring has to
   survive the depth shadow. A manilha winning the round wears both — its own yellow ring,
   with the blue one around it — so neither thing is lost. */
.round-table .trick .play.leading .card { box-shadow: 0 0 0 3px var(--hint), 0 0 14px rgb(142 203 255 / 0.5), 0 8px 14px rgb(0 0 0 / 0.45); }
.round-table .trick .play.leading .card.manilha { box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px var(--hint), 0 0 14px rgb(142 203 255 / 0.5), 0 8px 14px rgb(0 0 0 / 0.45); }
/* Taking the round is the moment of the hand, and a ring that just appears is easy to miss
   among eight cards: the winning card lifts once, over the others, as it is marked. It
   keeps the turn it was played at (--rest-rot), so it only grows, never jumps. */
@keyframes round-won {
  0% { transform: rotate(var(--rest-rot)) scale(1); }
  45% { transform: rotate(var(--rest-rot)) scale(1.14); }
  100% { transform: rotate(var(--rest-rot)) scale(1); }
}
.round-table .trick .play.winner { z-index: 2; }
/* `just-won` is only on while the lift lasts (table.js), with a negative delay when the
   page re-renders in the middle of it — the same way a card flies in only once. */
.round-table .trick .play.just-won .card {
  animation: round-won 620ms ease-out both;
  animation-delay: var(--won-delay, 0ms);
}
/* Reduced motion: the ring and the glow already say it; nothing has to move. */
@media (prefers-reduced-motion: reduce) {
  .round-table .trick .play.just-won .card { animation: none; }
}

/* The vira is turned face up to open a hand — the manilha is decided there — so it comes in
   on its edge instead of simply being there. `flipping` is only on while the turn lasts
   (cards-view.js), with a negative delay when the page re-renders in the middle of it. */
.vira { perspective: 600px; }
@keyframes card-flip {
  from { transform: rotateY(90deg) scale(0.92); }
  to { transform: rotateY(0) scale(1); }
}
.vira.flipping .card {
  animation: card-flip 520ms ease-out both;
  animation-delay: var(--flip-delay, 0ms);
}
@media (prefers-reduced-motion: reduce) {
  .vira.flipping .card { animation-name: fade-in; }
}

/* A place changing hands — somebody sitting down, leaving, or a bot taking over — used to
   happen with nothing to notice. The place is put where it is with a transform (see .seats
   .player), so the animation has to carry that transform and only add the growing. */
@keyframes seat-change {
  from { transform: translate(-50%, calc(-50% + var(--y) * 50%)) scale(0.88); opacity: 0; }
  to { transform: translate(-50%, calc(-50% + var(--y) * 50%)) scale(1); opacity: 1; }
}
.seats .player.seat-change {
  animation: seat-change 380ms ease-out both;
  animation-delay: var(--seat-delay, 0ms);
}
@media (prefers-reduced-motion: reduce) {
  .seats .player.seat-change { animation-name: fade-in; }
}
.hand .card.manilha { box-shadow: 0 0 0 3px var(--accent), 0 0 12px rgb(242 193 78 / 0.5), 0 6px 14px rgb(0 0 0 / 0.45); }
.hand .card.manilha.playable:hover { box-shadow: 0 0 0 3px var(--accent), 0 0 14px rgb(242 193 78 / 0.6), 0 16px 24px rgb(0 0 0 / 0.5); }
/* Tags and small buttons in a place never break inside ("pronto ✓", "→👑"); if a row runs
   out of room the tags are cut, and the × to remove stays visible. */
.seats .tag, .seats .make-host, .seats .seat-kind, .seats .replace-bot { flex: none; white-space: nowrap; }
.seats .seat-row { flex-wrap: nowrap; }
.seats .seat-row .player-tags { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
.seats .seat-row .remove { flex: none; }
/* "🚪 Sair" next to the invite button. */
.share .quit-btn { color: var(--danger); border-color: rgb(255 138 128 / 0.35); }

/* ---------- replay (/g/:code/replay) ---------- */
/* The replay draws the same felt, places and cards as the table; what it adds is the
   controls, the bar with one button per hand, and everybody's cards open underneath. */
.replay-top { margin-bottom: 8px; }
.replay-hands-bar {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin;
}
.replay-hand-btn {
  flex: none; min-width: 34px; padding: 4px 8px; border-radius: 8px; cursor: pointer;
  background: var(--panel); color: var(--muted); border: 1px solid var(--panel-border);
  font: inherit; font-variant-numeric: tabular-nums;
}
.replay-hand-btn.current { color: var(--ink); border-color: var(--accent); background: rgb(242 193 78 / 0.15); }
.replay-controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 0 0 12px; }
.replay-btn { min-width: 46px; padding: 8px 10px; font-size: 1.05rem; }
.replay-progress { margin: 0 0 8px; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.replay-hands ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.replay-hand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.replay-who { display: inline-flex; align-items: center; gap: 6px; min-width: 9ch; }
.replay-who .avatar { width: 28px; height: 28px; }
.replay-cards { display: flex; gap: 4px; flex-wrap: wrap; }
/* A card already played is out of the hand: it stays in place, faded, so the hand still
   reads as the three (or six) cards it was dealt. */
.replay-card.played .card { opacity: 0.35; filter: grayscale(0.6); }
.replay-results { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.replay-results .name { font-weight: 700; }
.replay-results .hit strong { color: var(--accent); }
.replay-results .missed strong { color: var(--danger); }
.replay-result > strong { display: block; margin-bottom: 4px; }
/* "Suas mesas" on the ranking page: this browser's tables and their replays. */
.your-tables { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.your-tables li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.your-tables li .btn { margin-left: auto; }
.your-tables li .btn + .btn { margin-left: 0; }
/* Truco paulista replay: the score above the table (the places have no lives to show). */
.replay-score { margin: 0 0 6px; font-size: 1.05rem; }
.replay-score strong { color: var(--accent); font-variant-numeric: tabular-nums; }
