/* Texas Hold'em (Brief 15): the table for Solo practice and friends tables. An oval felt with up
   to 8 seats placed round it by holdem.js (left / top, each centred on its point), you at the bottom
   centre with your cards large; the board and the pots in the middle; your actions in a bar under
   the felt (never over your cards or the board). Everything sizes itself from the felt (container
   units) times --fit, which holdem.js steps down while anything runs into anything else. */

/* ---------- The page ---------- */
.table.hd {
  display: flex;
  flex-direction: column;
  max-width: none;
  gap: 4px;
  padding: 4px clamp(6px, 1.4vw, 24px) calc(6px + env(safe-area-inset-bottom));
  overflow: clip;
}
.hd-felt { position: relative; flex: 1 1 0; width: 100%; min-height: 0; container: felt / size; }
.hd.paused :is(.hd-stage, .hd-foot, .hd-controls) { opacity: 0.25; pointer-events: none; }

/* Panels over the felt (the room, setup, places), as on the other tables. */
.hd .panel-card {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 20;
  translate: -50% -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(440px, calc(100% - 16px));
  max-height: calc(100% - 8px);
  overflow-y: auto;
  padding: 22px 20px;
  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: hd-card-in 0.3s var(--ease);
}
@keyframes hd-card-in { from { opacity: 0; scale: 0.96; } }
.hd .panel-card h2 { margin: 0; font-family: var(--font-display); font-size: 1.5rem; color: var(--gold-2); }
.hd .seg { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.hd .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); }
.hd .seg label { position: relative; }
.hd .seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.hd .seg span {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  min-height: 44px;
  padding: 0 14px;
  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;
}
.hd .seg input:checked + span { color: #2b1c04; border-color: transparent; background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.hd .seg input:focus-visible + span { outline: 2px solid var(--gold-2); outline-offset: 3px; }
.mode-badge.online { color: #2b1c04; background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.hd-styles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; width: 100%; }
.hd-styles label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--ink-3); text-align: left; }
.hd-styles select { min-height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.06); color: var(--ink); font: inherit; }
.hd-styles option { color: #111; }
.hd-places { margin: 0; padding: 0; list-style: none; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.hd-places li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); }
.hd-places li.me { outline: 1px solid var(--gold); }
.hd-places .place { min-width: 88px; font-weight: 800; color: var(--gold-2); text-align: left; }
.hd-over-you { margin: 0; font-size: 1.15rem; color: var(--ink); }

/* ---------- The stage ---------- */
.hd-stage {
  --fit: 1;
  /* Sizes from the felt (phones first). */
  --board-w: max(30px, calc(min(10.5cqw, 11cqh, 84px) * var(--fit)));
  --me-w: max(44px, calc(min(15cqw, 15cqh, 104px) * var(--fit)));
  --hole-w: max(20px, calc(min(5cqw, 7cqh, 40px) * var(--fit)));
  --shown-w: max(32px, calc(min(7.5cqw, 9cqh, 56px) * var(--fit)));
  --plate-w: clamp(76px, calc(min(25cqw, 184px) * var(--fit)), 192px);
  --avatar: max(26px, calc(min(8cqw, 6cqh, 38px) * var(--fit)));
  --fs: max(12px, calc(min(3.4cqw, 2.7cqh, 15px) * var(--fit)));
  position: absolute;
  inset: 0;
  overflow: hidden;
}
/* The printed rail. */
.hd-oval {
  position: absolute;
  left: var(--oval-l, 8%);
  right: var(--oval-l, 8%);
  top: var(--oval-t, 10%);
  bottom: var(--oval-t, 10%);
  border-radius: 50%;
  border: 2px solid rgba(244, 220, 149, 0.14);
  background: radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, 0.05), transparent 70%);
  box-shadow: inset 0 0 0 10px rgba(0, 0, 0, 0.06);
  pointer-events: none;
}

