/* Hearts & Spades — palette from the Board & Card Games hub (same tokens as Cribbage). */
:root {
  --bg: #0f1117;
  --bg-soft: #161923;
  --card: #1a1e2b;
  --card-hover: #212636;
  --line: #2a3042;
  --text: #e8eaf0;
  --muted: #969db4;
  --accent: #6ea8fe;
  --accent-warm: #f0b354;
  --good: #6ee7a8;
  --bad: #f08c8c;
  --felt: #17342a;
  --felt-2: #10261e;
  --felt-line: #23483b;
  --felt-text: #9cc8b6;
  --face: #f6f2e8;
  --face-line: #d4ccbb;
  --ink: #16181f;
  --red: #c0392b;
  --radius: 12px;
  --tabs-h: 60px;
  --cw: clamp(52px, calc((100vw - 20px) / 5.2), 74px);  /* hand card width (set per layout) */
  --tw: clamp(56px, min(19vw, 11.4vh), 84px);  /* trick card width: as big as the felt's middle allows */
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

/* ------------------------------------------------------------ app frame */
.app {
  height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: 1fr auto; grid-template-columns: 1fr;
}
.views { min-height: 0; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; display: none; }
.view.active { display: block; animation: viewIn .18s ease; }
@keyframes viewIn { from { opacity: 0; } to { opacity: 1; } }

.tabs {
  grid-row: 2; display: flex; background: var(--bg-soft); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .02em;
  transition: color .15s, transform .08s;
}
.tab svg { width: 22px; height: 22px; fill: currentColor; }
.tab svg[fill="none"] { fill: none; }
.tab.active { color: var(--text); }
.tab.active svg use { fill: var(--accent-warm); }
.tab:active { transform: scale(.94); }

/* ------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 16px; font-weight: 650; min-height: 40px;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover:not(:disabled) { background: var(--card-hover); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d1424; }
.btn.warm { background: var(--accent-warm); border-color: var(--accent-warm); color: #231703; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; }

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 7px; padding: 7px 6px; font-size: 13.5px; font-weight: 650; color: var(--muted);
  transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] { background: var(--card-hover); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.seg button .sub { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 14px; transition: background .18s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .18s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(18px); }

.help {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted); font-size: 11px; font-weight: 700;
  padding: 0; vertical-align: middle; margin-left: 4px; flex: none; line-height: 1;
}
.help::before { content: ""; position: absolute; inset: -11px; }  /* 40px tap area */
.help { position: relative; }

input.num, select.num {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; width: 100%;
  font-size: 16px; text-align: center; font-variant-numeric: tabular-nums; min-height: 38px;
}
input.txt { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; font-size: 16px; min-height: 38px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* -------------------------------------------------------------- the game */
.game { height: 100%; display: flex; flex-direction: column; }
.game-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.game-side { display: none; }

.bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
  min-height: 48px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.bar .title { font-weight: 750; font-size: 15px; white-space: nowrap; }
.bar .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.icon-btn { width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:active { transform: scale(.94); }
.hint-btn { display: inline-flex; align-items: center; gap: 5px; }
.hint-btn.on { background: rgba(240,179,84,.16); border-color: var(--accent-warm); color: var(--accent-warm); }
.hint-btn.thinking { opacity: 1; border-color: var(--accent-warm); animation: think 1s ease-in-out infinite alternate; }
@keyframes think { from { opacity: .45; } to { opacity: 1; } }

/* The table: one green felt (css/table.css surface) under the seats, the trick, the helpers and your hand,
   seen from your chair. Card backs everywhere match the deck's back (navy lattice in a white margin). */
.table {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  --back: #1d2a4a; --ink: rgba(217,165,49,.42); --back-frame: #f7f4ec;
  --ow: 24px;              /* opponents' held cards */
  --wc: 17px; --wstep: 3px; /* tricks won, face down */
  --pw: 24px; --pstep: 6px; /* Hearts point cards, face up */
}
.felt { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.seat { position: absolute; z-index: 2; display: flex; align-items: center; gap: 6px; }
.seat.top { top: 0; left: 50%; translate: -50% 0; flex-direction: column; gap: 3px; }
/* phone: the side players sit high enough that their plates and piles stay clear of the trick */
.seat.left { left: 0; top: 27%; translate: 0 -50%; }
.seat.right { right: 0; top: 27%; translate: 0 -50%; flex-direction: row-reverse; }
.seat.bottom { left: 8px; bottom: 6px; }
.seat-front { display: flex; align-items: center; gap: 6px; }
.seat.left .seat-front, .seat.right .seat-front { flex-direction: column; gap: 5px; }
.seat-info { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.seat.bottom .seat-info { align-items: flex-start; }
.plate.tbl-plate { display: flex; align-items: center; gap: 5px; padding: 1px 7px; font-size: 12px; transition: border-color .25s, box-shadow .25s; }
.plate .cpu svg { width: 12px; height: 12px; display: block; opacity: .8; }
.seat-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70px; }
.seat-score { font-size: 13px; font-weight: 800; color: #f3cf7a; font-variant-numeric: tabular-nums; }
.seat.turn .plate.tbl-plate { border-color: #f0c35a; box-shadow: 0 0 0 2px rgba(240,195,90,.5), 0 0 14px rgba(240,195,90,.45); }
.seat-sub { font-size: 12.5px; color: #e4efe8; white-space: nowrap; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.seat-sub .pts { color: #ffb3b3; font-weight: 700; }

/* an opponent's held cards: a fan of backs drawn for the bottom seat, then turned to face its owner */
/* (held upright, so from your chair the card tops point away from the middle of the table) */
.ofan-wrap { position: relative; flex: none; --fw: calc(var(--ow) * 5.2); --fh: calc(var(--ow) * 1.6); }
.seat.top .ofan-wrap { width: var(--fw); height: var(--fh); margin-top: calc(var(--ow) * -.3); }
.seat.left .ofan-wrap, .seat.right .ofan-wrap { width: var(--fh); height: var(--fw); }
.seat.left .ofan-wrap { margin-left: calc(var(--ow) * -.3); }
.seat.right .ofan-wrap { margin-right: calc(var(--ow) * -.3); }
.ofan { position: absolute; left: 50%; top: 50%; width: var(--fw); height: var(--fh); translate: -50% -50%; --card-w: var(--ow); }
.seat.left .ofan { rotate: -90deg; } .seat.right .ofan { rotate: 90deg; }
.ofan .ob {
  position: absolute; left: 50%; bottom: 0; margin-left: calc(var(--ow) / -2); transform-origin: 50% 160%;
  translate: calc(var(--o) * var(--ow) * .2) 0; rotate: var(--a); transition: none;
}
.ofan .ob.deal { animation: obIn .3s ease-out both; }
@keyframes obIn { from { opacity: 0; transform: translateY(calc(var(--ow) * 2.5)); } }

/* tricks won, face down and staggered so they can be counted; Hearts point cards face up beside them */
.won-area { display: flex; align-items: center; gap: 6px; }
.won { position: relative; flex: none; width: calc(var(--wc) + (var(--n) - 1) * var(--wstep)); height: calc(var(--wc) * 1.4); --card-w: var(--wc); }
.won.empty { display: none; }
.won > .tbl-card { position: absolute; top: 0; left: calc(var(--i) * var(--wstep)); box-shadow: 0 1px 1px rgba(0,0,0,.45); }
/* Spades: tricks squared crosswise on each other; the crossed cards stick out .2 card each side */
.won.cross { margin: 0 calc(var(--wc) * .22); --wstep: calc(var(--wc) * .3); }
/* Hearts pass: the 3 cards wait face down in front of whoever passed them */
.passpile { position: relative; flex: none; --card-w: calc(var(--wc) * 1.15); width: calc(var(--wc) * 1.15 + 8px); height: calc(var(--wc) * 1.15 * 1.4 + 4px); }
.passpile > .tbl-card { position: absolute; top: 0; left: calc(var(--i) * 4px); box-shadow: 0 1px 2px rgba(0,0,0,.45); }
.wpts { display: none; position: relative; flex: none; width: calc(var(--pw) + (var(--n) - 1) * var(--pstep)); height: calc(var(--pw) * 1.4); }
.wpts .wp { position: absolute; top: 0; left: calc(var(--i) * var(--pstep)); width: var(--pw); }
.wpts .wp .pc { box-shadow: 0 1px 2px rgba(0,0,0,.45); }

/* the deck in the middle while the cards go round */
.deal-deck { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 4; --card-w: calc(var(--tw) * .8); pointer-events: none; transition: opacity .25s; }
.deal-deck.gone { opacity: 0; }

/* trick area */
/* a loose cross in the true middle of the table, clear of the seat plates */
/* --tdx/--tdy: how far each card sits from the middle; side cards clear the middle two, so only
   yours and Across's overlap, and yours lies on top so both corner indexes always show */
.trick { position: absolute; left: 50%; top: var(--ty0, 60%); width: 0; height: 0; z-index: 3; --tdx: calc(var(--tw) + 10px); --tdy: calc(var(--tw) * .5); }
.trick .slot { position: absolute; width: var(--tw); transform: translate(-50%, -50%); }
.trick .slot.s0 { left: 0; top: var(--tdy); z-index: 1; }
.trick .slot.s1 { left: calc(var(--tdx) * -1); top: 0; }
.trick .slot.s2 { left: 0; top: calc(var(--tdy) * -1); }
.trick .slot.s3 { left: var(--tdx); top: 0; }
/* the squared deck waiting on the table before the first deal */
.rest-deck { position: absolute; left: 50%; top: 14px; translate: -50% 0; z-index: 1; --card-w: calc(var(--tw) * .8); pointer-events: none; }
.rest-deck > .tbl-card { display: block; rotate: -4deg; }
.deal-deck > .tbl-card { display: block; }
.trick .slot.fresh .pc { animation: fly .32s cubic-bezier(.2,.8,.25,1) both; }
.trick .slot.s0 .pc { --fx: 0px; --fy: 160px; }
.trick .slot.s1 .pc { --fx: -150px; --fy: 0px; }
.trick .slot.s2 .pc { --fx: 0px; --fy: -150px; }
.trick .slot.s3 .pc { --fx: 150px; --fy: 0px; }
@keyframes fly { from { transform: translate(var(--fx), var(--fy)) rotate(-8deg); opacity: .2; } to { transform: none; opacity: 1; } }
.trick .slot .pc { box-shadow: 0 1px 1px rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.35); }
.trick.collect .slot .pc { animation: none; transition: transform .38s ease-in, opacity .38s ease-in; transform: translate(var(--tx), var(--ty)) scale(.3) rotate(25deg); opacity: 0; }
.trick .slot.win .pc { box-shadow: 0 0 0 2px var(--accent-warm), 0 6px 14px rgba(0,0,0,.5); border-radius: 6px; }

.felt-msg {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 4; width: min(300px, calc(100% - 170px));
  text-align: center; font-size: 13px; color: var(--felt-text); pointer-events: none;
}
/* the moon warning / Spades make-it chip: the free bottom-right corner of the felt, clear of the trick */
.moon {
  position: absolute; right: 8px; bottom: 6px; z-index: 5; max-width: calc(100% - 16px);
  background: rgba(60,12,16,.88); border: 1px solid #a8434b; color: #ffd3d3; border-radius: 20px;
  padding: 4px 6px 4px 12px; font-size: 12.5px; font-weight: 650; display: flex; align-items: center; gap: 4px; white-space: nowrap;
  animation: pop .25s ease; transform-origin: 100% 100%;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* center panel on the felt (hand summary, bidding, start) */
.panel-c {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6;
  width: min(360px, calc(100% - 24px)); max-height: calc(100% - 20px); overflow: auto;
  background: rgb(15,17,23); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: panelIn .22s ease;
}
@keyframes panelIn { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; transform: translate(-50%, -50%); } }
.panel-c h3 { margin: 0 0 8px; font-size: 16px; }
.panel-c .row { display: flex; gap: 8px; align-items: center; }
.panel-c .muted { color: var(--muted); font-size: 12.5px; }
table.mini { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13.5px; }
table.mini th, table.mini td { padding: 4px 4px; text-align: right; border-bottom: 1px solid var(--line); }
table.mini th:first-child, table.mini td:first-child { text-align: left; }
table.mini th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.mini tr.me td { color: var(--text); font-weight: 700; }
.good { color: var(--good); } .bad { color: var(--bad); } .warm { color: var(--accent-warm); }

/* tracker strip */
.strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px 10px; background: var(--bg-soft);
  border-bottom: 1px solid var(--line); cursor: pointer; min-height: 46px;
}
.strip .cell { display: flex; align-items: center; gap: 6px; justify-content: center; border-radius: 8px; padding: 2px 0; }
svg.suit { width: 16px; height: 16px; flex: none; }
.strip .cell svg.suit { width: 15px; height: 15px; }
.strip .n { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; min-width: 16px; }
.strip .voids { display: flex; flex-direction: column; font-size: 10px; line-height: 1.1; color: var(--muted); }
.strip .voids b { color: var(--bad); font-weight: 700; white-space: nowrap; }
.strip .lbl { grid-column: 1 / -1; display: none; }
.suit-red { fill: #e2584b; color: #e2584b; }
.suit-black { fill: #d9dce6; color: #d9dce6; }

/* prompt row */
.prompt { display: flex; align-items: center; gap: 8px; padding: 6px 12px; min-height: 46px; }
.prompt .msg { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.25; }
.prompt .msg b { font-weight: 700; }
.prompt .msg .small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* the helpers sit on the felt, along your edge of the table */
.table .strip { background: rgba(0,0,0,.2); border-bottom: 0; border-top: 1px solid rgba(255,255,255,.05); }
.table .strip .voids { color: rgba(230,240,232,.7); }
.table .prompt .msg .small { color: rgba(232,240,234,.78); }
.table .help { background: rgba(0,0,0,.3); border-color: rgba(255,255,255,.22); color: #e6efe9; }

/* your hand: held as a fan on a gentle arc (positions from TABLE.fanLayout in js/table.js) */
.hand-wrap { padding: 0 10px 10px; position: relative; }
.hand { position: relative; height: calc(var(--cw) * 1.4 + 26px); }
.hand .hc {
  position: absolute; left: 0; bottom: 0; width: var(--cw); transform-origin: 50% 100%;
  transform: translate(var(--x, 0px), calc(var(--y, 0px) - var(--up, 0px))) rotate(var(--r, 0deg)); transition: transform .16s ease;
}
.hand .hc .pc { box-shadow: 0 1px 1px rgba(0,0,0,.3), -2px 3px 7px rgba(0,0,0,.35); }
.hand .hc.deal { animation: dealIn .42s cubic-bezier(.2,.8,.3,1) both; }
@keyframes dealIn { from { transform: translate(var(--dx, 0px), var(--dy, -120px)) rotate(90deg) scale(.7); opacity: 0; } 12% { opacity: 1; } }
.hand .hc.flip { perspective: 700px; }
.hand .hc.flip > .pc { -webkit-backface-visibility: hidden; backface-visibility: hidden; animation: flipFront .5s ease both; animation-delay: var(--fd, 0ms); }
.hand .hc.flip > .pc.flip-back { position: absolute; left: 0; top: 0; animation-name: flipBack; pointer-events: none; }
/* visibility swaps at the half-way point too, so the right face shows even where backface-visibility is ignored */
@keyframes flipFront { 0% { transform: rotateY(180deg); visibility: hidden; } 50% { visibility: hidden; } 50.1% { visibility: visible; } 100% { transform: rotateY(0deg); visibility: visible; } }
@keyframes flipBack { 0% { transform: rotateY(0deg); visibility: visible; } 50% { visibility: visible; } 50.1% { visibility: hidden; } 100% { transform: rotateY(-180deg); visibility: hidden; } }
.hand .hc.legal { cursor: pointer; }
.hand .hc.illegal .pc { filter: brightness(.68) saturate(.85); }
.hand .hc.sel { --up: 20px; }
.hand .hc.sel .pc { box-shadow: 0 0 0 2px var(--accent-warm), 0 8px 18px rgba(0,0,0,.55); }
.hand .hc.best .pc { box-shadow: 0 0 0 2px var(--good), 0 6px 14px rgba(0,0,0,.5); }
.hand .hc.new .pc::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; box-shadow: inset 0 0 0 3px #7fb2ff, 0 0 0 1px #7fb2ff; pointer-events: none; }
.hand .ev {
  position: absolute; left: 1px; top: -21px; font-size: 11px; font-weight: 800; padding: 1px 2px; letter-spacing: -.02em; border-radius: 6px; z-index: 2;
  background: #0b0d12; border: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* a playing card (SVG face) */
.pc { position: relative; width: 100%; aspect-ratio: 5 / 7; border-radius: 7%; background: var(--face); box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.pc svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: inherit; }
.pc.back { background: var(--face); }

/* score pad: the hand-over sheet and the laptop score table are paper, like the pad at a real table */
.pad {
  --text: #23211c; --muted: #6d6555; --line: rgba(60,70,110,.2); --good: #17804a; --bad: #b3261e; --accent-warm: #a35d00;
  --card: #ece3cc; --card-hover: #e3d8bc; --bg-soft: #ece3cc; --bg: #f3ecd9;
  color: var(--text); background: #f6f0df !important; border: 0 !important; border-top: 7px solid #7b2d26 !important;
  box-shadow: 0 2px 3px rgba(0,0,0,.35), 0 12px 30px rgba(0,0,0,.45) !important;
}
.pad.panel-c { border-radius: 3px 3px 6px 6px; }
/* phone: at the end of a hand the pad sits below the table instead of covering the seats */
.pad-slot { flex: none; max-height: 66%; overflow-y: auto; padding: 0 10px 10px; }
.pad-slot .panel-c { position: relative; left: auto; top: auto; transform: none; width: auto; max-width: 420px; max-height: none; margin: 0 auto; animation: padUp .22s ease; }
@keyframes padUp { from { opacity: 0; transform: translateY(10px); } }
.pad .btn.primary { color: #0d1424; }
.side-pad { margin: -2px -4px; padding: 10px 12px 8px; border-radius: 2px 2px 4px 4px; }
.side-pad h4 { color: var(--muted) !important; }
.pc.mini { width: 22px; border-radius: 3px; }

/* bid picker */
.bids { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
@media (max-width: 899px) {
  /* the opaque panel already covers the side seats on a phone; hide their stray edges */
  .felt:has(.panel-c) .seat.left, .felt:has(.panel-c) .seat.right { visibility: hidden; }
  /* the score pad at the end of a hand covers the whole middle; don't leave half-hidden name plates */
  .felt:has(.panel-c.pad) .seat.top, .felt:has(.panel-c.pad) .seat.bottom { visibility: hidden; }
  /* Hearts point cards stay face up beside each pile on a phone too, just smaller */
  .table .wpts { display: block; }
  /* a side player's plate, line and piles (point cards beside the tricks) start at the top of
     their seat, above the trick */
  .seat.left .seat-front, .seat.right .seat-front { align-self: flex-start; padding-top: 8px; }
  .felt .panel-c { padding: 12px; }
  .panel-c .dist { height: 54px; }
}
.bids button {
  min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-weight: 750; font-size: 14px; padding: 0;
  font-variant-numeric: tabular-nums; position: relative;
}
.bids button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #0d1424; }
.bids button.sugg::after { content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.dist { display: flex; align-items: flex-end; gap: 3px; height: 64px; margin: 6px 0 2px; }
.dist .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.dist .b i { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; transition: height .3s; }
.dist .b.mine i { background: var(--accent-warm); }
.dist .b span { font-size: 10px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- sheet (pop-up) */
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .18s; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 460px; max-height: 82dvh; overflow: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .22s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet h3 { margin: 0 0 8px; font-size: 17px; }
.sheet p { margin: 0 0 10px; color: #c9cede; font-size: 14px; }
.sheet .acts { display: flex; gap: 8px; justify-content: space-between; margin-top: 12px; }

/* ----------------------------------------------------- scrolling pages */
.page { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px 24px; padding-top: calc(12px + env(safe-area-inset-top)); }
.page-in { max-width: 980px; margin: 0 auto; }
.page h2 { margin: 2px 0 12px; font-size: 20px; }
.sec { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.sec h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; }
.set-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); min-height: 48px; }
.set-row:first-of-type { border-top: 0; }
.set-row .lab { flex: 1; min-width: 0; font-size: 14.5px; display: flex; align-items: center; }
.set-row .seg { flex: 0 1 250px; }
.set-row .seg button { flex: 1 1 auto; white-space: nowrap; padding: 7px 7px; }
.cols { display: grid; grid-template-columns: 1fr; gap: 12px; }
.ver { color: var(--muted); font-size: 12px; text-align: center; margin-top: 10px; }

/* start panel */
.start { max-width: 420px; margin: 0 auto; }
.start .levels { margin: 10px 0 12px; }
.start a { white-space: nowrap; text-decoration-color: rgba(110,168,254,.45); text-underline-offset: 2px; }
.start .seats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.start .seats div { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 9px; padding: 6px; text-align: center; font-size: 12px; color: var(--muted); }
.start .seats b { display: block; color: var(--text); font-size: 13px; }

/* scorekeeper */
.sk-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sk-table th, .sk-table td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); font-size: 14px; }
.sk-table th { font-size: 12px; color: var(--muted); font-weight: 650; }
.sk-table tr.tot td { font-weight: 800; font-size: 18px; border-bottom: 2px solid var(--line); }
.sk-table td.lead { color: var(--good); }
.sk-entry { display: grid; gap: 6px; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.chk { min-height: 40px; min-width: 40px; justify-content: center; }
.chk input { width: 22px; height: 22px; accent-color: var(--accent-warm); }

/* lab */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bars .r { display: grid; grid-template-columns: 74px 1fr 56px; gap: 8px; align-items: center; font-size: 13px; }
.bars .t { height: 14px; background: var(--bg); border-radius: 7px; overflow: hidden; }
.bars .t i { display: block; height: 100%; border-radius: 7px; }
.bars .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.pick { display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px; }
.pick button { padding: 0; border: 1px solid var(--line); background: var(--bg-soft); border-radius: 5px; font-size: 11px; font-weight: 700; min-height: 36px; }
.pick button[aria-pressed="true"] { background: var(--face); color: var(--ink); border-color: var(--face); }
.pick button.r[aria-pressed="true"] { color: var(--red); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: #0b0d12; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-size: 13.5px; animation: up .2s; }

/* ------------------------------------------------------------- laptop */
@media (min-width: 900px) {
  :root { --cw: clamp(76px, min(8vw, 12.5vh), 108px); --tw: clamp(70px, min(8.2vw, 13.2vh), 122px); --tabs-h: 64px; }
  body { font-size: 15.5px; }
  .app { grid-template-columns: 84px 1fr; grid-template-rows: 1fr; }
  .tabs { grid-row: 1; grid-column: 1; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 10px 0; justify-content: flex-start; gap: 4px; }
  .tab { flex: none; height: 66px; font-size: 12px; }
  .views { grid-column: 2; }
  .game { flex-direction: row; }
  .game-main { flex: 1; min-width: 0; }
  .game-side { display: flex; flex-direction: column; width: 340px; border-left: 1px solid var(--line); background: var(--bg-soft); min-height: 0; }
  .game-side .side-sec { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .game-side .side-sec.fill { flex: 1; min-height: 0; overflow-y: auto; }
  .game-side h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; }
  .trick { --tdx: calc(var(--tw) * 1.06); --tdy: calc(var(--tw) * .82); }
  .table { --ow: clamp(32px, min(3.6vw, 5.6vh), 48px); --wc: clamp(24px, min(2.5vw, 4vh), 32px); --wstep: 5px; --pw: clamp(34px, min(3.2vw, 4.8vh), 42px); --pstep: 11px; }
  .seat { gap: 10px; }
  .seat.left .seat-front, .seat.right .seat-front { gap: 8px; }
  .seat.bottom { left: 22px; bottom: 14px; }
  .seat.bottom .seat-front { gap: 12px; }
  .plate.tbl-plate { font-size: 16px; line-height: 24px; padding: 2px 11px; gap: 7px; }
  .plate .cpu svg { width: 16px; height: 16px; }
  .seat-name { max-width: 130px; } .seat-score { font-size: 18px; } .seat-sub { font-size: 15px; }
  .wpts { display: block; }
  .seat.left .won-area, .seat.right .won-area { flex-direction: column; }
  .felt .panel-c.pad { top: 56%; max-height: calc(88% - 40px); } /* the score pad sits below Across's name and pile */  .strip { display: none; }
  .prompt { padding: 10px 18px; }
  .prompt .msg { font-size: 15px; }
  .hand-wrap { padding: 6px 18px 16px; }
  .moon { right: 18px; bottom: 14px; font-size: 14px; }
  .seat.left, .seat.right { top: 44%; }
  .trick { --ty0: 57%; }
  .sheet-back { align-items: center; }
  .sheet { border-radius: 16px; max-width: 460px; }
  .page { padding: 24px 28px; }
  .cols { grid-template-columns: 1fr 1fr; }
  .panel-c { width: 380px; }
  .prompt .msg { font-size: 16px; }
  .hand .ev { font-size: 13px; padding: 2px 6px; top: -25px; }
  .sk-table th, .sk-table td { font-size: 16px; padding: 8px 6px; }
  .sk-table th { font-size: 13px; }
  .sk-table tr.tot td { font-size: 24px; }
  .sk-table input.num, .sk-table select.num { min-height: 44px; font-size: 17px; }
}
@media (min-width: 1200px) {
  .set-page { max-width: 1240px; }
  .set-page .cols { grid-template-columns: repeat(3, 1fr); align-items: start; }
}
@media (max-width: 360px) { :root { --tw: 56px; } .table { --ow: 19px; } .seat-name { max-width: 54px; } }
@media (max-height: 640px) and (max-width: 899px) { :root { --cw: 50px; --tw: 54px; } .seat.left, .seat.right { top: 24%; } .trick { --ty0: 63%; --tdy: calc(var(--tw) * .42); } }
/* very narrow phones: the Spades score line must fit beside Hint and the menu */
@media (max-width: 360px) { .bar { gap: 6px; padding-left: 8px; padding-right: 8px; } .bar .title { font-size: 14px; letter-spacing: -.01em; } }

/* ------------------------------------------------- phone held sideways */
/* Only ~390px of height: the tabs move to a rail on the left (as on a laptop), and every row is tightened
   so the table keeps its seats, the trick and your hand on one screen. */
@media (max-width: 899px) and (max-height: 500px) {
  :root { --cw: 44px; --tw: 52px; }
  .app { grid-template-columns: calc(58px + env(safe-area-inset-left)) 1fr; grid-template-rows: 1fr; }
  .tabs { grid-row: 1; grid-column: 1; flex-direction: column; justify-content: center; border-top: 0; border-right: 1px solid var(--line); padding: 0 0 0 env(safe-area-inset-left); }
  .tab { flex: 1 1 0; height: auto; max-height: 66px; font-size: 10px; }
  .tab svg { width: 20px; height: 20px; }
  .views { grid-column: 2; }
  .toast { bottom: 16px; }
  .bar { min-height: 40px; padding-top: calc(3px + env(safe-area-inset-top)); padding-bottom: 3px; }
  .bar .grow { flex-direction: row; align-items: baseline; gap: 8px; }
  .icon-btn { width: 36px; height: 34px; }
  .table { --ow: 18px; }
  .strip { min-height: 28px; padding: 2px 10px; }
  .strip .voids { flex-direction: row; gap: 4px; }
  .prompt { min-height: 36px; padding: 2px 12px; }
  .prompt .btn { min-height: 34px; padding: 5px 14px; }
  .prompt .msg .small { display: inline; margin-left: 8px; }
  .hand-wrap { padding-bottom: 4px; }
  .hand { height: calc(var(--cw) * 1.4 + 18px); }
  .seat.top { flex-direction: row; gap: 8px; }
  .seat.top .ofan-wrap { margin-top: 0; }
  .trick { top: 55%; --tdy: 24px; --tdx: calc(var(--tw) + 8px); }
  .felt .panel-c { max-height: calc(100% - 8px); padding: 8px 10px; }
  .felt .panel-c h3 { margin-bottom: 4px; }
  .panel-c .dist { height: 30px; margin: 2px 0; }
  .bids { grid-template-columns: repeat(14, 1fr); gap: 3px; }
  .bids button { min-height: 34px; font-size: 13px; }
  .moon { bottom: 4px; }
  .seat.left, .seat.right { top: 44%; }
  /* the hand-over pad sits beside the table instead of below it */
  .table.end { flex-direction: row; }
  .table.end .pad-slot { width: 290px; max-height: none; padding: 6px 8px 6px 0; }
  .table.end .pad-slot .panel-c { padding: 10px 12px; }
}

/* ---------------------------------------------------------------- online */
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.fld input, .on-row input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 16px; min-height: 42px; color: var(--text); width: 100%; }
.on-row { display: flex; gap: 8px; align-items: center; }
.on-row .btn { flex: none; min-width: 110px; }
.on-row input { text-transform: uppercase; letter-spacing: .2em; }
.on-or { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 8px; }
.lobby .on-code-big { text-align: center; font-size: 34px; font-weight: 800; letter-spacing: .22em; padding-left: .22em; font-variant-numeric: tabular-nums; }
.on-seats { display: flex; flex-direction: column; gap: 6px; }
.on-seat { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.on-seat .pos { width: 52px; flex: none; color: var(--muted); font-size: 12px; }
.on-seat .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sound & effects (js/fx.js settings rows; the table's own animations follow its switches) */
.fx-set .fx-lab { font-size: 14.5px; }
.fx-set .set-row .seg { flex: 0 1 160px; }
.fx-set .fx-vol { flex: 0 1 180px; }
.fx-set .fx-test { min-height: 36px; }
html.fx-noanim .hand .hc.deal, html.fx-noanim .trick .slot.fresh .pc, html.fx-noanim .panel-c, html.fx-noanim .moon,
html.fx-noanim .ofan .ob.deal, html.fx-noanim .hand .hc.flip > .pc { animation: none; }
html.fx-noanim .hand .hc.flip > .pc.flip-back { display: none; }
html.fx-fast .ofan .ob.deal { animation-duration: .18s; }
html.fx-fast .hand .hc.flip > .pc { animation-duration: .3s; }
html.fx-noanim .trick.collect .slot .pc { transition: none; }
html.fx-fast .hand .hc.deal { animation-duration: .21s; }
html.fx-fast .trick .slot.fresh .pc { animation-duration: .18s; }
html.fx-fast .trick.collect .slot .pc { transition-duration: .21s; }
