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

:root {
  --card-w: 70px;
  --card-h: 100px;
  --stack-offset: 18px;
}

body {
  background-color: #1a5c2a;
  font-family: Arial, sans-serif;
  color: #ffffff;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 52px;
}

#site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 12px 20px;
  background-color: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}

.site-nav-back {
  color: #ffffff;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.85rem;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.site-nav-back:hover { opacity: 1; }

.site-nav-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.site-nav-links a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}

.site-nav-links a:hover { color: #FFD700; }

#game-container {
  width: 90%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

.card-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
  min-height: 100px;
  justify-content: center;
  align-items: center;
}

.stack-row {
  display: flex;
  flex-direction: row;
  gap: 16px;
  min-height: calc(var(--card-h) + var(--stack-offset));
  justify-content: center;
  align-items: flex-start;
}

.card-stack {
  position: relative;
  width: calc(var(--card-w) + var(--stack-offset));
  height: calc(var(--card-h) + var(--stack-offset));
}

.card-stack .card {
  position: absolute;
  top: 0;
  left: 0;
}

.card-stack .card.stack-front {
  top: var(--stack-offset);
  left: var(--stack-offset);
  z-index: 2;
  box-shadow: -3px 4px 8px rgba(0, 0, 0, 0.3);
}

.card-stack .card.stack-back {
  z-index: 1;
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  background-color: #ffffff;
  border-radius: 8px;
  border: 2px solid #cccccc;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease;
}

.card:hover {
  transform: translateY(-8px);
}

.card.face-down {
  background-color: #1a237e;
  background-image: repeating-linear-gradient(
    45deg,
    #283593 0px,
    #283593 2px,
    #1a237e 2px,
    #1a237e 10px
  );
  color: transparent;
}

.card.red {
  color: #cc0000;
}

.card.black {
  color: #111111;
}

.card.selected {   /* ✅ was .card._selected */
  transform: translateY(-16px);
  border-color: #FFD700;
  box-shadow: 0 0 10px #FFD700;
}

#table-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  padding: 20px 0;
}

#draw-pile,
#waste-pile {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  border: 2px dashed rgba(255, 255, 255, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
}

#ai-area,
#player-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#ai-area h3,
#player-area h3 {
  font-size: 1rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.8;
}

#message-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}

#message-text {
  font-size: 1.1rem;
  font-weight: bold;
}

button {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background-color: #FFD700;
  color: #111111;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

button:hover {
  background-color: #FFC200;
}

button:disabled {
  background-color: #888888;
  cursor: not-allowed;
}

#play-btn { display: none; }

.card.playable {
  cursor: pointer;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

#cheat-sheet {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 200px;
  background-color: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 16px;
  font-size: 0.8rem;
  line-height: 1.5;
}

#cheat-sheet h3 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  padding-bottom: 8px;
}

#cheat-sheet h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.rule-section {
  margin-bottom: 12px;
}

.rule-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-tag {
  display: inline-block;
  background-color: #FFD700;
  color: #111;
  font-weight: bold;
  border-radius: 4px;
  padding: 0px 5px;
  margin-right: 4px;
  font-size: 0.75rem;
}
#stats-panel {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 200px;
  background-color: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 16px;
  font-size: 0.8rem;
  line-height: 1.5;
}

#stats-panel h3 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  padding-bottom: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.stat-label {
  opacity: 0.7;
}

.stat-value {
  font-weight: bold;
}

.stat-divider {
  border-top: 1px solid rgba(255,255,255,0.15);
  margin: 10px 0;
}

#reset-stats-btn {
  width: 100%;
  margin-top: 12px;
  padding: 6px;
  font-size: 0.75rem;
  background-color: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}

#reset-stats-btn:hover {
  background-color: rgba(255,255,255,0.25);
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 88px 0 32px;
    overflow-x: hidden;
  }

  #site-nav {
    justify-content: center;
    text-align: center;
  }

  #cheat-sheet,
  #stats-panel {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    width: 90%;
    max-width: 360px;
    margin: 0 auto 12px;
  }

  #cheat-sheet { order: 2; }
  #game-container { order: 1; }
  #stats-panel { order: 3; }

  #game-container {
    width: 100%;
    padding: 12px;
    gap: 12px;
  }

  .card-row,
  .stack-row {
    flex-wrap: wrap;
    min-height: auto;
    gap: 6px;
  }

  #table-area {
    flex-wrap: wrap;
    gap: 20px;
  }

  :root {
    --card-w: 52px;
    --card-h: 74px;
    --stack-offset: 14px;
  }

  .card { font-size: 0.95rem; }
  #draw-pile,
  #waste-pile { font-size: 0.65rem; }

  .card:hover { transform: none; }
  .card.selected { transform: translateY(-10px); }
}

@media (max-width: 420px) {
  :root {
    --card-w: 42px;
    --card-h: 60px;
    --stack-offset: 11px;
  }

  .card { font-size: 0.8rem; }
}