/* ---------- Base ---------- */
body {
  font-family: Arial, sans-serif;
  text-align: center;
  background: linear-gradient(135deg, #222, #003366);
  margin: 0;
  padding: 0;
  position: relative;
  min-height: 100vh;
  color: #fff;
}

button {
  font-family: inherit;
}

/* ---------- Controls ---------- */
#controls {
  margin-top: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 0 16px;
}
#controls.centered {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin-top: 0;
  width: 100%;
  box-sizing: border-box;
}

#crack-btn,
#bottom-btn,
#retry-btn {
  padding: 15px 30px;
  font-size: 20px;
  cursor: pointer;
  border: none;
  background-color: #007acc;
  color: #fff;
  border-radius: 8px;
  transition: background-color 0.3s ease;
}
#crack-btn {
  min-width: 300px;
}
#crack-btn:hover,
#bottom-btn:hover,
#retry-btn:hover {
  background-color: #005fa3;
}
#crack-btn:disabled {
  background-color: #555;
  cursor: not-allowed;
}
#bottom-btn {
  margin: 40px auto 60px auto;
  display: block;
}
#bottom-btn[hidden] {
  display: none;
}
#retry-btn {
  padding: 8px 16px;
  font-size: 16px;
  margin-left: 10px;
}

#set-select,
#product-select {
  padding: 10px;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  max-width: 90vw;
}
#product-select:disabled {
  opacity: 0.75;
}

/* Status line: loading progress or an error message. */
#status {
  flex-basis: 100%;
  margin: 0;
  min-height: 1.4em;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
}
#status.error {
  color: #ffb3b3;
}

/* Pack value pill */
#pack-value {
  display: inline-block;
  margin: 24px auto 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 15px;
}
#pack-value[hidden] {
  display: none;
}

/* ---------- Pack grid ---------- */
@media (min-width: 801px) {
  #pack-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(256px, 1fr));
    gap: 20px;
    justify-items: center;
    justify-content: center;
    max-width: 1360px;
    margin: 20px auto;
  }
}
@media (max-width: 800px) {
  #pack-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: 20px auto;
  }
}

/* ---------- Cards ---------- */
.card {
  box-sizing: border-box;
  margin: 10px;
  width: 256px;
  border-radius: 8px;
  overflow: hidden;
  background-color: #fff;
  transition: transform 0.2s ease;
  opacity: 0;
  cursor: pointer;
  position: relative;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.card img {
  width: 100%;
  max-width: 256px;
  height: auto;
  display: block;
}
.card:hover {
  transform: scale(1.05);
}

/* Foil: a faint warm sheen at rest, a full flare while the card is tilted. */
.foil::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, transparent, rgba(218, 165, 32, 0.35), transparent);
  opacity: var(--foil-opacity, 0.35);
  transition: opacity 0.2s ease;
  pointer-events: none;
}
/* Badge strip: treatment, origin sheet and special frames. */
.badges {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  pointer-events: none;
}
.badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-foil { color: #ffd76a; }
.badge-guest { color: #ff9ad5; }
.badge-bonus { color: #8ad7ff; }
.badge-fun { color: #b8f5c0; }

/* ---------- Credit ---------- */
#karpi-credit {
  position: fixed;
  bottom: 10px;
  right: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 14px;
}
#karpi-credit a {
  text-decoration: none;
  color: #fff;
}
#karpi-credit a:hover {
  text-decoration: underline;
}

/* ---------- Modal ---------- */
#modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  overflow: hidden;
  touch-action: pan-y;
}
#modal-overlay[hidden] {
  display: none;
}
#modal-card-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal-card {
  margin: 0;
  padding: 10px;
  position: relative;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease;
}
.modal-card img {
  display: block;
  max-width: min(90vw, 488px);
  max-height: 85vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
}
.modal-card.foil::after {
  inset: 10px;
  border-radius: 12px;
}
.modal-card.swipe-left {
  transform: translateX(-150%) rotate(-10deg);
  opacity: 0;
}
.modal-card.swipe-right {
  transform: translateX(150%) rotate(10deg);
  opacity: 0;
}
.modal-card.enter-from-left {
  transform: translateX(-150%) rotate(-10deg);
  opacity: 0;
  transition: none;
}
.modal-card.enter-from-right {
  transform: translateX(150%) rotate(10deg);
  opacity: 0;
  transition: none;
}
.modal-hint {
  position: absolute;
  bottom: -28px;
  left: 0;
  right: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

.modal-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 48px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.7);
  background: none;
  border: none;
  cursor: pointer;
  user-select: none;
  z-index: 1001;
  padding: 20px;
  transition: color 0.2s ease, transform 0.2s ease;
}
.modal-nav-arrow:hover,
.modal-nav-arrow:focus-visible {
  color: #fff;
  transform: translateY(-50%) scale(1.2);
  outline: none;
}
.modal-nav-arrow:disabled {
  opacity: 0.25;
  cursor: default;
  transform: translateY(-50%);
}
.modal-nav-arrow.left {
  left: 20px;
}
.modal-nav-arrow.right {
  right: 20px;
}

/* ---------- Mobile ---------- */
@media (max-width: 800px) {
  .modal-nav-arrow {
    font-size: 36px;
    padding: 15px;
  }
  .modal-nav-arrow.left {
    left: 5px;
  }
  .modal-nav-arrow.right {
    right: 5px;
  }
  #crack-btn {
    padding: 20px 40px;
    font-size: 24px;
    min-width: 0;
    width: 100%;
    max-width: 360px;
  }
  #set-select,
  #product-select {
    font-size: 18px;
  }
  .card {
    width: 90%;
    max-width: none;
  }
  .card img {
    max-width: none;
  }
  .card:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .modal-card {
    transition: none !important;
  }
}
