/* Common Styles */

/* Global Styles */

body {
  font-family: "IBM Plex Mono", Arial, sans-serif;
  font-size: 14px; /* Reduced base font size for mobile */
  line-height: 1.6;
  margin: 0;
  padding: 0;
  /* Add dark mode styles */
  background-color: #333;
  color: #f4f4f4;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  max-width: 100%;
  padding: 20px;
  box-sizing: border-box;
}

.d-none{
  display: none;
}

.d-block{
  display: block;
}

/* Add a media query for dark mode */
@media (prefers-color-scheme: dark) {
  body {
    background-color: rgb(34, 34, 34);
    color: #f4f4f4;
  }

  /* Add dark mode styles for other elements as needed */
  .container {
    background-color: #333;
  }

  /* ... other dark mode styles ... */
}

.container {
  width: 100%;
  max-width: 1200px;
  padding: 0 10px; /* Reduced padding for mobile */
  margin: 0 auto;
}

h1 {
  text-align: center;
  margin: 20px 0;
  font-size: 2em;
}

h2 {
  font-size: 1.5em;
}

h3 {
  font-size: 1.17em;
}

button {
  padding: 10px 15px;
  font-size: 14px;
  margin: 5px;
  cursor: pointer;
  border: none;
  border-radius: 5px;
  background-color: #f80;
  color: white;
  transition: background-color 0.3s ease;
  min-height: 44px;
  min-width: 44px;
  width: auto;
  max-width: 100%;
}

button:hover:not(:disabled) {
  background-color: #a50;
}

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

a {
  text-decoration: none;
  color: inherit;
}

.buttons {
  text-align: center;
}

.buttons button {
  padding: 10px 20px;
  font-size: 1em;
  margin: 5px;
  cursor: pointer;
}

/* Message when binder is empty */
.binder-gallery p {
  text-align: center;
  color: #fff;
  font-size: 1.2em;
  margin-top: 35%;
}
.binder-gallery p.fail-message {
  text-align: center;
  color: #fff;
  font-size: 1.2em;
  margin-top: 9%;
  left:33%;
  position: absolute;
}

.image-container {
  width: 90%;
  grid-column: 1 / 2;
  grid-row: 1;
}
.market-binder {
  grid-column: 2;
  grid-row: 1;
}

.market-container {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

.binder-selection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: white;
}

.binder-selection .binder-card {
  color: black;
  text-align: left;
  font-size: 0.75em;
}

.binder-selection .binder-card input {
  width: 90%;
}

.binder-selection .binder-card p {
  margin: 0;
}

/* Card Styles */


.card {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    cursor: default;
    transition: transform 0.3s ease;
    border-radius: 15px;
    perspective: 1000px;
}

/* Ensure card stays visible during animation */
.card.animate__animated {
    position: absolute !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.card.flipping {
  transform: rotateY(-180deg);
}

.card-stack {
  position: relative;
  width: 200px;
  height: 300px;
}

#main-stack {
  z-index: 10;
}

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

#main-stack .card.flipped {
  transform: rotateY(-180deg);
}

#viewed-stack {
  position: relative;
  width: 200px; /* Adjust based on your card size */
  height: 300px; /* Adjust based on your card size */
}

#viewed-stack .card {
  position: absolute;
  top: 0;
  left: 0;
  transition: transform 0.5s ease;
}

/* Ensure cards don't flip horizontally during animation */
@keyframes slideInRight {
  from {
    transform: translate3d(100%, 0, 0);
    visibility: visible;
  }

  to {
    transform: translate3d(0, 0, 0);
  }
}

.top-card {
  z-index: 1000 !important;
}

#main-stack .card,
#viewed-stack .card {
  transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
}

#main-stack .card.sliding {
  transform: translateX(100%);
  opacity: 0;
}

#viewed-stack .card.sliding {
  transform: translateX(-100%);
  opacity: 0;
}

#viewed-stack .card.sliding-in {
  transform: translateX(0);
  opacity: 1;
}

#card-info {
  text-align: center;
  margin-top: 20px;
}

#skip,
#flip-card,
#next-card,
#collect-button,
#view-all-button {
  display: block;
  margin: 20px auto;
}


.glow {
  border-radius: 15px;
  overflow: hidden;
  position: relative;
}

