:root {
  --bg-a: #0f1d2a;
  --bg-b: #14283a;
  --panel: rgba(8, 18, 28, 0.82);
  --border: rgba(142, 181, 206, 0.36);
  --text: #eff8fe;
  --muted: #9fb6c7;
  --accent: #ffb76b;
  --accent-2: #70dcc3;
  --red: #f07b7b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, #21415a 0%, transparent 34%),
    radial-gradient(circle at 88% 92%, #243c5f 0%, transparent 36%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b));
}

.solitaire-page {
  width: min(1100px, 98vw);
  margin: 0 auto;
  padding: 1.2rem 0 2.2rem;
}

/* ── Topbar ──────────────────────────────────────────────────────────────────── */

.topbar {
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--panel);
  padding: 0.95rem 1rem;
}

.back-link {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.92rem;
}

.back-link:hover,
.back-link:focus-visible {
  text-decoration: underline;
}

.topbar h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.85rem, 5vw, 2.65rem);
  font-family: "Fraunces", Georgia, serif;
}

.topbar p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

/* ── Setup panel ─────────────────────────────────────────────────────────────── */

.setup-panel {
  margin-top: 0.8rem;
  padding: 0.85rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.62rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--panel);
}

.setup-panel label {
  color: var(--muted);
  font-size: 0.92rem;
}

select,
button {
  border: 0;
  border-radius: 0.62rem;
  font-family: inherit;
}

select {
  padding: 0.52rem 0.62rem;
  background: #203347;
  color: var(--text);
}

button {
  padding: 0.55rem 0.85rem;
  font-weight: 700;
  cursor: pointer;
  color: #0b1621;
  background: linear-gradient(135deg, #ffc68e, #f8a95f);
}

button.secondary {
  color: #d9e8f4;
  background: linear-gradient(130deg, #30495e, #273c4e);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* ── Status bar ──────────────────────────────────────────────────────────────── */

.status-bar {
  margin-top: 0.8rem;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--panel);
}

.label {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#moves-count {
  font-weight: 700;
  min-width: 2ch;
}

.status-text {
  color: var(--accent);
  font-weight: 600;
  flex: 1;
}

/* ── Game area ───────────────────────────────────────────────────────────────── */

.game-area {
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* Top row: stock/waste + foundation */
.top-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.stock-waste-group {
  display: grid;
  grid-template-columns: 88px 88px;
  grid-template-rows: auto auto;
  gap: 0.35rem 0.55rem;
}

.col-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

.foundation-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.foundation-slots {
  display: flex;
  gap: 0.55rem;
}

/* ── Pile area (stock / waste / foundation) ──────────────────────────────────── */

.pile-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 112px;
}

.waste-area {
  position: relative;
}

/* ── Tableau area ────────────────────────────────────────────────────────────── */

.tableau-area {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.55rem;
}

.tableau-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 112px;
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */

.card {
  user-select: none;
  width: 80px;
  height: 112px;
  border-radius: 0.65rem;
  border: 1px solid rgba(10, 18, 24, 0.35);
  background: #faf0e4;
  color: #1c222c;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  flex-shrink: 0;
  width: 80px;
  cursor: default;
  padding: 4px 5px;
  position: relative;
  transition: outline 60ms ease;
}

.card.selectable {
  cursor: pointer;
}

.card.selectable:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.card.selected {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

.card .inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.rank-top {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1;
  display: block;
}

.rank-top.red,
.rank-bot.red,
.suit-center.red {
  color: var(--red);
}

.suit-center {
  font-size: 1.45rem;
  text-align: center;
  line-height: 1;
  display: block;
  margin: auto 0;
}

.rank-bot {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1;
  display: block;
  transform: rotate(180deg);
  text-align: right;
}

/* ── Face-down card ──────────────────────────────────────────────────────────── */

.card.face-down {
  background: #1e3a52;
  cursor: default;
}

.card-back {
  width: 100%;
  height: 100%;
  border-radius: 0.45rem;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255,255,255,0.04) 0px,
      rgba(255,255,255,0.04) 3px,
      transparent 3px,
      transparent 9px
    ),
    #1a3248;
  border: 3px solid rgba(80, 140, 190, 0.25);
}

/* ── Ghost / empty slot ──────────────────────────────────────────────────────── */

.card.ghost {
  width: 80px;
  height: 112px;
  background: transparent;
  border: 1.5px dashed rgba(180, 210, 230, 0.28);
  box-shadow: none;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(160, 200, 220, 0.45);
  font-size: 1.6rem;
}

.card.ghost.ghost-red {
  color: rgba(240, 123, 123, 0.45);
}

.card.ghost.stock-empty {
  cursor: pointer;
  border-color: rgba(255, 183, 107, 0.4);
  color: rgba(255, 183, 107, 0.6);
}

.card.ghost.stock-empty:hover {
  border-color: rgba(255, 183, 107, 0.7);
  color: rgba(255, 183, 107, 0.9);
}

/* Stock pile card */
.card.stock-pile {
  cursor: pointer;
}

.card.stock-pile:hover {
  transform: translateY(-2px);
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (max-width: 680px) {
  .card,
  .card.ghost {
    width: 48px;
    height: 68px;
  }

  .card-back {
    border-width: 2px;
  }

  .rank-top,
  .rank-bot {
    font-size: 0.65rem;
  }

  .suit-center {
    font-size: 0.9rem;
  }

  .stock-waste-group {
    grid-template-columns: 56px 56px;
  }

  .foundation-slots {
    gap: 0.3rem;
  }

  .tableau-area {
    gap: 0.25rem;
  }
}
