/* Oh Hell — browser table */

:root {
  --felt-hi: #23624a;
  --felt: #18493a;
  --felt-lo: #0d2c22;
  --ink: #f4ecdb;
  --ink-2: #c9d3c8;
  --plate-sub: #f1dfae;          /* player plates: a warm light gold instead of grey */
  --muted: #8fa597;
  --brass: #dcb46c;
  --brass-2: #b88d45;
  --panel: rgba(9, 24, 18, 0.78);
  --panel-solid: #0f241c;
  --line: rgba(244, 236, 219, 0.12);
  --line-2: rgba(244, 236, 219, 0.22);
  --good: #84d39a;
  --bad: #ef8a7c;
  --red-suit: #e0645a;
  --chip: #f4ecdb;
  --chip-ink: #13261e;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --card-w: 96px;
  --card-ar: 0.631;
  --card-r: 7px;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  --speed: 1;
  --sidebar-w: 160px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* The page runs edge to edge (viewport-fit=cover): on a notched iPhone, above all when
   launched from the home screen with a translucent status bar, these keep the bar and
   the table clear of the status bar, the notch and the home indicator.  0 elsewhere. */
:root {
  --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px);
}
body {
  background: var(--felt-lo);
  color: var(--ink);
  font: 14px/1.4 var(--ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ── top bar ─────────────────────────────────────────────────────────── */

#topbar {
  position: relative; z-index: 30;
  height: calc(52px + var(--sa-t)); display: flex; align-items: center; gap: 14px;
  padding: var(--sa-t) max(16px, var(--sa-r)) 0 max(16px, var(--sa-l));
  background: linear-gradient(#0b1f17, #0a1c15);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font: 600 19px var(--display); letter-spacing: .01em; white-space: nowrap; }
.brand-mark { color: var(--brass); font-size: 20px; }
.tb-group { display: flex; align-items: center; gap: 8px; color: var(--ink-2); white-space: nowrap; }
.tb-group .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.tb-group .v { font: 600 16px var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.tb-spacer { flex: 1; }
.tb-btn {
  background: transparent; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; color: var(--ink-2); white-space: nowrap;
}
.tb-btn:hover { background: rgba(255,255,255,.06); color: var(--ink); }
.tb-btn.icon { padding: 6px 8px; display: grid; place-items: center; }
.tb-btn.primary { border-color: var(--brass-2); color: var(--brass); }
.tb-btn.on { background: rgba(220,180,108,.14); color: var(--brass); border-color: var(--brass-2); }
.trump-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 10px 3px 4px; border-radius: 99px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
}
.trump-pill .sym { font-size: 22px; line-height: 1; width: 26px; text-align: center; }
.sym.red { color: var(--red-suit); }
/* drawn suit marks: a small white tile so ♣ ♠ read on the dark felt too */
.si {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: -0.28em;
  width: 1.3em; height: 1.3em; margin: 0 .08em; border-radius: .26em;
  background: #fbf8f1; box-shadow: 0 0 0 1px rgba(0,0,0,.18), 0 1px 2px rgba(0,0,0,.25);
}
.si svg { width: 82%; height: 82%; display: block; }
.si.big { font-size: 22px; }
.si.huge { font-size: 34px; box-shadow: none; background: transparent; }
.trump-pill.only { padding: 3px; }
.bubble .si.big { font-size: 26px; }

/* ── layout ──────────────────────────────────────────────────────────── */

#main { position: absolute; inset: calc(52px + var(--sa-t)) var(--sa-r) var(--sa-b) var(--sa-l); display: flex; overflow: hidden; }
#table {
  position: relative; flex: 1; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, var(--felt-hi) 0%, var(--felt) 55%, var(--felt-lo) 100%);
}
#table::before {           /* fine felt grain */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
#table::after {            /* the table's painted ring */
  content: ""; position: absolute; pointer-events: none;
  left: 50%; top: var(--ring-y, 42%); width: var(--ring-w, 60%); aspect-ratio: 1.9;
  transform: translate(-50%, -50%);
  border-radius: 50%; border: 1px solid rgba(220,180,108,.16);
  box-shadow: 0 0 0 10px rgba(0,0,0,.035), inset 0 0 80px rgba(0,0,0,.12);
}

#sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column;
  background: var(--panel-solid); border-left: 1px solid var(--line);
  transition: margin-right calc(.25s * var(--speed)) ease;
}
#sidebar.closed { margin-right: calc(-1 * var(--sidebar-w)); }
.tabs { display: flex; align-items: center; gap: 2px; padding: 8px 6px 0; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; padding: 7px 7px; font-size: 13px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--brass); }
.tab-close { margin-left: auto; background: none; border: 0; font-size: 22px; color: var(--muted); cursor: pointer; display: none; }
.tab-body { flex: 1; overflow: auto; padding: 8px 6px; }
#log { font-size: 11.5px; line-height: 1.35; color: var(--ink-2); }
#log .ln { padding: 3px 2px; border-bottom: 1px solid rgba(255,255,255,.04); }
#log .ln.head { color: var(--brass); font-weight: 600; padding-top: 10px; }

/* ── score sheet ─────────────────────────────────────────────────────── */

.sheet { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 11.5px; }
.sheet.dense .bt { display: none; }
.sheet.dense td { padding: 3px 1px; }
.sheet th { position: sticky; top: -8px; font-size: 11px; padding: 5px 2px !important; background: var(--panel-solid); color: var(--ink-2); font-weight: 600; padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line-2); }
.sheet th.me { color: var(--brass); }
.sheet td { padding: 3px 2px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.05); }
.sheet td.hn { color: var(--muted); text-align: left; white-space: nowrap; }
.sheet .bt { display: block; font-size: 10.5px; color: var(--muted); }
.sheet .pt { font-weight: 600; }
.sheet .made .pt { color: var(--good); }
.sheet .miss .pt { color: var(--bad); }
.sheet .solo .bt::before { content: "★ "; color: var(--brass); }
.sheet tfoot td { position: sticky; bottom: -8px; font-size: 13px !important; background: var(--panel-solid); border-top: 1px solid var(--line-2); font: 700 15px var(--display); }
.sheet tfoot td.lead { color: var(--brass); }
.sheet .x2 { color: var(--brass); font-size: 10px; }
.sheet-empty { color: var(--muted); padding: 20px 6px; text-align: center; }

/* ── cards ───────────────────────────────────────────────────────────── */

#stage { position: absolute; inset: 0; pointer-events: none; }
.card {
  position: absolute; left: 0; top: 0;
  width: var(--card-w); height: calc(var(--card-w) / var(--card-ar));
  transform-origin: 50% 50%;
  transition: transform calc(.36s * var(--speed)) cubic-bezier(.2,.75,.25,1),
              opacity calc(.3s * var(--speed)) ease;
  pointer-events: auto;
  perspective: 900px;
}
.card.still, .card.still .inner { transition: none !important; }
.card .lift { width: 100%; height: 100%; transition: transform .14s ease; }
.card .inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform calc(.42s * var(--speed)) ease;
}
.card.down .inner { transform: rotateY(180deg); }
.card .face, .card .back {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: var(--card-r);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.22);
  background: #fff;
}
.card .face { object-fit: fill; }
/* Trump tint: a translucent wash over the face; hidden
   when the card is face down, and in Settings it can be off, pale yellow or pale blue. */
.card .tint {
  position: absolute; inset: 0; border-radius: var(--card-r); pointer-events: none;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--trump-tint, transparent);
  opacity: 0; transition: opacity .25s ease;
}
.card.trump .tint { opacity: 1; }
/* Backs keep their own image's proportions (--back-ar, measured when the back is
   chosen): full card width, centred; just the image with rounded corners. */