.card.holographic.glow:after {
  content: "";
  top: 0;
  transform: translateX(100%);
  width: 100%;
  height: 100%;
  position: absolute;
  z-index: 3;
  animation: slide 2s infinite;
  opacity: 0.1;
  pointer-events: none;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(128, 186, 232, 0) 99%,
    rgba(125, 185, 232, 0) 100%
  );
}

.binder-cards.glow:after {
  content: "";
  top: 0;
  transform: translateX(100%);
  width: 100%;
  height: 100%;
  position: absolute;
  z-index: 1;
  animation: slide2 3s infinite;
  opacity: 0.1;

  /* 
    CSS Gradient - complete browser support from http://www.colorzilla.com/gradient-editor/ 
    */
  background: -moz-linear-gradient(
    left,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(128, 186, 232, 0) 99%,
    rgba(125, 185, 232, 0) 100%
  ); /* FF3.6+ */
  background: -webkit-gradient(
    linear,
    left top,
    right top,
    color-stop(0%, rgba(255, 255, 255, 0)),
    color-stop(50%, rgba(255, 255, 255, 0.8)),
    color-stop(99%, rgba(128, 186, 232, 0)),
    color-stop(100%, rgba(125, 185, 232, 0))
  ); /* Chrome,Safari4+ */
  background: -webkit-linear-gradient(
    left,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(128, 186, 232, 0) 99%,
    rgba(125, 185, 232, 0) 100%
  ); /* Chrome10+,Safari5.1+ */
  background: -o-linear-gradient(
    left,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(128, 186, 232, 0) 99%,
    rgba(125, 185, 232, 0) 100%
  ); /* Opera 11.10+ */
  background: -ms-linear-gradient(
    left,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(128, 186, 232, 0) 99%,
    rgba(125, 185, 232, 0) 100%
  ); /* IE10+ */
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(128, 186, 232, 0) 99%,
    rgba(125, 185, 232, 0) 100%
  ); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#007db9e8',GradientType=1 ); /* IE6-9 */
}

/* animation */

@keyframes slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}
@keyframes slide2 {
  0% {
    transform: translateX(-150%);
  }
  100% {
    transform: translateX(150%);
  }
}

.trade-summary {
  margin-top: 20px;
  display: flex;
  grid-column: 1/3;
}

#trade-options {
  grid-row: 2;
  grid-column: 1/4;
  display: flex;
}

.trade-option {
  margin-bottom: 10px;
  margin-right: 10px;
}

.execute-trade-button {
  padding: 10px 20px;
  background-color: #008cba;
  border: none;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  height: 3em;
}

.execute-trade-button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.execute-trade-button:hover:not(:disabled) {
  background-color: #005f6b;
}

.circle {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #999;
  vertical-align: middle;
}

.binder-cards {
  position: relative;
  width: 100%;
  perspective: 1000px;
  overflow: hidden;
  border-radius: 13px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    z-index: 2;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 15px;
    z-index: 2;
}

.card.holographic .card-front {
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
}

.card-front {
  transform: rotateY(180deg);
}

.card-stack {
  transform-style: preserve-3d;
}

.card-back {
  background-image: url("images/backofcard.png");
}

.centered-message {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  text-align: center;
}

.animate__flipInY {
  animation-duration: 0.8s;
}

.animate__slideInLeft {
  animation-duration: 0.5s;
}

.count-badge {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 5px;
  font-size: 0.8em;
  border-radius: 3px;
}

.binder-cards img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.rarity-label {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1002;
    width: auto;
    min-width: 80px;
}

.card:hover .rarity-label {
    opacity: 1;
}

.card.animate__animated .rarity-label {
    opacity: 1;
    z-index: 1002;
}

.card.animate__animated {
    pointer-events: none;
}

.card:not(.animate__animated) {
    pointer-events: auto;
}


.binder-cards .rarity-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px;
  text-align: center;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.binder-cards:hover .rarity-label {
  transform: translateY(0);
}

.binder-cards[data-rarity="common"]:hover {
  box-shadow: 0 0 10px 5px #cccccc;
}

.binder-cards[data-rarity="rare"]:hover {
  box-shadow: 0 0 10px 5px #3498db;
}

.binder-cards[data-rarity="epic"]:hover {
  box-shadow: 0 0 10px 5px #9b59b6;
}

.binder-cards[data-rarity="legendary"]:hover {
  box-shadow: 0 0 10px 5px #f1c40f;
}

