:root {
  --card-width: 100px;
  --card-height: calc(var(--card-width) * 1.2);
  --card-overlap: 30px;
  --waste-overlap: 25px;
  --zone-gap: 16px;
  --board-padding: 20px;
  --sidebar-width: calc(var(--card-width) + 16px);
  --bg-color: #1a6b3c;
  --bg-darker: #145a30;
  --text-color: #e8e8e8;
  --zone-border: rgba(255, 255, 255, 0.15);
  --zone-bg: rgba(0, 0, 0, 0.12);
  --header-bg: rgba(0, 0, 0, 0.2);
  --btn-bg: rgba(255, 255, 255, 0.15);
  --btn-hover: rgba(255, 255, 255, 0.25);
}

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

body {
  background: var(--bg-color);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#game {
  /* The board is about eight cards wide; let it grow with the cards on large screens. */
  max-width: max(1200px, calc(var(--card-width) * 8 + 160px));
  margin: 0 auto;
  padding: var(--board-padding);
}

/* Header bar */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  margin-bottom: var(--board-padding);
  background: var(--header-bg);
  border-radius: 8px;
}

#top-bar button {
  background: var(--btn-bg);
  color: var(--text-color);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 150ms;
}

#top-bar button:hover:not(:disabled) {
  background: var(--btn-hover);
}

#top-bar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#btn-4color.active {
  background: rgba(100, 200, 100, 0.3);
  border-color: rgba(100, 200, 100, 0.5);
}

#game-info {
  display: flex;
  gap: 24px;
  font-size: 15px;
  font-weight: 500;
}

/* Board layout — sidebar (foundations) + main area */
#board {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: var(--zone-gap);
}

/* Foundations sidebar — stacked vertically on the left */
#foundations-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Main area — deal row on top, tableau below */
#main-area {
  display: flex;
  flex-direction: column;
  gap: var(--board-padding);
}

/* Deal row: stock + full-width waste */
#deal-row {
  display: flex;
  gap: var(--zone-gap);
  align-items: start;
}

/* Tableau: 7 equal columns */
#tableau {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

/* Zone base styles */
.zone {
  position: relative;
  width: var(--card-width);
  min-height: var(--card-height);
  border-radius: 8px;
}

/* Waste zone — flexible width to show all dealt cards */
#waste-zone {
  flex: 1;
  min-width: var(--card-width);
}

.zone-placeholder {
  width: var(--card-width);
  height: var(--card-height);
  border: 2px dashed var(--zone-border);
  border-radius: 8px;
  background: var(--zone-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-label {
  font-size: 12px;
  opacity: 0.4;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.suit-icon {
  font-size: 28px;
  opacity: 0.3;
}

.foundation .suit-icon {
  color: var(--text-color);
}

#foundation-0 .suit-icon,
#foundation-1 .suit-icon {
  color: #e55;
}

/* 4-color mode: diamonds blue, clubs green */
.four-color #foundation-1 .suit-icon {
  color: #22a;
}

.four-color #foundation-2 .suit-icon {
  color: #080;
}

/* Tableau columns - use grid width, not fixed card width */
.tableau-column {
  width: auto;
  min-height: var(--card-height);
}

.tableau-column .zone-placeholder {
  display: none;
}

/* Foundation zones in sidebar — full width of sidebar */
#foundations-sidebar .zone {
  width: var(--card-width);
}

#foundations-sidebar .zone-placeholder {
  width: var(--card-width);
  height: var(--card-height);
}

/* Stock zone cursor */
#stock-zone {
  cursor: pointer;
}

/* Free cell indicator */
#stock-zone.free-cell .zone-placeholder {
  border-color: rgba(100, 200, 255, 0.4);
  background: rgba(100, 200, 255, 0.08);
}

#stock-zone.free-cell .placeholder-label {
  font-size: 0;
}

#stock-zone.free-cell .placeholder-label::after {
  content: 'FREE CELL';
  font-size: 11px;
  letter-spacing: 1px;
}

/* Drag layer */
#drag-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* Drop target highlights (only visible when Guides enabled) */
.show-guides .drop-target-valid {
  outline: 2px solid rgba(100, 255, 100, 0.5);
  outline-offset: -2px;
}

.show-guides .drop-target-hover {
  outline-color: rgba(100, 255, 100, 0.9);
  background: rgba(100, 255, 100, 0.1);
}

/* Destinations for a tapped/selected card are always shown */
.zone.tap-target {
  outline: 2px dashed rgba(120, 200, 255, 0.7);
  outline-offset: -2px;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Toggle button active state */
#btn-fullscreen.active {
  background: rgba(100, 200, 100, 0.3);
  border-color: rgba(100, 200, 100, 0.5);
}

/* "winnable" badge next to the deal number */
.deal-badge {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(100, 200, 100, 0.25);
  color: #cfead6;
}

/* Notice banner (lost-deal warning, hint messages) */
.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: calc(-1 * var(--board-padding) + 6px) 0 var(--board-padding);
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(230, 170, 60, 0.18);
  border: 1px solid rgba(230, 170, 60, 0.45);
  font-size: 14px;
}

.notice span {
  flex: 1;
}

.notice button {
  background: var(--btn-bg);
  color: var(--text-color);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.notice button:hover {
  background: var(--btn-hover);
}

/* Hint highlight */
.card.hint-source,
.zone.hint-target,
.card.hint-target {
  outline: 3px solid rgba(255, 220, 80, 0.95);
  outline-offset: -1px;
  box-shadow: 0 0 14px rgba(255, 220, 80, 0.7);
  animation: hint-pulse 0.9s ease-in-out 2;
}

/* The move that lost the game, after "Where did it go wrong?" rewinds to before it */
.card.mistake-source,
.zone.mistake-target,
.card.mistake-target {
  outline: 3px solid rgba(235, 90, 80, 0.95);
  outline-offset: -1px;
  box-shadow: 0 0 14px rgba(235, 90, 80, 0.6);
}

@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 220, 80, 0.4); }
  50% { box-shadow: 0 0 18px rgba(255, 220, 80, 0.95); }
}
