/* PokerDex. Dark by default: it is used at a card table, often in dim light,
   and a bright phone draws eyes. Phone-first; on a PC the app is centred. */

@font-face {
  font-family: "Big Shoulders Display";
  src: url("../fonts/BigShouldersDisplay.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #08130f;
  --bg2: #0d1b16;
  --surface: #13241d;
  --surface2: #1c3229;
  --line: #2a4338;
  --text: #f2efe6;
  --muted: #9bb0a5;
  --felt: #12704a;
  --felt2: #0a3d28;
  --rail: #4a2f1c;
  --rail2: #6b4629;
  --gold: #f0bf4c;
  --gold-text: #f0bf4c;
  --gold-ink: #201603;
  --red: #ec5a4f;
  --ok: #5fc38f;
  --ice: #6fb7e8;
  --ember: #ff7a45;
  --tap: 48px;
  --display: "Big Shoulders Display", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  /* Radii are different on purpose: buttons 14, inputs 12, cards 18. */
  --radius: 14px;
  --radius-input: 12px;
  --radius-card: 18px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1ec;
  --bg2: #e4e9e2;
  --surface: #fafbf8;
  --surface2: #eaeee7;
  --line: #ccd5cb;
  --text: #15201a;
  --muted: #55665c;
  --felt: #1f7a52;
  --felt2: #145a3b;
  --rail: #6e4b2f;
  --rail2: #8a6343;
  --gold: #b9850c; --gold-text: #7a5605;
  --gold-ink: #1d1503;
  --red: #c23b30;
  --ok: #26804f;
  --ice: #1d6fa8;
  --ember: #c2410c;
  --tap: 48px;
  --display: "Big Shoulders Display", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --shadow: 0 6px 20px rgba(30, 50, 40, .15);
}

@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    color-scheme: light;
    --bg: #eef1ec;
    --bg2: #e4e9e2;
    --surface: #fafbf8;
    --surface2: #eaeee7;
    --line: #ccd5cb;
    --text: #15201a;
    --muted: #55665c;
    --felt: #1f7a52;
    --felt2: #145a3b;
    --rail: #6e4b2f;
    --rail2: #8a6343;
    --gold: #b9850c; --gold-text: #7a5605;
    --gold-ink: #1d1503;
    --red: #c23b30;
    --ok: #26804f;
    --ice: #1d6fa8;
    --ember: #c2410c;
    --tap: 48px;
    --display: "Big Shoulders Display", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
    --shadow: 0 6px 20px rgba(30, 50, 40, .15);
  }
}

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

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

/* A faint felt-tinted glow at the top so the app is not flat black. */
body {
  background: radial-gradient(130% 60% at 50% -8%, color-mix(in srgb, var(--felt) 26%, var(--bg)), var(--bg) 72%) fixed var(--bg);
}

#app { display: flex; justify-content: center; min-height: 100dvh; }

.screen { width: 100%; max-width: 640px; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- header and footer ---------- */

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 6px) 8px 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar-title { flex: 1; min-width: 0; text-align: center; }
.bar h1 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: .01em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sub { font-size: 12.5px; line-height: 1.3; color: var(--muted); text-wrap: balance; }