.binder-cards[data-rarity="megalegendary"]:hover {
  box-shadow: 0 0 10px 5px #e74c3c;
}
.binder-card.holographic:hover::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.5) 50%,
    rgba(255, 255, 255, 0.1) 100%
  );
  z-index: 1;
  pointer-events: none;
}

.sort-container {
  text-align: center;
  margin: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
  padding: 20px;
  margin-top: 90px
}


@media (max-width: 400px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    padding: 5px;
  }
}

  .card-grid .card.common:hover {
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 10px 5px #cccccc;
  border-radius: 15px;
}

.card-grid .card.rare:hover {
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 10px 5px #3498db;
  border-radius: 15px;
}

.card-grid .card.epic:hover {
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 10px 5px #9b59b6;
  border-radius: 15px;
}

.card-grid .card.legendary:hover {
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 10px 5px #f1c40f;
  border-radius: 15px;
}

/* Add these new styles */
@media (max-width: 600px) {
  .card {
    margin-bottom: 10px; /* Add bottom margin to maintain spacing */
    aspect-ratio: unset;
  }

  .card.flipped {
    margin-bottom: 10px; /* Maintain the same margin when flipped */
  }
}

.binder-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  max-width: 1000px;
  margin: 20px auto;
  padding: 15px;
}

#threejs-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Pack Selection Styles */
.pack-selection {
  text-align: center;
  margin: 20px;
}

.pack-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

.pack-animation-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    perspective: 1000px;
    z-index: 1000;
}

.pack-animation-container img,
.pack-animation-container .card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 280px;
    backface-visibility: hidden;
}

.pack {
    position: relative;
    width: 180px;
    height: 100%;
    transform-style: preserve-3d;
}

.pack:hover {
  transform: scale(1.05);
}

.pack img {
  width: 100%;
  border-radius: 10px;
  pointer-events: none;
}

.pack span {
  display: block;
  margin-top: 10px;
  font-size: 1.2em;
  color: #fff;
}

#collect-button,
#flip-button {
  padding: 10px 30px;
  font-size: 1.2em;
  cursor: pointer;
  background-color: #f80;
  color: white;
  border: none;
  border-radius: 4px;
}

#collect-button:hover {
  background-color: #a50;
}

#collect-button:disabled,
#flip-button:disabled {
  background-color: #ddd;
  cursor: not-allowed;
}

/* Message Display */
.message {
  text-align: center;
  margin-top: 20px;
  font-size: 1.1em;
  color: #333;
}

.top-section {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(35, 35, 35, 0.9);
  z-index: 1000;
  padding: 10px 0;
}

.navbar {
  list-style-type: none;
  display: flex;
  flex-wrap: nowrap; /* Prevent wrapping to new line */
  justify-content: center;
  align-items: center;
  padding: 0;
  margin: 10px 0;
}

.navbar a {
  display: inline-block;
  padding: 10px 20px;
  margin: 0 5px;
  background-color: #f80;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  transition: background-color 0.3s;
  white-space: nowrap; /* Prevent text wrapping */
}

.navbar a:hover {
  background-color: #a50;
}

/* Adjust main content to account for fixed header */
.main,
.binder-main {
  margin-top: 210px; /* Adjust this value based on the height of your header */
  padding-top: 20px;
}

.welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.welcome-window {
  background-color: rgba(35, 35, 35, 0.9);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

#magicLinkForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

#magicLinkForm input,
#magicLinkForm button {
  padding: 10px;
  font-size: 16px;
}

#formMessage {
  margin-top: 10px;
  font-weight: bold;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .top-section {
    padding: 5px 0;
  }

  .navbar {
    justify-content: space-around;
  }

  .navbar a {
    padding: 8px 12px;
    font-size: 14px;
    margin: 0 2px; /* Reduce horizontal margin */
  }

  .main,
  .binder-main {
    margin-top: 120px; /* Adjust for smaller screens */
  }
}

@media (max-width: 400px) {
  .navbar a {
    padding: 6px 8px;
    font-size: 12px;
    width: 100px;
    text-align: center;
    margin: 5px;
  }

  .main,
  .binder-main {
    margin-top: 100px; /* Further adjust for very small screens */
  }
}

/* Additional adjustment for very small screens */
@media (max-width: 320px) {
  .navbar a {
    padding: 4px 6px;
    font-size: 10px;
  }
}