.card .back {
  inset: auto; left: 0; top: 50%; height: auto; aspect-ratio: var(--back-ar, .64);
  transform: translateY(-50%) rotateY(180deg);
  background: transparent var(--back-img) center / 100% 100% no-repeat;
}
.card.dim .face { filter: brightness(.55) saturate(.6); }
.card.playable { cursor: pointer; }
.card.focus .lift { transform: translateY(-16%); }
/* a mouse hovering lifts a card; a finger's tap must not leave one "hovered" */
@media (hover: hover) and (pointer: fine) { .card.playable:hover .lift { transform: translateY(-16%); } }
.card.focus .face { box-shadow: 0 0 0 3px var(--brass), 0 6px 16px rgba(0,0,0,.4); }
.card.selected .lift { transform: translateY(-22%); }
.card.selected .face { box-shadow: 0 0 0 3px #7fc3ff, 0 6px 16px rgba(0,0,0,.4); }
.card.win .face { box-shadow: 0 0 0 3px var(--brass), 0 0 24px 4px rgba(220,180,108,.55); }
.card.hinted .face { animation: hintpulse 1.1s ease-in-out infinite; }
@keyframes hintpulse {
  0%,100% { box-shadow: 0 0 0 2px #9fe3b0, 0 0 8px 2px rgba(132,211,154,.4); }
  50% { box-shadow: 0 0 0 4px #9fe3b0, 0 0 22px 6px rgba(132,211,154,.7); }
}
.card .tag {
  position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%);
  font-size: 11px; color: var(--ink-2); white-space: nowrap; pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

/* ── seats ───────────────────────────────────────────────────────────── */

#seats { position: absolute; inset: 0; pointer-events: none; }
.seat {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: auto;
}
/* Bots' backs: 48 × 68 at 100 %; the lower ~third tucks behind the name plate. */
.seat .fan { position: relative; z-index: 0; height: calc(48px * var(--fan-s, 1) / var(--back-ar, .64)); margin-bottom: calc(-24px * var(--fan-s, 1)); }
.seat .plate { position: relative; z-index: 1; background: linear-gradient(var(--panel), var(--panel)), var(--felt); }
.seat .fan i {
  position: absolute; top: 0; width: calc(48px * var(--fan-s, 1)); aspect-ratio: var(--back-ar, .64);
  border-radius: calc(4px * var(--fan-s, 1));
  background: var(--back-img) center / 100% 100% no-repeat;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
  transform-origin: 50% 120%;
}
.plate {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  min-width: 210px; padding: 9px 13px 9px 9px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  transition: box-shadow .25s, border-color .25s;
}
.seat.offense .plate {                    /* declarer / picker / maker and known partners */
  background: linear-gradient(rgba(214, 176, 92, .2), rgba(214, 176, 92, .2)), linear-gradient(var(--panel), var(--panel)), var(--felt);
  border-color: rgba(220, 180, 108, .42);
}
.seat.turn .plate { border-color: var(--brass); box-shadow: 0 0 0 2px rgba(220,180,108,.35), 0 0 26px rgba(220,180,108,.25), var(--shadow); }
.avatar {
  position: relative; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 17px var(--display); color: #10251c;
  background: var(--av, #cfc2a4);
}
.avatar .dealer {
  position: absolute; right: -5px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: #10251c; font: 800 10px var(--ui);
  display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.who .name { font-weight: 650; font-size: 16.5px; white-space: nowrap; }
.who .sub { font-size: 13px; color: var(--plate-sub); white-space: nowrap; }
.who .sub .solo { color: var(--brass); font-weight: 600; }
.nums { text-align: right; }
.nums .score { font: 700 22px var(--display); font-variant-numeric: tabular-nums; }
.nums .score small { font: 600 11px var(--ui); color: var(--brass); display: block; letter-spacing: .06em; text-transform: uppercase; }
.bidline { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; grid-column: 1 / -1; font-size: 14px; color: var(--ink); min-height: 18px; }
.pips { display: inline-flex; gap: 3px; }
.pips b { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); }
.pips b.f { background: var(--good); border-color: var(--good); }
.pips b.over { background: var(--bad); border-color: var(--bad); }
.bidline .ok { color: var(--good); }
.plate .legend { color: var(--plate-sub); }    /* "To Bid", "bid 3" …: bright, not grey */
.bidline .over { color: var(--bad); }
.thinking { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.thinking i { width: 4px; height: 4px; border-radius: 50%; background: var(--brass); animation: blink 1s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,100% { opacity: .2 } 50% { opacity: 1 } }

.seat.me { transform: none; align-items: flex-start; }
.seat.compact .plate { min-width: 190px; padding: 7px 11px 7px 7px; gap: 8px; }
.seat.compact .avatar { width: 32px; height: 32px; font-size: 15px; }
.seat.me .plate { min-width: 230px; }

/* ── bubbles, banner, toast ──────────────────────────────────────────── */

#bubbles { position: absolute; inset: 0; pointer-events: none; z-index: 60; }
.bubble {
  position: absolute; transform: translate(-50%, -100%);
  padding: 6px 14px; border-radius: 14px;
  background: var(--chip); color: var(--chip-ink); font: 700 16px var(--display);
  box-shadow: var(--shadow); white-space: nowrap;
  animation: pop calc(.25s * var(--speed)) ease-out;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%) rotate(45deg);
  width: 12px; height: 12px; background: var(--chip);
}
.bubble.gold { background: var(--brass); }
.bubble.gold::after { background: var(--brass); }
.bubble.out { opacity: 0; transition: opacity .4s; }
@keyframes pop { from { transform: translate(-50%, -80%) scale(.7); opacity: 0 } }

#banner {
  position: absolute; left: 50%; top: var(--banner-y, 40%); transform: translate(-50%, -50%);
  pointer-events: none; z-index: 70; text-align: center;
  font: 600 28px var(--display); text-shadow: 0 2px 12px rgba(0,0,0,.6);
  opacity: 0; transition: opacity calc(.3s * var(--speed));
}
#banner.show { opacity: 1; }
#banner small { display: block; font: 500 14px var(--ui); color: var(--ink-2); margin-top: 4px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #3a1612; border: 1px solid #a24a3e; color: #ffd9d2;
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; z-index: 200;
  transition: all .25s;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ── action panel ────────────────────────────────────────────────────── */

#action {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: var(--action-bottom, 200px); z-index: 50;
  max-width: min(760px, calc(100% - 32px));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
}
#action > * { pointer-events: auto; }
#action:empty { display: none; }
.prompt {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 12px 16px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  animation: rise calc(.25s * var(--speed)) ease-out;
}
@keyframes rise { from { transform: translateY(10px); opacity: 0 } }
.prompt h3 { margin: 0; font: 600 18px var(--display); text-align: center; }
.prompt .sub { color: var(--ink-2); font-size: 12.5px; text-align: center; margin-top: -6px; }
.prompt.slim { flex-direction: row; padding: 8px 10px 8px 16px; gap: 14px; }
.prompt.slim h3 { font-size: 16px; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.chip {
  min-width: 44px; height: 44px; padding: 0 12px; border-radius: 22px;
  border: 0; cursor: pointer;
  background: var(--chip); color: var(--chip-ink);
  font: 700 18px var(--display); font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 0 rgba(0,0,0,.35), inset 0 -2px 0 rgba(0,0,0,.08);
  position: relative; transition: transform .1s, background .15s;
}
.chip:hover:not(:disabled) { transform: translateY(-2px); background: #fff; }
.chip:active:not(:disabled) { transform: translateY(1px); }
.chip:disabled { opacity: .3; cursor: not-allowed; text-decoration: line-through; }
.chip.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-2); box-shadow: none; font: 600 15px var(--ui); }
.chip.ghost:hover:not(:disabled) { background: rgba(255,255,255,.08); }
.chip.claims::after {
  content: "★"; position: absolute; top: -6px; right: -4px; font-size: 12px; color: var(--brass);
}
.chip.hinted { animation: chippulse 1.1s ease-in-out infinite; }
@keyframes chippulse { 50% { box-shadow: 0 0 0 4px #9fe3b0, 0 0 18px #84d39a; } }
.btn {
  height: 38px; padding: 0 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.05); color: var(--ink);
  font-weight: 600;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,.1); }
.btn.primary { background: var(--brass); color: #1c1407; border-color: var(--brass); }
.btn.primary:hover:not(:disabled) { background: #e8c27e; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { height: 30px; padding: 0 12px; font-size: 12.5px; font-weight: 500; }
.legend { font-size: 11.5px; color: var(--muted); }
.legend b { color: var(--brass); }

.suits { display: flex; gap: 10px; }
.suitbtn {
  width: 76px; height: 86px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--chip); color: #1b1b1b; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .1s;
}
.suitbtn .s { font-size: 36px; line-height: 1; }
.suitbtn.red .s { color: #c0352d; }
.suitbtn small { font-size: 11px; color: #555; }
.suitbtn:hover { transform: translateY(-3px); }
.suitbtn.hinted { animation: chippulse 1.1s infinite; }


/* ── modal ───────────────────────────────────────────────────────────── */

#modal-wrap {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center;
  background: rgba(3, 10, 7, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade calc(.2s * var(--speed));
}
@keyframes fade { from { opacity: 0 } }
#modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6); padding: 22px 24px;
  animation: rise calc(.25s * var(--speed)) ease-out;
}
#modal h2 { margin: 0 0 4px; font: 600 26px var(--display); }
#modal .lede { color: var(--ink-2); margin: 0 0 16px; }
#modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.res { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.res th { text-align: right; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.res th:first-child, .res td:first-child { text-align: left; }
.res td { text-align: right; padding: 8px; border-bottom: 1px solid rgba(255,255,255,.06); }
.res tr.me td { background: rgba(220,180,108,.06); }
.res .pts { font: 700 17px var(--display); }
.res .pos { color: var(--good); } .res .neg { color: var(--bad); }
.res .tot { font: 700 17px var(--display); }
.mark { display: inline-block; width: 18px; text-align: center; }
.mark.ok { color: var(--good); } .mark.no { color: var(--bad); }
.podium { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.podium .pl { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.04); }
.podium .pl.first { background: linear-gradient(90deg, rgba(220,180,108,.22), rgba(220,180,108,.04)); border: 1px solid rgba(220,180,108,.4); }
.podium .rk { font: 700 20px var(--display); color: var(--muted); text-align: center; }
.podium .first .rk { color: var(--brass); }
.podium .nm { font-weight: 650; font-size: 16px; }
.podium .nm small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.podium .sc { font: 700 22px var(--display); font-variant-numeric: tabular-nums; }

.set-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set-row .lab { color: var(--ink-2); }
.game-decks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; }
.game-decks .gd { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-2); }
.game-decks select { flex: 0 1 230px; min-width: 0; }
.seg { display: inline-flex; background: rgba(255,255,255,.05); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--brass); color: #1c1407; font-weight: 600; }
.backs { display: flex; flex-wrap: wrap; gap: 8px; }
.backs button { width: 44px; height: 66px; border-radius: 5px; border: 2px solid transparent; padding: 0; cursor: pointer; background: #233 center / cover; outline: 2px solid #fff; outline-offset: -4px; }
.backs button.on { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass); }
.switch { position: relative; width: 42px; height: 24px; border-radius: 12px; border: 0; background: rgba(255,255,255,.18); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--brass); }
.switch.on::after { transform: translateX(18px); }

.last-trick { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.last-trick figure { margin: 0; text-align: center; font-size: 12px; color: var(--ink-2); }
.last-trick img { width: 84px; border-radius: 6px; display: block; margin-bottom: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.last-trick figure.won img { box-shadow: 0 0 0 3px var(--brass); }
.last-trick figure.won { color: var(--brass); font-weight: 600; }

/* ── setup screen ────────────────────────────────────────────────────── */

#setup {
  position: fixed; inset: 0; z-index: 100; overflow: auto;
  background:
    radial-gradient(ellipse 80% 70% at 50% 0%, #1e5640 0%, #10342a 50%, #0a1f18 100%);
  user-select: none;
}
.setup-inner { max-width: 1060px; margin: 0 auto; padding: 44px 24px 60px; }
.setup-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.setup-head h1 { margin: 0; font: 600 54px/1 var(--display); letter-spacing: -.01em; }
.setup-head h1 span { color: var(--brass); }
.setup-head p { margin: 8px 0 0; color: var(--ink-2); font-size: 15px; }
.modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.mode {
  position: relative; text-align: left; cursor: pointer;
  padding: 14px 14px 16px; border-radius: 16px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  transition: border-color .2s, background .2s, transform .15s;
  display: flex; flex-direction: column; gap: 8px;
}
.mode:hover { background: rgba(255,255,255,.07); transform: translateY(-2px); }
.mode.on { border-color: var(--brass); background: rgba(220,180,108,.09); box-shadow: 0 0 0 1px var(--brass); }
.mode .art { position: relative; height: 128px; }
.mode .art img {
  position: absolute; bottom: 0; left: 50%; height: 112px; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.45); transform-origin: 50% 140%;
}
.mode h3 { margin: 0; font: 600 21px var(--display); }
.mode p { margin: 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.45; }
.panel {
  margin-top: 18px; padding: 6px 22px 18px; border-radius: 16px;
  background: rgba(0,0,0,.18); border: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 36px;
}
.panel h4 { grid-column: 1 / -1; margin: 14px 0 0; font: 600 13px var(--ui); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.panel .set-row { grid-template-columns: 170px 1fr; }
select {
  background: #0d241b; color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 10px; font: inherit; max-width: 100%;
}
.seat-levels { display: flex; flex-direction: column; gap: 6px; }
.seat-levels .sl { display: flex; align-items: center; gap: 10px; }
.seat-levels .sl .nm { width: 64px; color: var(--ink-2); }
.setup-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 20px; }
.setup-foot .btn.primary { height: 48px; padding: 0 34px; font-size: 17px; border-radius: 12px; }
.hint-text { color: var(--muted); font-size: 12.5px; }

/* ── narrow screens ──────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  :root { --sidebar-w: 200px; }
  #sidebar { position: absolute; right: 0; top: 0; bottom: 0; z-index: 90; box-shadow: -10px 0 30px rgba(0,0,0,.4);
             transition: transform calc(.25s * var(--speed)) ease; }
  #sidebar.closed { margin-right: 0; transform: translateX(100%); box-shadow: none; }
  .tab-close { display: block; }
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px), (max-height: 500px) {   /* phones, upright or on their side */
  #topbar { gap: 8px; padding: var(--sa-t) max(10px, var(--sa-r)) 0 max(10px, var(--sa-l)); }
  #btn-last, .brand #mode-name, #hand-info .k, #trump-box .k, #trump-box .trump-pill > span:not(.sym):not(.si) { display: none; }
  #btn-new { font-size: 0; } #btn-new::after { content: "New"; font-size: 14px; }
  .plate, .seat.compact .plate { min-width: 0; width: 96px; grid-template-columns: auto 1fr; padding: 5px 6px; gap: 2px 6px; border-radius: 10px; }
  .seat.me .plate { width: auto; min-width: 150px; grid-template-columns: auto 1fr auto; }
  .plate .who .name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; max-width: 58px; }
  .plate .nums .score { font-size: 17px; } .plate .nums .score small { display: none; }
  .bidline { font-size: 12px; gap: 1px 3px; } .bidline .pips { display: none; }
  .who .sub { display: none; }
  .avatar, .seat.compact .avatar { width: 26px; height: 26px; font-size: 13px; }
  .avatar .dealer { width: 14px; height: 14px; font-size: 8px; }
  .seat .fan { display: none; }
  .prompt.slim { padding: 6px 8px 6px 12px; gap: 8px; } .prompt.slim h3 { font-size: 14px; white-space: nowrap; } .prompt.slim .legend { display: none; }
  .prompt { padding: 10px; } .prompt h3 { font-size: 16px; }
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mode .art { height: 90px; } .mode .art img { height: 80px; }
  .panel { grid-template-columns: 1fr; padding: 4px 14px 14px; }
  .panel .set-row, .set-row { grid-template-columns: 1fr; gap: 6px; }
  .setup-head h1 { font-size: 40px; }
  .setup-inner { padding: 24px 16px 40px; }
  .chip { min-width: 38px; height: 38px; font-size: 16px; }
  .suitbtn { width: 60px; height: 70px; }
}

