/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at 50% 0%, #0f4f7a, #0a2f4a 55%, #06182a);
  color: #f2f2f2;
  /* Prevent double-tap zoom on touch devices without disabling pinch-zoom */
  touch-action: manipulation;
}

/* ── Fluid card dimensions ────────────────────────────────────────────────────
   The board sets the scale; hole cards derive from it, and the player's own
   cards are a size up. Everything follows --card-w, so there are no
   breakpoints to keep in sync.                                               */
:root {
  --card-w:      clamp(38px, 9vw, 62px);
  --card-h:      calc(var(--card-w) * 1.3636);       /* 120 / 88 ratio         */
  --card-radius: max(4px, calc(var(--card-w) * 0.09));
  --font-rank:   clamp(10px, calc(var(--card-w) * 0.26), 17px);
  --font-center: clamp(15px, calc(var(--card-w) * 0.5), 32px);
  --felt-line:   rgba(255, 255, 255, 0.2);
  --gold:        #ffd700;
  --chip:        #f0b429;
}

/* ── App shell ────────────────────────────────────────────────────────────── */
.app {
  max-width: 780px;
  margin: 0 auto;
  padding: 12px 14px 28px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.bank { display: flex; align-items: center; gap: 10px; }

.blinds { font-size: 12px; opacity: 0.7; }

.stack {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
button {
  background: #17618f;
  color: white;
  border: 1px solid #0d4468;
  border-radius: 6px;
  /* 44 px minimum touch target (Apple HIG / WCAG 2.5.5) */
  min-height: 44px;
  padding: 8px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
button:hover:not(:disabled)  { filter: brightness(1.15); }
button:active:not(:disabled) { filter: brightness(0.9); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.primary { background: var(--chip); border-color: #b9821a; color: #2a1c00; }
button.ghost   { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.25); }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 10px;
  border: 1px solid var(--felt-line);
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(30, 140, 90, 0.35), transparent 70%),
    rgba(0, 0, 0, 0.18);
}

/* ── Opponents ────────────────────────────────────────────────────────────── */
.bots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

/* ── A seat ───────────────────────────────────────────────────────────────── */
.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: opacity 150ms ease;
}

.seat--turn   { border-color: var(--gold); background: rgba(255, 215, 0, 0.09); }
.seat--folded { opacity: 0.4; }
.seat--winner { background: rgba(46, 204, 113, 0.16); border-color: #2ecc71; }

/* The player's own seat: bigger cards, but not stretched across the felt */
.seat--big {
  --card-w: clamp(52px, 13vw, 78px);
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.seat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.seat-name  { font-weight: 600; }
.seat-stack { color: var(--gold); font-variant-numeric: tabular-nums; }

.button-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font-size: 10px;
  font-weight: 700;
}

.hole { display: flex; gap: 3px; min-height: var(--card-h); }

.seat-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
  font-size: 11px;
  flex-wrap: wrap;
  justify-content: center;
}

.bet {
  background: var(--chip);
  color: #2a1c00;
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.action    { opacity: 0.8; }
.made-hand { color: #9be7b4; font-weight: 600; }

/* ── Board & pot ──────────────────────────────────────────────────────────── */
.middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.pot {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.pot-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.65;
  font-size: 11px;
}

.pot-amount {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--felt-line);
  border-radius: 999px;
  padding: 3px 12px;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.board { display: flex; gap: 5px; }

.card-slot {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  border: 2px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  position: relative;
  flex: 0 0 auto;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  background: white;
  color: #111;
  border: 2px solid #d8d8d8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  animation: deal 220ms ease-out;
}

@keyframes deal {
  from { transform: translateY(-18px) scale(0.9); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
}

.card.face-down {
  background: repeating-linear-gradient(
    45deg,
    #123a5c, #123a5c 7px,
    #17486f 7px, #17486f 14px
  );
  border-color: #0b2740;
}

.card--win {
  outline: 3px solid #2ecc71;
  outline-offset: 1px;
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.6);
}

/* ── Card content ─────────────────────────────────────────────────────────── */
.card .corner {
  position: absolute;
  top: 3px;
  left: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  font-weight: 700;
  pointer-events: none;
}

.rank { font-size: var(--font-rank); }
.suit { font-size: var(--font-rank); }

.center-suit {
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-size: var(--font-center);
  line-height: 1;
  pointer-events: none;
}

.red   { color: #c01818; }
.black { color: #111; }

/* ── Message ──────────────────────────────────────────────────────────────── */
.message {
  margin: 0;
  min-height: 22px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.message--result { color: #7ef0a6; }

/* ── Controls ─────────────────────────────────────────────────────────────── */
.controls { min-height: 60px; }

.control-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.raise-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--felt-line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
}

.chip-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  min-height: 40px;
  padding: 6px 14px;
}

.chip-btn--on { background: var(--chip); border-color: #b9821a; color: #2a1c00; }

.raise-panel input[type="range"] {
  width: 100%;
  max-width: 420px;
  accent-color: var(--chip);
  height: 32px;
}

/* ── Action log ───────────────────────────────────────────────────────────── */
.log {
  height: 76px;
  overflow-y: auto;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.85;
}

.log p { margin: 0; }

/* ── Status bar & rules ───────────────────────────────────────────────────── */
.statusbar {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  opacity: 0.7;
}

.rules { font-size: 13px; opacity: 0.85; }

.rules summary { cursor: pointer; padding: 4px 0; }

.rules ul { margin: 6px 0 0; padding-left: 20px; line-height: 1.6; }

kbd {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 11px;
}
