/* =============================================================
   GAME: Patience B (Yukon, Scorpion, Forty Thieves, Canfield,
   Beleaguered Castle). Cards are absolutely positioned by
   patienceb.js (--cw / --ch = card size).
   ============================================================= */
.board-patienceb {
  --pb-glow: var(--glow, #b768ff);
  --pb-red: #f2335a;
  --pb-black: #1b1736;
  position: relative; width: 100%; max-width: 860px; min-height: 320px;
  isolation: isolate; /* card z-indexes stay inside the board, under the result popup */
  touch-action: manipulation; -webkit-touch-callout: none;
}
.board-patienceb .pb-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
/* felt table behind the piles (a pseudo-element, so the layout width stays the same) */
.board-patienceb::before {
  content: ""; position: absolute; inset: -8px; border-radius: 16px; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% 0%, color-mix(in srgb, var(--pb-glow) 14%, transparent), transparent 70%),
    repeating-radial-gradient(circle at 70% 30%, rgba(255, 255, 255, .02) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, color-mix(in srgb, var(--c1, #24124a) 62%, #0b0a1c), color-mix(in srgb, var(--c2, #0d0820) 82%, #07060f));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pb-glow) 24%, transparent), inset 0 0 40px rgba(0, 0, 0, .45);
}

/* ---- empty piles ---- */
.pb-slot {
  position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch);
  border-radius: calc(var(--cw) * .1); z-index: 1;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--pb-glow) 10%, transparent), rgba(0, 0, 0, .22));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--pb-glow) 38%, transparent), inset 0 2px 8px rgba(0, 0, 0, .35);
  display: grid; place-items: center; color: color-mix(in srgb, var(--pb-glow) 55%, transparent);
}
.pb-slot[role="button"] { cursor: pointer; }
.pb-ghost { width: 46%; height: 46%; fill: currentColor; opacity: .55; }
.pb-kghost { width: auto; height: auto; font: 800 calc(var(--cw) * .42) var(--font-head); }
.pb-base { display: flex; flex-direction: column; align-items: center; gap: calc(var(--cw) * .04); opacity: .7; }
.pb-brank { font: 800 calc(var(--cw) * .38) / 1 var(--font-head); }
.pb-bpip { width: calc(var(--cw) * .3); height: calc(var(--cw) * .3); fill: currentColor; }
.pb-slot-d { opacity: .6; }
.pb-slot-d .pb-ghost { width: 50%; height: 50%; }
/* stock: sits above its cards so a tap anywhere on it deals */
.pb-slot-s.pb-has { background: transparent; box-shadow: none; z-index: 400; }
.pb-slot-s .pb-redeal { display: none; }
.pb-slot-s.pb-can-redeal .pb-redeal { display: block; opacity: .9; width: 52%; height: 52%; }
.pb-slot-s.pb-off { opacity: .45; }
.pb-slot-r.pb-has { background: transparent; box-shadow: none; z-index: 300; pointer-events: none; }
.pb-count {
  position: absolute; right: -4px; bottom: -6px; min-width: 1.7em; padding: 1px 5px; border-radius: 999px;
  font: 800 .72rem / 1.35 var(--font-body); text-align: center; color: #fff; pointer-events: none;
  background: color-mix(in srgb, var(--c2, #0f0622) 70%, #000); box-shadow: 0 0 0 1.5px var(--pb-glow), 0 0 8px color-mix(in srgb, var(--pb-glow) 60%, transparent);
}
.pb-count:empty { display: none; }
.pb-slot-r .pb-count { right: auto; left: -4px; }

/* ---- cards ---- */
.pb-card {
  position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch);
  border-radius: calc(var(--cw) * .09); color: var(--pb-black);
  background: linear-gradient(160deg, #ffffff 0%, #f7f5ff 55%, #e9e5f8 100%);
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, .45), 0 3px 8px rgba(4, 2, 16, .28), inset 0 0 0 1px rgba(40, 30, 90, .2), inset 0 1px 0 #fff;
  transition: transform .2s cubic-bezier(.3, .7, .3, 1), box-shadow .2s, filter .2s;
  cursor: default; overflow: hidden; will-change: transform;
}
.pb-card[role="button"] { cursor: grab; touch-action: none; }
.pb-red { color: var(--pb-red); }
.pb-idx {
  position: absolute; left: 7%; right: 7%; top: 3.5%; display: flex; justify-content: space-between; align-items: center;
  font: 800 calc(var(--cw) * .3) / 1 var(--font-body); letter-spacing: -.03em;
}
.pb-idx b { font-weight: 800; }
.pb-ten { letter-spacing: -.1em; margin-left: -.06em; }
.pb-sm { width: calc(var(--cw) * .24); height: calc(var(--cw) * .24); fill: currentColor; flex: none; }

/* number cards: pips (roomy cards) or one large suit (compact cards on phones) */
.pb-pips { position: absolute; inset: 0; pointer-events: none; }
.pb-pip { position: absolute; width: calc(var(--cw) * .175); height: calc(var(--cw) * .175); fill: currentColor; transform: translate(-50%, -50%); }
.pb-pip.pb-inv { transform: translate(-50%, -50%) rotate(180deg); }
.pb-ace {
  position: absolute; left: 50%; top: 60%; width: calc(var(--cw) * .5); height: calc(var(--cw) * .5); fill: currentColor;
  transform: translate(-50%, -50%); filter: drop-shadow(0 1px 1px rgba(30, 20, 60, .25));
}
.pb-big { display: none; position: absolute; left: 22%; bottom: 8%; width: 56%; height: 48%; fill: currentColor; }
.pb-compact .pb-pips { display: none; }
.pb-compact .pb-big { display: block; }

/* court cards: drawn portrait in a gold frame */
.pb-art { position: absolute; left: 12%; top: 29.5%; width: 76%; height: 66%; }
.pb-compact .pb-art { left: 8%; width: 84%; top: 31%; height: 65%; }

/* face down: neon back in the game's theme colour (diamond lattice) */
.pb-card.pb-down {
  background:
    radial-gradient(ellipse at 50% 50%, color-mix(in srgb, var(--pb-glow) 32%, transparent), transparent 62%),
    repeating-linear-gradient(60deg, color-mix(in srgb, var(--pb-glow) 15%, transparent) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(-60deg, color-mix(in srgb, var(--pb-glow) 15%, transparent) 0 1px, transparent 1px 6px),
    linear-gradient(155deg, var(--c1, #3a1270), var(--c2, #0f0622));
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, .55), 0 3px 8px rgba(4, 2, 16, .3), inset 0 0 0 1px color-mix(in srgb, var(--pb-glow) 55%, transparent), inset 0 0 0 2px rgba(0, 0, 0, .3);
}
.pb-card.pb-down > * { display: none; }
.pb-card.pb-down::before {
  content: ""; position: absolute; inset: calc(var(--cw) * .07); border-radius: calc(var(--cw) * .05);
  border: 1px solid color-mix(in srgb, var(--pb-glow) 70%, transparent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--pb-glow) 45%, transparent), inset 0 0 6px color-mix(in srgb, var(--pb-glow) 30%, transparent);
}
.pb-card.pb-down::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: calc(var(--cw) * .3); height: calc(var(--cw) * .3);
  transform: translate(-50%, -50%); border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--pb-glow) 90%, #fff);
  background: radial-gradient(circle, color-mix(in srgb, var(--pb-glow) 65%, transparent) 0 24%, transparent 28%), color-mix(in srgb, var(--c2, #0f0622) 70%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--pb-glow) 70%, transparent);
}

/* states */
.pb-card:focus { outline: none; }
.pb-card:focus-visible, .pb-slot:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; z-index: 450 !important; }
.pb-card.pb-sel { box-shadow: 0 0 0 2px var(--pb-glow), 0 0 16px color-mix(in srgb, var(--pb-glow) 80%, transparent), inset 0 0 0 1px rgba(40, 30, 90, .2); }
.pb-card.pb-drag {
  transition: none; cursor: grabbing; filter: brightness(1.03);
  box-shadow: 0 18px 32px rgba(4, 2, 16, .55), 0 6px 12px rgba(4, 2, 16, .35), 0 0 0 1.5px var(--pb-glow), 0 0 18px color-mix(in srgb, var(--pb-glow) 45%, transparent);
}
@media (hover: hover) {
  .pb-card[role="button"]:hover { filter: brightness(1.04); }
  .pb-slot[role="button"]:not(.pb-has):hover { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--pb-glow) 70%, transparent), inset 0 2px 8px rgba(0, 0, 0, .35); }
  .pb-slot-s.pb-has:hover { box-shadow: 0 0 14px color-mix(in srgb, var(--pb-glow) 45%, transparent); }
}
.pb-hint { animation: pb-hint .6s ease-in-out 3 alternate; }
.pb-slot.pb-hint { box-shadow: inset 0 0 0 2px var(--t-gold), 0 0 16px var(--t-gold); }
@keyframes pb-hint { to { box-shadow: 0 0 0 2px var(--t-gold), 0 0 18px var(--t-gold); filter: brightness(1.08); } }
.pb-notrans .pb-card { transition: none !important; }
.pb-won .pb-card:not(.pb-down) { box-shadow: 0 0 0 1px color-mix(in srgb, var(--pb-glow) 60%, transparent), 0 4px 14px color-mix(in srgb, var(--pb-glow) 35%, transparent); animation: pb-shine 1.4s ease-in-out 1.3s 2 alternate; }
@keyframes pb-shine { to { filter: brightness(1.1); box-shadow: 0 0 0 1.5px var(--pb-glow), 0 0 22px color-mix(in srgb, var(--pb-glow) 70%, transparent); } }
.pb-won::before { animation: pb-glow 1.4s ease-in-out 1.3s 2 alternate; }
@keyframes pb-glow { to { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pb-glow) 60%, transparent), inset 0 0 70px color-mix(in srgb, var(--pb-glow) 30%, transparent); } }

