/* General body and layout styles for a fixed, non-scrolling game interface. */

html,
body {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none; /* Prevents scrolling and zooming on touch devices */
  overscroll-behavior: none; /* Disables pull-to-refresh gesture */
  user-select: none; /* Prevents text selection */
  -webkit-user-select: none; /* Prevents text selection in Safari */
  -webkit-touch-callout: none; /* Prevents long press of images in Safari */
}

body {
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent; /* Disable tap highlight on mobile */
}

* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none; /* Chrome, Safari, and Opera */
}

.game-area {
  position: relative;
}

/* --- Preloading screen --- */

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* --- Stat Counter Styles --- */
.stat-text {
  font-size: clamp(0.875rem, 3vw, 1.125rem); /* Responsive font size */
}

/* --- Cursor Styles --- */
#stock-pile.clickable,
.tableau-stack .card-container[draggable='true'],
#waste-pile .card[draggable='true'] {
  cursor: pointer;
}

/* --- Card and Layout Styles --- */
.card {
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 0.25rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  user-select: none;
  position: relative;
  transition: opacity 0.1s ease-in-out;
  overflow: hidden;
  outline: 1px solid #b0b0b0;
  outline-offset: -1px;
}
.card img {
  border-radius: inherit;
}
.card-back {
  background: repeating-linear-gradient(-45deg, #ff5252, #ff5252 5px, #e64a4a 5px, #e64a4a 10px);
}
.card-placeholder {
  outline: none;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  background-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}
.placeholder-text {
  color: rgba(255, 255, 255, 0.3);
  font-size: clamp(1.5rem, 10vw, 3.5rem); /* Responsive font size */
}

/* --- 3D Flip Animation Styles --- */
.tableau-stack {
  align-self: start;
  position: relative;
}
.card-container {
  position: relative;
  width: 100%;
  aspect-ratio: 5/7;
  perspective: 1000px;
}
.card-container.dragging,
.card.dragging {
  opacity: 0 !important;
  pointer-events: none;
}
.tableau-stack .card-container:not(:first-child) {
  margin-top: -115%; /* Overlap cards in tableau */
}
.flipper {
  position: absolute;
  width: 100%;
  height: 100%;
  transition: transform 0.8s;
  transform-style: preserve-3d;
}
.flipper.is-flipped {
  transform: rotateY(180deg);
}
.face {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden; /* For old iOS devices */
  backface-visibility: hidden;
}
.face.back {
  transform: rotateY(180deg);
}

/* --- Animation Styles --- */
.animated-card {
  position: fixed;
  z-index: 100;
  perspective: 1000px;
  transition: top 0.8s, left 0.8s;
  pointer-events: none;
}
.animated-card .flipper {
  position: relative;
  transition: transform 0.8s;
  transform-style: preserve-3d;
}
.animated-card.is-flipping .flipper {
  transform: rotateY(180deg);
}

/* --- iOS Toggle Styles --- */
.peer:checked + label .dot {
  transform: translateX(1.5rem);
}
.peer:checked + label .toggle-bg {
  background-color: #4ade80;
}

/* --- Footer Button Hover Fix --- */
@media (hover: hover) {
  .footer-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
  }
}

/* --- Confetti Explosion Styles --- */
#confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
  display: none;
}

#confetti-container.active {
  display: block;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 16px;
  opacity: 1;
  top: -20px;
  animation: confetti-fall 5s linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotateZ(720deg);
    opacity: 0;
  }
}

/* --- Stats Modal Table Styles --- */
#stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
#stats-table th,
#stats-table td {
  padding: 8px;
  text-align: center;
  border: none;
  border-bottom: 1px dashed #ddd;
}
#stats-table th {
  background-color: transparent;
  font-weight: normal;
}
#stats-table tr:last-child td {
  border-bottom: none;
}
#stats-table td {
  font-weight: bold;
}
#stats-table td:first-child {
  text-align: left;
  font-weight: normal;
}

/* --- Media Query for Larger Screens --- */
@media (min-width: 640px) {
  .card {
    border-radius: 0.5rem;
  }
}

@media (max-width: 340px) {
  .stat-text {
    font-size: clamp(0.75rem, 3vw, 1.125rem); /* Responsive font size */
  }
}
