*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 800px;
  font-family: "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif;
  background: linear-gradient(160deg, #1a5f3c 0%, #0d3d24 100%);
  color: #f5f5f5;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0 0 1rem;
  opacity: 0.85;
  font-size: 0.9rem;
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.foundations {
  display: flex;
  gap: 0.5rem;
}

.stock-area {
  display: flex;
  gap: 0.5rem;
}

.tableau {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  min-height: 420px;
}

.pile {
  position: relative;
  width: 72px;
  min-height: 96px;
}

.pile-slot {
  width: 72px;
  height: 96px;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 8px;
}

.card {
  position: absolute;
  left: 0;
  width: 72px;
  height: 96px;
  border-radius: 8px;
  border: 1px solid #bbb;
  background: #fff;
  color: #222;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.35);
  transition: outline 0.1s;
}

.card.red {
  color: #c62828;
}

.card.black {
  color: #1a1a1a;
}

.card.face-down {
  background: repeating-linear-gradient(
    45deg,
    #1565c0,
    #1565c0 6px,
    #0d47a1 6px,
    #0d47a1 12px
  );
  color: transparent;
  cursor: default;
}

.card.selected {
  outline: 3px solid #ffeb3b;
  outline-offset: 2px;
  z-index: 100 !important;
}

.card .rank {
  font-size: 1.1rem;
  line-height: 1;
}

.card .suit {
  font-size: 1.4rem;
  line-height: 1;
}

.tableau .pile {
  min-height: 420px;
}

.stock:not(:empty)::before,
.stock .card-back {
  content: "";
  display: block;
  width: 72px;
  height: 96px;
  border-radius: 8px;
  border: 1px solid #888;
  background: repeating-linear-gradient(
    45deg,
    #1565c0,
    #1565c0 6px,
    #0d47a1 6px,
    #0d47a1 12px
  );
  cursor: pointer;
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.35);
}

.stock {
  cursor: pointer;
}

.stock:focus-visible {
  outline: 2px solid #ffeb3b;
  outline-offset: 2px;
}

.controls {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

#new-game-btn {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  background: #ffc107;
  color: #222;
  cursor: pointer;
  font-weight: 600;
}

#new-game-btn:hover {
  background: #ffca28;
}

.message {
  margin: 0;
  flex: 1;
  min-height: 1.5em;
  color: #ffecb3;
}

.message.error {
  color: #ff8a80;
  font-weight: 600;
}

.win-banner {
  margin-top: 1rem;
  padding: 1rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  background: rgba(255, 193, 7, 0.95);
  color: #1a1a1a;
  border-radius: 8px;
}

.win-banner.hidden {
  display: none;
}

.drop-target.highlight {
  background: rgba(255, 235, 59, 0.15);
  border-radius: 8px;
}
