/* Go Fish table. Seats, fans, books and bubbles come from assets/css/seats.css. */

.table.gf {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 1100px;
  min-height: calc(100vh - 64px);
  min-height: calc(100dvh - 64px);
  margin: 0 auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

/* ---------- 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: 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'; }
.opponents { display: contents; }
.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; }
.you .books { min-height: 30px; }

/* ---------- Pond ---------- */
.pond-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.pond {
  position: relative;
  width: 200px;
  height: 118px;
}
.pond .card {
  --w: 44px;
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -31px 0 0 -22px;
  transform: translate(var(--x), var(--y)) 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: 40px; }

/* ---------- Your hand ---------- */
.prompt {
  min-height: 1.4em;
  margin: 6px 0 0;
  text-align: center;
  font-weight: 600;
  color: var(--ink-2);
}
.prompt strong { color: var(--gold-2); }
.hand {
  --card-w: clamp(58px, 8.6vw, 90px);
  --overlap: calc(var(--card-w) * -0.45);
  --gap: 10px;
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: calc(var(--card-w) * 1.4 + 22px);
  padding-top: 20px;
}
.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 { display: flex; justify-content: center; padding-top: 8px; min-height: 60px; }
#ask-btn { min-width: 220px; }

/* ---------- History ---------- */
.history {
  width: min(560px, 100%);
  margin-top: 8px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
}
.history summary {
  cursor: pointer;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  list-style-position: inside;
}
.history summary:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; border-radius: 14px; }
.history-note { margin-left: 6px; font-weight: 500; letter-spacing: 0.02em; text-transform: none; color: var(--ink-3); }
.history ol { margin: 0; padding: 0 16px 12px; list-style: none; }
.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); border-top: 0; }

/* ---------- 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.7rem; 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; } }

/* ---------- 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); }
  .table.gf { padding-top: 10px; }
  .ring, .ring[data-opponents] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'opps' 'pond' 'you';
    gap: 10px;
  }
  .ring[data-opponents='3'] .seat[data-pos] { margin-top: 0; }
  .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.6rem; }
  .opponents .seat-count { position: absolute; top: 4px; right: 4px; min-width: 22px; height: 20px; padding: 0 5px; font-size: 0.72rem; }
  .opponents .seat-key { top: -6px; left: -2px; right: auto; }
  .opponents .fan { --mini: 22px; width: min(100%, 96px); }
  .opponents .books { gap: 0; min-height: 20px; }
  .opponents .book { width: 15px; height: 20px; font-size: 0.6rem; border-radius: 3px; }
  .opponents .book + .book { margin-left: -5px; }
  .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 { width: 170px; height: 84px; }
  .pond .card { --w: 34px; margin: -24px 0 0 -17px; transform: translate(calc(var(--x) * 0.85), calc(var(--y) * 0.5)) rotate(var(--r)); }
  .hand { --card-w: 54px; padding-top: 18px; }
  .history { margin-top: 4px; }
  #ask-btn { min-width: 0; width: 100%; max-width: 360px; }
  .speed-text { display: none; }
  .speed-btn { width: 36px; padding: 0; }
  .controls { flex-wrap: wrap; gap: 6px; }
  .leave-btn { margin-left: 0; min-height: 36px; }
  .credits-pill .pill-label { 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: 3px 7px; font-size: 0.6rem; }
  .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; }
}
