/* Spades: a midnight-slate felt, the card kit's cards (with copper backs), a partner and two opponents. Phone first. */
.sp-page { --cb-felt-1: #36537e; --cb-felt-2: #111a30; --cb-card-back-1: #d06a3f; --cb-card-back-2: #9a4224;
  --sp-cream: #f1f4fb; --sp-cream-2: #c3cde3; --sp-gold: #ffd166; --sp-ink: #1c2338; --sp-us: #ffd166; --sp-them: #9fc2ff; }
.sp-page [hidden] { display: none !important; }
.sp-hero { margin-bottom: 10px; }
.sp { position: relative; min-width: 0; font-family: var(--cbx-body); }
.sp button { font-family: var(--cbx-body); -webkit-tap-highlight-color: transparent; }

/* ---- lobby ---- */
.sp-lobby { border-radius: 20px; padding: 18px 16px 16px; color: var(--sp-cream); box-shadow: inset 0 0 0 3px rgba(0,0,0,.2), inset 0 0 60px rgba(0,0,0,.3), 0 14px 30px rgba(17,26,48,.28); }
.sp-faces { display: flex; gap: 8px; font-size: 34px; line-height: 1; }
.sp-faces span { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: rgba(241,244,251,.14); box-shadow: inset 0 0 0 2px rgba(241,244,251,.32); }
.sp-faces span.pa { box-shadow: inset 0 0 0 2px var(--sp-us); background: rgba(255,209,102,.16); }
.sp-lobby h2 { margin: 12px 0 2px; font: 900 28px/1.1 var(--cbx-display); color: #fff; }
.sp-lead { margin: 0 0 12px; font: 800 15px/1.4 var(--cbx-body); color: var(--sp-cream-2); }
.sp-label { margin: 12px 0 6px; font: 900 12px var(--cbx-body); letter-spacing: .12em; text-transform: uppercase; color: var(--sp-cream-2); }
.sp-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.sp-seg.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sp-seg button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 58px; padding: 8px 10px; text-align: left; border: 0; border-radius: 12px; cursor: pointer;
  background: rgba(241,244,251,.1); color: var(--sp-cream); box-shadow: inset 0 0 0 2px rgba(241,244,251,.22); }
.sp-seg button b { font: 900 16px var(--cbx-body); }
.sp-seg button small { font: 800 12px/1.25 var(--cbx-body); color: var(--sp-cream-2); }
.sp-seg button[aria-checked="true"] { background: var(--sp-cream); color: var(--sp-ink); box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.sp-seg button[aria-checked="true"] small { color: #5a6684; }
.sp-toggle { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(241,244,251,.08); cursor: pointer; }
.sp-toggle input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--sp-gold); }
.sp-toggle b { display: block; font: 900 15px var(--cbx-body); color: var(--sp-cream); }
.sp-toggle small { display: block; font: 800 12.5px/1.35 var(--cbx-body); color: var(--sp-cream-2); }
.sp-lobby .cbx-btn { margin-top: 14px; }
.sp-lobby .cbx-btn + .cbx-btn { margin-top: 10px; }
.sp-lobby .cbx-btn.alt { background: transparent; color: var(--sp-cream); box-shadow: inset 0 0 0 2px rgba(241,244,251,.5); }
.sp-stats { margin: 12px 0 0; text-align: center; font: 800 13px var(--cbx-body); color: var(--sp-cream-2); }
.sp-stats:empty { display: none; }

/* ---- top bar and team scores ---- */
.sp-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.sp-info { flex: 1; min-width: 0; text-align: center; font: 900 13px var(--cbx-body); color: var(--cbx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-chip { min-height: 38px; padding: 0 11px; border: 0; border-radius: 999px; background: var(--cbx-soft); color: var(--cbx-ink); font: 900 13px var(--cbx-body); cursor: pointer; white-space: nowrap; }
.sp-chip[aria-pressed="true"] { background: var(--cbx-accent); color: #fff; }
.sp-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.sp-team { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 6px; padding: 6px 10px; border-radius: 14px; background: #fff; box-shadow: 0 1px 0 var(--cbx-line), inset 0 0 0 2px var(--cbx-line); min-width: 0; }
.sp-team.us { box-shadow: 0 1px 0 var(--cbx-line), inset 0 0 0 2px #e9b949; background: #fffaf0; }
.sp-team .nm { font: 900 13px/1.2 var(--cbx-body); color: var(--cbx-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-team .nm small { font: 800 11.5px var(--cbx-body); color: var(--cbx-muted); }
.sp-team .sc { grid-row: span 2; font: 900 24px/1 var(--cbx-display); color: var(--cbx-ink); font-variant-numeric: tabular-nums; }
.sp-team .tk { font: 800 12px/1.3 var(--cbx-body); color: var(--cbx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-team .tk b { color: var(--cbx-ink); font-weight: 900; }
.sp-team .tk b.ok { color: var(--cbx-good); }

/* ---- the table ---- */
.sp-table { --cw: 48px; position: relative; display: grid; grid-template-columns: 66px minmax(0, 1fr) 66px; grid-template-areas: "top top top" "left trick right" "me me me" "hand hand hand";
  gap: 4px 4px; padding: 8px 8px 10px; border-radius: 20px; color: var(--sp-cream); overflow: hidden;
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.2), inset 0 0 70px rgba(0,0,0,.35), 0 14px 30px rgba(17,26,48,.28); }
.sp-seat { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; text-align: center; }
.sp-seat.top { grid-area: top; flex-direction: row; justify-content: center; gap: 10px; }
.sp-seat.left { grid-area: left; align-self: center; }
.sp-seat.right { grid-area: right; align-self: center; }
.sp-face { position: relative; width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 26px; line-height: 1;
  background: rgba(241,244,251,.14); box-shadow: inset 0 0 0 2px rgba(241,244,251,.32); transition: box-shadow .2s; }
.sp-seat.partner .sp-face { box-shadow: inset 0 0 0 2px rgba(255,209,102,.7); }
.sp-seat.now .sp-face { box-shadow: inset 0 0 0 2px var(--sp-gold), 0 0 0 3px rgba(255,209,102,.4), 0 0 16px rgba(255,209,102,.6); }
.sp-deal { position: absolute; right: -6px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--sp-ink); font: 900 11px/1 var(--cbx-body); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.sp-who { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.sp-seat.top .sp-who { align-items: flex-start; }
.sp-name { font: 900 13px/1.1 var(--cbx-body); color: #fff; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-name small { font: 800 10.5px var(--cbx-body); color: var(--sp-us); letter-spacing: .04em; }
.sp-chips { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.sp-bid { padding: 1px 7px; border-radius: 999px; background: var(--sp-cream); color: var(--sp-ink); font: 900 12px/1.5 var(--cbx-body); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-bid.wait { background: rgba(0,0,0,.25); color: rgba(241,244,251,.6); }
.sp-bid.made { background: #bff0d2; color: #0e5a31; }
.sp-bid.nil { background: #1c2338; color: #fff; box-shadow: inset 0 0 0 1.5px var(--sp-gold); }
.sp-bid.nil.bust { background: #5a2330; color: #ffd0d6; box-shadow: none; text-decoration: line-through; }
.sp-bid.pop { animation: sp-pop .35s cubic-bezier(.2,.9,.3,1.4); }
@keyframes sp-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sp-fan { --cw: 14px; display: flex; height: calc(var(--cw) * 1.4); margin-top: 2px; }
.sp-fan .cb-card { box-shadow: inset 0 0 0 1.5px #fff, 0 1px 2px rgba(0,0,0,.3); border-radius: 2px; }
.sp-fan .cb-card + .cb-card { margin-left: calc(var(--cw) * -.68); }
.sp-seat.top .sp-fan { --cw: 16px; }

/* the trick in the middle */
.sp-trick { grid-area: trick; position: relative; height: calc(var(--cw) * 1.4 * 2 + 34px); min-height: 150px; }
.sp-trick .cb-card { position: absolute; cursor: default; }
.sp-trick .t0 { left: 50%; bottom: 0; transform: translateX(-50%); }
.sp-trick .t2 { left: 50%; top: 0; transform: translateX(-50%); }
.sp-trick .t1 { left: 4%; top: 50%; transform: translateY(-50%) rotate(-6deg); }
.sp-trick .t3 { right: 4%; top: 50%; transform: translateY(-50%) rotate(6deg); }
.sp-trick .cb-card.in { animation: sp-in var(--sp-in, .28s) cubic-bezier(.2,.8,.3,1) both; }
.sp-trick .t0.in { --fx: 0px; --fy: 160px; } .sp-trick .t2.in { --fx: 0px; --fy: -140px; }
.sp-trick .t1.in { --fx: -140px; --fy: 0px; } .sp-trick .t3.in { --fx: 140px; --fy: 0px; }
@keyframes sp-in { from { translate: var(--fx) var(--fy); opacity: .2; } to { translate: 0 0; opacity: 1; } }
.sp-trick.sweep .cb-card { transition: translate var(--sp-sweep, .4s) ease-in, opacity var(--sp-sweep, .4s) ease-in; translate: var(--sx) var(--sy); opacity: 0; }
.sp-trick .win { box-shadow: 0 0 0 3px var(--sp-gold), 0 6px 14px rgba(0,0,0,.35); }
.sp-mid { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; font: 900 13px/1.35 var(--cbx-body); color: var(--sp-cream-2); width: 80%; }
.sp-mid b { display: block; font: 900 17px/1.2 var(--cbx-display); color: #fff; }
.sp-broken { position: absolute; right: 0; bottom: 0; font: 900 11px var(--cbx-body); color: #c9d8ff; opacity: .85; }

/* you */
.sp-me { grid-area: me; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 26px; }
.sp-me .sp-name { font-size: 14px; }
.sp-me.now .sp-name { color: var(--sp-gold); }
.sp-me .sp-deal { position: static; }

/* your hand: one overlapped row, or two on narrow screens (sizes set from spades.js) */
.sp-hand { grid-area: hand; --hw: 60px; --ov: -.5; display: flex; flex-direction: column; align-items: center; padding-top: 10px; min-height: calc(var(--hw) * 1.4 + 10px); }
.sp-row { display: flex; justify-content: center; }
.sp-row + .sp-row { margin-top: calc(var(--hw) * -.72); }
.sp-hand .cb-card { --w: var(--hw); }
.sp-hand .cb-card + .cb-card { margin-left: calc(var(--hw) * var(--ov)); }
.sp-hand .cb-card.ok { transform: translateY(-9%); box-shadow: 0 0 0 2px var(--sp-gold), 0 5px 10px rgba(0,0,0,.3); }
.sp-hand .cb-card.dim { filter: brightness(.68) saturate(.6); }
.sp-hand .cb-card.shake { animation: sp-shake .35s; }
@keyframes sp-shake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
.sp-hand.locked .cb-card { cursor: default; }

/* status, the bid panel and buttons under the table */
.sp-status, .cbx-card .sp-status { margin: 10px 0 0; min-height: 44px; text-align: center; font: 900 16px/1.35 var(--cbx-body); color: var(--cbx-ink); }
.sp-status small { display: block; font: 800 13px var(--cbx-body); color: var(--cbx-muted); }
.sp-status.oops { color: var(--cbx-bad); }
.sp-bidpanel { margin-top: 8px; padding: 12px; border-radius: 18px; background: #fff; box-shadow: 0 1px 0 var(--cbx-line), 0 10px 26px rgba(17,26,48,.1), inset 0 0 0 2px var(--cbx-line); }
.sp-hint { margin: 0 0 10px; font: 800 14px/1.4 var(--cbx-body); color: var(--cbx-ink-2); }
.sp-hint b { color: var(--cbx-ink); font-weight: 900; }
.sp-nums { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.sp-nums button { position: relative; min-height: 42px; padding: 0; border: 0; border-radius: 10px; background: var(--cbx-soft); color: var(--cbx-ink); font: 900 17px var(--cbx-body); cursor: pointer; font-variant-numeric: tabular-nums; }
.sp-nums button.nil { background: #1c2338; color: #fff; font-size: 14px; }
.sp-nums button.sug::after { content: ''; position: absolute; left: 50%; bottom: 4px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--cbx-accent); }
.sp-nums button[aria-checked="true"] { background: var(--cbx-accent); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--cbx-accent) 60%, #000); }
.sp-nums button.nil[aria-checked="true"] { background: #e9b949; color: #1c2338; box-shadow: 0 3px 0 #a37a1c; }
.sp-nums button[aria-checked="true"].sug::after { background: #fff; }
.sp-explain { margin: 10px 0; min-height: 38px; font: 800 13.5px/1.4 var(--cbx-body); color: var(--cbx-muted); }
.sp-explain b { color: var(--cbx-ink); }
.sp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp-actions { margin-top: 6px; display: grid; gap: 8px; }
.sp-actions:not(:has(> :not([hidden]))) { display: none; }

/* ---- dialog (scores, end of hand, game over) ---- */
.sp-dlg { border: 0; padding: 0; border-radius: 22px; width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: 0 30px 80px rgba(0,0,0,.35); color: #1c2338; background: #fbfcff; }
.sp-dlg::backdrop { background: rgba(10, 16, 32, .55); }
.sp-dlg [hidden] { display: none !important; }
.sp-dlg-card { padding: 16px 16px 18px; font-family: 'Nunito', system-ui, sans-serif; }
.sp-dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sp-dlg h2 { margin: 0; font: 900 24px/1.1 'Fraunces', Georgia, serif; }
.sp-x { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: #e8ecf6; color: #1c2338; font: 400 28px/1 Georgia, serif; cursor: pointer; }
.sp-dlg p { margin: 0 0 10px; font: 800 15px/1.45 'Nunito', sans-serif; color: #5f6a85; }
.sp-dlg p.sp-big { color: #1c2338; font-weight: 900; }
.sp-note { margin: 0 0 10px; padding: 9px 12px; border-radius: 12px; background: #1c2338; color: #fff; font: 900 14.5px/1.4 'Nunito', sans-serif; }
.sp-note.bad { background: #fde3df; color: #8f241d; }
.sp-sheet { width: 100%; border-collapse: collapse; margin: 4px 0 12px; font: 800 14px 'Nunito', sans-serif; font-variant-numeric: tabular-nums; }
.sp-sheet th { padding: 6px 4px; font: 900 13px 'Nunito', sans-serif; color: #1c2338; text-align: center; }
.sp-sheet th span { display: block; font-size: 18px; line-height: 1.1; letter-spacing: 2px; }
.sp-sheet th.us { color: #9a6b00; }
.sp-sheet td { padding: 5px 4px; text-align: center; border-top: 1px solid #e3e8f2; color: #3a4460; }
.sp-sheet td:first-child, .sp-sheet th:first-child { text-align: left; color: #5f6a85; font-size: 12.5px; white-space: nowrap; }
.sp-sheet td small { display: block; font: 800 11px 'Nunito', sans-serif; color: #8a93ab; }
.sp-sheet td.good { color: #1f9d57; }
.sp-sheet td.bad { color: #c8372f; }
.sp-sheet tr.now td { background: #fff7e6; color: #1c2338; }
.sp-sheet tr.total td { border-top: 2px solid #1c2338; font: 900 17px 'Nunito', sans-serif; color: #1c2338; }
.sp-sheet td.lead { color: #1f9d57; }
.sp-sheet-wrap { max-height: 46dvh; overflow-y: auto; }
.sp-over { text-align: center; }
.sp-over .crest { font-size: 48px; line-height: 1; margin-top: 2px; }
.sp-over h3 { margin: 6px 0 4px; font: 900 28px/1.1 'Fraunces', Georgia, serif; color: #1c2338; }
.sp-final { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 14px; }
.sp-final div { padding: 10px 8px; border-radius: 14px; background: #eef1f8; font: 900 14px 'Nunito', sans-serif; color: #1c2338; }
.sp-final div.win { background: #fff7e6; box-shadow: inset 0 0 0 2px #e9b949; }
.sp-final b { display: block; font: 900 30px/1.1 'Fraunces', Georgia, serif; }
.sp-final span { display: block; font-size: 20px; letter-spacing: 2px; }
.sp-dlg .cbx-btn + .cbx-btn { margin-top: 8px; }

@media (min-width: 560px) {
  .sp-table { --cw: 58px; grid-template-columns: 92px minmax(0, 1fr) 92px; padding: 12px 12px 14px; }
  .sp-face { width: 52px; height: 52px; font-size: 30px; }
  .sp-name { font-size: 14px; }
  .sp-fan { --cw: 16px; }
  .sp-seat.top .sp-fan { --cw: 18px; }
  .sp-team { padding: 8px 14px; }
  .sp-team .nm { font-size: 14px; }
  .sp-team .tk { font-size: 13px; }
  .sp-nums button { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  .sp-trick .cb-card.in, .sp-hand .cb-card.shake, .sp-bid.pop { animation: none; }
  .sp-trick.sweep .cb-card { transition: opacity .2s; translate: 0 0; }
}
@media (max-width: 420px) {
  .sp-team { padding: 6px 9px; }
  .sp-team .nm small { display: none; }
  .sp-team .sc { font-size: 21px; }
  .sp-team .tk { white-space: normal; }
}
