#bb-tool {
  --felt: #1a7a4b; --felt2: #0d4f31; --felt-line: #0a3a22; --rim: #5c3d24;
  --card-face: #faf7f0; --card-ink: #1a1a1a; --card-red: #c62828;
  --red: #d21f3c; --black: #1a1a2e;
  --pass: #1f8f4e; --dbl: #c0392b; --rdbl: #2b5fd0; --vio: #6d28d9;
  --cw: clamp(38px, 7.4vw, 58px); --ch: calc(var(--cw) * 1.42);
}
.bb-wrap { max-width: 920px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
.bb-crumb { font-size: 0.85rem; color: var(--color-muted); margin-bottom: 1rem; }
.bb-crumb a { color: var(--color-accent); text-decoration: none; }
.bb-wrap h1 { font-family: var(--font-display); font-size: clamp(1.8rem, 4.5vw, 2.6rem); font-weight: 900; color: var(--color-text); margin: 0 0 0.6rem; }
.bb-lead { color: var(--color-text); line-height: 1.7; font-size: 1.05rem; margin: 0 0 1.8rem; max-width: 70ch; }

.bb-tool { border: 1px solid var(--color-border); border-radius: 18px; background: var(--color-surface); overflow: hidden; }
.bb-tabs { display: flex; border-bottom: 1px solid var(--color-border); }
.bb-tab { flex: 1; padding: 0.9rem 1rem; background: var(--color-surface2); border: 0; border-right: 1px solid var(--color-border); font-weight: 700; font-size: 0.95rem; color: var(--color-muted); cursor: pointer; }
.bb-tab:last-child { border-right: 0; }
.bb-tab.active { background: var(--color-surface); color: var(--color-accent); box-shadow: inset 0 -3px 0 var(--color-accent); }
.bb-panel { padding: 1.4rem 1.5rem 1.7rem; }
.bb-meta { display: flex; gap: 1.3rem; flex-wrap: wrap; color: var(--color-muted); font-size: 0.9rem; margin-bottom: 1.1rem; }
.bb-meta strong { color: var(--color-text); }

/* the table */
.bb-table { display: grid; grid-template-columns: minmax(64px, 1fr) minmax(240px, 1.7fr) minmax(64px, 1fr); grid-template-areas: ". north ." "west center east" "south south south"; gap: 0.9rem; align-items: center; justify-items: center; background: radial-gradient(ellipse at 50% 38%, var(--felt), var(--felt2)); border: 10px solid var(--rim); border-radius: 26px; padding: 1.1rem 1rem 1.4rem; box-shadow: inset 0 0 46px rgba(0,0,0,0.34), 0 10px 30px rgba(0,0,0,0.18); }
@media (max-width: 640px) { .bb-table { grid-template-columns: 1fr; grid-template-areas: "north" "west" "center" "east" "south"; } }
.pos-N { grid-area: north; } .pos-W { grid-area: west; } .pos-E { grid-area: east; }
.bb-center { grid-area: center; width: 100%; display: flex; justify-content: center; }
.bb-southarea { grid-area: south; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 0.55rem; }

.bb-seat { display: inline-flex; align-items: center; gap: 0.5rem; background: rgba(0,0,0,0.26); border: 1px solid rgba(255,255,255,0.14); border-radius: 100px; padding: 0.28rem 0.7rem 0.28rem 0.3rem; color: #fff; max-width: 100%; }
.bb-seat.active { box-shadow: 0 0 0 2px #ffd23f, 0 0 16px rgba(255,210,63,0.5); }
.bb-avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; background: #2b3a72; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; color: #fff; border: 2px solid rgba(255,255,255,0.35); }
.bb-avatar.you { background: var(--vio); }
.bb-seatmeta { display: flex; flex-direction: column; line-height: 1.2; gap: 0.15rem; }
.bb-seatname { font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.bb-dl { background: #ffd23f; color: #14152e; font-size: 0.58rem; font-weight: 800; border-radius: 4px; padding: 0 3px; margin-left: 4px; }
.bb-bidchip { font-size: 0.88rem; font-weight: 800; background: var(--card-face); border-radius: 6px; padding: 0.05rem 0.4rem; align-self: flex-start; min-width: 1.6em; text-align: center; }
.bb-bidchip.empty { background: transparent; color: #ffd23f; }
.bb-bidchip .red { color: var(--card-red); } .bb-bidchip .black { color: var(--card-ink); }
.bb-bidchip .bb-call { color: var(--card-ink); }
.bb-bidchip .bb-call.pass { color: var(--pass); } .bb-bidchip .bb-call.dbl { color: var(--dbl); } .bb-bidchip .bb-call.rdbl { color: var(--rdbl); }

/* fanned hand of real cards */
.bb-fan { display: flex; justify-content: center; align-items: flex-end; min-height: var(--ch); overflow-x: auto; max-width: 100%; padding-top: 6px; }
.bb-fan .bb-pc:not(:first-child) { margin-left: calc(var(--cw) * -0.44); }
.bb-pc { width: var(--cw); height: var(--ch); flex: none; position: relative; border-radius: calc(var(--cw) * 0.12); background: var(--card-face); color: var(--card-ink); box-shadow: 0 2px 6px rgba(0,0,0,0.4); font-family: 'Segoe UI', system-ui, sans-serif; transition: transform 0.12s ease; }
.bb-pc.red { color: var(--card-red); }
.bb-fan .bb-pc:hover { transform: translateY(-12px); z-index: 3; }
.bb-pc-c { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 0.86; font-weight: 700; }
.bb-pc-c.tl { left: calc(var(--cw) * 0.08); top: calc(var(--cw) * 0.07); }
.bb-pc-c.br { right: calc(var(--cw) * 0.08); bottom: calc(var(--cw) * 0.07); transform: rotate(180deg); }
.bb-pc-r { font-size: calc(var(--cw) * 0.32); }
.bb-pc-s { font-size: calc(var(--cw) * 0.26); }
.bb-pc-mid { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: calc(var(--cw) * 0.56); }

.bb-eval { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.bb-badge { display: inline-flex; align-items: center; background: rgba(255,255,255,0.18); color: #fff; font-weight: 700; font-size: 0.82rem; padding: 0.25rem 0.7rem; border-radius: 100px; }
.bb-badge.ghost { background: rgba(255,255,255,0.08); }
.bb-badge.sm { font-size: 0.72rem; padding: 0.08rem 0.5rem; }

/* centre: bidding box, or final contract */
.bb-box { background: rgba(0,0,0,0.2); border-radius: 14px; padding: 0.7rem; width: 100%; max-width: 340px; }
.bb-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.bb-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.bb-tile { display: flex; align-items: center; justify-content: center; gap: 2px; min-height: 46px; background: var(--card-face); border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; font-weight: 800; font-size: 1rem; color: var(--card-ink); cursor: pointer; box-shadow: 0 2px 0 rgba(0,0,0,0.22); transition: transform 0.1s ease, box-shadow 0.1s ease; }
.bb-tile:not([disabled]):hover { transform: translateY(-3px); box-shadow: 0 8px 15px rgba(0,0,0,0.34); }
.bb-tile:not([disabled]):active { transform: translateY(-1px); }
.bb-tile[disabled] { opacity: 0.22; cursor: not-allowed; box-shadow: none; }
.bb-tile:focus-visible { outline: 3px solid #ffd23f; outline-offset: 2px; }
.bb-lv { font-variant-numeric: tabular-nums; }
.bb-sy { font-size: 1.14rem; line-height: 1; } .bb-sy.red { color: var(--card-red); } .bb-sy.black { color: var(--card-ink); }
.bb-nt { font-size: 0.8rem; font-weight: 800; }
.bb-tile.act { color: #fff; font-size: 0.92rem; border-color: transparent; }
.bb-tile.act.pass { background: var(--pass); } .bb-tile.act.dbl { background: var(--dbl); } .bb-tile.act.rdbl { background: var(--rdbl); }

.bb-final { text-align: center; color: #fff; padding: 1.2rem 0.5rem; }
.bb-final .bb-clabel { display: block; color: rgba(255,255,255,0.75); font-size: 0.8rem; margin-bottom: 0.2rem; }
.bb-final .bb-cbig { font-family: var(--font-display); font-size: 2.1rem; font-weight: 900; color: #fff; }
.bb-final .bb-cbig .red { color: #ff7a8a; } .bb-final .bb-cbig .black { color: #fff; }
.bb-final .bb-cmeta { color: rgba(255,255,255,0.85); font-size: 0.92rem; margin: 0.4rem 0 0; }
.bb-final .bb-passed { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; }

.bb-controls { display: flex; gap: 0.6rem; margin: 1.1rem 0 0; flex-wrap: wrap; justify-content: center; }
.bb-btn { min-height: 42px; padding: 0.6rem 1.3rem; background: var(--color-accent); color: #fff; border: 0; border-radius: 10px; font-weight: 700; font-size: 0.9rem; cursor: pointer; }
.bb-btn.ghost { background: transparent; color: var(--color-accent); border: 1px solid var(--color-border); }
.bb-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bb-btn:hover:not(:disabled) { filter: brightness(1.05); }
.bb-hintmsg { margin: 0.9rem auto 0; max-width: 520px; background: var(--color-surface2); border: 1px solid var(--color-border); border-radius: 10px; padding: 0.6rem 0.9rem; font-size: 0.92rem; color: var(--color-text); text-align: center; }
.bb-hintmsg .bb-call { font-size: 1.05rem; margin: 0 0.15rem; }
.bb-hintmsg .bb-call.bid { color: var(--color-text); }
.bb-tile.hint { outline: 3px solid #ffd23f; outline-offset: 2px; box-shadow: 0 0 18px rgba(255,210,63,0.75); }
@media (prefers-reduced-motion: no-preference) { .bb-tile.hint { animation: bb-pulse 0.9s ease-in-out 2; } }
@keyframes bb-pulse { 50% { transform: translateY(-4px); } }

/* reveal-all + bidding log */
.bb-allhands { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; margin-top: 1.1rem; }
.bb-allhands:empty { display: none; }
.bb-seatcard { background: var(--color-surface2); border: 1px solid var(--color-border); border-radius: 12px; padding: 0.7rem 0.8rem; }
.bb-seatcard.you { border-color: var(--vio); }
.bb-seathd { font-weight: 700; font-size: 0.85rem; color: var(--color-text); margin-bottom: 0.4rem; display: flex; gap: 0.45rem; align-items: center; }
.bb-seatcard .bb-badge { background: var(--vio); }
.bb-fan.mini { --cw: clamp(24px, 5vw, 34px); min-height: auto; justify-content: flex-start; }
.bb-fan.mini .bb-pc { box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

.bb-logwrap { margin-top: 1.6rem; }
.bb-h { font-family: var(--font-display); font-size: 1.05rem; font-weight: 800; color: var(--color-text); margin: 0 0 0.7rem; display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.bb-hint { font-family: system-ui, sans-serif; font-weight: 400; color: var(--color-muted); font-size: 0.82rem; }
.bb-log { overflow-x: auto; border: 1px solid var(--color-border); border-radius: 12px; }
.bb-auction { width: 100%; border-collapse: collapse; font-size: 1rem; }
.bb-auction th { font-weight: 700; font-size: 0.82rem; color: var(--color-muted); padding: 0.5rem 0.3rem; border-bottom: 2px solid var(--color-border); text-align: center; white-space: nowrap; }
.bb-auction td { padding: 0.45rem 0.3rem; text-align: center; border-bottom: 1px solid var(--color-border); min-width: 3.2em; }
.bb-auction tr:last-child td { border-bottom: 0; }
.bb-auction th.you, .bb-auction td.you { background: rgba(109,40,217,0.06); }
.bb-auction th.you { color: var(--vio); }
.bb-call { font-weight: 800; color: var(--black); }
.bb-call .red { color: var(--red); } .bb-call .black { color: var(--black); }
.bb-call.pass { color: var(--pass); font-weight: 700; }
.bb-call.dbl { color: var(--dbl); } .bb-call.rdbl { color: var(--rdbl); }

/* deal-a-hand mode */
.bb-felt { background: radial-gradient(ellipse at 50% 40%, var(--felt), var(--felt2)); border: 10px solid var(--rim); border-radius: 20px; padding: 1.2rem 1rem; box-shadow: inset 0 0 30px rgba(0,0,0,0.3); }
.bb-deal-intro { margin: 0 0 1rem; }
.bb-one-eval { margin-top: 1.1rem; justify-content: flex-start; }
.bb-one-eval .bb-badge { background: var(--vio); } .bb-one-eval .bb-badge.ghost { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.bb-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.bb-open { font-size: 1.05rem; color: var(--color-text); display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.bb-open .bb-call { font-size: 1.3rem; } .bb-open .bb-call.bid { color: var(--color-text); }
.bb-reason { color: var(--color-muted); font-size: 0.9rem; }
.bb-one-answer { margin-top: 1rem; background: var(--color-surface2); border: 1px solid var(--color-border); border-radius: 12px; padding: 0.8rem 1rem; }
.bb-one-answer .bb-open { margin: 0; }

/* supporting prose */
.bb-note { background: var(--color-surface2); border: 1px solid var(--color-border); border-radius: 12px; padding: 1rem 1.2rem; margin: 1.8rem 0; font-size: 0.9rem; color: var(--color-text); line-height: 1.6; }
.bb-note a { color: var(--color-accent); }
.bb-prose { margin-top: 2.2rem; }
.bb-prose h2 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; color: var(--color-text); margin: 0 0 0.8rem; }
.bb-prose p, .bb-prose li { color: var(--color-text); line-height: 1.8; font-size: 1rem; }
.bb-prose a { color: var(--color-accent); }
.bb-prose ol { padding-left: 1.3rem; }
.bb-faq { margin-bottom: 1.1rem; }
.bb-faq dt { font-weight: 700; color: var(--color-text); margin-bottom: 0.3rem; }
.bb-faq dd { margin: 0; color: var(--color-text); line-height: 1.7; }
.bb-related { border-top: 1px solid var(--color-border); margin-top: 2.2rem; padding-top: 1.4rem; }
.bb-related h2 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 800; color: var(--color-text); margin: 0 0 0.8rem; }
.bb-related ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.bb-related a { color: var(--color-accent); text-decoration: none; font-weight: 600; }
