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

body {
  background: #35654d;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
  min-height: 100vh;
  user-select: none;
  overflow-x: hidden;
}

/* Top bar */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: rgba(0,0,0,0.25);
}
#top-bar .title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}
#top-bar .stats {
  display: flex;
  gap: 24px;
  font-size: 15px;
}
#top-bar .stats span { white-space: nowrap; }
#timer { font-variant-numeric: tabular-nums; font-weight: 700; }

/* Game area */
#game {
  max-width: 840px;
  margin: 16px auto 0;
  padding: 0 12px;
}

#top-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.gap { width: 24px; flex-shrink: 0; }

#tableau {
  display: flex;
  gap: 12px;
}

/* Card slots */
.card-slot {
  width: 100px;
  min-height: 140px;
  border-radius: 8px;
  border: 2px dashed rgba(255,255,255,0.2);
  position: relative;
  flex-shrink: 0;
}

.stock-slot { cursor: pointer; }
.stock-slot::after {
  content: '↻';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: rgba(255,255,255,0.3);
  pointer-events: none;
}

.foundation::after {
  content: attr(data-suit);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: rgba(255,255,255,0.15);
  pointer-events: none;
}

.tableau-col { min-height: 300px; }

/* Cards */
.card {
  width: 100px;
  height: 140px;
  border-radius: 8px;
  position: absolute;
  left: 0;
  cursor: pointer;
  transition: box-shadow 0.15s;
  z-index: 1;
}

.card.face-up {
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.card.face-down {
  background: linear-gradient(135deg, #1a3a6b 25%, #2255a4 25%, #2255a4 50%, #1a3a6b 50%, #1a3a6b 75%, #2255a4 75%);
  background-size: 14px 14px;
  border: 3px solid #1a3a6b;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  cursor: default;
}
.card.face-down::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 4px;
  border: 2px solid rgba(255,255,255,0.15);
}

.card .rank-top, .card .rank-bot {
  position: absolute;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}
.card .rank-top { top: 6px; left: 7px; }
.card .rank-bot { bottom: 6px; right: 7px; transform: rotate(180deg); }
.card .suit-top, .card .suit-bot {
  position: absolute;
  font-size: 13px;
  line-height: 1;
}
.card .suit-top { top: 21px; left: 8px; }
.card .suit-bot { bottom: 21px; right: 8px; transform: rotate(180deg); }
.card .center-suit {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 42px;
}

.card.red { color: #c0392b; }
.card.black { color: #222; }

/* Drag */
.card.dragging {
  z-index: 1000 !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  pointer-events: none;
  transition: none;
}

/* Highlight hint */
.card.hint-flash {
  animation: hintPulse 0.5s ease 3;
}
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,0.35); }
  50% { box-shadow: 0 0 18px 6px rgba(255,255,0,0.8); }
}

/* Flip animation */
.card.flipping {
  animation: flipCard 0.3s ease;
}
@keyframes flipCard {
  0% { transform: scaleX(1); }
  50% { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}

/* Move animation */
.card.animating {
  transition: left 0.25s ease, top 0.25s ease;
}

/* Bottom bar */
#bottom-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  margin-top: 12px;
}
#bottom-bar button {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
#bottom-bar button:hover { background: rgba(255,255,255,0.3); }

/* Overlay / Dialog */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}
#overlay.hidden { display: none; }
#dialog {
  background: #2c3e50;
  border-radius: 12px;
  padding: 28px 36px;
  min-width: 320px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#dialog-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}
#dialog-body {
  font-size: 15px;
  margin-bottom: 20px;
  line-height: 1.6;
}
#dialog-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}
#dialog-buttons button {
  padding: 8px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.15s;
}
#dialog-buttons button:hover { opacity: 0.85; }
.btn-primary { background: #27ae60; color: #fff; }
.btn-secondary { background: rgba(255,255,255,0.2); color: #fff; }

/* Win cascade */
#cascade-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4000;
  overflow: hidden;
}
.cascade-card {
  position: absolute;
  width: 80px;
  height: 112px;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 900px) {
  .card-slot { width: 80px; min-height: 112px; }
  .card { width: 80px; height: 112px; }
  .card .center-suit { font-size: 32px; }
  .card .rank-top, .card .rank-bot { font-size: 13px; }
  .card .suit-top, .card .suit-bot { font-size: 11px; }
  #game { max-width: 680px; }
  #top-row, #tableau { gap: 8px; }
}
