:root {
  --felt-deep: #07140e;
  --felt: #0d3b28;
  --felt-lit: #176b45;
  --rail: #c9a227;
  --rail-dark: #7a5c12;
  --gold: #d4af37;
  --gold-soft: #f3e0a0;
  --gold-dim: #a6862a;
  --ink: #0b0d0c;
  --cream: #f4e9c8;
  --muted: #cbbd93;
  --fold: #7a2a2a;
  --fold-hover: #9a3838;
  --call: #1c6b4e;
  --call-hover: #22845f;
  --raise: #c9a227;
  --raise-hover: #e0bc44;
  --danger: #c45c5c;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --font-display: "Cinzel", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --font-ui: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --radius: 16px;
  --safe-b: max(12px, env(safe-area-inset-bottom));
  --safe-t: max(8px, env(safe-area-inset-top));
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--felt-deep);
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 50% 0%, #143b28 0%, var(--felt-deep) 55%);
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 0;
  background: none;
}

img, svg { display: block; max-width: 100%; }

.hidden { display: none !important; }

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Logo ── */
.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
  color: var(--gold-soft);
}
.logo-mark {
  width: min(220px, 70vw);
  height: auto;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.45));
}
.logo-suits {
  letter-spacing: 0.7em;
  font-size: 1.05rem;
  color: var(--gold);
  padding-left: 0.7em;
}
.logo-suits .red { color: #e25b5b; }
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.95rem;
  color: var(--gold-soft);
}

