/* Layout: a card room seen from your seat. Opponents across the top, the felt with the board and pot
   in the middle, your cards and betting controls at your edge. Midnight-blue felt, brass accents. */
:root {
  --felt: #142b4c;
  --felt-deep: #08142a;
  --rail: #2a4168;
  --wood: #4a2e1c;
  --ink: #f3efe6;
  --muted: #a9b8d0;
  --gold: #d9b45a;
  --win: #6fd39a;
  --red-suit: #c3313a;
  --c-red: #c3313a; /* alert red, shared rules (timer) use this name */
  --black-suit: #1b1b22;
  --card-face: #fbfaf6;
  --card-back: #7a1f2b;
  --shade: rgba(0, 0, 0, 0.4);
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}


* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--felt-deep); }
body {
  margin: 0;
  background: radial-gradient(120% 90% at 50% 45%, var(--felt) 0%, var(--felt-deep) 100%) fixed, var(--felt-deep);
  color: var(--ink);
  font: 15px/1.45 var(--font-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.app {
  max-width: 1040px;
  margin: 0 auto;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto auto auto auto;
  gap: 14px;
  padding-block: 12px 20px;
}

/* Header */
.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font: 800 1.35rem/1 var(--font-display); letter-spacing: 0.01em; margin: 0; }
.round { margin: 0; color: var(--muted); font-size: 0.85rem; flex: 1; font-variant-numeric: tabular-nums; }
.ghost {
  background: transparent; border: 1px solid var(--rail); border-radius: 999px;
  padding: 6px 14px; color: var(--ink);
}
.ghost:hover { background: var(--rail); }
.primary {
  background: var(--gold); color: #2a1d05; border: 0; border-radius: 999px;
  padding: 11px 26px; font-weight: 700; font-size: 1rem;
}
.primary:hover { filter: brightness(1.06); }

/* Opponents */
.opponents { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.seat {
  min-width: 0; flex: 1 1 150px; max-width: 260px;
  border: 1px solid var(--rail); border-radius: 14px; padding: 10px 12px;
  display: grid; gap: 8px; background: rgba(0, 0, 0, 0.12);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.seat.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 22px rgba(241, 199, 91, 0.25); }
.seat-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.seat-name { font: 700 1rem/1.1 var(--font-display); }
.count, .score { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.score { margin-left: auto; }
.fan { display: flex; height: 36px; align-items: center; padding-left: 14px; }
.fan .card { --cw: 24px; margin-left: -14px; box-shadow: 0 1px 2px var(--shade); }
.badge {
  justify-self: start; background: var(--gold); color: #2a1d05; border-radius: 999px;
  padding: 1px 9px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}


/* The felt: board and pot */
.felt {
  display: grid; justify-items: center; align-content: center; gap: 10px;
  padding: 22px 14px; border-radius: 160px / 110px;
  background: radial-gradient(ellipse at center, #1d3d6b 0%, var(--felt) 55%, var(--felt-deep) 100%);
  border: 10px solid var(--wood);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.45);
}
.board { display: flex; gap: clamp(4px, 1.4vw, 10px); }
.pot { margin: 0; font: 700 1.25rem/1 var(--font-display); font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; }
.pot-label { color: var(--muted); font: 600 0.72rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.1em; }
.street { margin: 0; color: var(--muted); font-size: 0.85rem; min-height: 1.2em; }

/* Playing cards */
.pcard {
  --pw: clamp(42px, 11vw, 68px);
  position: relative; flex: none; width: var(--pw); aspect-ratio: 5 / 7;
  display: grid; grid-template-rows: auto 1fr; padding: calc(var(--pw) * 0.07) calc(var(--pw) * 0.11);
  background: var(--card-face); color: var(--black-suit);
  border-radius: calc(var(--pw) * 0.12);
  box-shadow: 0 3px 8px var(--shade);
  font-family: var(--font-display); user-select: none;
}
.pcard.red { color: var(--red-suit); }
.pcard .rank { font-weight: 800; font-size: calc(var(--pw) * 0.34); line-height: 1; }
.pcard .suit { font-size: calc(var(--pw) * 0.46); line-height: 1; justify-self: center; align-self: center; }
.pcard.slot { background: transparent; border: 2px dashed rgba(255, 255, 255, 0.16); box-shadow: none; }
.pcard.back { background: repeating-linear-gradient(45deg, var(--card-back) 0 5px, #8f2a38 5px 10px); border: 3px solid var(--card-face); }
.pcard.small { --pw: 30px; border-width: 2px; }
.pcard.big { --pw: clamp(64px, 18vw, 92px); }
.pcard.win { outline: 3px solid var(--win); outline-offset: 2px; }

/* Seats */
.seat.folded { opacity: 0.55; }
.seat.out { opacity: 0.4; }
.seat.winner { border-color: var(--win); box-shadow: 0 0 0 1px var(--win), 0 0 22px rgba(111, 211, 154, 0.25); }
.seat-stack, .stack { margin: 0; display: flex; align-items: center; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-dot {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: radial-gradient(circle, var(--gold) 0 34%, var(--card-face) 35% 47%, var(--gold) 48%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
.seat-cards { display: flex; gap: 4px; min-height: 42px; }
.seat-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-height: 1.5em; font-size: 0.78rem; }
.last { color: var(--muted); }
.seat-hand { font-weight: 600; }
.bet { margin-left: auto; background: var(--gold); color: #2a1d05; border-radius: 999px; padding: 0 8px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pos { border: 1px solid var(--muted); color: var(--muted); border-radius: 999px; padding: 0 6px; font-size: 0.68rem; font-weight: 800; }
.pos.dealer { background: var(--card-face); border-color: var(--card-face); color: var(--black-suit); }

/* Result banner */
.result { border: 1px solid var(--win); background: rgba(111, 211, 154, 0.08); border-radius: 14px; padding: 10px 14px; display: grid; gap: 6px; }
.result-text { margin: 0; font: 600 1rem/1.35 var(--font-display); text-wrap: balance; }

/* Your seat and betting controls */
.you { display: grid; gap: 12px; border-top: 1px solid var(--rail); padding-top: 12px; }
.you-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.you-name { margin: 0; font: 700 1.05rem/1 var(--font-display); display: flex; gap: 8px; align-items: center; }
.badges { display: inline-flex; gap: 4px; }
.stack { font: 700 1.15rem/1 var(--font-display); }
.you-cards { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.hole { display: flex; gap: 8px; }
.hole.folded { opacity: 0.45; filter: grayscale(0.6); }
.hand-name { margin: 0; font: 600 1.05rem/1.2 var(--font-display); color: var(--gold); min-width: 8ch; }
.actions { display: grid; gap: 10px; width: 100%; max-width: 560px; justify-self: center; }
.main-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.act { border: 0; border-radius: 12px; padding: 12px; font: 800 1rem/1 var(--font-display); }
.act.fold { background: transparent; border: 2px solid var(--rail); color: var(--ink); }
.act.call { background: var(--card-face); color: var(--felt); }
.act.raise-btn { background: var(--gold); color: #2a1d05; white-space: nowrap; }
.act:hover { filter: brightness(1.08); }
.raise { display: grid; gap: 8px; }
.presets { display: flex; gap: 6px; }
.preset { flex: 1; background: transparent; border: 1px solid var(--rail); border-radius: 999px; padding: 6px 4px; font-size: 0.85rem; }
.preset:hover { border-color: var(--muted); }
.raise-row { display: grid; grid-template-columns: minmax(0, 1fr) 92px auto; gap: 8px; align-items: center; }
#raiseRange { width: 100%; min-width: 0; margin: 0; accent-color: var(--gold); }
#raiseInput {
  width: 100%; min-width: 0; font: 1rem var(--font-body); font-variant-numeric: tabular-nums; color: var(--ink);
  background: var(--felt-deep); border: 1px solid var(--rail); border-radius: 10px; padding: 8px;
}

/* Log */
.log { color: var(--muted); font-size: 0.85rem; }
.log summary { cursor: pointer; width: max-content; }
.log ol { margin: 8px 0 0; padding-left: 20px; max-height: 180px; overflow-y: auto; display: grid; gap: 2px; }
.fineprint { margin: 0; color: var(--muted); font-size: 0.75rem; text-align: center; opacity: 0.8; }

/* Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(3, 18, 16, 0.72); backdrop-filter: blur(3px);
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  overflow-y: auto;
}
.panel {
  width: min(460px, 100%); background: var(--felt); border: 1px solid var(--rail);
  border-radius: 18px; padding: 22px; display: grid; gap: 14px; justify-items: start;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.panel h2 { margin: 0; font: 800 1.6rem/1.1 var(--font-display); text-wrap: balance; }
.lede { margin: 0; color: var(--muted); }
.seats { border: 0; padding: 0; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seats legend { float: left; margin-right: 6px; font-weight: 600; }
.seats label {
  border: 1px solid var(--rail); border-radius: 999px; padding: 6px 14px; cursor: pointer;
  display: flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums;
}
.seats label:has(input:checked) { border-color: var(--gold); background: rgba(241, 199, 91, 0.12); }
.seats input { accent-color: var(--gold); margin: 0; }
.rules { width: 100%; color: var(--muted); font-size: 0.9rem; }
.rules summary { cursor: pointer; color: var(--ink); }
.rules ul { padding-left: 18px; display: grid; gap: 6px; margin: 10px 0 0; }
.rules strong { color: var(--ink); }

.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.pick {
  background: var(--cc); color: #fff; border: 3px solid var(--card-face); border-radius: 14px;
  padding: 18px 10px; font: 800 1.1rem/1 var(--font-display); text-shadow: 0 1px 0 var(--shade);
}
.pick:hover { transform: translateY(-2px); }

.scores { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.scores th, .scores td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--rail); }
.scores th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.scores td:not(:first-child), .scores th:not(:first-child) { text-align: right; }
.scores tr.winner td { color: var(--gold); font-weight: 700; }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* ---------- Online play, lobby and house rules ---------- */
.status-wrap { display: grid; gap: 2px; justify-items: center; }
.status-sub { margin: 0; color: var(--muted); font-size: 0.85rem; text-align: center; text-wrap: balance; min-height: 1.3em; }
.timer {
  display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px;
  border: 1px solid var(--rail); font-variant-numeric: tabular-nums; color: var(--ink);
}
.timer.low { border-color: var(--c-red); color: #fff; background: var(--c-red); }

.room-chip {
  margin: 0; font: 700 0.85rem/1 var(--font-mono); letter-spacing: 0.12em;
  border: 1px dashed var(--rail); border-radius: 8px; padding: 6px 9px;
}
.tag {
  border: 1px solid var(--rail); border-radius: 999px; padding: 0 7px;
  font-size: 0.7rem; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase;
}
.tag.gold { border-color: var(--gold); color: var(--gold); }
.seat.away { opacity: 0.7; }
.chip.pending { border-color: var(--c-red); background: rgba(216, 54, 61, 0.18); font-weight: 700; }
.hand .card.drawn { animation: land 0.32s cubic-bezier(.2, .9, .3, 1.2); }

.warn {
  background: var(--card-face); color: #3b0d10; border: 2px solid var(--c-red); border-radius: 999px;
  padding: 7px 16px; font: 800 0.95rem/1 var(--font-display);
}
.link { background: none; border: 0; color: var(--gold); text-decoration: underline; padding: 2px 4px; margin-left: auto; font-size: 0.85rem; }

.panel.wide { width: min(640px, 100%); }
.panel h3 { margin: 0; font: 700 1.05rem/1.2 var(--font-display); }
.hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
.field { display: grid; gap: 4px; width: 100%; font-size: 0.85rem; color: var(--muted); }
.field.inline { display: flex; align-items: center; gap: 10px; width: auto; }
.field input, .field select {
  font: 1rem/1.2 var(--font-body); color: var(--ink); background: var(--felt-deep);
  border: 1px solid var(--rail); border-radius: 10px; padding: 9px 11px; width: 100%; min-width: 0;
}
.field.inline select { width: auto; }
.field input:focus-visible, .field select:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
#codeInput { font-family: var(--font-mono); letter-spacing: 0.2em; text-transform: uppercase; }

.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; width: 100%; }
.mode {
  display: grid; gap: 10px; align-content: start; justify-items: start; min-width: 0;
  border: 1px solid var(--rail); border-radius: 14px; padding: 14px; background: rgba(0, 0, 0, 0.14);
}
.join { display: flex; gap: 8px; align-items: end; width: 100%; }
.join .field { flex: 1; }
.home-error { margin: 0; color: #ffb4b0; min-height: 1.2em; font-size: 0.9rem; }

.rules-set { display: grid; gap: 8px; width: 100%; }
.rule { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.rule input { accent-color: var(--gold); margin-top: 3px; width: 16px; height: 16px; flex: none; }
.rule input:disabled + .rule-text { opacity: 0.75; }
.rule-text { display: grid; gap: 1px; min-width: 0; }
.rule-text strong { font-size: 0.9rem; }
.rule-text .hint { font-size: 0.78rem; }

.eyebrow { margin: 0; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; }
.panel .code { font: 800 clamp(2rem, 9vw, 2.8rem)/1 var(--font-mono); letter-spacing: 0.18em; color: var(--gold); }
.share { display: flex; gap: 8px; width: 100%; }
.share input {
  flex: 1; min-width: 0; font: 0.85rem/1.2 var(--font-mono); color: var(--muted); background: var(--felt-deep);
  border: 1px solid var(--rail); border-radius: 10px; padding: 8px 10px;
}
.seat-list { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 6px; }
.seat-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px solid var(--rail); border-radius: 10px; padding: 8px 10px;
}
.seat-row-name { font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rail); flex: none; }
.dot.on { background: #4fd18b; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 40;
  background: var(--card-face); color: #1d1a22; border-radius: 12px; padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); font-weight: 600; max-width: calc(100% - 32px);
}

/* Big tables (5+ opponents): smaller seats so your hand stays on screen. */
.opponents.many { gap: 8px; }
.opponents.many .seat { flex-basis: 128px; max-width: 200px; padding: 7px 9px; gap: 5px; }
.opponents.many .seat-name { font-size: 0.9rem; }
.opponents.many .fan { height: 28px; padding-left: 12px; }
.opponents.many .fan .card { --cw: 18px; margin-left: -12px; }
@media (max-width: 480px) {
  .opponents.many .seat { flex-basis: 104px; }
  .opponents.many .fan { display: none; }
  .opponents.many .score { margin-left: 0; }
}


/* Big tables and phones */
.opponents.many .seat-cards { min-height: 30px; }
.opponents.many .pcard.small { --pw: 22px; }
@media (max-width: 480px) {
  .round { order: 3; flex-basis: 100%; }
  .felt { border-radius: 48px; border-width: 6px; padding: 16px 8px; }
  .raise-row { grid-template-columns: minmax(0, 1fr) 84px; }
  .raise-btn { grid-column: 1 / -1; }
  .opponents.many .seat-cards { display: none; }
}
