:root {
  --bg: #0b1f18;
  --panel: #12301f;
  --felt: #17603f;
  --felt-edge: #0e3d28;
  --text: #f1f5f2;
  --muted: #a9bdb2;
  --accent: #f2c14e;
  --danger: #d9534f;
  --card: #fbfbf8;
  --red: #c62828;
  --black: #1b1b1b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 20px 0 6px; }
.muted { color: var(--muted); }
.error { color: #ffb4a9; min-height: 1.4em; margin: 6px 0; }

.panel { margin-top: 18vh; text-align: center; }
#password-row { display: grid; gap: 10px; }
.panel form { display: grid; gap: 10px; margin-top: 20px; text-align: left; }

input, button {
  font: inherit;
  color: inherit;
  border-radius: 10px;
  border: 1px solid #2c5a45;
  background: #0f2a20;
  min-height: 48px;
  padding: 0 14px;
}
button { cursor: pointer; font-weight: 600; touch-action: manipulation; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1c1503; }
button.danger { background: transparent; border-color: var(--danger); color: #ffb4a9; }
button:disabled { opacity: 0.35; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Seats */
.seat { display: grid; justify-items: center; gap: 4px; padding: 8px 0; border-radius: 14px; }
.seat.turn { background: rgba(242, 193, 78, 0.1); box-shadow: inset 0 0 0 2px var(--accent); }
.who { display: flex; align-items: center; gap: 8px; }
.name { font-weight: 700; max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { color: var(--muted); font-variant-numeric: tabular-nums; }
.bet { min-height: 1.4em; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.tag { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
#score { text-align: center; color: var(--muted); font-size: 0.85rem; min-height: 1.4em; padding-right: 44px; padding-left: 44px; }
.pct {
  background: #fff; color: #111; font-weight: 800; font-size: 0.95rem;
  padding: 2px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.btn-chip {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; color: #111; font-size: 0.75rem; font-weight: 800;
}

/* Table */
.felt {
  background: radial-gradient(ellipse at center, var(--felt), var(--felt-edge));
  border: 3px solid #0a2b1c;
  border-radius: 28px;
  padding: 16px 8px 10px;
  text-align: center;
}
.pot { margin-top: 10px; font-variant-numeric: tabular-nums; }
.pot strong { color: var(--accent); font-size: 1.2rem; }
.handno { font-size: 0.75rem; color: rgba(255, 255, 255, 0.6); }

.cards { display: flex; justify-content: center; gap: 6px; min-height: 64px; }
.card {
  width: 46px; height: 64px; border-radius: 7px;
  background: var(--card); color: var(--black);
  display: grid; place-items: center; align-content: center;
  font-weight: 800; font-size: 1.15rem; line-height: 1.05;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
/* Four-colour deck with the whole card filled: spades black, hearts red,
   diamonds blue, clubs green. White rank and suit on top. */
.card.suit-s, .card.suit-h, .card.suit-d, .card.suit-c {
  color: #fff; border: 1px solid rgba(255, 255, 255, 0.45);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.card.suit-s { background: #23262b; }
.card.suit-h { background: #c62828; }
.card.suit-d { background: #1556c0; }
.card.suit-c { background: #1a7f37; }
.card .suit { font-size: 1.25rem; }
.card.back {
  background: repeating-linear-gradient(45deg, #7b1e2b, #7b1e2b 5px, #932838 5px, #932838 10px);
  border: 3px solid var(--card);
}
.card.empty { background: rgba(0, 0, 0, 0.18); box-shadow: none; }
#me .card { width: 58px; height: 80px; font-size: 1.4rem; }
#me .card .suit { font-size: 1.5rem; }
#me .cards { min-height: 80px; }

#status { text-align: center; font-weight: 700; margin: 12px 0 4px; min-height: 1.4em; }
#error { text-align: center; }

/* Actions */
.row { display: flex; gap: 8px; margin-top: 8px; }
.row > button { flex: 1; padding: 0 6px; }
#amount-range { flex: 1; padding: 0; min-height: 48px; accent-color: var(--accent); border: 0; background: transparent; }
#amount { width: 6.5em; text-align: center; }
.presets button { min-height: 44px; font-weight: 500; font-size: 0.9rem; }
#between { display: grid; margin-top: 8px; }

#log, #rp-log {
  margin: 0; padding: 10px 12px 10px 34px;
  background: var(--panel); border-radius: 12px;
  max-height: 14em; overflow-y: auto;
  font-size: 0.9rem; color: #dbe6df;
}
#log li, #rp-log li { padding: 1px 0; }

/* Turn clock */
#turn-timer { text-align: center; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
#turn-timer .bar { height: 6px; margin-top: 4px; background: rgba(255, 255, 255, 0.12); border-radius: 3px; overflow: hidden; }
#turn-timer-fill { height: 100%; width: 100%; background: var(--accent); transition: width 0.2s linear; }
#turn-timer.bank { color: #ffb4a9; font-weight: 700; }
#turn-timer.bank #turn-timer-fill, #turn-timer.low #turn-timer-fill { background: var(--danger); }

/* Runout cards shown after a fold: what would have come */
.card.ghost { opacity: 0.55; outline: 2px dashed rgba(255, 255, 255, 0.7); outline-offset: -2px; }
#between { gap: 8px; }

/* The river of an all-in: covered, then peeled up slowly from the bottom */
.card { position: relative; }
.card.peel { transform: scale(1.12); z-index: 1; overflow: hidden; box-shadow: 0 0 0 3px var(--accent), 0 6px 14px rgba(0, 0, 0, 0.6); }
.card.peel::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: repeating-linear-gradient(45deg, #7b1e2b, #7b1e2b 5px, #932838 5px, #932838 10px);
  border: 3px solid var(--card);
  animation: peel var(--peel-ms, 3500ms) cubic-bezier(0.6, 0, 0.9, 0.6) var(--peel-skip, 0ms) forwards;
}
@keyframes peel {
  0% { clip-path: inset(0 0 0 0); }
  15% { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(0 0 100% 0); }
}
@media (prefers-reduced-motion: reduce) { .card.peel::after { animation: none; display: none; } }

/* Betting panel: sits right under the hand and stays pinned to the bottom of
   the screen, so there is never a need to scroll to act. */
#actions {
  position: sticky; bottom: 0; z-index: 5;
  margin: 6px -16px 0; padding: 2px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg); box-shadow: 0 -8px 12px -6px rgba(0, 0, 0, 0.6);
}
#actions .row { margin-top: 6px; }
#actions .presets button { min-height: 40px; padding: 0 2px; font-size: 0.9rem; }
#actions #amount-range, #actions #amount { min-height: 40px; }
#actions .row > button { min-height: 50px; }

/* Bomb pot: second board, four hole cards */
#board2 { margin-top: 6px; }
#bomb-next { margin-top: 4px; font-weight: 800; color: var(--accent); }
.seat.four .card { width: 44px; height: 62px; font-size: 1.1rem; }
.seat.four .card .suit { font-size: 1.2rem; }
#me.four .cards { min-height: 62px; }
#opp.four .card { width: 36px; height: 50px; font-size: 0.95rem; }
#opp.four .card .suit { font-size: 1rem; }
#opp.four .cards { min-height: 50px; }
.felt.double .card { width: 42px; height: 56px; font-size: 1.05rem; }
.felt.double .card .suit { font-size: 1.1rem; }
.felt.double .cards { min-height: 56px; }
#bomb-toggle[aria-pressed="false"], #seven2-toggle[aria-pressed="false"] { opacity: 0.7; }

/* Made hand: its name under the cards, and a glow on the cards that form it */
.made-label { min-height: 1.3em; font-weight: 800; color: var(--accent); font-size: 0.95rem; }
.card.made { box-shadow: 0 0 0 3px var(--accent), 0 0 12px 2px rgba(242, 193, 78, 0.75); transform: translateY(-4px); }
.card.peel.made { transform: scale(1.12); }

/* Game paused because somebody dropped */
#paused {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px; text-align: center;
  background: #4a1c1a; border: 1px solid var(--danger); font-weight: 700;
}

/* Commentator */
#commentary {
  margin: 10px 0 0; padding: 8px 12px; min-height: 4.6em;
  background: var(--panel); border-radius: 12px; border-left: 3px solid var(--accent);
  font-size: 0.92rem; display: flex; flex-direction: column; justify-content: flex-end;
}
#commentary p { margin: 0; }
#comment-prev { color: var(--muted); font-size: 0.8rem; opacity: 0.75; }
#comment-now::before { content: "🎙 "; }
#comment-now:empty::before { content: ""; }

/* Showing one card (cash game) */
#show-row { margin-top: 2px; }
#show-row button { min-height: 44px; padding: 0 14px; font-weight: 500; font-size: 0.9rem; }
.card.shown { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Last-hand replay */
dialog#replay {
  background: var(--bg); color: var(--text);
  border: 1px solid #2c5a45; border-radius: 16px;
  width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 16px;
}
dialog#replay::backdrop { background: rgba(0, 0, 0, 0.7); }
dialog#replay h2 { margin-top: 0; text-align: center; }
dialog#replay .felt { padding: 12px 6px; }
#rp-log { margin-top: 10px; max-height: 9em; min-height: 9em; }

/* Fruit throwing */
.small { font-size: 0.8rem; text-align: center; margin: 6px 0 0; }
#throwables { margin-top: 16px; }
#throwables button { min-height: 44px; font-size: 1.3rem; padding: 0; }
.flying {
  position: fixed; left: 0; top: 0; z-index: 10; pointer-events: none;
  font-size: 2.6rem; line-height: 1; margin: -1.3rem 0 0 -1.3rem;
}
.hit { animation: hit 0.45s ease-out; }
@keyframes hit {
  20% { transform: translate(-6px, 3px) rotate(-3deg); }
  45% { transform: translate(5px, -2px) rotate(2deg); }
  70% { transform: translate(-3px, 1px) rotate(-1deg); }
}
@media (prefers-reduced-motion: reduce) { .hit { animation: none; } }

#voice-picker select {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 10px; font: inherit; color: inherit;
  background: #0f2a20; border: 1px solid #2c5a45; border-radius: 10px;
}
#voice-picker #voice-test { flex: 0 0 5.5em; }
/* Make it obvious when sound or the voice is switched off. */
#mute[aria-pressed="true"], #voice[aria-pressed="true"] { border-color: var(--danger); background: #4a1c1a; }

#voice {
  position: fixed; top: calc(60px + env(safe-area-inset-top)); right: 8px;
  width: 44px; min-height: 44px; padding: 0; font-size: 1.2rem;
  background: rgba(15, 42, 32, 0.85);
}
#mute {
  position: fixed; top: calc(8px + env(safe-area-inset-top)); right: 8px;
  width: 44px; min-height: 44px; padding: 0; font-size: 1.2rem;
  background: rgba(15, 42, 32, 0.85);
}

#offline {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--danger); color: #fff; padding: 12px 14px; border-radius: 12px; text-align: center; font-weight: 600;
}