/* status */
.pb-stat b { font-variant-numeric: tabular-nums; color: var(--ink); }
.pb-stat { color: var(--muted); }
.pb-msg { flex-basis: 100%; color: var(--t-gold); font-size: .9rem; }

@media (max-width: 600px) {
  .board-patienceb { min-height: 260px; }
  .board-patienceb::before { inset: -5px; border-radius: 12px; }
  .pb-card { box-shadow: 0 1px 1.5px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(40, 30, 90, .25); }
  .pb-card.pb-down { box-shadow: 0 1px 1.5px rgba(0, 0, 0, .55), inset 0 0 0 1px color-mix(in srgb, var(--pb-glow) 55%, transparent); }
  .pb-card.pb-down::before { box-shadow: none; }
  .pb-count { font-size: .64rem; right: -3px; bottom: -5px; }
}
.pb-compact .pb-idx { left: 6%; right: 5%; top: 2%; font-size: calc(var(--cw) * .38); }
.pb-compact .pb-sm { width: calc(var(--cw) * .3); height: calc(var(--cw) * .3); }
.pb-compact .pb-card.pb-down::after { width: calc(var(--cw) * .34); height: calc(var(--cw) * .34); border-width: 1px; }
.pb-compact .pb-kghost { font-size: calc(var(--cw) * .5); }
@media (prefers-reduced-motion: reduce) {
  .pb-card { transition: none; }
  .pb-won .pb-card, .pb-won::before, .pb-hint { animation: none; }
  .pb-card.pb-hint { box-shadow: 0 0 0 2px var(--t-gold), 0 0 18px var(--t-gold); }
}
