/* Go Fish table. Seats, fans, books and bubbles come from assets/css/seats.css. */

/* The table is the window under the header (base.css; Brief 18): the cards, fans and pond size
   themselves from its box (container units) times --fit, which TC.fitTable steps down if a big
   hand or a full table would still overflow. Nothing scrolls. */
.table.gf {
  --fit: 1;
  --seat-k: 1; /* the opponents' fans and the pond, bigger on a tall screen */
  --hand-w: max(44px, calc(min(max(54px, 8.6cqw), 15cqh, 124px) * var(--fit)));
  container: gf-table / size;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  max-width: max(1100px, 150dvh);
  margin: 0 auto;
  padding: clamp(6px, 2dvh, 16px) 16px calc(clamp(6px, 2dvh, 16px) + env(safe-area-inset-bottom));
}
@media (min-height: 900px) { .table.gf { --seat-k: 1.25; } }
.table.gf.locked { justify-content: center; }

/* ---------- Seats around the felt ---------- */
.ring {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  gap: clamp(4px, 1.6cqh, 14px) 16px;
}
.ring[data-opponents='1'] { grid-template-areas: '. top .' '. pond .' 'you you you'; }
.ring[data-opponents='2'] { grid-template-areas: 'left pond right' 'you you you'; }
.ring[data-opponents='3'] { grid-template-areas: '. top .' 'left pond right' 'you you you'; }
/* Online tables seat up to 6 (Brief 11): 4 or 5 opponents. */
.ring[data-opponents='4'] { grid-template-areas: 'tl . tr' 'left pond right' 'you you you'; }
.ring[data-opponents='5'] { grid-template-areas: 'tl top tr' 'left pond right' 'you you you'; }
.opponents { display: contents; }
.seat[data-pos='top-left'] { grid-area: tl; }
.seat[data-pos='top-right'] { grid-area: tr; }
.seat[data-pos='top'] { grid-area: top; }
.seat[data-pos='left'] { grid-area: left; }
.seat[data-pos='right'] { grid-area: right; }
.pond-area { grid-area: pond; }
.you { grid-area: you; display: flex; justify-content: center; width: 100%; }
.ring[data-opponents='3'] .seat[data-pos='left'], .ring[data-opponents='3'] .seat[data-pos='right'] { margin-top: -28px; }

