/* Card visuals shared by Klondike, FreeCell, and Hearts.
   Owns the --card-* CSS variables and their responsive scaling. */

:root {
  --card-w: 80px;
  --card-h: 112px;
  --tableau-offset: 25px;
  --pile-gap: 10px;
  --board-pad: 24px;
  --rank-size: 15px;
  --suit-corner-size: 14px;
  --center-size: 34px;
  --corner-pad: 6px;
  --top-row-mb: 32px;
}

.topbar .seed {
  font-size: 13px;
  opacity: 0.9;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.topbar .seed #seed-value {
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Board container — sized so the top row's `space-between` aligns the
   right-most piles with the right edge of the tableau. */
.board {
  padding: var(--board-pad);
  max-width: calc(7 * var(--card-w) + 6 * var(--pile-gap) + 2 * var(--board-pad));
  margin: 0 auto;
}

.top-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--top-row-mb);
}

.foundations,
.stockwaste,
.tableau,
.freecells {
  display: flex;
  gap: var(--pile-gap);
}

.pile {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  border: 2px dashed rgba(255, 255, 255, 0.22);
  position: relative;
  flex-shrink: 0;
}

.tableau-pile {
  min-height: var(--card-h);
  height: calc(var(--card-h) + var(--count, 0) * var(--tableau-offset));
}

.foundation::after,
.freecell::after {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--card-h) * 0.3);
  color: rgba(255, 255, 255, 0.18);
  pointer-events: none;
}
.foundation::after { content: '♢'; }
.freecell::after  { content: '○'; }

/* === Card === */

.card {
  position: absolute;
  left: 0;
  top: calc(var(--idx, 0) * var(--tableau-offset));
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  background: white;
  color: #222;
  font-family: 'Georgia', 'Times New Roman', serif;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  border: 1px solid #888;
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.35);
}

.card.red { color: #c62828; }

.card.face-down {
  background:
    repeating-linear-gradient(45deg, #1e3a8a 0, #1e3a8a 6px, #2563eb 6px, #2563eb 12px);
  border: 1px solid #1e3a8a;
}
.card.face-down .corner,
.card.face-down .center { display: none; }

.card .corner {
  position: absolute;
  font-weight: bold;
  line-height: 1;
  text-align: center;
}
.card .corner.top    { top: var(--corner-pad);    left: var(--corner-pad); }
.card .corner.bottom { bottom: var(--corner-pad); right: var(--corner-pad); transform: rotate(180deg); }
.card .corner .rank { display: block; font-size: var(--rank-size); }
.card .corner .suit { display: block; font-size: var(--suit-corner-size); margin-top: 1px; }

.card .center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--center-size);
}

.card.selected {
  outline: 3px solid #ffd54f;
  outline-offset: -1px;
  box-shadow: 0 0 12px rgba(255, 213, 79, 0.7);
}

.card.dragging {
  cursor: grabbing;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  transform: rotate(-1.5deg);
}

/* Hint pulse — used by Klondike & FreeCell hint button. */
.hint-source,
.hint-target {
  position: relative;
  animation: hint-pulse 0.85s ease-in-out 3 both;
  z-index: 5;
}
@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 213, 79, 0); }
  50%      { box-shadow: 0 0 0 5px rgba(255, 213, 79, 0.95); }
}
#hint-btn.hint-none {
  background: #ef9999;
  color: #5a1a1a;
}

/* Win/stuck overlay shared by Klondike & FreeCell */
#win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#win-overlay.hidden { display: none; }
.win-modal {
  background: white;
  color: #222;
  padding: 36px 56px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.win-modal h1 { margin: 0 0 18px; font-size: 36px; }

/* === Card responsive scaling === */

@media (max-width: 820px) {
  :root {
    --card-w: 62px;
    --card-h: 87px;
    --tableau-offset: 21px;
    --pile-gap: 7px;
    --board-pad: 14px;
    --rank-size: 13px;
    --suit-corner-size: 11px;
    --center-size: 26px;
    --corner-pad: 4px;
    --top-row-mb: 24px;
  }
}
@media (max-width: 580px) {
  :root {
    --card-w: 46px;
    --card-h: 64px;
    --tableau-offset: 17px;
    --pile-gap: 5px;
    --board-pad: 8px;
    --rank-size: 11px;
    --suit-corner-size: 10px;
    --center-size: 18px;
    --corner-pad: 3px;
    --top-row-mb: 20px;
  }
  .topbar .seed { font-size: 12px; }
  .win-modal { padding: 28px 40px; }
  .win-modal h1 { font-size: 28px; }
}
@media (max-width: 420px) {
  :root {
    --card-w: 38px;
    --card-h: 53px;
    --tableau-offset: 14px;
    --pile-gap: 4px;
    --rank-size: 10px;
    --suit-corner-size: 9px;
    --center-size: 14px;
    --corner-pad: 2px;
  }
}
@media (max-width: 360px) {
  :root {
    --card-w: 34px;
    --card-h: 48px;
    --tableau-offset: 12px;
    --pile-gap: 3px;
    --rank-size: 9px;
    --suit-corner-size: 8px;
    --center-size: 12px;
  }
}