/* Market Grid Styles */
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 20px;
}

.market-card {
  border: 2px solid #ccc;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  background-color: #f9f9f9;
  color: #000;
  font-size: 0.7em;
}

.market-card-image {
  width: 100%;
  height: auto;
  border-radius: 5px;
}

.trade-button {
  margin-top: 10px;
  padding: 13px 16px;
  background-color: #f80;
  border: none;
  color: white;
  border-radius: 5px;
  cursor: pointer;
}

.trade-button:hover {
  background-color: #a50;
}

.rendered-cards {
  position: relative;
  width: 200px;
  height: 300px;
  background-size: cover;
  background-position: center;
  border-radius: 15px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.rendered-cards-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
}

/* Responsive Design */

.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 5000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
  display: grid;
  position: relative;
  margin: 5% auto;
  width: 90%;
  max-width: 600px;
  height: 80%;
  max-height: 600px;
  padding: 20px;
}

#trade-modal .modal-content {
  display: grid;
  position: relative;
  margin: 5% auto;
  width: 95%;
  max-width: 600px;
  height: 90%;
  max-height: 967px;
  background-color: #222;
  padding: 15px;
  border-radius: 10px;
}

.close-button:hover,
.close-button:focus {
  color: red;
  text-decoration: none;
}

.modal-card-image {
  width: 100%;
  height: auto;
  border-radius: 5px;
}

.close-button {
  position: absolute;
  top: -40px;
  right: -40px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
}

/* Filters styling */
.filters {
  text-align: center;
  margin: 20px;
  display: flex;
  justify-content: center;
}

.filters label {
  margin-right: 10px;
  color: #fff;
  padding-top: 5px;
}

.filters select {
  margin-right: 20px;
  font-size: 1em;
}

/* Basic styles for authentication forms */
.auth-container {
  max-width: 400px;
  margin: 40px auto;
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.auth-container h2 {
  text-align: center;
  margin-bottom: 20px;
}
.auth-container label {
  display: block;
  margin-bottom: 5px;
}
.auth-container input[type="email"],
.auth-container input[type="text"] {
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  border: 1px solid #ccc;
  border-radius: 5px;
}
.auth-container button {
  width: 100%;
  padding: 10px;
  background-color: #f50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.auth-container button:hover {
  background-color: #a50;
}
.message {
  text-align: center;
  margin-top: 10px;
  font-weight: bold;
}

.card.common:hover {
  transform: scale(1.05);
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 10px 5px #cccccc;
  border-radius: 13px;
}

.card.rare:hover {
  transform: scale(1.05);
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 10px 5px #3498db;
  border-radius: 13px;
}

.card.epic:hover {
  transform: scale(1.05);
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 10px 5px #9b59b6;
  border-radius: 13px;
}

.card.legendary:hover {
  transform: scale(1.05);
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 10px 5px #f1c40f;
  border-radius: 13px;
}

.card .rarity-label {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px;
  text-align: center;
  transition: opacity 0.3s ease;
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 15px;
}

/* Show rarity label on hover */
.card:hover .rarity-label {
  display: block;
  transform: rotateY(180deg);
}

@keyframes tilt-n-move-shaking {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(5px, 5px) rotate(5deg);
  }
  50% {
    transform: translate(0, 0) rotate(0eg);
  }
  75% {
    transform: translate(-5px, 5px) rotate(-5deg);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}

@media (max-width: 1080px) {
  .binder-main {
    margin-top: 300px;
  }

  .navbar a {
    width: 100px;
    text-align: center;
    margin: 5px;
  }

  .card.flipped.common {
    transform: scale(1.05);
    color: rgba(255, 255, 255, 1);
    box-shadow: 0 0 3px 1px #cccccc;
    border-radius: 13px;
  }

  .card.flipped.rare {
    transform: scale(1.05);
    color: rgba(255, 255, 255, 1);
    box-shadow: 0 0 3px 1px #3498db;
    border-radius: 13px;
  }

  .card.flipped.epic {
    transform: scale(1.05);
    color: rgba(255, 255, 255, 1);
    box-shadow: 0 0 3px 1px #9b59b6;
    border-radius: 13px;
  }

  .card.flipped.legendary {
    transform: scale(1.05);
    color: rgba(255, 255, 255, 1);
    box-shadow: 0 0 3px 1px #f1c40f;
    border-radius: 13px;
  }

  /*     .binder-cards[data-rarity="common"] {
        box-shadow: 0 0 3px 1px #cccccc;
    } */

  .binder-cards[data-rarity="rare"] {
    box-shadow: 0 0 3px 1px #3498db;
  }

  .binder-cards[data-rarity="epic"] {
    box-shadow: 0 0 3px 1px #9b59b6;
  }

  .binder-cards[data-rarity="legendary"] {
    box-shadow: 0 0 3px 1px #f1c40f;
  }
}

@media (min-width: 900px) {
  .card-grid,
  .binder-gallery {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
  }
}

@media (max-width: 900px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 45px;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 14px;
  }

  h1 {
    margin-bottom: 10px;
    font-size: 2em;
  }

  .navbar {
    flex-direction: row;
    align-items: stretch;
    margin: 10px;
  }

  .navbar a button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
  }

  #collect-button,
  #flip-button,
  .trade-button,
  .execute-trade-button {
    width: 42%;
    padding: 12px;
    font-size: 16px;
    margin: 5px;
  }

  .binder-gallery {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    padding: 10px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 20px;
    padding: 10px;
  }
  

  .binder-gallery {
    margin-top: 70px;
  }

  .close-button {
    top: 5px;
    right: 5px;
    font-size: 24px;
  }

  .modal-content {
    width: 95%;
    height: 90%;
    margin: 5% auto;
    padding: 15px;
  }

  .count-badge {
    font-size: 0.7em;
    padding: 3px 5px;
  }

  .card.flipped {
    pointer-events: auto;
  }

  #trade-modal .modal-content {
    display: flex;
    position: relative;
    margin: 5% auto;
    width: 80%;
    max-width: 600px;
    height: 100%;
    max-height: 967px;
    background-color: #222;
    padding: 2em;
    border-radius: 10px;
    flex-direction: column;
    overflow: scroll;
  }

  .image-container {
    width: 100%;
  }

  .card-grid {
    margin-top: 70px;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filters label,
  .filters select {
    width: 100%;
  }

  .binder-selection .binder-card input {
    width: 90%;
  }

  .binder-main {
    margin-top: 250px;
  }

  #loginStatus {
    text-align: center;
    top: 0;
  }

  .rendered-cards {
    width: 150px;
    height: 250px;
  }

  #collect-button {
    margin:0 auto;
    padding: 6px 8px;
  }
}

