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

:root {
  --card-w: 72px;
  --card-h: 102px;
  --card-offset: 24px;
  --felt: #0f5c38;
  --felt-dark: #0a4529;
  --felt-light: #147a4d;
  --gold: #c9a227;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: radial-gradient(ellipse at 50% 20%, var(--felt-light) 0%, var(--felt) 45%, var(--felt-dark) 100%);
  color: #f5f0e1;
}

#game-root {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  gap: 8px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 0 4px;
}

.toolbar h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.stats {
  display: flex;
  gap: 16px;
  font-size: 0.75rem;
}

.stat-label {
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  font-family: system-ui, sans-serif;
}

.stat-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-undo {
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(0, 0, 0, 0.2);
  color: #f5f0e1;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.btn-undo:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.32);
}

.btn-undo:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-new {
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-new:hover {
  background: rgba(0, 0, 0, 0.35);
}

.board {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: auto;
}

.top-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: nowrap;
}

.top-spacer {
  flex: 1;
  min-width: 8px;
}

.pile-slot {
  position: relative;
  width: var(--card-w);
  min-width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  border: 2px dashed rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.08);
}

.pile-slot.foundation-slot {
  border-color: rgba(201, 162, 39, 0.35);
}

.pile-slot .suit-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  opacity: 0.15;
  pointer-events: none;
}

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

.tableau-col {
  position: relative;
  width: var(--card-w);
  min-width: var(--card-w);
  min-height: var(--card-h);
}

.card {
  position: absolute;
  left: 0;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.12s, transform 0.12s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.15) inset;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.card.selected {
  box-shadow: 0 0 0 3px var(--gold), 0 4px 14px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
  z-index: 50 !important;
}

.card.face-down {
  background: linear-gradient(135deg, #1a3d8f 0%, #0f2660 50%, #1a3d8f 100%);
  border: 2px solid #2a5099;
}

.card.face-down::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.04) 0px,
    rgba(255, 255, 255, 0.04) 4px,
    transparent 4px,
    transparent 8px
  );
}

.card.face-up {
  background: linear-gradient(160deg, #fffef8 0%, #f5f0e6 100%);
  border: 1px solid #c8c0b0;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card.red { color: #c41e3a; }
.card.black { color: #1a1a2e; }

.card-corner {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.1;
  -webkit-font-smoothing: antialiased;
}

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

.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
}

.card.rank-jack .card-center::after { content: 'J'; font-size: 1.85rem; font-weight: 700; }
.card.rank-queen .card-center::after { content: 'Q'; font-size: 1.85rem; font-weight: 700; }
.card.rank-king .card-center::after { content: 'K'; font-size: 1.85rem; font-weight: 700; }

.hint-bar {
  text-align: center;
  font-size: 0.65rem;
  font-family: system-ui, sans-serif;
  opacity: 0.55;
  flex-shrink: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
}

.overlay.visible {
  display: flex;
}

.overlay-card {
  background: linear-gradient(160deg, #fffef8, #f0ebe0);
  color: #1a1a1a;
  border-radius: 16px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  border: 3px solid var(--gold);
}

.overlay-card h2 {
  font-size: 1.6rem;
  color: var(--felt-dark);
  margin-bottom: 8px;
}

.overlay-card p {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 18px;
  font-family: system-ui, sans-serif;
}

.overlay-card button {
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  background: var(--felt);
  color: #fff;
  cursor: pointer;
}

@media (max-width: 700px) {
  :root {
    --card-w: 48px;
    --card-h: 68px;
    --card-offset: 16px;
  }
  .toolbar h1 { font-size: 0.85rem; }
  .card-corner { font-size: 0.65rem; }
  .card-center { font-size: 1.4rem; }
  .card.rank-jack .card-center::after,
  .card.rank-queen .card-center::after,
  .card.rank-king .card-center::after { font-size: 1.3rem; }
}