*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #2f6b24, #02330d);
  color: #f7f7f7;
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-height: 100vh;
}

#solitaire-app {
  width: 100%;
  max-width: 1200px;
  margin: 16px;
  padding: 16px 20px 20px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Top bar */

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.title-area h1 {
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.primary-btn {
  border: none;
  outline: none;
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4caf50, #81c784);
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, opacity 0.12s;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  opacity: 0.95;
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.5);
}

.stats-area {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stat {
  min-width: 72px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
  font-size: 0.75rem;
}

.stat .label {
  opacity: 0.7;
}

.stat .value {
  font-weight: 600;
  font-size: 0.95rem;
}

/* Board layout */

#game-board {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.row-top {
  min-height: 130px;
}

.left-area {
  display: flex;
  align-items: center;
  gap: 18px;
}

.right-area {
  margin-left: auto;
}

.foundation-wrapper {
  padding: 6px 10px 10px;
  border-radius: 14px;
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.65));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.foundation-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.7;
  margin-bottom: 6px;
}

.foundation-row {
  display: flex;
  gap: 10px;
}

/* Piles & cards */

.pile {
  width: 80px;
  height: 112px;
  border-radius: 10px;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  position: relative;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  background: radial-gradient(circle at top, rgba(5, 60, 12, 0.7), rgba(0, 0, 0, 0.7));
}

.pile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.pile.empty-highlight {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.6);
}

/* Stock / waste special styling */

.pile.stock {
  cursor: pointer;
  background: rgba(0, 0, 0, 0.3) url("../assets/card-back.svg") center/70px 100px no-repeat;
}

.pile.stock.empty {
  background-image: none;
  border-style: dashed;
  opacity: 0.6;
}

.pile.waste {
  background: transparent;
  border-style: dashed;
}

/* Foundations */

.pile.foundation {
  background: rgba(0, 0, 0, 0.28);
}

.pile.foundation .placeholder-suit {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  opacity: 0.2;
}

/* Tableau */

.tableau-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.tableau-pile {
  position: relative;
  width: 80px;
  min-height: 140px;
}

.tableau-pile .pile {
  position: absolute;
  inset: 0;
}

.card {
  position: absolute;
  width: 80px;
  height: 112px;
  border-radius: 10px;
  background: #fdfdfd;
  color: #222;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(0, 0, 0, 0.25);
  cursor: pointer;
  user-select: none;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}

.card.face-down {
  background: #0b3d16 url("../assets/card-back.svg") center/70px 100px no-repeat;
  border-color: rgba(255, 255, 255, 0.05);
}

.card.face-up {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 7px;
}

.card .corner {
  font-size: 0.9rem;
  font-weight: 600;
}

.card .corner.bottom {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card .suit-large {
  font-size: 1.4rem;
  align-self: center;
}

.card.red {
  color: #d32f2f;
}

.card.black {
  color: #212121;
}

.card.selected {
  box-shadow: 0 0 0 2px #ffeb3b, 0 10px 24px rgba(0, 0, 0, 0.6);
  transform: translateY(-4px);
}

/* Waste top card slightly offset */

.pile.waste .card {
  position: absolute;
  top: 0;
  left: 0;
}

/* Hover feedback */

.card.face-up:hover {
  /*transform: translateY(-2px);*/
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

/* Message bar */

.message-bar {
  min-height: 22px;
  font-size: 0.85rem;
  opacity: 0.85;
  padding: 6px 4px 0;
}

/* Utility */

.hidden {
  display: none !important;
}

/* Responsive tweaks */

@media (max-width: 768px) {
  #solitaire-app {
    margin: 8px;
    padding: 12px 12px 16px;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-area {
    align-self: stretch;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .tableau-row {
    gap: 10px;
  }
}
