/* ===========================================================
   Spider Solitaire — game-specific styles only.
   Chrome, buttons, stats and the help modal come from shared.css.
   Card width drives everything via the --cw custom property so the
   ten overlapping columns always fit, right down to ~360px wide.
   =========================================================== */

:root {
  /* Card width scales with the viewport; height follows a poker-ish ratio.
     clamp keeps 10 columns + gaps inside a narrow phone screen. */
  --cw: clamp(28px, 9vw, 64px);
  --ch: calc(var(--cw) * 1.4);
  --col-gap: clamp(2px, 0.8vw, 8px);  /* gap between columns / upper piles */
  --stack: calc(var(--ch) * 0.26);    /* vertical offset of stacked cards  */
  --stack-down: calc(var(--ch) * 0.14); /* tighter offset for face-down cards */
}

/* Tighten the page so the wide board has room. */
body { gap: 12px; }

/* ---------- difficulty pills (suit count) ---------- */
#difficulty {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.diff-btn {
  padding: 8px 16px;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
}
.diff-btn:hover { opacity: 1; background: var(--surface-3); }
.diff-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}

/* ---------- top bar ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.top button { padding: 10px 22px; }
.stats { display: flex; gap: 10px; }
.stat { min-width: 64px; padding: 6px 12px; }
.stat .val { font-size: 1.1rem; }

/* ---------- board layout ---------- */
#board {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: calc(var(--cw) * 10 + var(--col-gap) * 9 + 8px);
}

.upper {
  display: flex;
  align-items: flex-start;
  gap: var(--col-gap);
  width: 100%;
}
.upper .spacer { flex: 1; }   /* push foundations away from the stock */

/* Foundations: completed suit-runs stack up to the right. */
.foundations {
  display: flex;
  gap: var(--col-gap);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tableau {
  display: grid;
  grid-template-columns: repeat(10, var(--cw));
  gap: var(--col-gap);
  justify-content: center;
}

/* ---------- pile slots (the empty "wells") ---------- */
.pile {
  position: relative;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.12);
  border: 2px dashed var(--border);
  background: var(--surface-2);
  flex: none;
}
/* The stock shows how many deals remain via stacked face-down chips. */
.stock { cursor: pointer; }
.stock.empty { cursor: default; }
.stock .deal-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.42);
  font-weight: 700;
  color: var(--btn-text);
  pointer-events: none;
  z-index: 2;
}
.stock.empty::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.5);
  color: var(--muted);
  pointer-events: none;
}

/* A completed-run foundation is a small face-up marker (the King). */
.foundation {
  width: calc(var(--cw) * 0.6);
  height: calc(var(--ch) * 0.6);
  border-radius: calc(var(--cw) * 0.1);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.36);
  font-weight: 700;
  flex: none;
}
.foundation.red   { color: var(--red); }
.foundation.black { color: var(--text); }

/* A tableau column is a relatively-positioned stack of absolute cards. */
.column {
  position: relative;
  width: var(--cw);
  min-height: var(--ch);
}
.column .pile-base {  /* dashed well shown only when a column is empty */
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.12);
  border: 2px dashed var(--border);
  background: var(--surface-2);
}

/* ---------- cards ---------- */
.card {
  position: absolute;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.12);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px var(--shadow);
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  overflow: hidden;
}
/* Cards in the stock sit flat in their slot. */
.pile .card { position: absolute; top: 0; left: 0; }

/* Face-up card faces: a big corner index + a centre pip. */
.card .corner {
  position: absolute;
  top: calc(var(--cw) * 0.06);
  left: calc(var(--cw) * 0.1);
  line-height: 1;
  font-weight: 700;
  font-size: calc(var(--cw) * 0.4);
  text-align: center;
}
.card .corner .suit { font-size: calc(var(--cw) * 0.34); display: block; }
.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.62);
  opacity: 0.9;
}

/* Suit colours — reds use --red, blacks use the theme text colour. */
.card.red   { color: var(--red); }
.card.black { color: var(--text); }

/* Face-down cards: a patterned back, no rank shown. */
.card.down {
  background:
    repeating-linear-gradient(45deg,
      var(--blue-board) 0, var(--blue-board) 6px,
      var(--blue-board-dark) 6px, var(--blue-board-dark) 12px);
  border-color: var(--blue-board-dark);
  cursor: default;
}
.card.down .corner, .card.down .pip { display: none; }

/* Selected card (and any cards riding along with it) glow gold. */
.card.selected {
  outline: 3px solid var(--accent);
  outline-offset: -1px;
  box-shadow: 0 0 0 2px var(--accent), 0 4px 12px var(--shadow);
  z-index: 50;
}

/* A column flagged as a legal drop target while a card is held. */
.drop-ok {
  outline: 3px dashed var(--green);
  outline-offset: 2px;
}

/* ---------- win banner ---------- */
#status.win { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* On very small screens, drop the stat chips' min width a touch more. */
@media (max-width: 380px) {
  .stat { min-width: 50px; padding: 5px 7px; }
  .stats { gap: 6px; }
  .diff-btn { padding: 7px 12px; font-size: 0.82rem; }
}