.you .seat { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 10px 14px; }
/* Wide screens: your speech bubble sits beside your seat, clear of the pond's label. */
@media (min-width: 641px) {
  .you .seat.mine .bubble { top: 50%; bottom: auto; left: calc(100% + 12px); translate: 0 -50%; transform-origin: left center; }
  .you .seat.mine .bubble::before { top: 50%; bottom: auto; left: -7px; margin: -8px 0 0; border: 8px solid transparent; border-left: 0; border-right-color: #fbf7e9; }
}
.you .fan { display: none; }
/* Watching an online game (no seat): the bottom seat is someone else's, so show their cards' backs. */
.ring.watching .you .fan { display: block; }
.you .books { min-height: 30px; }
/* The opponents' face-down fans, from the table's height. */
.gf .fan { --mini: calc(34px * var(--seat-k) * var(--fit)); }
.gf .seat { gap: clamp(3px, 1cqh, 8px); }

/* ---------- Pond ---------- */
.pond-area {
  --ps: calc(var(--seat-k) * var(--fit)); /* the pond's scale */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(3px, 1cqh, 8px);
}
.pond {
  position: relative;
  width: calc(200px * var(--ps));
  height: calc(118px * var(--ps));
}
.pond .card {
  --w: calc(44px * var(--ps));
  position: absolute;
  left: 50%;
  top: 50%;
  margin: calc(-31px * var(--ps)) 0 0 calc(-22px * var(--ps));
  transform: translate(calc(var(--x) * var(--ps)), calc(var(--y) * var(--ps))) rotate(var(--r));
}
.pond .card .card-back { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 3px 8px rgba(0, 0, 0, 0.25); }
.pond-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.pond-area.empty .pond { height: calc(40px * var(--ps)); }

/* ---------- Your hand ---------- */
.prompt {
  min-height: 1.4em;
  margin: 0;
  text-align: center;
  font-weight: 600;
  color: var(--ink-2);
}
.prompt strong { color: var(--gold-2); }
.hand {
  --card-w: var(--hand-w);
  --overlap: calc(var(--card-w) * -0.45);
  --gap: 10px;
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: calc(var(--card-w) * 1.4 + 18px);
  padding-top: 18px; /* (room for the picked cards to rise) */
}
.hc {
  appearance: none;
  flex: none;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  border-radius: calc(var(--card-w) * 0.085);
  cursor: default;
  transition: translate 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.hc + .hc { margin-left: var(--overlap); }
.hc.rank-start + .hc, .hc + .hc.rank-start { margin-left: calc(var(--overlap) + var(--gap)); }
.hc + .hc:not(.rank-start) { margin-left: var(--overlap); }
.hand.live .hc { cursor: pointer; }
.hand.live .hc:hover { translate: 0 -6px; }
.hc.picked { translate: 0 -16px; }
.hand.live .hc.picked:hover { translate: 0 -18px; }
.hc.picked .card-face { box-shadow: 0 0 0 3px var(--gold-2), 0 8px 22px rgba(244, 220, 149, 0.35); }
.hc:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 3px; }

/* ---------- Controls ---------- */
.controls { position: relative; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 10px; }
#ask-btn { min-width: min(220px, 100%); }

/* ---------- History: a button in the controls, the list a sheet over the table (Brief 18) ---------- */
.history { position: static; }
.history summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  list-style: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.history summary::-webkit-details-marker { display: none; }
.history[open] summary { color: #2b1c04; border-color: transparent; background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.history summary:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.history-note { display: none; }
/* The list opens above the controls, over the felt, and scrolls inside itself if it must. */
.history ol {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 25;
  translate: -50% 0;
  width: min(560px, calc(100cqw - 16px));
  max-height: min(420px, 62cqh);
  overflow-y: auto;
  margin: 0;
  padding: 4px 16px 10px;
  list-style: none;
  border-radius: 16px;
  background: rgba(3, 22, 13, 0.97);
  border: 1px solid rgba(217, 180, 90, 0.45);
  box-shadow: var(--shadow);
  animation: card-in 0.2s var(--ease);
}
.history ol::before { content: 'Last 10 asks'; display: block; padding: 8px 0 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.history li {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--hairline);
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--ink-2);
}
.history li b { color: var(--ink); font-weight: 700; }
.history .res { margin-left: auto; white-space: nowrap; font-weight: 700; }
.history .res.got { color: var(--win); }
.history .res.fish { color: var(--ink-3); }
.history .res.lucky { color: var(--gold-2); }
.history .empty { color: var(--ink-3); }

/* ---------- Setup and game over ---------- */
.panel-card {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 20;
  translate: -50% -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 26px 22px;
  text-align: center;
  border-radius: 20px;
  background: rgba(3, 22, 13, 0.96);
  border: 1px solid rgba(217, 180, 90, 0.45);
  box-shadow: var(--shadow);
  animation: card-in 0.3s var(--ease);
}
/* Not base.css's rise: that animates translate, which this panel uses to centre itself. */
@keyframes card-in { from { opacity: 0; scale: 0.96; } }
.panel-card h2 { margin: 0; font-family: var(--font-display); font-size: 1.6rem; color: var(--gold-2); }
.table.gf.paused > :is(.ring, .prompt, .hand, .controls, .history) { opacity: 0.25; pointer-events: none; }

.seg { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.seg legend { width: 100%; margin-bottom: 8px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: inline-grid;
  place-items: center;
  min-width: 64px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.seg input:checked + span { color: #2b1c04; border-color: transparent; background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.seg input:focus-visible + span { outline: 2px solid var(--gold-2); outline-offset: 3px; }
.setup-note { margin: 0; min-height: 2.6em; color: var(--ink-2); font-size: 0.92rem; line-height: 1.4; }

.standings { width: 100%; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.standings li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  text-align: left;
}
.standings li.winner { background: rgba(244, 220, 149, 0.12); box-shadow: inset 0 0 0 1px rgba(244, 220, 149, 0.45); }
.standings .avatar { width: 34px; height: 34px; font-size: 0.95rem; }
.standings .who { flex: 1; min-width: 0; font-weight: 700; }
.standings .who small { display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.standings .n { font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.standings .n small { font-weight: 600; font-size: 0.75rem; color: var(--ink-3); }
.standings .crown { color: var(--gold-2); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }

/* ---------- Top bar ---------- */
.speed-btn { min-height: 40px; height: 40px; padding: 0 14px; font-size: 0.85rem; }
.speed-btn svg { width: 18px; height: 18px; }
.speed-btn[aria-pressed='true'] { color: #2b1c04; border-color: transparent; background: linear-gradient(180deg, var(--gold-2), var(--gold)); }

.stats-note { margin: 10px 0 0; font-size: 0.85rem; color: var(--ink-3); }

/* ---------- Ranked (server-run) ---------- */
.rank-pill { padding: 0 14px; color: var(--gold-2); text-decoration: none; }
.rank-pill:hover { border-color: rgba(217, 180, 90, 0.55); }
.leave-btn { min-height: 44px; margin-left: 10px; color: var(--ink-3); }
.leave-btn:hover { color: var(--ink); }
.ranked-start p { margin: 0; }
.ranked-terms { font-size: 1.05rem; line-height: 1.5; color: var(--ink-2); }
.ranked-terms strong { color: var(--gold-2); font-size: 1.15rem; }
.ranked-note { font-size: 0.88rem; line-height: 1.4; color: var(--ink-3); }
.ranked-balance { font-weight: 600; color: var(--ink-2); }
.ranked-balance strong, .over-balance strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.ranked-next { color: var(--ink-2); }
.claim-btn .coin { width: 20px; height: 20px; }
.ranked-start.broke h2 { color: var(--lose); }
.over-prize { margin: -6px 0 0; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: var(--gold-2); }
.over-prize.none { font-family: inherit; font-weight: 600; font-size: 1rem; color: var(--ink-2); }
.over-balance { margin: 0; color: var(--ink-2); }
.toast {
  position: absolute;
  left: 50%;
  top: 12px;
  z-index: 30;
  translate: -50% 0;
  max-width: calc(100% - 32px);
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  background: rgba(2, 14, 8, 0.9);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  opacity: 0;
  scale: 0.9;
  pointer-events: none;
  transition: opacity 0.25s, scale 0.3s var(--ease);
}
.toast.show { opacity: 1; scale: 1; }
.toast.lose { color: var(--lose); border-color: rgba(255, 114, 114, 0.4); }
.toast.gold { color: #2b1c04; background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-color: transparent; }
/* Start: the pond is shuffled on the click, while the server deals. */
.pond.shuffling .card { animation: pond-shuffle 0.5s var(--ease) infinite alternate; animation-delay: calc(var(--i, 0) * -70ms); }
@keyframes pond-shuffle { to { transform: translate(calc(var(--x) * 0.25), calc(var(--y) * 0.25)) rotate(calc(var(--r) + 40deg)); } }
/* An answer that's taking over 1.5s: a soft light sweeps across the waiting cards' backs (the pond,
   or the fan of the player who was asked). As in Ranked Blackjack. */
.waiting > .card .card-back { overflow: hidden; }
.waiting > .card .card-back::before {
  content: '';
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255, 243, 210, 0.24), transparent);
  transform: translateX(-130%) skewX(-16deg);
  animation: shimmer 2s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-130%) skewX(-16deg); }
  60%, 100% { transform: translateX(260%) skewX(-16deg); }
}
@media (prefers-reduced-motion: reduce) {
  .pond.shuffling .card { animation: none !important; }
  .waiting > .card .card-back::before { content: none; }
  .waiting > .card .card-back { animation: waiting-pulse 2s ease-in-out infinite !important; }
}
@keyframes waiting-pulse { 50% { opacity: 0.72; } }

/* ---------- Wide screens (Brief 18): your seat, your hand and the controls share the bottom row ---------- */
/* The opponents and the pond keep their places round the felt; your plate (and books) sits at the
   left of your hand and the Ask button at its right, so a laptop's short window still fits. */
@media (min-width: 641px) and (min-height: 501px) {
  .table.gf { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); align-content: space-evenly; justify-items: center; align-items: center; gap: 0 16px; }
  .table.gf > .ring { display: contents; }
  .table.gf:has(> .ring[data-opponents='0']), .table.gf:has(> .ring[data-opponents='1']) { grid-template-areas: '. top .' '. pond .' 'prompt prompt prompt' 'you hand ctl' 'bar bar bar'; }
  .table.gf:has(> .ring[data-opponents='2']) { grid-template-areas: 'left pond right' 'prompt prompt prompt' 'you hand ctl' 'bar bar bar'; }
  .table.gf:has(> .ring[data-opponents='3']) { grid-template-areas: '. top .' 'left pond right' 'prompt prompt prompt' 'you hand ctl' 'bar bar bar'; }
  .table.gf:has(> .ring[data-opponents='4']) { grid-template-areas: 'tl . tr' 'left pond right' 'prompt prompt prompt' 'you hand ctl' 'bar bar bar'; }
  .table.gf:has(> .ring[data-opponents='5']) { grid-template-areas: 'tl top tr' 'left pond right' 'prompt prompt prompt' 'you hand ctl' 'bar bar bar'; }
  .ring[data-opponents='3'] .seat[data-pos='left'], .ring[data-opponents='3'] .seat[data-pos='right'] { margin-top: 0; }
  .gf .prompt { grid-area: prompt; margin: clamp(2px, 1cqh, 8px) 0 0; }
  .gf .hand { grid-area: hand; }
  .gf .controls { grid-area: ctl; }
  .gf .online-bar { grid-area: bar; margin-top: 4px; }
  .gf .you { width: auto; max-width: 100%; }
  .gf .opponents .seat { max-width: 100%; }
  .gf .you .seat { flex-direction: column; gap: 8px; }
  .gf .lock-panel { grid-column: 1 / -1; }
  .you .seat.mine .bubble { top: auto; bottom: calc(100% + 4px); left: 50%; translate: -50% 0; transform-origin: center bottom; }
  .you .seat.mine .bubble::before { top: auto; bottom: -7px; left: 50%; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: #fbf7e9; }
  .gf .history ol { left: auto; right: 0; translate: none; }
}

/* ---------- Small screens: opponents in a row along the top ---------- */
@media (max-width: 640px) {
  .topbar .brand { display: none; }
  .topbar-title { border-left: none; padding-left: 4px; font-size: 1.05rem; color: var(--ink); }
  /* The opponents in a row, then the pond with your plate beside it, then your hand. */
  .ring, .ring[data-opponents] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: 'opps opps' 'pond you';
    gap: clamp(4px, 1.4cqh, 10px) 8px;
  }
  .ring[data-opponents='0'] { grid-template-areas: 'pond you'; }
  .ring[data-opponents='3'] .seat[data-pos] { margin-top: 0; }
  .you .seat { flex-direction: column; gap: 6px; }
  /* Your seat is at the right: your speech bubble opens leftwards from it, inside the screen. */
  .you .seat.mine .bubble { left: auto; right: 0; translate: 0 0; transform-origin: right bottom; }
  .you .seat.mine .bubble::before { left: auto; right: 22px; }
  .opponents {
    grid-area: opps;
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
  }
  .opponents .seat { flex: 1 1 0; gap: 5px; }
  .opponents .seat-plate { flex-direction: column; gap: 3px; min-height: 0; width: 100%; padding: 6px 4px 7px; border-radius: 14px; text-align: center; }
  .opponents .seat-who { align-items: center; max-width: 100%; }
  .opponents .avatar { width: 30px; height: 30px; font-size: 0.9rem; }
  .opponents .seat-name { font-size: 0.85rem; max-width: 100%; }
  .opponents .seat-tag { font-size: 0.75rem; letter-spacing: 0.04em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .opponents .seat-count { position: absolute; top: 4px; right: 4px; min-width: 22px; height: 20px; padding: 0 5px; font-size: 0.75rem; }
  .opponents .seat-key { display: none; } /* (no keyboard on a phone) */
  .opponents .fan { --mini: calc(22px * var(--fit)); width: min(100%, 96px); }
  .opponents .books { gap: 0; min-height: 21px; }
  .opponents .book { width: 16px; height: 21px; font-size: 0.75rem; border-radius: 3px; }
  .opponents .book + .book { margin-left: -6px; }
  .opponents .seat[data-pos='left'] .bubble { left: 0; translate: 0 0; }
  .opponents .seat[data-pos='left'] .bubble::before { left: 24px; }
  .opponents .seat[data-pos='right'] .bubble { left: auto; right: 0; translate: 0 0; }
  .opponents .seat[data-pos='right'] .bubble::before { left: auto; right: 16px; }
  .pond-area { --ps: calc(0.85 * var(--fit)); }
  .pond { height: calc(84px * var(--ps)); }
  .pond .card { transform: translate(calc(var(--x) * var(--ps)), calc(var(--y) * 0.6 * var(--ps))) rotate(var(--r)); }
  #ask-btn { flex: 1 1 140px; min-width: 0; max-width: 360px; }
  .speed-text { display: none; }
  .speed-btn { width: 36px; padding: 0; }
  .controls { width: 100%; gap: 6px; }
  .controls .btn, .history summary { min-height: 44px; }
  .leave-btn { margin-left: 0; padding: 0 14px; }
  .react-btn { padding: 0 14px; }
  .history summary { padding: 0 14px; letter-spacing: 0.04em; }
  .credits-pill .pill-label { display: none; }
}
/* Small screens with 4 or 5 opponents (online): a tighter row, so 5 fit across 360 px. */
@media (max-width: 640px) {
  .ring[data-opponents='4'] .opponents, .ring[data-opponents='5'] .opponents { gap: 3px; }
  .ring[data-opponents='4'] .opponents .seat-plate, .ring[data-opponents='5'] .opponents .seat-plate { padding: 5px 2px 6px; border-radius: 12px; }
  .ring[data-opponents='4'] .opponents .avatar, .ring[data-opponents='5'] .opponents .avatar { width: 26px; height: 26px; font-size: 0.8rem; }
  .ring[data-opponents='4'] .opponents .seat-name, .ring[data-opponents='5'] .opponents .seat-name { font-size: 0.75rem; }
  .ring[data-opponents='4'] .opponents .seat-tag, .ring[data-opponents='5'] .opponents .seat-tag { letter-spacing: 0; }
  .ring[data-opponents='4'] .opponents .seat-count, .ring[data-opponents='5'] .opponents .seat-count { top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; }
  .ring[data-opponents='4'] .opponents .fan, .ring[data-opponents='5'] .opponents .fan { --mini: calc(17px * var(--fit)); width: min(100%, 70px); }
  .ring[data-opponents='4'] .opponents .book + .book, .ring[data-opponents='5'] .opponents .book + .book { margin-left: -8px; }
  .ring[data-opponents='4'] .opponents .seat-key, .ring[data-opponents='5'] .opponents .seat-key { display: none; }
}
@media (max-width: 480px) {
  .topbar { padding-inline: 12px; gap: 6px; }
  .topbar-heading { flex-direction: column; align-items: flex-start; gap: 3px; }
  .topbar-title { font-size: 1rem; line-height: 1.1; padding-left: 0; }
  .mode-badge { padding: 2px 7px; font-size: 0.75rem; letter-spacing: 0.04em; }
  .topbar .btn-icon, .speed-btn { width: 36px; height: 36px; min-height: 36px; }
  .pill { gap: 6px; height: 36px; padding: 0 10px 0 6px; font-size: 0.92rem; }
  .pill .coin { width: 20px; height: 20px; }
  .rank-pill { padding: 0 9px; }
}

/* ---------- Phones on their side (Brief 18): a compact table, the controls in a column at the right ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .table.gf {
    --side: 168px;
    --hand-w: max(40px, calc(min(max(48px, 7cqw), 20cqh, 80px) * var(--fit)));
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--side);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: 'ring side' 'prompt side' 'hand side' 'bar side';
    align-items: center;
    justify-items: center;
    gap: 2px 10px;
    max-width: none;
    padding-top: 4px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
  }
  .table.gf > .ring {
    display: grid;
    grid-area: ring;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: 'opps opps opps' '. pond you';
    gap: 2px 10px;
  }
  .table.gf > .ring[data-opponents='0'] { grid-template-areas: '. pond you'; }
  .gf .prompt { grid-area: prompt; font-size: 0.9rem; }
  .gf .hand { grid-area: hand; padding-top: 12px; min-height: calc(var(--card-w) * 1.4 + 12px); }
  .gf .online-bar { grid-area: bar; }
  .gf .lock-panel { grid-area: 1 / 1 / -1 / -1; padding: 16px; gap: 10px; }
  .gf .controls { grid-area: side; grid-row: 1 / -1; flex-direction: column; flex-wrap: nowrap; align-items: stretch; width: 100%; gap: 6px; }
  .gf .controls > * { width: 100%; }
  .gf #ask-btn { flex: none; width: 100%; max-width: none; min-height: 48px; padding: 0 12px; font-size: 1rem; }
  .gf .controls .btn, .gf .history summary { width: 100%; justify-content: center; min-height: 40px; }
  .gf .react-menu { bottom: auto; top: 0; right: calc(100% + 8px); }
  .gf .history ol { left: auto; right: calc(100% + 8px); bottom: auto; top: 0; translate: none; width: min(420px, calc(100cqw - var(--side) - 24px)); max-height: calc(100cqh - 8px); }
  /* Opponents: one compact row of pills, the fan and books under each. */
  .gf .opponents { grid-area: opps; display: flex; justify-content: space-around; align-items: center; gap: 4px; width: 100%; }
  .gf .opponents .seat { flex: 1 1 0; display: flex; flex-flow: row wrap; justify-content: center; align-items: center; gap: 2px 4px; min-width: 0; }
  .gf .opponents .seat-plate { flex: 0 0 100%; flex-direction: row; gap: 5px; min-height: 0; width: auto; min-width: 0; max-width: 100%; padding: 3px 8px 3px 3px; border-radius: 999px; text-align: left; }
  .gf .opponents .seat-who { align-items: flex-start; }
  .gf .opponents .avatar { width: 24px; height: 24px; font-size: 0.75rem; }
  .gf .opponents .seat-name { font-size: 0.8rem; }
  .gf .opponents .seat-tag { font-size: 0.75rem; letter-spacing: 0; }
  .gf .opponents .seat-count { position: static; min-width: 20px; height: 18px; padding: 0 4px; font-size: 0.75rem; }
  .gf .opponents .seat-key { display: none; }
  .gf .opponents .fan { flex: none; --mini: calc(16px * var(--fit)); width: 46px; }
  .gf .opponents .books { flex: none; gap: 0; min-height: 0; }
  .gf .opponents .book { width: 14px; height: 19px; font-size: 0.75rem; border-radius: 3px; }
  .gf .opponents .book + .book { margin-left: -7px; }
  .gf .opponents .seat .bubble { top: 100%; left: 50%; translate: -50% 0; right: auto; }
  /* Four or five opponents: the names get the room (the count sits on the plate's corner). */
  .gf .ring:is([data-opponents='4'], [data-opponents='5']) .opponents .avatar { display: none; }
  .gf .ring:is([data-opponents='4'], [data-opponents='5']) .opponents .seat-plate { padding: 3px 18px 3px 8px; }
  .gf .ring:is([data-opponents='4'], [data-opponents='5']) .opponents .seat-count { position: absolute; top: -6px; right: -4px; }
  .gf .pond-area { grid-area: pond; flex-direction: row; gap: 8px; --ps: calc(0.5 * var(--fit)); }
  .gf .pond { height: calc(80px * var(--ps)); }
  .gf .you { grid-area: you; width: auto; }
  .gf .you .seat { flex-direction: row; gap: 6px; }
  .gf .you .seat-plate { min-height: 36px; padding: 3px 10px 3px 3px; }
  .gf .you .avatar { width: 28px; height: 28px; font-size: 0.85rem; }
  .gf .you .books { min-height: 0; }
  .gf .panel-card { padding: 14px 16px; gap: 10px; }
  .gf .panel-card h2 { font-size: 1.25rem; }
}