.icon-btn {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius-input); background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:active { background: var(--surface2); }
.body .icon-btn, .sheet-panel .icon-btn { width: var(--tap); height: var(--tap); }
.icon-spacer { flex: none; width: 44px; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.body { flex: 1; padding: 16px; }

.foot {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: 8px;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.foot > * { flex: 1; }

/* ---------- controls ---------- */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface2); color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  font: inherit; font-weight: 600; text-align: center; text-decoration: none;
  cursor: pointer; user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
/* Primary is a brass chip: top highlight and a darker bottom edge that
   closes up when pressed. */
.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 82%, #fff), var(--gold));
  color: var(--gold-ink); border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 2px 0 color-mix(in srgb, var(--gold) 55%, #000);
}
.btn.primary:active:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 1px 0 color-mix(in srgb, var(--gold) 55%, #000); }
.btn.danger {
  /* Darker than --red: white on the bright token is about 3.4:1. */
  background: color-mix(in srgb, var(--red) 76%, #000); color: #fff; border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 2px 0 color-mix(in srgb, var(--red) 55%, #000);
}
.btn.danger:active:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 color-mix(in srgb, var(--red) 55%, #000); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger.ghost { background: transparent; color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); box-shadow: none; }
.btn.big { min-height: 60px; font-size: 18px; flex-direction: column; gap: 0; }
.btn small { font-size: 12px; font-weight: 400; color: var(--muted); }
.btn.small { width: auto; min-height: 44px; padding: 8px 14px; font-size: 14px; }
.btn .ic { width: 20px; height: 20px; }
.btn:focus-visible, .icon-btn:focus-visible, .link-btn:focus-visible, .list-row:focus-visible, .seat-pick:focus-visible,
.check input:focus-visible, input[type="range"]:focus-visible, .field-input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.link-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 8px 10px;
  background: none; border: 0; color: var(--gold-text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}

.row { display: flex; gap: 10px; align-items: stretch; }
.row > * { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }

.muted { color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.low { opacity: .55; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--surface2); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip.small { padding: 1px 6px; font-size: 11px; }
.chip.open { color: var(--ok); }
.chip.setup { color: var(--gold-text); }

.card {
  display: grid; gap: 4px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-card);
  background: var(--surface); color: var(--text); text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
.card.warn { margin-top: 16px; border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.card.warn .btn { justify-self: start; }

/* ---------- home ---------- */

.brand { display: flex; align-items: center; gap: 14px; margin: 20px 2px 22px; }
.brand-mark { flex: none; width: 96px; height: 96px; border-radius: 22px; animation: home-in .3s ease-out backwards; }
.brand-text { min-width: 0; }
.brand-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; }
.brand-name { margin: 0; font-family: var(--display); font-size: 52px; line-height: 1; font-weight: 800; letter-spacing: -.02em; }
.brand-ver { color: var(--muted); font-size: 13px; }
.brand-tag { margin: 6px 0 0; color: var(--muted); font-size: 15px; line-height: 1.35; }

.table-panel { display: grid; gap: 8px; margin-bottom: 14px; animation: home-in .3s ease-out .06s backwards; }
.rail {
  display: grid; align-content: center; gap: 4px; width: 100%; min-height: 120px; padding: 16px 20px;
  border: 7px solid var(--rail); border-radius: 22px; color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
  background: radial-gradient(120% 140% at 30% 25%, var(--felt), var(--felt2));
  box-shadow: inset 0 3px 14px rgba(0, 0, 0, .5), 0 3px 0 color-mix(in srgb, var(--rail) 60%, #000);
}
.rail:active { transform: translateY(2px); box-shadow: inset 0 3px 14px rgba(0, 0, 0, .5); }
.rail:focus-visible, .rail-other:focus-visible, .home-tile:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.rail-title { font-family: var(--display); font-size: 34px; line-height: 1; font-weight: 800; letter-spacing: -.01em; }
.rail-name { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-sub { font-size: 15px; color: color-mix(in srgb, var(--text) 80%, var(--felt)); }
.rail-other {
  min-height: var(--tap, 48px); padding: 8px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.rail-other:active { transform: translateY(1px); background: var(--surface2); }
.home-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-tile {
  display: grid; align-content: start; gap: 2px; min-width: 0; min-height: 96px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  color: var(--text); text-decoration: none;
}
.home-tile .ic { width: 28px; height: 28px; margin-bottom: 6px; color: var(--gold-text); }
.home-tile-name { font-weight: 700; font-size: 17px; }
.home-tile-line { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-tile:active { transform: translateY(1px); background: var(--surface2); }
@keyframes home-in { from { opacity: 0; transform: translateY(10px); } }
.resume-label { font-size: 13px; font-weight: 600; color: var(--gold-text); }
.btn.resume { justify-content: space-between; text-align: left; min-height: 52px; }
.btn.lt { min-height: 52px; }
.resume-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume-sub { color: var(--muted); font-weight: 400; font-size: 14px; }
.foot-note { margin-top: 28px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- forms ---------- */

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.field-input {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-input);
  background: var(--bg2); color: var(--text); font: inherit;
}
textarea.field-input { min-height: 80px; resize: vertical; }
.field-input:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: transparent; }

.seg { display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-input); background: var(--bg2); }
.seg-opt { position: relative; flex: 1; }
.seg-opt input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 8px; color: var(--muted); font-weight: 600; text-align: center; }
.seg-opt input:checked + span { background: var(--surface2); color: var(--text); box-shadow: inset 0 -3px 0 var(--gold); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: -2px; }
.seg.small { flex: none; }
.seg.small span { min-height: 44px; padding: 8px 12px; font-size: 14px; }

.money { display: flex; align-items: center; gap: 8px; }
.money .cur { color: var(--muted); font-weight: 700; }

.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check input { flex: none; width: 26px; height: 26px; margin: 0; accent-color: var(--gold); }

.rating-head { display: flex; align-items: baseline; gap: 10px; }
.rating-val { color: var(--gold-text); font-family: var(--display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* A 44px-high row so a thumb can grab it; the visible track is only 6px. */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 44px; margin: 0; padding: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--surface2); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--surface2); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; margin-top: -11px; border-radius: 50%; /* 24 + 2x2px border = 28 */
  background: var(--gold); border: 2px solid var(--gold-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--gold-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
input[type="range"].unset { opacity: .35; }
.rating-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

.photo-row { display: flex; gap: 14px; align-items: center; }
.photo-actions { flex: 1; display: grid; gap: 8px; }
.photo-box {
  flex: none; width: 140px; height: 140px; display: grid; place-items: center; overflow: hidden;
  border: 2px solid var(--line); border-radius: var(--radius-card); background: var(--surface); color: var(--muted);
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-box .ic { width: 48px; height: 48px; }
.photo-initials { display: grid; place-items: center; font-size: 40px; font-weight: 700; }

/* ---------- lists ---------- */

.list {
  display: grid; gap: 1px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--line);
}
.sheet .list { max-height: 42dvh; overflow-y: auto; }
.list-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  width: 100%; min-height: var(--tap); padding: 12px 14px; border: 0;
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.list-row[aria-selected="true"] { background: color-mix(in srgb, var(--gold) 16%, var(--surface)); box-shadow: inset 4px 0 0 var(--gold); }
.list-main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; }
.list-sub { width: 100%; color: var(--muted); font-size: 13px; }
.player-row { flex-wrap: nowrap; }
.list-vpip { display: grid; text-align: right; font-family: var(--display); font-size: 24px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.list-vpip small { color: var(--muted); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 12px; font-weight: 400; }
.list-title { margin: 14px 2px 8px; color: var(--muted); font-size: 14px; font-weight: 600; }

.avatar {
  flex: none; display: inline-grid; place-items: center; overflow: hidden;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface2); color: var(--muted); font-weight: 700;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 44px; height: 44px; font-size: 15px; }
.avatar.lg { width: 64px; height: 64px; font-size: 20px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.pick .picked { display: grid; justify-items: center; gap: 8px; margin-bottom: 12px; }
.picked-name { color: var(--muted); font-size: 14px; text-align: center; }
.search-row { align-items: center; margin-bottom: 4px; }
.pick > .btn { margin-top: 14px; }

/* ---------- player ---------- */

.stat-card { text-align: center; }
.big-vpip { font-family: var(--display); font-size: 48px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.big-vpip small { color: var(--muted); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; font-weight: 600; }
.section { display: grid; gap: 8px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.section h3 { margin: 0; font-size: 15px; }
.section p { margin: 0; }
.book-line {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px;
  padding: 8px 0; border-bottom: 1px dashed var(--line); color: var(--text); text-decoration: none;
}
.other-notes { display: grid; gap: 8px; }
.note-from { padding: 10px 12px; border-radius: 12px; background: var(--surface); }
.note-from p { margin: 4px 0 0; white-space: pre-wrap; }
.who-head { display: flex; align-items: center; gap: 14px; }

/* ---------- table setup ---------- */

.seat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seat-pick {
  display: grid; align-content: start; gap: 6px; min-height: 76px; padding: 10px 12px;
  border: 1px dashed var(--line); border-radius: var(--radius-card);
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.seat-pick.taken { border-style: solid; }
.seat-pick.me { border: 1px solid var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--surface)); cursor: default; }
.seat-no { color: var(--muted); font-size: 12px; font-weight: 700; }
.seat-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.seat-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-top { display: flex; justify-content: space-between; gap: 8px; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 13px; }
.detail-notes { margin: 6px 0 0; font-size: 14px; white-space: pre-wrap; }

/* ---------- live table ---------- */

.screen.live { height: 100dvh; min-height: 0; max-width: 760px; }
.screen.live .body { display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 10px; overflow: hidden; }
.screen.live .card.warn { margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Left and right seat columns with the felt between. Rows fill the screen but
   never go under 76px (the 48px notes button under a clear name row); then the grid scrolls. */
.table-grid {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr); gap: 6px;
}
.cell { display: flex; min-height: 0; }
.cell > * { flex: 1; min-width: 0; }

.seat {
  position: relative; display: flex; min-height: 0; overflow: hidden; container-type: size;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--text);
  transition: background .12s, border-color .12s, transform .12s;
}
.seat:has(.seat-hit:active) { transform: scale(.98); }
button.seat {
  display: grid; align-content: center; justify-items: start; gap: 2px; padding: 8px 10px;
  font: inherit; text-align: left; cursor: pointer;
}
.seat-hit {
  all: unset; box-sizing: border-box;
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 5px 7px 8px;
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.seat-hit:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; border-radius: 16px; }
.seat-head { display: flex; align-items: center; gap: 5px; min-width: 0; min-height: 20px; }
.seat-no, .seat-photo {
  flex: none; width: 20px; height: 20px; display: grid; place-items: center; overflow: hidden;
  border-radius: 50%; background: var(--surface2); color: var(--text); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.seat-photo img { width: 100%; height: 100%; object-fit: cover; }
.seat-name { flex: 1; min-width: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.seat-vpip {
  margin-top: auto; font-family: var(--display); font-size: clamp(24px, 40cqh, 36px); font-weight: 700;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.seat-sub { overflow: hidden; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.seat-rate { display: none; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.seat-vpip.tone-ice, .seat-meter i.tone-ice { color: var(--ice); }
.seat-vpip.tone-even, .seat-meter i.tone-even { color: var(--text); }
.seat-vpip.tone-warm, .seat-meter i.tone-warm { color: var(--gold-text); }
.seat-vpip.tone-ember, .seat-meter i.tone-ember { color: var(--ember); }
.seat-vpip.tone-hot, .seat-meter i.tone-hot { color: var(--red); }
.seat-vpip.tone-none, .seat-meter i.tone-none { color: var(--muted); }
.seat-meter { position: absolute; left: 0; right: 48px; bottom: 0; height: 4px; background: color-mix(in srgb, var(--line) 70%, transparent); }
.seat-meter i { display: block; height: 100%; background: currentColor; }
.seat-meter i.tone-none { opacity: .4; }

/* The notes button sits in the tile's bottom right corner, under the name
   row and the action line, so both keep the tile's full width (a
   full-height strip left about 30px for it at 375px). 48px is the floor:
   tiles are never shorter than 76px (live.js), which keeps the name row
   above it clear; under 94px it rises beside the action line (below). */
.seat-notes {
  position: absolute; right: 0; bottom: 0; width: 48px; height: max(48px, 100% - 46px);
  display: grid; place-items: center; padding: 0;
  border: 0; border-left: 1px solid var(--line); border-top: 1px solid var(--line); border-top-left-radius: 14px;
  background: var(--surface2); color: var(--text); cursor: pointer;
}
.seat-vpip, .seat-sub, .seat-rate { padding-right: 50px; }
.seat-notes .ic { width: 24px; height: 24px; }
.seat-notes:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; }

/* The hand, turn by turn (v1.5). The seat to act: a brass ring drawn inside
   the tile (an outer ring would be clipped by the scrolling grid) and a
   "To act" line. Folded seats fade but keep their notes button usable. */
.seat-act {
  overflow: hidden; color: var(--muted); font-size: 11.5px; font-weight: 700; line-height: 15px;
  font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap;
}
.seat-act .as { display: none; }
.seat-act.to-act { color: var(--gold-text); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.seat.turn {
  border-color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, var(--surface));
  /* An outline paints above the positioned notes button, a box-shadow under it. */
  outline: 2px solid var(--gold); outline-offset: -3px;
  animation: turn-glow 1.6s ease-in-out infinite;
}
@keyframes turn-glow { 50% { box-shadow: inset 0 0 18px color-mix(in srgb, var(--gold) 45%, transparent); } }
.seat.turn .seat-no { background: var(--gold); color: var(--gold-ink); }
.seat.folded .seat-hit, .seat.folded .seat-meter { opacity: .42; }
.seat.folded .seat-act { font-weight: 600; }
.seat.away { opacity: .55; }
.seat.empty { border-style: dashed; background: transparent; color: var(--muted); justify-items: center; }
.seat.empty .seat-head { display: none; }
.seat.empty:disabled { cursor: default; }
.seat-add { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.seat-add .ic { width: 18px; height: 18px; }
/* Gold on this screen means "to act" (.seat.turn): your own seat is marked in
   ice so the two are never both gold. */
.seat.me { border-width: 2px; }
.seat.me:not(.turn) { border-color: var(--ice); background: color-mix(in srgb, var(--ice) 7%, var(--surface)); }
.seat.me .seat-name { flex: none; font-family: var(--display); font-size: 22px; }
.seat.me .me-sub { margin-top: auto; }

.badge { flex: none; padding: 1px 6px; border-radius: 999px; background: var(--surface2); color: var(--muted); font-size: 10.5px; font-weight: 800; }
.badge.away { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
/* Button, small and big blind: compact so a name keeps room at 375px. The
   button badge is white like a real dealer button (fixed colours: a chip). */
.badge.pos { padding: 0 4px; font-size: 9.5px; line-height: 16px; letter-spacing: .02em; border: 1px solid var(--line); }
.badge.pos-btn { background: #fff; color: #1b1b1b; border-color: rgba(0, 0, 0, .45); }
.badge.pos-bb { color: var(--text); }

/* Short tiles (10 seats on a small phone): drop the lines the sheet repeats.
   The action line stays; the "here" count goes first (the pop-up shows it).
   104px: head, action line, a 40cqh figure and the count no longer fit. */
@container (max-height: 104px) { .seat-sub { display: none; } }
/* Under 94px the 48px notes button rises beside the action line. */
@container (max-height: 94px) {
  .seat-notes { height: 48px; }
  .seat-act { padding-right: 50px; }
  .seat-act:has(.as) .al { display: none; }
  .seat-act .as { display: inline; }
}
@container (max-height: 88px) { .seat-vpip { font-size: 24px; } .seat-hit { padding-bottom: 6px; } }

.felt {
  min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 0; border: 6px solid var(--rail); border-radius: 999px;
  background: radial-gradient(ellipse at 50% 40%, var(--felt), var(--felt2) 78%);
  box-shadow: inset 0 0 0 2px var(--rail2), inset 0 1px 0 3px rgba(255, 255, 255, .08), inset 0 0 34px rgba(0, 0, 0, .5), var(--shadow);
  color: #eaf5ee; text-align: center;
}
.felt-dealer {
  margin-bottom: auto; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  background: #fff; color: #1b1b1b; font-size: 13px; font-weight: 800; box-shadow: 0 2px 5px rgba(0, 0, 0, .45);
}
/* Sticky inside the scrolling grid: with ten seats on a phone the felt is
   taller than the view, and the street, pot and its button must stay in it. */
.felt-mid { position: sticky; top: 8px; bottom: 8px; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.felt-hand { display: grid; line-height: 1; }
.felt-hand span { font-size: 12px; opacity: .8; }
.felt-hand strong { font-family: var(--display); font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* The felt is dark in both themes, so its text colours are fixed. */
.felt-street { color: #f0bf4c; font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; line-height: 1.1; }
.felt-street.over { color: #fff; }
.felt-why { margin-top: -8px; padding: 0 4px; font-size: 10.5px; line-height: 1.2; opacity: .85; }
.felt-pot { display: grid; line-height: 1; }
.felt-pot span { font-size: 11px; opacity: .8; }
.felt-pot strong { font-family: var(--display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* The felt's one button (the antes, dealing a runout): 52px wide inside the
   rail, so its words stack. */
.felt-act {
  width: calc(100% + 4px); min-height: 56px; padding: 6px 2px; border: 0; border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, #f0bf4c 82%, #fff), #f0bf4c); color: #201603;
  box-shadow: 0 2px 0 color-mix(in srgb, #f0bf4c 55%, #000), 0 3px 8px rgba(0, 0, 0, .4);
  /* The condensed display face: "Everyone" must fit about 54px at 375px. */
  font-family: var(--display); font-size: 15px; font-weight: 800; line-height: 1.05; cursor: pointer;
}
.felt-act:active { transform: translateY(1px); }
.felt-act:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.felt-blinds { margin-top: auto; font-size: 12px; font-variant-numeric: tabular-nums; opacity: .8; }

.screen.live .hint.center { padding: 0 8px; }

/* Bottom bar. Overrides the shared .foot > * { flex: 1 } for this screen. */
.screen.live .foot > * { flex: none; }
.screen.live .foot { flex-wrap: wrap; row-gap: 8px; }
.uf-sub { color: var(--muted); font-size: 10.5px; line-height: 1; }
/* The hand is over: Next hand is the thing to press. */
.screen.live .foot .next-foot.ready { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--gold), 0 0 22px color-mix(in srgb, var(--gold) 55%, transparent); }
.screen.live .foot .next-foot.ready .nf-sub { opacity: 1; font-weight: 700; }

/* Turn bar: one row above the bottom bar, only while someone is to act. */
.screen.live .foot > .turn-bar { flex: 1 1 100%; }
.turn-bar { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-who {
  all: unset; box-sizing: border-box; flex: 1; min-width: 0; min-height: 48px;
  display: grid; align-content: center; padding: 0 4px; border-radius: 12px; cursor: pointer;
}
.tb-who:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tb-label { color: var(--gold-text); font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.tb-who strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.tb-acts { flex: none; display: flex; gap: 6px; }
.tb-btn {
  min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface2); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  font: inherit; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer;
}
.tb-btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 82%, #fff), var(--gold));
  color: var(--gold-ink); border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 2px 0 color-mix(in srgb, var(--gold) 55%, #000);
}
.tb-btn:active { transform: translateY(1px); }
.tb-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* Toasts clear the turn bar instead of covering its buttons. */
body:has(.screen.live .turn-bar) #toast { bottom: calc(env(safe-area-inset-bottom) + 148px); }

/* The action window. */
.act-line { margin: 0; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.act-sheet .btn { min-height: 52px; font-variant-numeric: tabular-nums; }
.act-grid { display: grid; gap: 10px; }
.act-bet { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.act-bet[hidden] { display: none; }
/* Bet, raise and all-in confirms: brass edge, so the one gold button stays Check or Call. */
.act-sheet .btn.confirm { border-color: var(--gold); color: var(--gold-text); }
.act-amount { display: grid; gap: 4px; }
.act-quick { display: flex; gap: 6px; }
.act-sheet .act-quick .btn.quick { flex: 1; min-width: 0; min-height: 48px; padding: 0 4px; font-size: 14px; }
.menu-off { display: grid; gap: 4px; }
.screen.live .foot .undo-foot {
  width: 72px; height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.screen.live .foot .undo-foot:disabled { opacity: .4; cursor: default; }
.screen.live .foot .next-foot {
  flex: 1; min-width: 0; height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 0; border-radius: 16px; background: var(--gold); color: var(--gold-ink); cursor: pointer; font: inherit;
}
.nf-main { font-family: var(--display); font-size: 24px; font-weight: 700; line-height: 1; }
.nf-sub { font-size: 12px; font-variant-numeric: tabular-nums; opacity: .8; }
.screen.live .foot .next-foot:active:not(:disabled) { transform: scale(.98); }
.screen.live .foot .next-foot:disabled { opacity: .4; cursor: default; }
.screen.live .foot :is(.undo-foot, .next-foot):focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.step-btn { min-width: 48px; min-height: 48px; padding: 0; }
.row.tall .btn { min-height: 52px; }

@media (min-width: 560px) {
  .seat-vpip { font-size: clamp(30px, 40cqh, 40px); }
  .seat-name { font-size: 15px; }
  .seat-rate { display: block; }
}

/* ---------- wallet ---------- */

.hero {
  display: grid; gap: 2px; padding: 18px 16px; border-radius: var(--radius-card);
  border: 1px solid color-mix(in srgb, var(--felt) 55%, var(--line));
  background: linear-gradient(155deg, color-mix(in srgb, var(--felt) 38%, var(--surface)), var(--surface) 78%);
}
.hero-value { font-family: var(--display); font-size: 44px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.tile { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-input); background: var(--surface); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); min-width: 0; }
.tile-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.tile-value { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { color: var(--muted); font-size: 12px; }
.ledger-row { text-decoration: none; }
.ledger-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.field-input.small { width: auto; min-height: 44px; padding: 6px 10px; font-size: 14px; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap .seg-opt { flex: 1 1 45%; }

.chart-card { gap: 8px; }
.chart-title { margin: 0; font-size: 15px; }
.chart { position: relative; outline: none; border-radius: 8px; }
.chart:focus-visible { box-shadow: 0 0 0 2px var(--gold); }
.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-zero { stroke: var(--muted); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--gold); stroke: var(--surface); stroke-width: 2; }
.chart-cross { stroke: var(--muted); stroke-width: 1; }
.chart-mark { fill: var(--gold); stroke: var(--surface); stroke-width: 2; }
.chart-tip {
  position: absolute; top: 0; display: grid; gap: 1px; width: 170px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); box-shadow: var(--shadow);
  font-size: 12px; color: var(--muted); pointer-events: none;
}
.chart-tip strong { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- cards and the calculator ---------- */

/* Four-colour deck: no two suits share a colour. The faces are chalk-white in
   every theme, so the suit colours are fixed for a light face. */
.suit-s { --suit: #15171c; }
.suit-h { --suit: #c4372b; }
.suit-d { --suit: #1f6fd1; }
.suit-c { --suit: #1e8a4c; }

.cardface {
  display: inline-grid; place-items: center; align-content: center; gap: 0;
  width: 48px; height: 66px; border-radius: 8px; border: 1px solid #d6cfbd;
  background: #f7f3ea; color: var(--suit, #6b6658); font-weight: 800; line-height: 1;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .3);
  font-variant-numeric: tabular-nums;
}
.cardface.empty { border: 1px dashed var(--muted); background: transparent; box-shadow: none; color: var(--muted); font-size: 22px; font-weight: 400; }
.cf-rank { font-family: var(--display); font-size: 24px; font-weight: 700; }
.cf-suit { font-size: 19px; }
.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slots.board { gap: 14px; }
.slot-group { display: grid; gap: 4px; }
.slot-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.slot { min-width: 44px; min-height: 60px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 9px; }
.slot:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.slots.small .cardface { width: 44px; height: 60px; }
.slots.small .cf-rank { font-size: 21px; }
.slots.small .cf-suit { font-size: 16px; }
.opp-row { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.opp-name { flex: 1; font-weight: 600; }

.picker { display: grid; gap: 12px; }
.suit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.suit-btn, .rank-btn { background: #f7f3ea; border-color: #d6cfbd; color: var(--suit); }
.suit-btn { min-height: 76px; flex-direction: column; gap: 2px; }
.suit-big { font-size: 34px; line-height: 1; }
.rank-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rank-btn { min-height: 54px; padding: 4px; flex-direction: column; gap: 0; font-family: var(--display); font-size: 20px; font-weight: 700; }
.rank-btn .rank-suit { font-size: 13px; }
.rank-btn.current { box-shadow: inset 0 0 0 2px var(--gold); }
.rank-btn:disabled { opacity: .3; }

.calc-result { gap: 10px; }
.calc-top { display: flex; justify-content: space-between; gap: 12px; align-items: end; flex-wrap: wrap; }
.calc-made { display: grid; text-align: right; }
/* Win, tie and lose as one thin bar (a figure: no baseline, rounded ends). */
.segbar { display: flex; gap: 2px; height: 8px; border-radius: 999px; overflow: hidden; }
.segbar span { display: block; min-width: 0; }
.seg-win { background: var(--gold); }
.seg-tie { background: var(--muted); }
.seg-lose { background: var(--surface2); }
.odds-line { margin: 0; font-size: 14px; }

/* ---------- hand panel (optional tracking) ---------- */

.hand-panel { display: grid; gap: 4px; padding: 4px 6px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.hp-head { display: flex; justify-content: space-between; align-items: center; }
.panel-toggle { min-height: 44px; padding: 0 10px; }
/* One row at 375px: seven 44px slots, so the table above keeps its height. */
.hp-cards { display: flex; gap: 6px; }
.hand-panel .slots.small { flex-wrap: nowrap; gap: 2px; }
.hand-panel .slots.small .cardface, .cardface.sm { width: 44px; height: 60px; }
.cardface.sm .cf-rank { font-size: 21px; }
.cardface.sm .cf-suit { font-size: 16px; }
.hp-bets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; }
.hp-fig { padding: 0 2px; }
.hp-fig strong { overflow: hidden; color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.mini { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.mini .field-input.small { width: 100%; min-height: 48px; height: 48px; }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper .icon-btn { width: 48px; height: 48px; font-size: 22px; }
.stepper strong { min-width: 20px; text-align: center; color: var(--text); font-size: 18px; }
.hint-box { display: grid; gap: 2px; }
.hint-action { font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--text); }
.hint-action::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.act-raise::before, .act-bet::before { background: var(--gold); }
.act-call::before { background: var(--ok); }
.act-fold::before { background: var(--red); }
.hint-why { font-size: 13px; }
.hint-note { font-size: 11.5px; color: var(--muted); }

/* ---------- sheets ---------- */

dialog.sheet {
  width: 100%; max-width: 640px; max-height: 94dvh; margin: auto auto 0; padding: 0;
  border: 0; background: transparent; color: var(--text);
}
dialog.sheet::backdrop { background: rgba(0, 4, 2, .72); }
.sheet-panel {
  position: relative; display: grid; gap: 12px; max-height: 94dvh; overflow-y: auto;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 18px);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  background: var(--bg2);
  animation: sheet-up .18s ease-out;
}
/* Grab handle: a visual cue only, the sheet closes with its own button. */
.sheet-panel::before {
  content: ''; display: block; width: 36px; height: 4px; margin: 8px auto -4px; border-radius: 999px; background: var(--line);
}
.sheet-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 8px; background: var(--bg2);
}
.sheet-head h2 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: .01em; }
.sheet-text { margin: 0; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 700px) {
  dialog.sheet { margin: auto; }
  .sheet-panel { border-bottom: 1px solid var(--line); border-radius: 22px; }
}

.import-line { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface); font-size: 14px; }
.cand { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface); }
.rebuy-count { display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.count { font-family: var(--display); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

.book.hidden { opacity: .6; }
.book-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

/* ---------- toast and update bar ---------- */

#toast {
  width: max-content;
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 100;
  max-width: min(92vw, 520px); padding: 12px 16px 12px 14px; border-radius: var(--radius-input);
  background: var(--text); color: var(--bg); border-left: 4px solid var(--gold); font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transform: translate(-50%, 16px);
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.update-bar {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; z-index: 50; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; border-radius: 14px;
  background: var(--surface2); border: 1px solid var(--line); border-left: 4px solid var(--gold); box-shadow: var(--shadow); font-size: 14px; white-space: nowrap;
}

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

/* Table rules form: .field is display:grid, which beats the hidden attribute. */
.field[hidden] { display: none; }