/* The middle: the blind level, the pots, the board. */
.hd-centre {
  position: absolute;
  left: 50%;
  top: var(--centre-y, 46%);
  translate: -50% -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
/* The board's cards are on top of the felt (the middle lets taps through around them). */
.hd-board .card { pointer-events: auto; }
.hd-level { margin: 0; font-size: var(--fs); font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.hd-pots { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; min-height: calc(var(--fs) * 1.6); }
.hd-pot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px 2px 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-size: var(--fs);
  font-weight: 800;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hd-pot small { font-weight: 600; color: var(--ink-3); font-size: 1em; }
.hd-board { display: flex; gap: calc(var(--board-w) * 0.08); min-height: calc(var(--board-w) * 1.4); }
.hd-board .card { --w: var(--board-w); }
.hd-board .slot { width: var(--board-w); height: calc(var(--board-w) * 1.4); border-radius: calc(var(--board-w) * 0.085); border: 1px dashed rgba(244, 220, 149, 0.16); }
.card.best .card-face { box-shadow: 0 0 0 3px var(--gold-2), 0 0 18px rgba(244, 220, 149, 0.7); }
.hd-board.dim .card:not(.best) .card-face, .hd-seat.dim .card:not(.best) .card-face { filter: brightness(0.62); }
.hd-deck { position: absolute; left: 50%; top: var(--centre-y, 46%); width: 1px; height: 1px; }

/* ---------- Seats ---------- */
.hd-seats { margin: 0; padding: 0; list-style: none; }
.hd-seat {
  position: absolute;
  translate: -50% -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: var(--plate-w);
  z-index: 2;
}
.hd-seat .seat-plate {
  gap: 6px;
  width: 100%;
  min-height: 0;
  padding: 3px 8px 3px 3px;
  font-size: var(--fs);
}
.hd-seat .avatar { width: var(--avatar); height: var(--avatar); font-size: calc(var(--avatar) * 0.46); flex: none; }
.hd-seat .seat-who { min-width: 0; flex: 1 1 auto; }
.hd-seat .seat-name { font-size: var(--fs); }
.hd-seat .bot-chip { font-size: 12px; padding: 0.05em 0.4em; }
.hd-line2 { display: flex; align-items: center; gap: 4px; min-width: 0; }
.hd-seat .hd-stack { font-size: var(--fs); font-weight: 800; color: var(--gold-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hd-seat .guest-tag { font-size: 12px; margin-left: 4px; }
.hd-seat .seat-tag { font-size: 12px; letter-spacing: 0.04em; }
.hd-hole { display: flex; justify-content: center; min-height: calc(var(--hole-w) * 1.4); }
/* The big letter on a picture card never under 12px, however small the card. */
.hd .card .court { font-size: max(12px, calc(var(--w) * 0.36)); }
.hd-hole .card { --w: var(--hole-w); }
.hd-hole .card + .card { margin-left: calc(var(--hole-w) * -0.35); }
.hd-hole.shown .card { --w: var(--shown-w); }
.hd-hole.shown { min-height: calc(var(--shown-w) * 1.4); }
.hd-hole.shown .card + .card { margin-left: calc(var(--shown-w) * -0.15); }
.hd-seat.folded .hd-hole { opacity: 0.28; }
.hd-seat.folded .seat-plate, .hd-seat.out .seat-plate, .hd-seat.sitting .seat-plate { opacity: 0.55; }
.hd-tag {
  min-height: calc(var(--fs) * 1.3);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}
.hd-tag.blank { visibility: hidden; }
.hd-tag .tg-hand { display: none; }
.hd-tag.raise, .hd-tag.bet, .hd-tag.allin { color: var(--gold-2); }
.hd-tag.fold { color: var(--ink-3); }
.hd-tag.win { color: var(--win); }
.hd-handname { max-width: 100%; font-size: 12px; font-weight: 700; line-height: 1.15; color: var(--gold-2); text-align: center; overflow-wrap: anywhere; }
.hd-handname.blank { display: none; }
.hd-seat.empty { opacity: 0.5; }
.hd-seat.empty .seat-plate { justify-content: center; padding: 6px; border-style: dashed; background: transparent; box-shadow: none; }
.hd-seat .bubble { bottom: 100%; }

/* Your seat: your cards large, your hand's name under them. */
.hd-seat.me { width: auto; z-index: 3; }
.hd-seat.me .hd-hole .card { --w: var(--me-w); }
.hd-seat.me .hd-hole { min-height: calc(var(--me-w) * 1.4); }
.hd-seat.me .hd-hole .card + .card { margin-left: calc(var(--me-w) * 0.06); }
.hd-seat.me .seat-plate { width: auto; min-width: var(--plate-w); max-width: 220px; }
.hd-seat.me .hd-mine { font-size: var(--fs); font-weight: 700; color: var(--gold-2); min-height: calc(var(--fs) * 1.3); white-space: nowrap; }
.hd-seat.me .hd-equity { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }

/* The turn clock round the avatar (online.css), and the turn glow on the plate. */
.hd-seat.turn .seat-plate { border-color: var(--gold-2); box-shadow: 0 0 0 2px rgba(244, 220, 149, 0.4), 0 0 20px rgba(244, 220, 149, 0.28); }

/* Bets in front of each seat, the dealer button and blind markers (placed by holdem.js). */
.hd-bet {
  position: absolute;
  translate: -50% -50%;
  z-index: 1;
  pointer-events: none;
}
/* The dealer button and blind marker on the plate's corner. */
.hd-marks { position: absolute; top: -7px; right: -6px; display: flex; gap: 2px; pointer-events: none; }
.hd-bet {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 1px 2px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  font-size: var(--fs);
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hd-bet:empty, .hd-bet[data-amount='0'] { display: none; }
.hd-coin, .hd-fly {
  display: inline-block;
  width: calc(var(--fs) * 1.25);
  height: calc(var(--fs) * 1.25);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fff 0 22%, transparent 23%), repeating-conic-gradient(#c0392b 0 30deg, #f5f5f5 30deg 45deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(0, 0, 0, 0.15);
  flex: none;
}
.hd-fly { position: fixed; z-index: 50; pointer-events: none; }
.hd-btn {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e8e2cf 70%);
  color: #222;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.hd-btn.blind { width: auto; padding: 0 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.82); }

.hd-stage .toast {
  position: absolute;
  left: 50%;
  top: calc(var(--centre-y, 46%) - var(--board-w) * 1.6);
  translate: -50% -50%;
  z-index: 30;
  max-width: calc(100% - 16px);
}

/* ---------- Under the felt: the status line, the bar, your actions ---------- */
.hd-foot { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hd-status { margin: 0; min-height: 1.3em; font-size: 0.9rem; font-weight: 600; color: var(--ink-2); text-align: center; }
.hd-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.hd-bar .btn { min-height: 40px; padding: 0 14px; }
.hd-bar .btn[aria-pressed='true'] { color: #2b1c04; background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-color: transparent; }

.hd-controls { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
/* One row of buttons is always kept (your turn, act in advance, Rebuy, or none): the felt keeps its
   size as they come and go. */
.hd-controls { min-height: 46px; justify-content: flex-end; }
.hd-actions, .hd-pre, .hd-misc, .hd-presets, .hd-confirm { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: 100%; }
.hd-actions .btn, .hd-pre .btn, .hd-misc .btn, .hd-confirm .btn { min-height: 46px; flex: 1 1 0; max-width: 200px; padding: 0 10px; white-space: nowrap; }
.hd-actions .btn:disabled { opacity: 0.35; }
.hd-pre .btn[aria-pressed='true'] { color: #2b1c04; background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-color: transparent; }
.hd-presets .btn { min-height: 44px; flex: 1 1 0; max-width: 110px; padding: 0 6px; font-size: 0.9rem; }
.hd-sizer { display: flex; flex-direction: column; gap: 6px; width: min(640px, 100%); }
.hd-amount { display: flex; align-items: center; gap: 10px; }
.hd-amount input[type='range'] { flex: 1 1 auto; min-width: 0; min-height: 44px; accent-color: var(--gold); }
.hd-amount input[type='number'] {
  width: 104px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: 700 1rem var(--font-ui);
  text-align: right;
}
.hd-confirm { align-items: center; }
.hd-confirm span { width: 100%; text-align: center; font-weight: 700; color: var(--gold-2); }

/* ---------- Hand history ---------- */
.hd-hist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.hd-hist li { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); }
.hd-hist h4 { margin: 0 0 4px; display: flex; justify-content: space-between; gap: 10px; color: var(--ink); font-size: 0.95rem; }
.hd-hist h4 .won { color: var(--win); }
.hd-hist h4 .lost { color: var(--lose); }
.hd-hist p { margin: 2px 0; font-size: 0.85rem; color: var(--ink-2); }
.hd-hist .cards-line { color: var(--ink); font-weight: 700; }
.hd-hist .red { color: #ff8a8a; }
.hd-hist-empty { margin: 0; }

/* ---------- Phones on their side and other short windows: the actions beside the felt ---------- */
/* Quick reactions open from the button's left edge: the button sits at the left of the bar. */
.hd-bar .react-menu { right: auto; left: 0; }

@media (orientation: landscape) and (max-height: 500px) {
  .table.hd {
    display: grid;
    grid-template-columns: 1fr minmax(172px, 28%);
    grid-template-rows: 1fr auto;
    grid-template-areas: "felt controls" "felt foot";
    column-gap: 8px;
  }
  .hd-felt { grid-area: felt; }
  .hd-foot { grid-area: foot; }
  .hd-controls { grid-area: controls; justify-content: flex-end; }
  .hd-actions .btn, .hd-pre .btn, .hd-misc .btn, .hd-confirm .btn { flex: 1 1 calc(50% - 6px); max-width: none; min-height: 44px; }
  .hd-presets .btn { flex: 1 1 calc(33% - 6px); }
  .hd-amount { gap: 6px; }
  .hd-amount input[type='number'] { width: 64px; }
  .hd-bar .btn { min-height: 40px; padding: 0 10px; }
  .hd-status { font-size: 0.85rem; }
  /* No room for both: while you size a bet, the bar under it steps aside (Escape brings it back). */
  .table.hd:has(.hd-sizer:not([hidden])) .hd-foot { display: none; }
  /* The bar is at the right edge here: reactions open to the left. */
  .hd-bar .react-menu { left: auto; right: 0; }
}
/* Phones: while you size a bet, the bar steps aside to leave the table its room (Escape brings it back). */
@media (max-width: 600px) {
  .table.hd:has(.hd-sizer:not([hidden])) .hd-foot { display: none; }
}
@media (max-width: 480px) {
  .hd-actions .btn { padding: 0 6px; font-size: 0.95rem; }
  .hd-bar .btn { padding: 0 10px; }
}


/* ---------- The header on phones (as the other game pages) ---------- */
@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .topbar .brand { display: none; }
  .topbar-title { border-left: none; padding-left: 4px; font-size: 1.05rem; color: var(--ink); }
  .pill { padding-right: 12px; }
}
@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 { 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; }
}
@media (max-width: 400px) {
  .topbar .pill .coin { display: none; }
}

/* ---------- Seats: the info column (plate, your hand's name, the last action) ---------- */
.hd-info { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; min-width: 0; }
.hd-line2 { flex-wrap: wrap; }

/* A narrow felt (phones upright, phones on their side): the others' plates drop the avatar so
   the name has the room, and their turn clock is a bar under the plate. */
@container felt (max-width: 600px) {
  /* Others' hand names, short, in the tag's place (no extra lines); a winner's in the win colour. */
  .hd-seat:not(.me) .hd-tag.has-hand { visibility: visible; white-space: nowrap; }
  .hd-seat:not(.me) .hd-tag.has-hand .tg-act { display: none; }
  .hd-seat:not(.me) .hd-tag.has-hand .tg-hand { display: inline; text-transform: none; letter-spacing: 0; }
  .hd-seat:not(.me) .hd-tag.has-hand:not(.win) .tg-hand { color: var(--gold-2); }
  .hd-seat:not(.me) .hd-handname { display: none; }
  .hd-seat:not(.me) .avatar { display: none; }
  .hd-seat:not(.me) .seat-plate { padding: 3px 7px; position: relative; }
  .hd-seat.clock:not(.me) .seat-plate::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: calc(var(--left, 1) * (100% - 24px));
    margin-left: 12px;
    border-radius: 2px;
    background: var(--clock-color, var(--gold-2));
  }
  .hd-seat.clock.hurry { --clock-color: var(--lose); }
}
/* A short felt (phones on their side, short windows): cards beside the plate, not above it. */
@container felt (max-height: 420px) {
  /* Others' hand names, short, in the tag's place (no extra lines); a winner's in the win colour. */
  .hd-seat:not(.me) .hd-tag.has-hand { visibility: visible; white-space: nowrap; }
  .hd-seat:not(.me) .hd-tag.has-hand .tg-act { display: none; }
  .hd-seat:not(.me) .hd-tag.has-hand .tg-hand { display: inline; text-transform: none; letter-spacing: 0; }
  .hd-seat:not(.me) .hd-tag.has-hand:not(.win) .tg-hand { color: var(--gold-2); }
  .hd-seat:not(.me) .hd-handname { display: none; }
  /* A shown hand's name is a label over the bottom of the cards (the corners stay clear), not a line. */
  .hd-seat:not(.me) .hd-tag.has-hand {
    position: absolute;
    bottom: 1px;
    left: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 0;
    padding: 0 5px;
    border-radius: 6px;
    background: rgba(3, 22, 13, 0.88);
    line-height: 1.4;
    z-index: 1;
  }
  /* Shown cards overlap more here (the first card's corner still shows): the seat stays narrow. */
  .hd-hole.shown .card + .card { margin-left: calc(var(--shown-w) * -0.42); }
  .hd-seat { flex-direction: row; width: auto; gap: 4px; }
  .hd-seat .hd-info { width: var(--plate-w); }
  .hd-seat.me .hd-info { width: var(--plate-w); }
  .hd-seat.me .seat-plate { max-width: var(--plate-w); }
  .hd-hole { min-height: 0; }
}