#loginButton{
  position:fixed;
  top:10px;
  right:15px;
  padding: 10px 25px;
  display: block;
}

/* Additional optimizations for very small screens */
@media (max-width: 400px) {
  body {
    font-size: 12px;
  }

  button {
    font-size: 14px;
    padding: 10px;
  }

  h1 {
    font-size: 2em;
  }

  .binder-gallery {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 7px;
  }

  .rendered-cards {
    width: 100px;
    height: 150px;
  }

  #collect-button {
    margin:0 auto;
    padding: 6px 8px;
  }

  .navbar a button {
    font-size: 14px;
    padding: 10px;
  }

  .modal-content {
    padding: 10px;
  }

  .close-button {
    font-size: 50px;
  }
}

/* Ensure touch targets are large enough */
button,
input[type="checkbox"],
select,
.close-button {
  min-height: 44px;
  min-width: 44px;
}

/* Improve form element spacing */
input,
select,
textarea {
  margin-bottom: 15px;
}

/* Ensure all interactive elements have hover and focus states */
button:hover,
input:hover,
select:hover,
textarea:hover,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #f80;
}

/* Improve readability */
body {
  line-height: 1.6;
}

/* Ensure proper spacing for better touch interaction */
.card,
.binder-card,
.market-card {
  margin-bottom: 15px;
}

/* Optimize images for mobile */
img {
  max-width: 100%;
  height: auto;
}


@supports (overscroll-behavior: auto) {
  body {
    overscroll-behavior: auto;
  }
}