/* ── Lobby ── */
#lobby {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-t) + 1.25rem) 1.25rem calc(var(--safe-b) + 1rem);
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}
.lobby-hero { margin: 1rem 0 0.5rem; }
.tagline {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}
.free-badge {
  margin-top: 0.85rem;
  border: 1px solid var(--gold-dim);
  color: var(--gold-soft);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  margin-top: 1.6rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 999px;
  padding: 0.9rem 1.4rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-gold {
  background: linear-gradient(180deg, #f1d36a 0%, var(--gold) 45%, #a6862a 100%);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.28);
}
.btn-gold:hover { filter: brightness(1.05); }
.btn-ghost {
  border: 1px solid var(--gold-dim);
  color: var(--gold-soft);
  background: rgba(0, 0, 0, 0.2);
}
.btn-danger {
  background: linear-gradient(180deg, #a33a3a, var(--fold));
  color: #fff;
}
.btn-call {
  background: linear-gradient(180deg, #2a8a64, var(--call));
  color: #fff;
}
.btn-raise {
  background: linear-gradient(180deg, #f1d36a 0%, var(--gold) 45%, #a6862a 100%);
  color: var(--ink);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.opp-picker {
  margin-top: 1.4rem;
  width: 100%;
  text-align: center;
}
.opp-picker label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.seg {
  display: flex;
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  overflow: hidden;
}
.seg button {
  flex: 1;
  padding: 0.55rem 0.4rem;
  color: var(--muted);
}
.seg button[aria-pressed="true"] {
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
}

.stats {
  width: 100%;
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}
.stat {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: 14px;
  padding: 0.8rem 0.7rem 0.7rem;
  text-align: center;
}
.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--gold-soft);
  font-weight: 700;
}
.stat span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.reset-link {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: underline;
  background: none;
}

.site-footer {
  margin-top: auto;
  padding-top: 1.6rem;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.site-footer strong { color: var(--gold-soft); font-weight: 600; }

/* ── Overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 7, 0.82);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  overflow: auto;
}
.overlay .sheet {
  background: linear-gradient(180deg, #163525, #0c1f16);
  border: 1px solid var(--gold-dim);
  border-radius: 20px 20px 12px 12px;
  padding: 1.2rem 1.2rem 1.4rem;
  width: min(560px, 100%);
  max-height: min(86dvh, 800px);
  overflow: auto;
  box-shadow: var(--shadow);
  margin-bottom: var(--safe-b);
}
.sheet h2 {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  color: var(--gold-soft);
  margin: 0 0 0.8rem;
  font-size: 1.25rem;
}
.sheet h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sheet p, .sheet li { color: var(--cream); }
.sheet ol, .sheet ul { padding-left: 1.15rem; margin: 0.25rem 0 0.5rem; }
.sheet li { margin: 0.25rem 0; }
.ranks { columns: 2; gap: 0.4rem; font-size: 0.92rem; }
.close-row { margin-top: 1rem; display: flex; justify-content: flex-end; }

@media (min-width: 640px) {
  .overlay { align-items: center; }
  .overlay .sheet { border-radius: 20px; }
}

/* ── Table screen ── */
#table-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: var(--safe-t);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  min-height: 48px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: var(--gold-soft);
  background: rgba(0, 0, 0, 0.25);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  flex: 0 0 auto;
}
.topbar .wordmark { flex: 1; text-align: center; font-size: 0.78rem; }
.chip-pill {
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-weight: 700;
  color: var(--gold-soft);
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

.table-stage {
  flex: 1;
  position: relative;
  min-height: 0;
  margin: 0 0.4rem;
}
.table {
  position: absolute;
  inset: 6px 8px 8px;
  border-radius: 50% / 42%;
  background:
    radial-gradient(ellipse at 50% 42%, #1d7a50 0%, var(--felt) 46%, #0a2a1c 100%);
  border: 10px solid var(--rail);
  box-shadow:
    inset 0 0 50px rgba(0, 0, 0, 0.45),
    0 0 0 3px var(--rail-dark),
    0 10px 28px rgba(0, 0, 0, 0.5);
}
.table::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: inherit;
  border: 1px solid rgba(243, 224, 160, 0.18);
  pointer-events: none;
}
.table-brand {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  letter-spacing: 0.28em;
  font-size: clamp(0.55rem, 2.6vw, 0.85rem);
  color: rgba(243, 224, 160, 0.22);
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
}

.board {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  z-index: 3;
}
.community {
  display: flex;
  gap: 0.28rem;
  min-height: 58px;
}
.pot-label {
  font-family: var(--font-display);
  color: var(--gold-soft);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 999px;
  padding: 0.12rem 0.7rem;
}
.street-label {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Seats */
.seat {
  position: absolute;
  width: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 4;
}
.seat.hero {
  width: min(260px, 86%);
}
.seat-cards {
  display: flex;
  gap: 4px;
  min-height: 46px;
}
.seat.hero .seat-cards { gap: 8px; }
.seat-meta {
  margin-top: 4px;
  background: rgba(6, 12, 9, 0.82);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 12px;
  padding: 0.22rem 0.5rem 0.28rem;
  text-align: center;
  min-width: 96px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.seat.hero .seat-meta { min-width: 140px; }
.seat-name {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}
.seat-chips { font-size: 0.75rem; color: var(--cream); }
.seat.folded { opacity: 0.48; }
.seat.folded .seat-cards { filter: grayscale(0.6); }
.seat.to-act .seat-meta {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.45), 0 0 16px rgba(212, 175, 55, 0.25);
}
.seat.winner .seat-meta {
  border-color: var(--gold-soft);
  background: #1a3d16;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0;
  background: var(--gold);
  color: var(--ink);
  padding: 0 0.2rem;
}
.badge.sb, .badge.bb { background: #eee8d0; }
.action-bubble {
  position: absolute;
  top: -1.15rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--gold-soft);
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
  z-index: 5;
}

/* Seat placement — percentages of the oval */
.seat-pos-hero { left: 50%; bottom: 3%; transform: translateX(-50%); }
.seat-pos-left { left: 1%; top: 48%; transform: translateY(-50%); }
.seat-pos-right { right: 1%; top: 48%; transform: translateY(-50%); left: auto; }
.seat-pos-top { left: 50%; top: 2%; transform: translateX(-50%); }
.seat-pos-top-left { left: 10%; top: 8%; }
.seat-pos-top-right { right: 10%; top: 8%; left: auto; }

/* Cards */
.card {
  width: 38px;
  height: 54px;
  border-radius: 5px;
  background: #f7f1de;
  color: #161616;
  position: relative;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-family: var(--font-ui);
  user-select: none;
  flex: 0 0 auto;
}
.card.red { color: #c21d1d; }
.card-rank {
  position: absolute;
  top: 2px;
  left: 3px;
  font-weight: 800;
  font-size: 0.72rem;
  line-height: 1;
}
.card-suit {
  position: absolute;
  top: 14px;
  left: 3px;
  font-size: 0.7rem;
  line-height: 1;
}
.card-suit-lg {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.95;
}
.card.back {
  background:
    repeating-linear-gradient(45deg, #1a2c22 0 4px, #122018 4px 8px);
  border: 1px solid var(--gold-dim);
  box-shadow: inset 0 0 0 3px #0e1a14, 0 3px 6px rgba(0, 0, 0, 0.4);
}
.card.back::after {
  content: "♠";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 1.1rem;
  opacity: 0.85;
}
.card.placeholder {
  background: rgba(0, 0, 0, 0.15);
  border: 1px dashed rgba(243, 224, 160, 0.25);
  box-shadow: none;
}
.card.winner-card {
  box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(241, 211, 106, 0.85);
  transform: translateY(-3px);
}
.seat.hero .card { width: 58px; height: 82px; border-radius: 7px; }
.seat.hero .card-rank { font-size: 1.05rem; top: 3px; left: 5px; }
.seat.hero .card-suit { font-size: 1rem; top: 20px; left: 5px; }
.seat.hero .card-suit-lg { font-size: 1.6rem; right: 5px; bottom: 3px; }
.community .card { width: 42px; height: 60px; }

.card.deal-in {
  animation: dealIn 0.38s ease both;
}
.card.flip-in {
  animation: flipIn 0.45s ease both;
}

@keyframes dealIn {
  from { opacity: 0; transform: translateY(-18px) scale(0.8) rotate(-8deg); }
  to { opacity: 1; transform: none; }
}
@keyframes flipIn {
  0% { transform: rotateY(90deg); opacity: 0.2; }
  100% { transform: none; opacity: 1; }
}

/* Action bar */
.action-bar {
  padding: 0.45rem 0.7rem calc(var(--safe-b) + 0.4rem);
  background: linear-gradient(180deg, transparent, rgba(5, 12, 9, 0.92) 18%);
  z-index: 8;
}
.action-status {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1.2rem;
  margin-bottom: 0.3rem;
}
.action-status strong { color: var(--gold-soft); }
.raise-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.raise-row input[type="range"] {
  flex: 1;
  accent-color: var(--gold);
}
.raise-amt {
  min-width: 4.5rem;
  text-align: right;
  font-weight: 700;
  color: var(--gold-soft);
}
.action-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
.action-row .btn { padding: 0.85rem 0.4rem; letter-spacing: 0.04em; font-size: 0.82rem; }
.action-row.four { grid-template-columns: 1fr 1.2fr 1.2fr 1fr; }
.sub-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.linkish {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: underline;
}

.hand-end {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: stretch;
}
.winner-banner {
  text-align: center;
  color: var(--gold-soft);
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

/* History drawer */
.history {
  max-height: 28vh;
  overflow: auto;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  margin: 0.4rem 0.7rem 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.history h3 {
  margin: 0 0 0.3rem;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
.history li { margin: 0.15rem 0; }
.history ul { list-style: none; padding: 0; margin: 0; }

.refill-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
}

@media (min-width: 720px) {
  .table { inset: 16px 12%; border-width: 14px; }
  .card, .community .card { width: 52px; height: 74px; }
  .seat.hero .card { width: 72px; height: 102px; }
  .seat { width: 140px; }
  .topbar .wordmark { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .card.deal-in, .card.flip-in { animation: none; }
  .btn { transition: none; }
}
