/* Pişti — card table, cards, hand result. The table is sized once in JS (px); everything inside is absolutely placed,
 * so nothing here can move or resize it. The card art (faces, back, colours, dark tones) is the site's shared deck,
 * assets/css/cards.css; the felt comes in two tones. Theme tokens for everything that is site UI. */
.ps-root { width: 100%; display: flex; justify-content: center; }
.ps-table {
  --ps-edge: rgba(30, 38, 54, .22);
  --ps-felt1: #2f8f66; --ps-felt2: #1f6c4b; --ps-felt3: #185a3e;
  position: relative; flex: none; border-radius: 22px; overflow: hidden; contain: layout paint; isolation: isolate;
  background: radial-gradient(120% 92% at 50% 44%, var(--ps-felt1), var(--ps-felt2) 64%, var(--ps-felt3));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .07), inset 0 0 0 8px rgba(0, 0, 0, .13), 0 5px 0 var(--line-2), var(--shadow);
  color: #fff; touch-action: manipulation; -webkit-tap-highlight-color: transparent; font-variant-numeric: tabular-nums;
}
:root[data-theme="dark"] .ps-table { --ps-felt1: #23714f; --ps-felt2: #17533a; --ps-felt3: #11432f; --ps-edge: rgba(0, 0, 0, .4); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ps-table { --ps-felt1: #23714f; --ps-felt2: #17533a; --ps-felt3: #11432f; --ps-edge: rgba(0, 0, 0, .4); } }
.ps-table::before { content: ""; position: absolute; inset: 9px; border-radius: 16px; border: 1.5px dashed rgba(255, 255, 255, .13); pointer-events: none; }
.ps-layer { position: absolute; inset: 0; pointer-events: none; }
.ps-handz { pointer-events: none; }
.ps-fx { z-index: 20; }

/* cards */
.ps-card { position: absolute; display: block; margin: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; border-radius: calc(var(--cw) * .09);
  transform-style: preserve-3d; transform-origin: 50% 60%; }
.ps-card.sm { border-radius: calc(var(--cw) * .06); }
.ps-f, .ps-b { position: absolute; inset: 0; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.ps-f { box-shadow: inset 0 0 0 1px var(--cd-edge), 0 1px 0 var(--ps-edge), 0 3px 8px rgba(0, 0, 0, .22); background: var(--cd-face); }
.ps-f > .cd, .ps-b > .cd { position: absolute; inset: 0; }
.ps-b { transform: rotateY(180deg); }
.ps-card.down .ps-b { transform: none; }
.ps-b { box-shadow: 0 1px 0 var(--ps-edge), 0 3px 8px rgba(0, 0, 0, .22); }
.ps-card.sm .ps-b { box-shadow: 0 1px 0 var(--ps-edge), 0 2px 5px rgba(0, 0, 0, .2); }
.ps-wait { visibility: hidden; }

/* empty places */
.ps-slot { position: absolute; border-radius: calc(var(--cw) * .09); border: 2px dashed rgba(255, 255, 255, .28); }
.ps-slot.pile { border-color: rgba(255, 255, 255, .2); }

/* counters */
.ps-badge { position: absolute; z-index: 6; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; box-sizing: border-box;
  font-weight: 800; font-size: 12px; line-height: 1; color: var(--ink); background: var(--surface); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); pointer-events: none; }
.ps-cap { position: absolute; }
.ps-cap .ps-card.c2 { transform: translate(3px, -3px) rotate(4deg); }
.ps-cap.none::after { content: ""; position: absolute; inset: 0; border-radius: calc(var(--cw) * .06); border: 1.5px dashed rgba(255, 255, 255, .25); }
.ps-cap .ps-cb { left: 50%; bottom: -9px; transform: translateX(-50%); }
/* whose stack: the same colour dot as the player's row in the score box */
.ps-cap .ps-cdot { position: absolute; z-index: 6; top: -4px; left: -4px; width: 11px; height: 11px; box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(0, 0, 0, .3); }
.ps-pk { position: absolute; z-index: 6; top: -8px; right: -10px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; font-size: 11px; color: #3b2a00; background: #ffc531; box-shadow: 0 2px 0 #b8860b; }

/* score + hand number */
.ps-score { position: absolute; z-index: 4; }
.ps-sbtn { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 4px 8px; margin: 0; box-sizing: border-box;
  border: 0; border-radius: 12px; background: rgba(0, 0, 0, .2); color: #fff; font: inherit; text-align: left; cursor: pointer; }
.ps-sbtn:disabled { cursor: default; }
.ps-sbtn:not(:disabled):hover { background: rgba(0, 0, 0, .28); }
.ps-sbtn:focus-visible { outline: 3px solid #ffc531; outline-offset: 2px; }
.ps-srow { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12.5px; line-height: 1.15; opacity: .82; }
.ps-srow.on { opacity: 1; }
.ps-srow .ps-sn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ps-srow b { font-size: 15px; font-weight: 800; min-width: 3ch; text-align: right; }
.ps-chip { flex: none; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
.ps-info { position: absolute; z-index: 4; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; gap: 1px; text-align: right; font-size: 12px; line-height: 1.2;
  color: rgba(255, 255, 255, .85); white-space: nowrap; overflow: hidden; }
.ps-info b { font-size: 13px; color: #fff; }
.ps-wide .ps-info { align-items: flex-start; text-align: left; padding-left: 8px; }

/* game length (before the first card): an overlay on the top row, nothing under it moves */
.ps-tg { position: absolute; z-index: 25; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; align-content: center; box-sizing: border-box;
  padding: 0 8px; border-radius: 12px; background: rgba(8, 30, 20, .78); box-shadow: 0 0 0 2px rgba(255, 197, 49, .55); color: #fff; }
.ps-tg[hidden] { display: none; }
.ps-tgl { font-size: 13px; font-weight: 700; white-space: nowrap; }
.ps-tgr { display: flex; gap: 6px; }
.ps-tgb { min-width: 50px; height: 44px; padding: 0 8px; margin: 0; border: 0; border-radius: 10px; font: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
  color: #fff; background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .35); }
.ps-tgb:hover:not(:disabled) { background: rgba(255, 255, 255, .24); }
.ps-tgb.on { color: #3b2a00; background: #ffc531; box-shadow: 0 3px 0 #b8860b; }
.ps-tgb:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.ps-tgb:disabled { opacity: .6; cursor: default; }
.ps-wide .ps-tg { flex-direction: column; gap: 4px; }

/* whose turn */
.ps-oh.turn .ps-card .ps-b, .ps-oh.turn .ps-card.down .ps-b { box-shadow: inset 0 0 0 calc(var(--cw) * .03) #fff, 0 0 0 2px #ffc531, 0 2px 6px rgba(0, 0, 0, .25); }

/* my hand */
.ps-hc { pointer-events: auto; cursor: default; transition: transform .16s cubic-bezier(.3, .7, .3, 1), filter .2s; outline: none; }
.ps-hc .ps-f { transition: box-shadow .2s; }
.ps-handz.turn .ps-hc.can { cursor: pointer; }
.ps-handz.turn .ps-hc.can .ps-f { box-shadow: 0 0 0 2.5px #ffc531, 0 4px 0 rgba(0, 0, 0, .18), 0 6px 14px rgba(0, 0, 0, .25); }
.ps-handz:not(.turn) .ps-hc { filter: saturate(.85) brightness(.94); }
@media (hover: hover) { .ps-handz.turn .ps-hc.can:hover { transform: translateY(calc(var(--ch) * -.08)); } }
.ps-hc.can:focus-visible { transform: translateY(calc(var(--ch) * -.08)); }
.ps-hc:focus-visible .ps-f { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--blue), 0 6px 14px rgba(0, 0, 0, .25) !important; }
.ps-hc.up { transform: translateY(calc(var(--ch) * -.1)); }
.ps-hc.tk::after, .ps-hc.pis::after { content: ""; position: absolute; z-index: 2; top: calc(var(--ch) * -.07); left: 50%; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  background: #7ee2a8; box-shadow: 0 0 0 2px rgba(0, 0, 0, .25); }
.ps-hc.pis::after { width: 14px; height: 14px; margin-left: -7px; background: #ffc531; box-shadow: 0 0 0 2px #b8860b, 0 0 10px #ffc531; }

/* pişti banner (FX.banner inside the table) */
.ps-table .fx-banner.ps-bn { top: 44%; font-size: clamp(22px, calc(var(--cw) * .42), 40px); padding: 10px 20px 12px; background: #ffc531; color: #3b2a00; box-shadow: 0 5px 0 #b8860b, var(--shadow-lg); }
.ps-table .fx-banner.ps-bn small { display: block; font-size: 15px; margin-top: 2px; }

/* hand result (overlay inside the table: nothing moves) */
.ps-sum { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 8px; background: rgba(10, 22, 16, .55); box-sizing: border-box; }
.ps-sumbox { width: min(100%, 340px); max-height: 100%; overflow: auto; box-sizing: border-box; padding: 10px 12px; border-radius: 16px; color: var(--ink); background: var(--surface);
  box-shadow: 0 5px 0 var(--line-2), var(--shadow-lg); text-align: center; }
.ps-sumbox h3 { margin: 0 0 4px; font-size: 15px; line-height: 1.25; }
.ps-st { width: 100%; border-collapse: collapse; font-size: 12.5px; line-height: 1.3; }
.ps-st th, .ps-st td { padding: 2px 6px; }
.ps-st thead th { font-size: 12px; color: var(--ink-2); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-st tbody th, .ps-st tfoot th { text-align: left; font-weight: 600; color: var(--ink-2); }
.ps-st td { text-align: right; font-weight: 700; width: 64px; }
.ps-st tbody tr:nth-child(odd) { background: var(--surface-2); }
.ps-st tfoot .tot td, .ps-st tfoot .tot th { border-top: 2px solid var(--line); color: var(--ink); font-weight: 800; }
.ps-st tfoot .gs td { color: var(--brand); font-size: 14px; font-weight: 800; }
.ps-note { margin: 4px 0 0; font-size: 11.5px; line-height: 1.3; color: var(--ink-2); }
.ps-go { margin-top: 8px; min-width: 140px; min-height: 44px; }
.ps-wide .ps-sumbox { width: min(100%, 540px); padding: 6px 10px; display: grid; grid-template-columns: 1fr minmax(130px, 36%); column-gap: 14px; align-items: center; }
.ps-wide .ps-sumbox h3, .ps-wide .ps-st { grid-column: 1; }
.ps-wide .ps-sside { grid-column: 2; grid-row: 1 / span 2; }
.ps-wide .ps-note { margin-top: 2px; }
.ps-wide .ps-st th, .ps-wide .ps-st td { padding: 0 6px; line-height: 1.2; }
.ps-wide .ps-sumbox h3 { font-size: 13.5px; margin-bottom: 1px; }

/* small tables: the hand result stays inside the table without scrolling; narrow score panel: colour chips + points */
.ps-compact .ps-sumbox { padding: 7px 10px; }
.ps-compact .ps-sumbox h3 { font-size: 13.5px; margin-bottom: 2px; }
.ps-compact .ps-st { font-size: 11.5px; }
.ps-compact .ps-st th, .ps-compact .ps-st td { padding: 0 6px; line-height: 1.32; }
.ps-compact .ps-st thead th { font-size: 11px; }
.ps-compact .ps-note { font-size: 11px; margin-top: 2px; }
/* wave16 fix: if the result still does not fit (phone held sideways), the list scrolls and the "Next hand" button stays
   pinned at the bottom edge of the box instead of being cut in half */
.ps-compact .ps-st th, .ps-compact .ps-st td { line-height: 1.22; }
.ps-sumbox .ps-go { position: sticky; bottom: 0; z-index: 1; }
.ps-compact .ps-go { margin-top: 5px; min-height: 40px; }
.ps-compact .ps-note.tl { display: none; }
.ps-narrow .ps-sn { display: none; }
.ps-narrow .ps-srow { justify-content: space-between; }
.ps-narrow .ps-sbtn { padding: 4px 8px; }

.ps-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* the room around the table: one-line status, the opponent-away line laid over the board instead of above it */
.status-line:has(+ #board .ps-root) { height: 22px; min-height: 22px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; line-height: 22px; }
.stage:has(#board .ps-root) { position: relative; }
/* (wave16 fix: app.js placeClaim sets the line's left / top / width inline over the opponent's bar; the old centring
   transform here moved it half its width off to the left) */
.stage:has(#board .ps-root) #claimLine { position: absolute; z-index: 35; transform: none; max-width: calc(100% - 24px);
  padding: 8px 12px; border-radius: 12px; background: var(--surface); box-shadow: 0 4px 0 var(--line-2), var(--shadow); }

/* Phone landscape (pisti.js: data-short): like Battleship, the two player bars become compact chips on the status row
   (opponent left, you right) and the table fills the rest of the window under the top bar. The row is 32 px tall
   (pisti.js counts it). */
#boardPanel:has(.ps-root[data-short="1"]) { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(0, 1.5fr) minmax(130px, 1fr);   /* wave18: fixed shares (the status line has contain: inline-size, so max-content was 0 px) */ align-items: center; align-content: start; column-gap: 10px; row-gap: 8px; min-height: 0; }
#boardPanel:has(.ps-root[data-short="1"]) > #pTopRow { display: contents; }
#boardPanel:has(.ps-root[data-short="1"]) #pTop { grid-row: 1; grid-column: 1; }
#boardPanel:has(.ps-root[data-short="1"]) > #status { grid-row: 1; grid-column: 2; display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 22px; }
#boardPanel:has(.ps-root[data-short="1"]) > #pBottom { grid-row: 1; grid-column: 3; }
#boardPanel:has(.ps-root[data-short="1"]) > #board { grid-column: 1 / -1; }
#boardPanel:has(.ps-root[data-short="1"]) .pbar { width: auto; min-width: 0; min-height: 0; height: 32px; padding: 2px 10px 2px 3px; gap: 7px; border-radius: 10px; }
#boardPanel:has(.ps-root[data-short="1"]) .pbar .avatar { width: 26px; height: 26px; border-radius: 8px; font-size: 13px; box-shadow: none; }
#boardPanel:has(.ps-root[data-short="1"]) .pbar .pn b { font-size: 13px; gap: 5px; }
#boardPanel:has(.ps-root[data-short="1"]) .pbar .pn b em, #boardPanel:has(.ps-root[data-short="1"]) .pbar .pn small { display: none; }
#boardPanel:has(.ps-root[data-short="1"]) .pbar .psc { font-size: 17px; min-width: 14px; }
#boardPanel:has(.ps-root[data-short="1"]) .pbar .ptag { font-size: 0; gap: 0; }
#boardPanel:has(.ps-root[data-short="1"]) .pbar .ptag:not(.think)::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
#boardPanel:has(.ps-root[data-short="1"]) .pbar .ptag .typing { gap: 3px; }
#boardPanel:has(.ps-root[data-short="1"]) .pbar .ptag .typing i { width: 5px; height: 5px; }
#boardPanel:has(.ps-root[data-short="1"]) .chat-bub { padding: 5px 9px 5px 10px; font-size: 12.5px; }
#boardPanel:has(.ps-root[data-short="1"]) .chat-bub span { -webkit-line-clamp: 1; }
#boardPanel:has(.ps-root[data-short="1"]) #claimLine { top: 46px; }
/* the chips have no room for a label: their number (games won) would read as the points shown on the table */
#boardPanel:has(.ps-root[data-short="1"]) .pbar .psc { display: none; }
/* site toasts go to the top in phone landscape, so they never cover the hand: just under the sticky top bar, where the
   chat bar sits in rooms (wave16: was top 8px, over the chat bar) */
body:has(.ps-root[data-short="1"]) .toast { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 64px); }

@media (prefers-reduced-motion: reduce) { .ps-hc { transition: none; } }
/* wave18: the game-length picker over the top row (portrait tables): label and the three buttons stay on one row
   (at 320 px they wrapped by 2 px and the label hung above the table edge, over the score strip) */
.ps-tall .ps-tg { flex-wrap: nowrap; gap: 6px; padding: 0 6px; }
.ps-tall .ps-tgr { gap: 5px; }
.ps-tall .ps-tgb { min-width: 46px; padding: 0 6px; }
/* the score strip under the picker no longer shows through it */
.ps-tg { background: rgba(8, 30, 20, .95); }
/* rooms: the phone chat-bar rule (chat.css) makes player bars 52 px tall; the chips on the status row stay 32 px
   (pisti.js counts 32 px for that row when it sizes the table) */
body.in-room #boardPanel.ps-panel:has(> #board .ps-root[data-short="1"]) .pbar { min-height: 0; height: 32px; padding-top: 2px; padding-bottom: 2px; }
/* small phones held sideways (568x320, 640x360): the chips take the larger shares (names were cut after 4-5 letters)
   and the status line may use two lines of the 32 px row, as on Mangala; fixed shares and height, nothing moves */
@media (max-width: 640px) {
  #boardPanel:has(.ps-root[data-short="1"]) { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.3fr); column-gap: 8px; }
  #boardPanel:has(.ps-root[data-short="1"]) > #status { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; height: 30px; min-height: 0; line-height: 15px; font-size: 12.5px; text-align: center; text-overflow: clip; }
  #boardPanel:has(.ps-root[data-short="1"]) .pbar { gap: 6px; padding-right: 8px; }
  #boardPanel:has(.ps-root[data-short="1"]) .pbar .ptag .typing i { width: 4px; height: 4px; }
}

/* wave19 room shell (room.css, BO_FIT_GAMES): pisti.js lays the table out once from the room the shell gives the board:
   the probe below reads that room from CSS (height: --rs-bh, svh-based; width in landscape: beside the column of player
   bars), then #board takes the table's own width (tall or wide layout, cards up to 170 px on big screens). */
#boardPanel.rs-fit > .ps-probe { position: absolute; left: 0; top: 0; width: 0; height: var(--rs-bh, 420px); visibility: hidden; pointer-events: none; }
@media (orientation: landscape) { #boardPanel.rs-fit > .ps-probe { width: calc(100cqw - var(--rs-col, 196px) - 14px); } }
body.in-room #boardPanel.rs-fit > #board:has(> .ps-root) { width: auto; max-width: 100%; }