/* Disable hover effects on mobile */
@media (hover: none) {
  .binder-cards:hover .rarity-label {
    transform: translateY(0);
  }

  .binder-cards[data-rarity="common"]:hover {
    box-shadow: 0 0 10px 5px #cccccc;
  }

  .binder-cards[data-rarity="rare"]:hover {
    box-shadow: 0 0 10px 5px #3498db;
  }

  .binder-cards[data-rarity="epic"]:hover {
    box-shadow: 0 0 10px 5px #9b59b6;
  }

  .binder-cards[data-rarity="legendary"]:hover {
    box-shadow: 0 0 10px 5px #f1c40f;
  }

  .binder-cards[data-rarity="megalegendary"]:hover {
    box-shadow: 0 0 10px 5px #e74c3c;
  }

  .card:not(.flipped):hover {
    animation: none;
  }

  .card.flipped:hover {
    transform: none;
    box-shadow: none;
  }
}

.login-section {
  text-align: center;
  margin: 20px auto;
  max-width: 300px;
}

.login-section input,
.login-section button {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 10px;
}

#loginMessage {
  margin-top: 10px;
  font-weight: bold;
}


.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.overlay-content {
  background-color: rgba(35, 35, 35, 0.9);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  max-width: 300px;
  width: 100%;
}

.overlay-content input,
.overlay-content button {
  display: block;
  margin: 0 auto;
  padding: 10px;
}

.welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.welcome-window {
  background-color: rgba(35, 35, 35, 0.9);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.welcome-window button {
  margin-top: 20px;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.overlay-content {
  background-color: rgba(35, 35, 35, 0.9);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  margin: 0 auto;
}

#loginForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

#loginForm input,
#loginForm button {
  padding: 10px;
  font-size: 16px;
}

#loginMessage {
  margin-top: 10px;
  font-weight: bold;
}

.login-status {
  position: fixed;
  top: 10px;
  right: 10px;
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 14px;
  z-index: 1000;
  height: 30px;
}

@media (max-width: 768px) {
  .login-status {
    top: auto;
    bottom: 10px;
    right: 50%;
    transform: translateX(50%);
    font-size: 12px;
    padding: 4px 8px;
    white-space: nowrap;
  }
}

.custom-alert-modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.custom-alert-content {
  background-color: rgba(35, 35, 35, 0.9);
  padding: 20px;
  border-radius: 5px;
  text-align: center;
  max-width: 80%;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.custom-alert-content h2 {
  color: #fff;
  margin-top: 0;
}

.custom-alert-content p {
  color: #fff;
  margin-bottom: 20px;
}

.custom-alert-content button {
  background-color: #f80;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 16px;
}

.custom-alert-content button:hover {
  background-color: #a50;
}

.toaster {
  position: fixed;
  top: 10px; /* Changed from 60px to 10px */
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.toaster.show {
  opacity: 1;
}

@media (max-width: 768px) {
  .toaster {
    top: 5px; /* Adjusted for mobile */
    font-size: 12px;
    padding: 8px 16px;
    max-width: 90%;
  }
}

#clear-binder-button {
  display: none;
}

.new-indicator {
  position: absolute;
  top: 5px;
  left: 5px;
  background-color: #ff4500;
  color: white;
  padding: 2px 5px;
  font-size: 0.8em;
  border-radius: 3px;
  z-index: 1;
}

#back-to-top {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99;
  border: none;
  outline: none;
  background-color: #f80;
  color: white;
  cursor: pointer;
  padding: 15px;
  border-radius: 50%;
  font-size: 18px;
  transition: opacity 0.3s;
}

#back-to-top:hover {
  background-color: #a50;
}

@media (max-width: 768px) {
  #back-to-top {
    bottom: 15px;
    right: 15px;
    padding: 10px;
    font-size: 16px;
  }
}

.pack-wrapper {
    position: absolute;
    width: 180px; /* Fixed width */
    height: 250px; /* Fixed height to maintain aspect ratio */
    transform-style: preserve-3d;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    perspective: 1000px;
}



.pack-front, .pack-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 15px;
    background-color: #fff; /* Add background color to ensure visibility */
}

.pack-back {
    transform: rotateY(180deg);
}

#card-stack-container {
    position: relative;
    width: 180px;
    height: 250px;
    margin: 20px auto;
    perspective: 1000px;
}

#card-stack-container .card {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: translateZ(var(--depth));
    transition: transform 0.3s ease;
}

#card-stack-container .card:not(.animate__animated) {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: translateZ(var(--depth));
    transition: transform 0.3s ease;
}

.card-stack {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}


.card-stack {
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Update the rarity label styles for cards in the card grid */
.card-grid .card .rarity-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1002;
    width: auto;
    min-width: 90%;
}

/* Show rarity label on hover only for revealed cards */

