/* =============================================================
   GAME: card games (Solitaire, FreeCell, Spider Solitaire)
   Cards are absolutely positioned by cards.js (--cw / --ch = card size)
   ============================================================= */
.board-cards {
  --cd-glow: var(--glow, #b768ff);
  --cd-red: #f2335a;
  --cd-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-cards .cd-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-cards::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(--cd-glow) 13%, transparent), transparent 70%),
    repeating-radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .02) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, color-mix(in srgb, var(--c1, #24124a) 60%, #0b0a1c), color-mix(in srgb, var(--c2, #0d0820) 80%, #07060f));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cd-glow) 22%, transparent), inset 0 0 40px rgba(0, 0, 0, .45);
}

/* ---- empty piles ---- */
.cd-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(--cd-glow) 10%, transparent), rgba(0, 0, 0, .22));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--cd-glow) 38%, transparent), inset 0 2px 8px rgba(0, 0, 0, .35);
  display: grid; place-items: center; color: color-mix(in srgb, var(--cd-glow) 55%, transparent);
}
.cd-slot[role="button"] { cursor: pointer; }
.cd-ghost { width: 46%; height: 46%; fill: currentColor; opacity: .55; }
.cd-kghost { width: auto; height: auto; font: 800 calc(var(--cw) * .42) var(--font-head); }
.cd-slot-s.cd-has { background: transparent; box-shadow: none; z-index: 400; }
.cd-slot-s .cd-redeal { display: none; }
.cd-slot-s.cd-can-redeal .cd-redeal { display: block; opacity: .9; width: 52%; height: 52%; }
.cd-slot-s.cd-off { opacity: .45; }
.cd-slot-d { opacity: .6; }

/* ---- cards ---- */
.cd-card {
  position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch);
  border-radius: calc(var(--cw) * .09); color: var(--cd-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;
}
.cd-card[role="button"] { cursor: grab; touch-action: none; }
.cd-red { color: var(--cd-red); }
.cd-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;
}
.cd-idx b { font-weight: 800; }
.cd-ten { letter-spacing: -.1em; margin-left: -.06em; }
.cd-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) */
.cd-pips { position: absolute; inset: 0; pointer-events: none; }
.cd-pip { position: absolute; width: calc(var(--cw) * .175); height: calc(var(--cw) * .175); fill: currentColor; transform: translate(-50%, -50%); }
.cd-pip.cd-inv { transform: translate(-50%, -50%) rotate(180deg); }
.cd-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));
}
.cd-big { display: none; position: absolute; left: 22%; bottom: 8%; width: 56%; height: 48%; fill: currentColor; }
.cd-compact .cd-pips { display: none; }
.cd-compact .cd-big { display: block; }

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

/* face down: neon back in the game's theme colour */
.cd-card.cd-down {
  background:
    radial-gradient(ellipse at 50% 50%, color-mix(in srgb, var(--cd-glow) 30%, transparent), transparent 62%),
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--cd-glow) 16%, transparent) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--cd-glow) 16%, transparent) 0 1px, transparent 1px 5px),
    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(--cd-glow) 55%, transparent), inset 0 0 0 2px rgba(0, 0, 0, .3);
}
.cd-card.cd-down > * { display: none; }
.cd-card.cd-down::before {
  content: ""; position: absolute; inset: calc(var(--cw) * .07); border-radius: calc(var(--cw) * .05);
  border: 1px solid color-mix(in srgb, var(--cd-glow) 70%, transparent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--cd-glow) 45%, transparent), inset 0 0 6px color-mix(in srgb, var(--cd-glow) 30%, transparent);
}
.cd-card.cd-down::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: calc(var(--cw) * .3); height: calc(var(--cw) * .3);
  transform: translate(-50%, -50%) rotate(45deg); border-radius: 3px;
  border: 1.5px solid color-mix(in srgb, var(--cd-glow) 90%, #fff);
  background: radial-gradient(circle, color-mix(in srgb, var(--cd-glow) 60%, transparent) 0 22%, transparent 26%), color-mix(in srgb, var(--c2, #0f0622) 70%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--cd-glow) 70%, transparent);
}

/* states */
.cd-card:focus { outline: none; }
.cd-card:focus-visible, .cd-slot:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; z-index: 450 !important; }
.cd-card.cd-sel { box-shadow: 0 0 0 2px var(--cd-glow), 0 0 16px color-mix(in srgb, var(--cd-glow) 80%, transparent), inset 0 0 0 1px rgba(40, 30, 90, .2); }
.cd-card.cd-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(--cd-glow), 0 0 18px color-mix(in srgb, var(--cd-glow) 45%, transparent);
}
.cd-hint { animation: cd-hint .6s ease-in-out 3 alternate; }
.cd-slot.cd-hint { box-shadow: inset 0 0 0 2px var(--t-gold), 0 0 16px var(--t-gold); }
@keyframes cd-hint { to { box-shadow: 0 0 0 2px var(--t-gold), 0 0 18px var(--t-gold); filter: brightness(1.08); } }
.cd-notrans .cd-card { transition: none !important; }
.cd-won .cd-card:not(.cd-down) { box-shadow: 0 0 0 1px color-mix(in srgb, var(--cd-glow) 60%, transparent), 0 4px 14px color-mix(in srgb, var(--cd-glow) 35%, transparent); animation: cd-shine 1.4s ease-in-out 1.3s 2 alternate; }
@keyframes cd-shine { to { filter: brightness(1.1); box-shadow: 0 0 0 1.5px var(--cd-glow), 0 0 22px color-mix(in srgb, var(--cd-glow) 70%, transparent); } }
.cd-won::before { animation: cd-glow 1.4s ease-in-out 1.3s 2 alternate; }
@keyframes cd-glow { to { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cd-glow) 60%, transparent), inset 0 0 70px color-mix(in srgb, var(--cd-glow) 30%, transparent); } }

/* toolbar extras */
.cd-dealform { display: inline-flex; align-items: center; gap: 6px; }
.cd-dealform input {
  width: 6.2em; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 10px;
  font: 600 .9rem var(--font-body); color: var(--ink); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.cd-dealform input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px rgba(183, 104, 255, .2); }

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

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