:root {
  --card-w: 78px;
  --card-h: 108px;
  --felt: #1b6b3a;
  --felt-dark: #145a30;
  --gold: #e0b84b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--felt-dark);
  color: #fdfdfd;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: #0f4425;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  color: var(--gold);
  white-space: nowrap;
}

#menu {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#menu button, #controls button {
  font-size: 1.05rem;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: #2c8a52;
  color: white;
  cursor: pointer;
  min-height: 44px;
}

#menu button:hover, #controls button:hover {
  background: #34a462;
}

#menu button.active {
  background: var(--gold);
  color: #1b3a24;
  font-weight: bold;
}

#controls {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

#status {
  text-align: center;
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--gold);
  min-height: 1.8rem;
  margin: 10px 0 0;
}

.help {
  text-align: center;
  color: #cfe9d8;
  font-size: 0.95rem;
  margin: 4px 0 10px;
}

#game-container {
  padding: 10px 20px 60px;
  overflow-x: auto;
}

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

.top-row {
  margin-bottom: 26px;
}

.spacer {
  flex: 1;
}

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

.tableau-row {
  gap: 14px;
}

.tableau-col {
  display: flex;
  flex-direction: column;
  min-height: var(--card-h);
}

.tableau-col .card {
  position: relative;
}

.tableau-col .card:not(:first-child) {
  margin-top: -80px;
}

.spider-row {
  gap: 8px;
}

.spider-row .tableau-col .card:not(:first-child) {
  margin-top: -84px;
}

.freecell-row .tableau-col .card:not(:first-child) {
  margin-top: -80px;
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  background: #fdfdfd;
  border: 1px solid #999;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  user-select: none;
  position: relative;
}

.card.red { color: #c62828; }
.card.black { color: #1a1a1a; }

.card.face-down {
  background: repeating-linear-gradient(
    45deg,
    #1e5fb0,
    #1e5fb0 6px,
    #2c72cc 6px,
    #2c72cc 12px
  );
  border: 1px solid #0d3d78;
  cursor: default;
}

.card.selected {
  outline: 3px solid var(--gold);
  transform: translateY(-8px);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.5);
}

.corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-size: 1rem;
  font-weight: bold;
}

.corner.top { top: 4px; left: 6px; }
.corner.bottom { bottom: 4px; right: 6px; transform: rotate(180deg); }

.pip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.1rem;
}

.empty-slot {
  width: var(--card-w);
  height: var(--card-h);
  border: 2px dashed rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: rgba(255, 255, 255, 0.5);
}

.empty-slot.red { color: #e08a8a; }
.empty-slot.black { color: rgba(255, 255, 255, 0.55); }

.foundation .empty-slot, .freecell .empty-slot {
  font-size: 1.8rem;
}

.stock-count {
  position: absolute;
  top: 100%;
  left: 0;
  width: var(--card-w);
  text-align: center;
  font-size: 0.75rem;
  color: #cfe9d8;
  margin-top: 4px;
}

.completed-count {
  width: auto;
  padding: 0 14px;
  min-height: var(--card-h);
  display: flex;
  align-items: center;
  font-size: 1.1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hearts-board {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.hearts-scorebar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.score-chip {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.95rem;
}

.score-chip.active {
  border-color: var(--gold);
  color: var(--gold);
  font-weight: bold;
}

.hearts-seats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.seat-top {
  display: flex;
  justify-content: center;
}

.seat-middle-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
}

.trick-area {
  min-width: 260px;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px;
}

.current-trick {
  display: flex;
  gap: 10px;
  align-items: center;
}

.trick-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.trick-tag {
  font-size: 0.75rem;
  color: #cfe9d8;
}

.trick-empty {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.95rem;
}

.opponent-hand {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.opponent-hand .card-row {
  display: flex;
}

.opponent-hand .card {
  width: 40px;
  height: 56px;
  margin-left: -28px;
  cursor: default;
}

.opponent-hand .card:first-child {
  margin-left: 0;
}

.opponent-hand .seat-label {
  margin-top: 6px;
  font-size: 0.85rem;
  color: #cfe9d8;
}

.seat-left .opponent-hand .card,
.seat-right .opponent-hand .card {
  margin-left: -32px;
}

.human-hand {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  min-height: var(--card-h);
}

.human-hand .card:not(:first-child) {
  margin-left: -34px;
}

.human-hand .card {
  transition: transform 0.1s ease;
}

.human-hand .card.playable:hover {
  transform: translateY(-10px);
}

.human-hand .card:not(.playable) {
  filter: brightness(0.75);
  cursor: default;
}

.pass-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 10px 16px;
}

.pass-bar button {
  font-size: 1rem;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--gold);
  color: #1b3a24;
  font-weight: bold;
  cursor: pointer;
}

.pass-bar button:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 700px) {
  :root {
    --card-w: 52px;
    --card-h: 74px;
  }
  h1 { font-size: 1.2rem; }
  .pip { font-size: 1.4rem; }
  .corner { font-size: 0.75rem; }
  .tableau-col .card:not(:first-child) { margin-top: -56px; }
  .spider-row .tableau-col .card:not(:first-child) { margin-top: -58px; }
}