/* Ensure rarity label is visible and correct in the card grid */
.card-grid .card .rarity-label {
    display: block;
    transform: translateX(-50%);
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
}

.card-grid .card:hover .rarity-label {
    opacity: 1;
}

/* Prevent hover effects before card is revealed */
.card:not([data-revealed="true"]) {
    pointer-events: none;
}

.card:not([data-revealed="true"]):hover .rarity-label,
.card:not([data-revealed="true"]).holographic.glow:after {
    display: none;
}

/* Update card hover behavior */
.card {
    perspective: 1000px;
    cursor: default; /* Default to no pointer cursor */
}

/* Enable hover effects only when flip button is active */
.card[data-flippable="true"] {
    cursor: pointer;
    pointer-events: auto;
}

/* Update holographic card structure */
.card.holographic {
    transform-style: preserve-3d;
}

.card.holographic .card-front {
    transform: rotateY(180deg);
    z-index: 2;
}

.card.holographic .card-back {
    transform: rotateY(0deg);
    z-index: 1;
}

/* Update glow effect to work with card faces */
.card.holographic.glow:after {
    content: "";
    top: 0;
    transform: translateX(100%);
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 3;
    animation: slide 2s infinite;
    opacity: 0.1;
    pointer-events: none;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(128, 186, 232, 0) 99%,
        rgba(125, 185, 232, 0) 100%
    );
}

/* Ensure proper flipping behavior */
.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card.flipped .card-front {
    z-index: 2;
}

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



/* Show rarity label on hover for flippable cards */
.card[data-flippable="true"]:hover .rarity-label {
    opacity: 1;
    display: block;
}

/* Ensure rarity label is visible in the card grid */
.card-grid .card .rarity-label {
    display: block;
    transform: translateX(-50%);
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
}

/* Fix rarity label orientation for flipped cards */
.card.flipped .rarity-label {
    transform: translateX(-50%) rotateY(180deg);
}

/* Prevent hover effects before card is flippable */
.card:not([data-flippable="true"]) .rarity-label {
    display: none;
}

/* Special handling for holographic cards */
.card.holographic .rarity-label {
    z-index: 1003; /* Ensure it's above the glow effect */
}

/* Base mobile-first styles (no media query needed) */
body {
    font-size: 14px;
    padding: 20px;
    /* ... other base styles ... */
}

/* Media query for tablets (600px - 900px) */
@media (min-width: 600px) {
    body {
        font-size: 16px;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 20px;
    }

    .binder-gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .rendered-cards {
        width: 150px;
        height: 250px;
    }

    .navbar a {
        padding: 8px 12px;
        font-size: 14px;
        margin: 0 5px;
    }

    .main,
    .binder-main {
        margin-top: 200px;
    }
}

/* Media query for desktop (900px and above) */
@media (min-width: 900px) {
    .card-grid,
    .binder-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }

    .rendered-cards {
        width: 200px;
        height: 300px;
    }

    .navbar a {
        padding: 10px 20px;
        font-size: 16px;
    }
}

/* Touch device specific styles */
@media (hover: none) {
    /* Disable all hover effects */
    .card:hover,
    .binder-cards:hover,
    .card.holographic.glow:after {
        transform: none;
        box-shadow: none;
        animation: none;
    }

    /* Modal specific adjustments for touch devices */
    .modal-content {
        width: 95%;
        height: 90%;
        margin: 5% auto;
        padding: 15px;
        overflow-y: auto;
    }
}

/* Small screen specific adjustments */
@media (max-width: 400px) {
    body {
        font-size: 12px;
    }

    .rendered-cards {
        width: 100px;
        height: 150px;
    }

    .navbar a {
        padding: 6px 8px;
        font-size: 12px;
        width: 100px;
    }
}

.login-close-button {
    background-color: transparent; /* Transparent background */
    border: none; /* No border */
    color: #fff; /* White color for the text */
    font-size: 24px; /* Font size */
    cursor: pointer; /* Pointer cursor on hover */
    position: absolute; /* Position it in the top right corner */
    top: 10px; /* Distance from the top */
    right: 10px; /* Distance from the right */
    transition: color 0.3s; /* Smooth color transition */
}

.login-close-button:hover {
    color: #ff0000; /* Change color on hover (red) */
}

.login-close-button:focus {
    outline: none; /* Remove outline on focus */
}
