/* ===================================
   1) BASE & RESET
   =================================== */
html, body {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  height: 100%;
  overflow: hidden;            /* 🚫 prevent page scrolling */
}
input, textarea {
  user-select: text;
  -webkit-user-select: text;
  -ms-user-select: text;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: Arial, sans-serif;
  background-color: #e5f0df;
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* When any modal is open, also lock scroll (JS toggles on <body>) */
body.modal-open {
  overflow: hidden;
}

/* Optional: while intro/welcome modal is open, hide the board (JS also does this) */
body.modal-open #game-container {
  visibility: hidden;
}


/* ===================================
   2) BACKGROUND VIDEO
   =================================== */
#background-video {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  object-fit: cover;
  z-index: -1;
  pointer-events: none;
}


/* ===================================
   3) HEADER
   =================================== */
header {
  position: relative;
  width: 100%;
  height: 60px;
  background-color: #333;
}
#header-rectangle {
  width: min(600px, 100%);      /* ✅ no overflow */
  height: 65px;
  margin: 0 auto;
  background-color: #333;
}
#header-group {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
}
#settings-btn,
#reset-game-btn {
  font-size: 14px;
  padding: 5px 10px;
  cursor: pointer;
}
#score-container,
#moves-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.9em;
  min-width: 60px;
}
#timer {
  font-size: 26px;
  font-weight: bold;
  color: #fff;
  width: 60px;
  text-align: center;
}


/* ===================================
   4) FOOTER
   =================================== */
footer {
  position: relative;
  width: 100%;
  max-width: 600px;             /* ✅ match header cap */
  height: 60px;
  background-color: #333;
  margin: 0 auto;               /* center */
  display: flex;
  align-items: center;
  justify-content: center;
}
#footer-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
}
#deck-collection-btn {
  position: absolute;
  left: 10px;
  width: 48px;
  height: 64px;
  border-radius: 6px;
  border: 1px solid #fff;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
  cursor: pointer;
}
#deck-collection-btn span {
  position: absolute;
  bottom: 2px;
  left: 4px;
  right: 4px;
  font-size: 10px;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
  pointer-events: none;
}
#player-name-container {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: bold;
  color: white;
}
#player-name { font-size: 16px; font-weight: 700; color: #fff; }
#undo-btn, #stats-btn {
  background-color: #007BFF;
  color: white;
  padding: 8px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  position: absolute;
}
#undo-btn { right: 10px; }
#stats-btn { right: 70px; }


/* ===================================
   5) MAIN GAME AREA (no page scroll)
   =================================== */
#game-container {
  /* Reserve space so header (65) + footer (60) fit without page scroll */
  height: calc(100vh - 125px);
  flex: 0 0 auto;

  display: flex;
  flex-direction: column;
  justify-content: space-between;

  max-width: 900px;
  margin: 0 auto;
  padding: 10px;
  align-items: center;

  overflow: hidden;            /* ✅ prevent container from pushing page */
}
#top-section { display: flex; flex-direction: column; align-items: center; }
#board-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: center;

  padding-left: 2px;

  /* Allow cards to visually overflow within board area without creating page scroll */
  overflow: visible;
}
#top-row, #tableau {
  display: flex;
  justify-content: center;
  gap: 0px;
  margin-top: 10px;
  margin-bottom: 6px;
}
.top-area, .tableau-column {
  width: clamp(38px, 12vw, 65px);
  height: clamp(48px, 16vw, 85px);
  position: relative;
  margin: 0 2px;
}
#empty-area { border: none !important; }
#opponent-space {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}
.opponent-placeholder {
  width: 200px;
  height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}


/* ===================================
   6) CARDS
   =================================== */
.card {
  width: clamp(38px, 12vw, 65px);
  height: clamp(48px, 16vw, 85px);
  background-color: #fff;
  position: relative;
  border-radius: 4px;
  border: 2px solid #ebe8e8;
  overflow: hidden;
  pointer-events: auto;
}
.card-top {
  position: absolute;
  top: 1.5px;
  left: 5px;
  font-size: clamp(10px, 2vw, 17px);
  font-weight: bold;
  line-height: 1;
}
.card-center {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(24px, 5vw, 48px);
  line-height: 1;
}
.card[data-suit="diamonds"] .big-suit,
.card[data-suit="hearts"] .big-suit { color: red; }
.card[data-suit="clubs"] .big-suit,
.card[data-suit="spades"] .big-suit { color: black; }
.card[data-face-up="false"] {
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 120%;
  color: transparent !important;
  border: 2px solid #000;
}
#stock .card, #waste .card {
  position: absolute;
  top: 0; left: 0;
}
/* Make sure child elements don't intercept drag/clicks */
.card * { pointer-events: none; }


/* ===================================
   7) FOUNDATIONS
   =================================== */
.foundation {
  position: relative;
  width: clamp(38px, 12vw, 65px);
  height: clamp(48px, 16vw, 85px);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: contain;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.foundation-bg {
  position: absolute;
  width: clamp(34px, 11vw, 60px);
  height: clamp(44px, 14vw, 80px);
  overflow: hidden;
  pointer-events: none;
  margin-top: 2.5px;
  margin-left: 2.5px;
  z-index: 0;
  opacity: 0.4;
}


/* ===================================
   8) MODALS
   =================================== */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: auto;                 /* modal content can scroll if needed */
  background-color: rgba(0, 0, 0, 0.5);
}
.modal-content {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background-color: #fefefe;
  padding: 0;
  border: 1px solid #888;
  width: 80%;
  max-width: 580px;
  border-radius: 8px;
  overflow: hidden;
}
.accept-button {
  background-color: #007bff;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 8px 16px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.accept-button:hover { background-color: #0056b3; }


/* ===================================
   9) STATS MODAL CONTENT
   =================================== */
label { color: black; }
.stats-content {
  font-size: 16px;
  color: #444;
  padding: 1em;
  line-height: 1.5;
}
.stats-content p { margin-bottom: 0.5em; }


/* ===================================
   10) SUIT ANIMATION
   =================================== */
@keyframes suit-pop {
  0%   { transform: scale(1);   opacity: 0; }
  50%  { transform: scale(2.5); opacity: 1; }
  100% { transform: scale(1.75);opacity: 0; }
}
.suit-animation {
  font-size: 24px;
  font-weight: bold;
  pointer-events: none;
  animation: suit-pop 1s ease-out forwards;
}


/* ===================================
   11) RESPONSIVE
   =================================== */
@media (min-width: 600px) {
  .modal-content { padding: 0 !important; }
}
