:root {
  --felt: #0e6b35;
  --felt-dark: #063d1f;
  --gold: #f7931a;
  --gold-light: #f0d878;
  --card-w: 72px;
  --card-h: 100px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
  background: #0a0a0a;
  color: #fff;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Top bar */
#top-bar {
  height: 44px;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
  font-size: 0.9rem;
}
#top-bar .stat { color: var(--gold-light); font-weight: 600; }
#top-bar .stat span { color: #fff; }
.btn-bar {
  background: transparent;
  border: 1px solid #555;
  color: #ccc;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  margin-left: 6px;
}
.btn-bar:hover { border-color: var(--gold); color: var(--gold); }

/* Board */
#board {
  flex: 1;
  min-height: 0;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 75%);
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.stock-waste {
  display: flex;
  gap: 12px;
}

.foundations {
  display: flex;
  gap: 10px;
}

.card, .card-slot {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  display: block;
}

.card {
  object-fit: cover;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  cursor: pointer;
  user-select: none;
  background: #fff;
}

.card-slot {
  border: 2px dashed rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.35);
  font-size: 1.4rem;
  font-weight: 700;
}

.empty-stock {
  cursor: pointer;
  border-color: var(--gold);
  color: var(--gold-light);
  font-size: 1.6rem;
}

.foundation-empty {
  color: rgba(255,255,255,0.2);
  font-size: 1.2rem;
}

#stock, #waste,
#foundation-0, #foundation-1, #foundation-2, #foundation-3 {
  width: var(--card-w);
  height: var(--card-h);
  position: relative;
}

.selected {
  outline: 3px solid var(--gold);
  outline-offset: 1px;
  border-radius: 6px;
}
.selected .card {
  box-shadow: 0 0 0 2px var(--gold), 0 4px 12px rgba(247,147,26,0.5);
}

/* Tableau */
.tableau-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex: 1;
  min-height: 280px;
}

.tableau-col {
  flex: 1;
  position: relative;
  min-width: var(--card-w);
  max-width: 100px;
}

.tableau-card {
  position: absolute;
  left: 0;
  width: var(--card-w);
  height: var(--card-h);
  cursor: pointer;
}
.tableau-card .card {
  width: 100%;
  height: 100%;
}

.tableau-empty {
  width: var(--card-w);
  height: var(--card-h);
}

/* Win modal */
.modal {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }
.modal-content {
  background: #1a1a1a;
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.modal-content h2 {
  color: var(--gold-light);
  font-size: 1.8rem;
  margin-bottom: 0.8rem;
}
.modal-content p {
  color: #ccc;
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
}
.modal-content .btn-primary {
  margin-top: 1.2rem;
  background: var(--gold);
  color: #111;
  border: none;
  padding: 0.7rem 1.6rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.modal-content .btn-primary:hover { background: #ffa940; }

/* Leaderboard (when game runs standalone with panel) */
.lb-empty {
  color: #666;
  text-align: center;
  padding: 1rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.lb-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: #1a1a1a;
  border-radius: 6px;
  font-size: 0.85rem;
}
.lb-rank { color: #888; width: 22px; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-time { color: var(--gold); font-weight: 700; }

@media (max-width: 700px) {
  :root {
    --card-w: 52px;
    --card-h: 72px;
  }
  .tableau-card { /* stack offset smaller */
  }
  #board { padding: 10px; gap: 12px; }
}
