:root {
  --bg: #120f0c;
  --panel: #1c1813;
  --panel2: #251f19;
  --line: #3a3128;
  --text: #f1ebe0;
  --dim: #b2a691;
  --accent: #e9c46a;
  --accent-ink: #1d1508;
  --ok: #7fd49b;
  --bad: #ff8c7c;
  --felt: #1d6b4b;
  --felt-dark: #0c3a28;
  --felt-ink: #d7eadf;
  --wood: #5b3a22;
  --wood-dark: #2f1d10;
  --card: #fbf8f0;
  --suit-red: #c4232c;
  --suit-black: #17171c;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --felt-label: #e0eee6;
  --tap: 44px;
  --chip: 44px;
  --chip-sm: 28px;
  --cw: 50px;
  --ch: 70px;
  color-scheme: dark;
}
@media (min-width: 900px) { :root { --chip: 50px; --chip-sm: 32px; --cw: 64px; --ch: 90px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: radial-gradient(900px 500px at 50% -120px, #2a2118 0%, transparent 70%), var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input { font: inherit; color: inherit; }
button { min-height: var(--tap); padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel2); cursor: pointer; transition: border-color .15s, background-color .15s, transform .1s; }
button:hover { border-color: #5a4c3d; }
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus { border-color: #6b5a3f; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: #f3d283; }
button:disabled, button:disabled:hover { opacity: .5; cursor: default; transform: none; }
button.primary:disabled { background: #2a241c; border-color: rgba(233,196,106,.28); color: #b8a98a; opacity: 1; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-weight: 700; letter-spacing: -.01em; }
.dim { color: var(--dim); font-weight: 400; }
.note { color: var(--dim); font-size: 13px; margin: 6px 0 12px; }
.note.warn { color: var(--bad); }

/* ---------- Header ---------- */

.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px max(12px, calc((100% - 1180px) / 2 + 10px)); padding-top: max(8px, env(safe-area-inset-top)); background: rgba(18,15,12,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; margin: 0; }
.brand-mark { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle, #c8282e 0 45%, transparent 46%), repeating-conic-gradient(#c8282e 0 30deg, #f6efe2 30deg 60deg); box-shadow: 0 0 0 1.5px #7d1418; }
.brand { white-space: nowrap; }
/* Below this width "(unofficial)" would push the hand tally to a second line; the footer still says it. */
@media (max-width: 479px) { .brand-tag { display: none; } }
.tally { flex: 1 0 auto; white-space: nowrap; display: flex; justify-content: flex-end; align-items: center; gap: 12px; font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; min-width: 0; }
.hand-no { color: var(--text); font-weight: 600; }
.pips { display: inline-flex; align-items: center; gap: 3px; }
.pips-label { margin-right: 3px; }
.pips-label .long { display: none; }
.pips-label.ok .short { color: var(--ok); font-weight: 700; }
.pips-label.bad .short { color: var(--bad); font-weight: 700; }
@media (min-width: 760px) { .pips-label .long { display: inline; } .pips-label .short { display: none; } }
.pip-dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #6b5d4c; }
.pip-dot.ok { background: var(--ok); border-color: var(--ok); }
.pip-dot.bad { background: var(--bad); border-color: var(--bad); }
.tools { display: flex; gap: 6px; width: 100%; }
.tools button { flex: 1; padding: 0 4px; font-size: 14px; background: transparent; }
.tools button:hover { background: var(--panel2); }
.tools button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #2c2414; }
@media (min-width: 760px) { .tools { width: auto; } .tools button { flex: none; padding: 0 14px; } }

main { max-width: 1180px; margin: 0 auto; padding: 10px 10px 48px; }
.foot { margin: 0 12px 24px; text-align: center; }
.save-warn { max-width: 1180px; margin: 10px auto 0; padding: 0 12px; }

/* ---------- Setup, History ---------- */

.setup, .history { max-width: 520px; margin: 0 auto; }
.setup-head, .sub-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setup h2, .history h2, .review h2 { margin: 14px 0 10px; font-size: 24px; }
.setup-art { display: flex; gap: 0; }
.setup-art .chip { margin-left: -10px; --chip: 40px; box-shadow: 0 3px 8px rgba(0,0,0,.5); }
.setup-art .chip:nth-child(1) { transform: rotate(-12deg); }
.setup-art .chip:nth-child(4) { transform: rotate(10deg); }
.lede { color: var(--dim); margin: 0 0 22px; line-height: 1.5; }
.field { display: block; margin: 0 0 18px; }
.label { display: block; color: var(--dim); font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.field input { width: 100%; min-height: var(--tap); padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel2); }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; background: var(--panel); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:focus-visible { outline-offset: -4px; }
.seg button[aria-checked="true"]:focus-visible { outline-color: var(--accent-ink); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions { margin-top: 6px; }
.actions .primary { flex: 1 1 100%; min-height: 50px; font-size: 16px; }
.actions button:not(.primary) { flex: 1 1 0; }
.history-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.hist-row { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; text-align: left; padding: 12px 14px; background: var(--panel); border-radius: var(--r-lg); }
.hist-row:hover { background: var(--panel2); }
.hist-res { font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }
.hist-res.ok { color: var(--ok); }
.hist-res.bad { color: var(--bad); }
.hist-meta { color: var(--dim); font-size: 13px; }
.history-list > .note { margin: 0; padding: 28px 16px; text-align: center; border: 1px dashed var(--line); border-radius: var(--r-lg); }
.stats { margin: 0 0 18px; padding: 4px 12px 2px; background: var(--panel); border-radius: var(--r-lg); }
.stats h3 { font-size: 17px; margin: 10px 0 6px; }
.weakest { margin: 0 0 6px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.stats-table thead th { font-size: 12.5px; font-weight: 500; color: var(--dim); padding: 2px; }
.stats-table th[scope="row"] { text-align: left; font-weight: 500; padding: 0 4px 0 0; border-bottom: 1px solid var(--line); }
.stats-table td { width: 22%; text-align: center; padding: 0; border-bottom: 1px solid var(--line); }
.stat-group th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--dim); padding: 10px 0 2px; }
button.stat { width: 100%; padding: 0 4px; border: 0; background: none; font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; }
.weakest button.stat { width: auto; min-width: var(--tap); padding: 0 2px; margin: -12px 0; color: var(--accent); }
.stats-table thead td { border: 0; }
button.stat.on { color: var(--accent); }
.stat-math { min-height: 3em; margin: 8px 0; color: var(--dim); font-size: 13px; }

/* ---------- The table ---------- */

.game { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "mods" "felt" "msg" "showdown" "bar" "group" "coach"; }
/* A group decision (a guess, a swap) is the only thing to do then: keep it right under the table. */
@media (max-width: 899px) { .game:has(.group:not([hidden])) { grid-template-areas: "mods" "felt" "msg" "bar" "group" "showdown" "coach"; } }
.felt { grid-area: felt; position: relative; padding: 12px 10px 14px; border-radius: 26px; color: var(--felt-ink);
  background:
    radial-gradient(120% 80% at 50% 45%, rgba(255,255,255,.07), transparent 60%),
    repeating-radial-gradient(circle at 30% 20%, rgba(0,0,0,.035) 0 1px, transparent 1px 3px),
    radial-gradient(130% 100% at 50% 50%, var(--felt) 0%, var(--felt-dark) 100%);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.35), inset 0 0 40px rgba(0,0,0,.45), 0 0 0 9px var(--wood), 0 0 0 11px var(--wood-dark), 0 18px 40px rgba(0,0,0,.6);
  margin: 11px 11px 4px; }
.msg { grid-area: msg; min-height: 40px; margin: 8px 4px 0; padding: 9px 12px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); font-size: 14px; }
.msg:empty { visibility: hidden; }
.game:has(.showdown:not([hidden])) .msg:empty { display: none; }
.msg.error { border-color: #7a3a30; color: var(--bad); }
.bar { grid-area: bar; display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; margin: 0 4px; }
.bar button { flex: 1 1 0; font-size: 16px; min-height: 48px; }
.bar .lock { flex: 1 1 100%; }
.why { color: var(--dim); font-size: 13px; }
.why:empty { display: none; }

.seats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.seat { padding: 7px 8px 8px; border-radius: var(--r-lg); background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.08); min-width: 0; }
.seat.moved { animation: moved 1.1s ease-out; }
@keyframes moved { from { box-shadow: 0 0 0 2px var(--accent); background: rgba(233,196,106,.14); } to { box-shadow: 0 0 0 2px transparent; } }
.seat-head, .me-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.name { font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you { font-size: 11px; font-weight: 600; color: var(--accent-ink); background: var(--accent); border-radius: var(--r-sm); padding: 1px 5px; margin-left: 4px; vertical-align: 1px; }
.pocket { display: flex; gap: 3px; flex: none; }
.made { display: block; font-size: 12.5px; color: #fff3cf; margin-top: 4px; }
.me-head .made { margin: 0; }
.chip-row { display: flex; align-items: center; gap: 4px; }

.middle { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 14px 0; }
.round-label { font-size: 13px; color: var(--felt-ink); display: flex; align-items: center; gap: 6px; }
.round-label .dim { color: var(--felt-label); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(0,0,0,.4); vertical-align: -1px; margin-right: 4px; }
.board { display: flex; gap: 6px; justify-content: center; }
.centre { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; background: rgba(0,0,0,.2); border: 1px dashed rgba(255,255,255,.18); }
.centre-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--felt-label); }
.centre-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

.me { padding: 10px; border-radius: var(--r-lg); background: rgba(0,0,0,.24); border: 1px solid rgba(233,196,106,.45); }
.me-body { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pocket.big { gap: 6px; }

/* ---------- Cards ---------- */

.card { position: relative; display: inline-block; flex: none; width: var(--cw); height: var(--ch); border-radius: var(--r-sm); background: var(--card); color: var(--suit-black); box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 2px 6px rgba(0,0,0,.45); font-family: "Iowan Old Style", Georgia, serif; }
.card.red { color: var(--suit-red); }
.card .corner { position: absolute; top: 3px; left: 4px; display: flex; flex-direction: column; align-items: center; line-height: .95; }
.card .corner b { font-size: calc(var(--cw) * .3); font-weight: 700; letter-spacing: -.04em; }
.card .corner i { font-style: normal; font-size: calc(var(--cw) * .24); }
.card .corner.flip { top: auto; left: auto; bottom: 3px; right: 4px; transform: rotate(180deg); }
.card .pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * .56); }
.card.sm { --cw: 28px; --ch: 40px; border-radius: 4px; }
.card.sm .pip, .card.xs .pip, .card.sm .corner.flip, .card.xs .corner.flip { display: none; }
.card.sm .corner { top: 2px; left: 0; right: 0; }
.card.sm .corner b { font-size: 13px; }
.card.sm .corner i { font-size: 12px; }
.card.xs { --cw: 22px; --ch: 30px; border-radius: 3px; }
.card.xs .corner { top: 2px; left: 0; right: 0; }
.card.xs .corner b { font-size: 11px; }
.card.xs .corner i { font-size: 10px; }
.pocket.big .card { --cw: 60px; --ch: 84px; }
@media (min-width: 900px) { .pocket.big .card { --cw: 72px; --ch: 100px; } }
.card.back { background: repeating-linear-gradient(45deg, #7c1f2a 0 3px, #5d1520 3px 6px), #6b1a24; border: 2px solid var(--card); }
.card.slot { background: transparent; border: 1.5px dashed rgba(255,255,255,.22); box-shadow: none; }

/* ---------- Chips ---------- */

.chip { --c: #ddd; --edge: #fff; --ink: #222; position: relative; display: inline-grid; place-items: center; flex: none; width: var(--chip); height: var(--chip); min-height: 0; padding: 0; border-radius: 50%; border: 0; color: var(--ink);
  background: radial-gradient(circle, var(--c) 0 55%, transparent 56%), repeating-conic-gradient(from 10deg, var(--c) 0 25deg, var(--edge) 25deg 45deg);
  box-shadow: 0 0 0 1px rgba(0,0,0,.45), 0 2px 4px rgba(0,0,0,.45); font-family: system-ui, sans-serif; line-height: 1; }
.chip::before { content: ""; position: absolute; inset: 17%; border-radius: 50%; border: 1.5px dashed color-mix(in srgb, var(--ink) 35%, transparent); }
.chip b { position: relative; font-size: calc(var(--chip) * .4); font-weight: 700; margin-top: -10%; }
.chip .stars { position: absolute; bottom: 25%; left: 0; right: 0; text-align: center; font-size: calc(var(--chip) * .13); letter-spacing: -.5px; line-height: 1; }
.chip.c-white { --c: #f2eee4; --edge: #3d6fa8; --ink: #1d2733; }
.chip.c-yellow { --c: #f4c51f; --edge: #fff6d6; --ink: #3a2a00; }
.chip.c-orange { --c: #ec7a22; --edge: #fff0e2; --ink: #2e1300; }
.chip.c-red { --c: #c8262d; --edge: #f8e9e9; --ink: #fff; }
.dot.c-white { --c: #f2eee4; } .dot.c-yellow { --c: #f4c51f; } .dot.c-orange { --c: #ec7a22; } .dot.c-red { --c: #c8262d; }
.t-white { color: #f2eee4; } .t-yellow { color: #f4c51f; } .t-orange { color: #f59a4f; } .t-red { color: #ff6b70; }
.chip.past { --chip: var(--chip-sm); }
.chip.past b { margin-top: 0; }
.chip.past .stars { display: none; }
.chip.xs { --chip: 30px; }
.chip.xs b { margin-top: 0; }
.chip.xs .stars { display: none; }
.chip.empty { background: transparent; box-shadow: none; border: 2px dashed color-mix(in srgb, var(--c) 70%, transparent); }
.chip.empty::before, .chip.ghost::before { display: none; }
.chip.ghost { --chip: var(--chip-sm); background: rgba(255,255,255,.04); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
button.chip { cursor: pointer; transition: transform .12s; }
button.chip:hover { transform: translateY(-2px); }
.me .chip.now { box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(0,0,0,.5); }
.chip.hinted { animation: hint 1.4s ease-in-out infinite; box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--accent) !important; }
@keyframes hint { 50% { transform: translateY(-3px); } }

/* ---------- Coach ---------- */

.coach { grid-area: coach; margin: 0 4px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid #5c4d2f; }
.coach-head { display: flex; align-items: baseline; gap: 8px; }
.coach-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.coach-why { margin: 6px 0 4px; font-size: 14px; line-height: 1.5; }
/* Its content's margins stay inside it, so its height is what closing it takes off the page (app.js). */
details.numbers { display: flow-root; }
.numbers summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; width: fit-content; color: var(--accent); font-weight: 600; font-size: 14px; }
.coach button.stat { width: auto; min-width: var(--tap); min-height: var(--tap); }
/* Every math button is its own 44 px box, none overlapping another, and stays put while pressed: a press that
   moved it could end on its neighbour. */
.coach button:active { transform: none; }
button.why-how { display: block; min-height: var(--tap); padding: 0 4px; margin: 0 -4px; border: 0; background: none; color: var(--accent); font-size: 13.5px; font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; text-align: left; }
button.why-how.on { color: var(--text); }
.num-line { margin: 0; font-size: 14px; }
.num-title { margin: 8px 0 0; color: var(--dim); font-size: 12.5px; }
.beat { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); column-gap: 14px; }
.beat li { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13.5px; border-bottom: 1px solid var(--line); min-width: 0; }
.beat li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.dist-row { width: 100%; min-height: var(--tap); margin: 0; padding: 0 4px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; font-weight: 400; }
button.dist-row.on { background: var(--panel2); }
.coach-math { min-height: 3em; margin: 8px 0; color: var(--dim); font-size: 13px; }
.checks { list-style: none; margin: 4px 0; padding: 0; }
button.check-row { display: block; width: 100%; min-height: var(--tap); padding: 4px 6px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; text-align: left; font-size: 13px; font-weight: 400; color: var(--dim); }
button.check-row.on { background: var(--panel2); color: var(--text); }
.why-calc summary { color: var(--accent); font-size: 13.5px; }
.mistake-why { display: block; margin: 2px 0; font-size: 13.5px; }
.dist-title { font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.dist-row { display: grid; grid-template-columns: 30px 1fr 40px; align-items: center; gap: 8px; font-size: 13px; font-variant-numeric: tabular-nums; margin: 3px 0; }
.dist-bar { height: 10px; border-radius: 5px; background: var(--panel2); overflow: hidden; }
.dist-bar span { display: block; height: 100%; background: #8a7a5c; border-radius: 5px; }
.dist-row.pick .dist-bar span { background: var(--accent); }
.dist-row.pick .dist-k { color: var(--accent); font-weight: 700; }
.dist-p { text-align: right; color: var(--dim); }

/* ---------- Showdown ---------- */

.showdown { grid-area: showdown; margin: 0 4px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); }
.showdown h2 { margin: 0 0 10px; font-size: 20px; }
.sd-sub { font: 400 13px system-ui, sans-serif; color: var(--dim); margin-left: 6px; }
.sd-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sd-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--r); background: var(--panel2); --chip: 38px; }
.sd-row .chip b { margin-top: 0; }
.sd-row .chip .stars { display: none; }
.sd-row.is-me { box-shadow: inset 0 0 0 1px rgba(233,196,106,.5); }
.sd-who { min-width: 0; display: flex; flex-direction: column; }
.sd-hand { font-size: 13.5px; }
.sd-hand small { display: block; font-size: 12px; color: var(--dim); }
.sd-row.broke { background: #3a1d19; box-shadow: inset 0 0 0 2px var(--bad); }
.sd-break { grid-column: 1 / -1; color: var(--bad); font-weight: 600; font-size: 13.5px; }
.sd-verdict { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r); font-weight: 600; font-size: 14px; background: var(--panel2); }
.sd-verdict.ok { color: var(--ok); background: rgba(127,212,155,.09); }
.sd-verdict.bad { color: var(--bad); background: rgba(255,140,124,.09); }
.sd-verdict b { display: block; color: var(--text); margin-top: 6px; font: 700 19px/1.25 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
.showdown.animate .sd-row, .showdown.animate .sd-verdict { animation: reveal .45s cubic-bezier(.2,.8,.3,1) both; animation-delay: calc(var(--i) * .65s); }
@keyframes reveal { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Review ---------- */

.review h2 .dim { font: 400 14px system-ui, sans-serif; margin-left: 6px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.tabs button { flex: none; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.review-felt { margin: 18px 11px 10px; padding: 14px 8px; }
.rev-result { font-weight: 600; margin: 14px 4px 8px; }
.rev-result.ok { color: var(--ok); }
.rev-result.bad { color: var(--bad); }
.table-wrap { overflow-x: auto; }
.rev-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rev-table caption { caption-side: bottom; text-align: left; color: var(--dim); padding-top: 6px; font-size: 12px; }
.rev-table th, .rev-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: center; vertical-align: top; }
.rev-table thead th { font-weight: 500; color: var(--dim); white-space: nowrap; }
.rev-table th[scope="row"] { text-align: left; width: 34%; }
.rev-table th[scope="row"] .pocket { margin: 3px 0; }
.rev-table th[scope="row"] .made { color: var(--dim); font-weight: 400; margin: 0; }
.rev-table td .true { display: block; color: var(--dim); margin-top: 3px; white-space: nowrap; }
.rev-table td.flag { background: #3a1d19; border-radius: var(--r-sm); }
.rev-table .coach-said { display: block; color: var(--bad); font-weight: 600; }
.rev-table tr.is-me th .name { color: var(--accent); }
.rev-notes { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.rev-notes li { padding: 8px 10px; border-radius: var(--r); background: var(--panel); }
.rev-notes li.off { border-left: 3px solid var(--bad); }
.review h3 { font-size: 17px; margin: 18px 0 8px; }
.mistakes { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; font-size: 14px; }
.mistake { padding: 8px 10px; border-radius: var(--r); background: var(--panel); border-left: 3px solid var(--bad); }
.mistake-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.mistake .skill { font-size: 12px; font-weight: 700; border-radius: var(--r-sm); padding: 1px 7px; background: #3a2f1a; color: var(--accent); white-space: nowrap; }
.mistake button.link { min-height: var(--tap); padding: 0 4px; border: 0; background: none; color: var(--accent); text-decoration: underline; font-weight: 600; }
.calc summary { cursor: pointer; font-weight: 600; color: var(--bad); min-height: var(--tap); display: flex; align-items: center; width: fit-content; }
.calc p { margin: 4px 0; color: var(--dim); font-size: 13px; }
.mistake-notes { display: block; font-size: 13px; }
.rev-table td.focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Rules sheet ---------- */

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.72); display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { width: 100%; max-width: 620px; max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 4px 16px 24px; }
@media (min-width: 760px) { .sheet { align-items: center; } .sheet-body { border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line); margin: 0 -16px; padding: 0 16px; }
.sheet-head h2 { font-size: 20px; }
.rules { max-width: 62ch; line-height: 1.6; }
.rules p, .rules li { color: #e2d9c8; }
.rules li + li { margin-top: 4px; }
.rules ol { padding-left: 20px; }

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
  .game { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "mods showdown" "felt showdown" "msg showdown" "bar coach" "group coach" ". coach"; align-items: start; column-gap: 20px; }
  .game:has(.showdown[hidden]) { grid-template-areas: "mods coach" "felt coach" "msg coach" "bar coach" "group coach"; }
  .game:has(.showdown[hidden]):has(.coach[hidden]) { grid-template-columns: minmax(0, 860px); grid-template-areas: "mods" "felt" "msg" "bar" "group"; justify-content: center; }
  .felt { padding: 20px 22px; }
  .seats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .middle { margin: 26px 0; gap: 12px; }
  .bar button, .bar .lock { flex: 0 1 260px; }
  .me-body { justify-content: flex-start; column-gap: 28px; }
  .review { max-width: 980px; margin: 0 auto; }
  .review-felt { width: fit-content; min-width: 60%; margin-inline: auto; }
}

/* Narrow phones (320 px): smaller chips and pocket cards so a seat's four chips fit its tile. */
@media (max-width: 359px) {
  :root { --chip: 36px; --chip-sm: 21px; }
  .chip-row { gap: 3px; }
  .pocket.big .card { --cw: 54px; --ch: 76px; }
  .board .card { --cw: 46px; --ch: 64px; }
}

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

/* ---------- Variants (setup) ---------- */

.variants { margin: 4px 0 18px; padding: 14px 16px 6px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); }
.variants h3 { margin: 0 0 12px; font-size: 18px; }
.variants .seg button { padding: 0 6px; font-size: 14px; }
.variants .note { margin: 6px 0 0; }
.switch, .mod-opt { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 10px 0; cursor: pointer; }
.switch + .switch { border-top: 1px solid rgba(255,255,255,.05); }
.switch input, .mod-opt input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }
.switch b, .mod-opt b { display: block; font-weight: 600; }
.switch .dim, .mod-opt .dim { display: block; font-size: 13px; line-height: 1.45; margin-top: 2px; }
.switch.off { cursor: default; opacity: .75; }
.switch.off b { color: var(--dim); }
.mod-pick { margin: 4px 0 10px; }
.mod-pick summary { min-height: var(--tap); display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.mod-pick fieldset { border: 0; padding: 0; margin: 0 0 8px; }
.mod-pick legend { color: var(--dim); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; padding: 6px 0 0; }

/* ---------- Modifiers in play ---------- */

.mods { grid-area: mods; margin: 0 4px; padding: 8px 12px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); font-size: 13.5px; }
.mod-list, .talk { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.mod-list .txt { color: var(--dim); }
.talk { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: #fff3cf; }
.mod-list:only-child, .talk:only-child { margin: 0; padding: 0; border: 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; border-radius: var(--r-sm); padding: 1px 6px; margin-right: 6px; vertical-align: 1px; white-space: nowrap; }
.tag.hard { background: #4a2420; color: #ffb4a8; }
.tag.help { background: #1f3a2c; color: var(--ok); }
.status { font-size: 12px; color: var(--accent); }
.rev-mods { margin: 10px 0 0; }
.rev-variants { margin: -4px 0 10px; }
.chip.locked { box-shadow: 0 0 0 2px #111, 0 0 0 4px #fff, 0 2px 4px rgba(0,0,0,.45); }
.me .chip.now.locked { box-shadow: 0 0 0 2px #111, 0 0 0 4px var(--accent); }
.chip.empty.gone { border-style: dotted; opacity: .55; }
.card.suitless { color: #5a3fa0; }
.pocket.big.three .card { --cw: 50px; --ch: 70px; }
@media (min-width: 900px) { .pocket.big.three .card { --cw: 62px; --ch: 86px; } }
/* Omaha: four or five pocket cards. Yours are smaller and the chips wrap below them if they must; other
   players' overlap so their names still fit. */
.me-body { flex-wrap: wrap; row-gap: 8px; }
.pocket.big.four { gap: 4px; }
.pocket.big.four .card { --cw: 36px; --ch: 50px; }
@media (min-width: 900px) { .pocket.big.four .card { --cw: 56px; --ch: 78px; } }
.pocket.many .card + .card { margin-left: -9px; }
.seat-head:has(.pocket.many) { flex-wrap: wrap; }
/* A joker on the board becomes a stack: its cards overlap downwards so each corner shows. */
.stack { display: inline-grid; flex: none; padding: 2px; margin: -2px; border-radius: var(--r-sm); outline: 1.5px dashed rgba(233,196,106,.7); }
.stack > .card { grid-area: 1 / 1; }
.stack > .card:nth-child(2) { margin-top: calc(var(--ch) * .34); }
.stack > .card:nth-child(3) { margin-top: calc(var(--ch) * .68); }
.card.known { box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(0,0,0,.45); }

/* ---------- Group decisions ---------- */

.group { grid-area: group; margin: 0 4px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid #2f5b45; }
.group h3 { margin: 0 0 4px; font-size: 17px; }
.group p { margin: 0 0 8px; color: var(--dim); font-size: 13.5px; }
.group .votes { color: #fff3cf; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opts.values { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
.opts.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.opt { display: flex; flex-direction: column; justify-content: center; align-items: center; line-height: 1.1; padding: 4px 6px; }
.opt small { font-size: 11px; color: var(--accent); }
.opt.voted { border-color: var(--accent); }
.opt.hinted-opt { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.card-btn { min-height: 48px; padding: 4px 10px; display: inline-flex; align-items: center; }
.card-btn .card.sm { --cw: 34px; --ch: 46px; }
.help-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 0 0 10px; }
.pick select { width: 100%; min-height: var(--tap); padding: 0 8px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; }
.group .primary { width: 100%; }
.sd-guesses { list-style: none; margin: 8px 0 0; padding: 0; font-weight: 600; font-size: 14px; }
.sd-guesses .ok { color: var(--ok); }
.sd-guesses .bad { color: var(--bad); }
.sd-row.hidden-hand .sd-hand { color: var(--dim); }
.rev-table td.skipped { color: var(--dim); font-style: italic; vertical-align: middle; }
.deck-order { margin: 4px 0 6px; }
.deck-order .note { margin: 4px 0 8px; }
/* ---------- Exit chip and two hands each ---------- */

/* Beside a red star it is small, and wraps below the chips where a seat is too narrow. */
.chip-row .chip.exit { --chip: calc(var(--chip-sm) + 6px); }
.chip-row:has(.exit) { flex-wrap: wrap; row-gap: 4px; }
.chip.exit b { font-size: calc(var(--chip) * .26); margin-top: 0; letter-spacing: .02em; text-transform: uppercase; }
.chip.exit::before { border-style: solid; }
.tag.exit-tag { background: #4a2420; color: #fff; }
.sd-row.exited { opacity: .7; }
.me-hand + .me-hand { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(233,196,106,.25); }
.me-hand.active .me-head .name { color: var(--accent); }
.hand-pick { margin-bottom: 8px; }
.coach-exit { color: #fff3cf; }
.coach-hand + .coach-hand { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

/* ---------- Drills ---------- */

.drills { max-width: 720px; margin: 0 auto; }
.drills h2 { margin: 14px 0 10px; font-size: 24px; }
.sub-tools { display: flex; gap: 8px; }
/* Nothing on the drill screen moves under a press. */
#drills button, #drill-stats button, button[data-act="to-drills"] { transform: none; transition: none; }
.skill-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); margin: 8px 0; }
.skill-pick button + button { border-left: 0; }
@media (min-width: 600px) { .skill-pick { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.drill-progress { margin: 8px 0 4px; font-size: 14px; }
.drill-progress button.stat, .drill-verdict button.stat { width: auto; min-width: var(--tap); padding: 0 6px; }
.drill-source { margin: 12px 0 6px; font-size: 13px; color: var(--dim); }
#drill-body, .drill-answer { scroll-margin-top: 70px; scroll-margin-bottom: 12px; }
.drills .mods { margin: 0 0 8px; }
.drill-felt { margin: 14px 11px; }
.drill-felt .seat .chip-row { flex-wrap: wrap; }
.chip.to-pick b { margin-top: 0; color: var(--text); }
.drill-ask { margin: 14px 0 6px; font-weight: 600; }
.drill-stars { display: flex; flex-wrap: wrap; gap: 6px; }
button.drill-star { width: 52px; height: 52px; min-height: 52px; padding: 0; display: grid; place-items: center; border-radius: var(--r); background: var(--panel); }
button.drill-star .chip { --chip: 40px; pointer-events: none; }
button.drill-star .chip b { margin-top: 0; }
button.drill-star.on { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
button.drill-star.coach { border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--ok); }
button.drill-star:disabled { opacity: 1; cursor: default; background: var(--bg); }
button.drill-star:disabled .chip { filter: saturate(.2) brightness(.6); }
button.drill-star.on:disabled .chip, button.drill-star.coach:disabled .chip { filter: none; }
.drill-answer { margin-top: 14px; padding: 10px 12px; border-radius: var(--r-lg); background: var(--panel); border-left: 3px solid var(--bad); }
.drill-answer.ok { border-left-color: var(--ok); }
.drill-verdict { margin: 0; font-size: 15px; }
.drill-answer .coach { margin: 10px 0; }
.drill-next { width: 100%; min-height: 50px; margin-top: 4px; font-size: 16px; }
.true-rank { color: var(--accent); font-weight: 600; margin-left: 4px; white-space: nowrap; }