/* ── keyboard focus ──────────────────────────────────────────────────── */

button:focus, select:focus, input:focus { outline: none; }
body.kbd button:focus, body.kbd select:focus, body.kbd input:focus {
  outline: 2px solid var(--brass); outline-offset: 3px;
}
body.kbd .chip:focus, body.kbd .suitbtn:focus { outline-offset: 2px; transform: translateY(-2px); }
body.kbd .seg button:focus { outline-offset: -2px; }
kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 5px; text-align: center;
  font: 600 12px var(--ui); color: var(--ink); background: rgba(255,255,255,.08);
  border: 1px solid var(--line-2); border-bottom-width: 2px;
}
.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys th { text-align: left; color: var(--brass); font: 600 12px var(--ui); text-transform: uppercase; letter-spacing: .08em; padding: 12px 0 4px; }
.keys td { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.05); color: var(--ink-2); }
.keys td:first-child { width: 42%; white-space: nowrap; }

/* ── settings: card faces ────────────────────────────────────────────── */

.legend.block { display: block; margin-top: 2px; }
.decks { display: flex; flex-direction: column; gap: 6px; }
.deck {
  display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer;
  padding: 6px 10px 6px 6px; border-radius: 10px;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.04);
}
.deck:hover:not(:disabled) { background: rgba(255,255,255,.08); }
.deck.on { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); background: rgba(220,180,108,.08); }
.deck:disabled { opacity: .38; cursor: not-allowed; filter: grayscale(1); }
.deck-art { position: relative; width: 74px; height: 52px; flex: none; }
.deck-art img { position: absolute; top: 2px; height: 48px; border-radius: 3px; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.deck-art img:nth-child(1) { left: 0; transform: rotate(-8deg); }
.deck-art img:nth-child(2) { left: 18px; }
.deck-art img:nth-child(3) { left: 36px; transform: rotate(8deg); }
.deck-txt b { display: block; font-weight: 650; }
.deck-txt small { color: var(--ink-2); font-size: 12px; }
.setup-gear { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; }

/* ── framework games ─────────────────────────────────────────────────── */
.more-h { margin: 26px 0 10px; font: 600 13px var(--ui); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.modes.more { margin-bottom: 4px; }
.mode.mini .art { height: 92px; }
.mode.mini .art img { height: 84px; }
.mode.mini h3 { font-size: 18px; display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.mode.mini h3 small { font: 500 11px var(--ui); color: var(--muted); white-space: nowrap; }
.mode.mini p { font-size: 12px; }
.seat.out .plate { opacity: .45; }
.prompt .row.wrap { flex-wrap: wrap; justify-content: center; max-width: min(720px, 92vw); }
.prompt .chip kbd { font: 600 10px var(--ui); opacity: .55; margin-right: 6px; }
body:not(.kbd) .prompt .chip kbd { display: none; }
#hand-info .v.small { font-size: 13px; }
.bidline .tag { color: var(--brass); font-weight: 700; margin-right: 6px; }

/* ── the info card: trump, contract, called ace … in the felt's top-left corner ── */
#info-card {
  position: absolute; left: 12px; top: 12px; z-index: 3; width: var(--ic-w, 210px); box-sizing: border-box;
  display: grid; gap: 7px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: var(--shadow);
}
#info-card[hidden] { display: none; }
#info-card .ic-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px; min-width: 0; }
#info-card .ic-row .v { margin-left: auto; }
#info-card .ic-row.stack { flex-direction: column; align-items: flex-start; gap: 4px; }
#info-card .ic-row.stack .v { margin-left: 0; text-align: left; }
#info-card .trump-pill { padding-left: 10px; }
#info-card .trump-pill.only { padding: 3px; }
#info-card .k { font: 600 11.5px var(--ui); color: var(--brass); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
#info-card .v { font: 600 16px var(--display); color: var(--ink); text-align: right; min-width: 0; overflow-wrap: anywhere; }
#info-card .trump-pill { margin: 0; }
@media (max-width: 760px), (max-height: 500px) {   /* phones: smaller, label above value */
  #info-card { left: 6px; padding: 6px 8px; gap: 4px; border-radius: 10px; }
  #info-card .ic-row { flex-direction: column; align-items: flex-start; gap: 0; }
  #info-card .k { font-size: 9.5px; } #info-card .v { font-size: 13px; text-align: left; }
  #info-card .trump-pill { padding: 2px 6px 2px 3px; } #info-card .trump-pill > span:not(.sym):not(.si) { font-size: 12px; }
}
.prompt .chip.wide { font: 600 14px var(--ui); }

/* card-size setting: slider + number field */
.size-ctl { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.size-ctl input[type=range] { flex: 1 1 160px; min-width: 120px; accent-color: var(--brass); }
.size-ctl .num { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); }
.size-ctl input[type=number] {
  width: 64px; padding: 5px 6px; border-radius: 8px; font: inherit; text-align: right;
  background: rgba(255,255,255,.06); color: inherit; border: 1px solid var(--line);
}
.size-ctl input[type=number]:focus { outline: 2px solid var(--brass); outline-offset: 1px; }

/* ── turned card / stock in the table corner ───────────────────────── */
#corner { position: absolute; right: 18px; z-index: 2; display: flex; gap: 14px; align-items: flex-end; pointer-events: none; }
#corner[hidden] { display: none; }
.fly-back { position: absolute; z-index: 40; pointer-events: none; border-radius: var(--card-r, 6px);
  background: var(--back-img) center / 100% 100% no-repeat; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.fly-back.mine { z-index: 400; }
.fly-face { position: absolute; z-index: 400; pointer-events: none; object-fit: fill; border-radius: 6%/4%;
  box-shadow: 0 6px 16px rgba(0,0,0,.45); }
.cn-side { display: flex; flex-direction: column; align-items: stretch; gap: 8px; pointer-events: auto; margin-bottom: 30px; }
.btn.side { white-space: nowrap; font-size: 14px; padding: 8px 14px; border-radius: 12px;
  background: rgba(20,32,26,.92); border: 1px solid var(--brass-2); color: var(--ink); box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.btn.side:hover { background: rgba(220,180,108,.18); }
.btn.side.hinted { animation: chippulse 1.1s infinite; }
@media (max-width: 760px) { #corner { flex-direction: column; align-items: flex-end; gap: 8px; } .cn-side { margin-bottom: 0; } }
@media (max-width: 760px), (max-height: 500px) { .btn.side { font-size: 12.5px; padding: 6px 10px; white-space: normal; max-width: 150px; } }
.cn-item { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cn-stack { position: relative; width: calc(var(--cn-w) + var(--n) * 5px); height: calc(var(--cn-w) / var(--cn-ar) + var(--n) * 3px); }
.cn-back, .cn-face { position: absolute; right: 0; bottom: 0; width: var(--cn-w); height: calc(var(--cn-w) / var(--cn-ar)); border-radius: calc(var(--cn-w) * .06); }
.cn-back { right: calc(var(--i) * 5px); bottom: calc(var(--i) * 3px); height: auto; aspect-ratio: var(--back-ar, .64);
  background: var(--back-img) center / 100% 100% no-repeat; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.cn-face { object-fit: contain; box-shadow: 0 4px 12px rgba(0,0,0,.45); }
.cn-item figcaption { font-size: 12px; color: var(--ink-2); background: rgba(0,0,0,.28); padding: 2px 9px; border-radius: 99px; white-space: nowrap; }

/* ── bridge: auction, bidding box, results ───────────────────────────── */

#auction {
  position: absolute; z-index: 40; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--shadow);
  padding: 8px 12px 10px; width: min(330px, calc(100% - 24px));
}
#auction[hidden] { display: none; }
#auction.side { transform: none; width: min(210px, calc(50% - 210px)); }
.au-head { font: 600 12px var(--ui); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; text-align: center; margin-bottom: 4px; }
.au-scroll { max-height: 170px; overflow-y: auto; }
table.au { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.au th { font: 700 13px var(--ui); color: var(--ink-2); padding: 3px 0; border-bottom: 1px solid var(--line-2); }
table.au th.vul { color: #fff; background: rgba(224,100,90,.55); }
table.au th small { font-size: 9px; margin-left: 3px; color: var(--brass); vertical-align: super; }
table.au td { text-align: center; padding: 3px 0; font: 700 16px var(--display); cursor: pointer; border-radius: 6px; }
table.au td:hover { background: rgba(255,255,255,.07); }
table.au td.ps { color: var(--muted); font: 500 13px var(--ui); }
table.au td.next { color: var(--brass); cursor: default; animation: chippulse 1.4s infinite; }
.au-note { margin-top: 6px; font-size: 12.5px; line-height: 1.35; color: var(--ink-2); min-height: 2.7em; text-align: center; }
.au-note b, .bb-note b { color: var(--ink); margin-right: 4px; }
.au-modal { max-width: 340px; margin: 0 auto 10px; }
.au-list { font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; max-height: 40vh; overflow-y: auto; }
.trump-pill.contract { cursor: pointer; color: var(--ink); font: 600 15px var(--display); padding: 3px 12px; }
.trump-pill.contract:hover { background: rgba(255,255,255,.12); }

.prompt.bbox { gap: 8px; padding: 10px 14px 12px; }
.bbox .row { gap: 6px; flex-wrap: wrap; justify-content: center; }
.bb-foot { display: flex; align-items: center; gap: 12px; max-width: 470px; }
.bbox .chip { min-width: 42px; height: 42px; padding: 0 8px; }
.bbox .chip.on { background: var(--brass); box-shadow: 0 0 0 2px #fff3, 0 2px 0 rgba(0,0,0,.35); }
.bbox .chip.ghost.on { background: rgba(220,180,108,.25); border-color: var(--brass); }
.bbox .chip:disabled { text-decoration: none; opacity: .22; }
.bbox .bb-s { min-width: 54px; }
.bbox .bb-s .si.big { font-size: 24px; }
.bbox .bb-s.nt { font: 700 17px var(--display); }
.bbox .bb-x { min-width: 64px; }
.bbox .bb-strains .bb-x:first-of-type { margin-left: 10px; }
.bb-note { flex: 1; min-height: 2.7em; font-size: 13px; line-height: 1.35; color: var(--ink-2); }
#bb-go { min-width: 110px; flex: none; }

.boards { display: flex; gap: 6px; align-items: flex-end; justify-content: center; margin: 12px 0 4px; flex-wrap: wrap; }
.boards .bd { width: 30px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 128px; }
.boards .bd i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: var(--bad); }
.boards .bd i.up { background: var(--good); }
.boards .bd span { font-size: 11px; color: var(--ink-2); }
.boards .bd small { font-size: 10px; color: var(--muted); margin-top: 2px; border-top: 1px solid var(--line-2); width: 100%; text-align: center; }

@media (max-width: 760px), (max-height: 500px) {
  #auction { padding: 5px 8px 6px; }
  .au-scroll { max-height: 92px; }
  table.au td { font-size: 14px; padding: 1px 0; }
  .au-note { font-size: 11.5px; min-height: 0; margin-top: 3px; }
  .prompt.bbox { width: min(400px, calc(100vw - 20px)); padding: 8px; }
  .bbox .bb-levels { flex-wrap: nowrap; gap: 5px; }
  .bb-foot { flex-direction: column; gap: 6px; width: 100%; }
  .bb-note { min-height: 2.6em; text-align: center; }
  .bbox .chip { min-width: 36px; height: 36px; font-size: 15px; padding: 0 4px; }
  .bbox .bb-s { min-width: 46px; }
  .bbox .bb-x { min-width: 60px; }
  .bb-note { font-size: 12px; }
}
