body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f7fb;
  margin: 0;
  padding: 12px;
}

h1 {
  margin-bottom: 6px;
  font-size: 22px;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 8px;
}

.top-bar h1 {
  font-size: 20px;
  margin: 0;
  margin-right: 8px;
}

.top-bar .status {
  font-size: 13px;
  color: #444;
}

/* Buttons (Admin / Edit / Swap) */
.top-bar button,
.top-bar .pill {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 999px;
  line-height: 1;
}

/* Reduce visual weight */
.top-bar button {
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
}

.top-bar .primary {
  background: #1677ff;
  color: #fff;
  border-color: #1677ff;
}

#summary {
  font-weight: bold;
  font-size: 14px;
}

#error {
  color: #c0392b;
  margin-bottom: 10px;
  font-size: 13px;
  display: none;
}

.btn {
  border-radius: 999px;
  border: none;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.btn-primary {
  background: #0a7be7;
  color: #ffffff;
}

.btn-secondary {
  background: #e0e4ec;
  color: #333;
}

.admin-btn.active {
  background: #2ecc71;
  border-color: #2ecc71;
  color: #fff;
}


/* ---- Add Card Panel ---- */
.add-card-panel {
  display: none;   /* HIDE BY DEFAULT */
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  margin-bottom: 16px;
  padding: 10px 10px 12px;
}


.add-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.add-card-header h2 {
  font-size: 16px;
  margin: 0;
}

.add-card-toggle {
  border: none;
  background: #0a7be7;
  color: #ffffff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.add-card-form {
  margin-top: 10px;
  display: none;
  gap: 8px;
  flex-direction: column;
  font-size: 13px;
}

.add-card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.add-card-field {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.add-card-field label {
  font-size: 12px;
  color: #444;
}

.add-card-field input,
.add-card-field select {
  font-size: 13px;
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid #c2cada;
  width: 100%;
  box-sizing: border-box;
}

.add-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  gap: 8px;
}

.add-card-message {
  margin-top: 4px;
  font-size: 12px;
  color: #27ae60;
  display: none;
}

/* ---- Tabs ---- */
/* Scroll container (handles scrolling) */
.tabs-wrapper {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;          /* let glow go up/down */
  -webkit-overflow-scrolling: touch;
  margin: -18px -12px 12px;         /* align with body padding */
  padding: 15px 17px;           /* <-- room above & below for glow */
  max-width: 100%;
  box-sizing: border-box;
}

.tabs-wrapper::-webkit-scrollbar {
  display: none;
}

/* Actual tab row */
.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  white-space: nowrap;
  overflow: visible;            /* glow can extend outside pills */
}

/* Reduce vertical spacing between tab rows */
.tabs-wrapper {
  margin-bottom: 6px;   /* was likely 12–16px */
}

/* Remove margin on the last tabs row */
.tabs-wrapper:last-of-type {
  margin-bottom: 0;
}
.tabs-set {
  margin-top: -4px;
}

/* Base tab */
.tab {
  flex: 0 0 auto;
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #c2cada;
  background: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  color: #000;
  backdrop-filter: blur(4px);
}

/* ACTIVE TAB — gold outer glow */
.tab.active {
  font-weight: 600;
  border-color: #d4af37;
  box-shadow:
    0 0 4px 2px rgba(212, 175, 55, 0.6),
    0 0 8px 3px rgba(212, 175, 55, 0.5),
    0 0 14px 6px rgba(218, 165, 32, 0.45);
}



/* --- SOFT COLOR TABS --- */
.tab[data-color="red"] {
  background: rgba(231, 76, 60, 0.35);
  border-color: rgba(192, 57, 43, 0.4);
  color: #5a0c0c;
}

.tab[data-color="yellow"] {
  background: rgba(241, 196, 15, 0.35);
  border-color: rgba(212, 172, 13, 0.4);
  color: #6b5505;
}

.tab[data-color="green"] {
  background: rgba(46, 204, 113, 0.35);
  border-color: rgba(39, 174, 96, 0.4);
  color: #0f4a26;
}

.tab[data-color="blue"] {
  background: rgba(52, 152, 219, 0.35);
  border-color: rgba(46, 134, 193, 0.4);
  color: #093a56;
}

.tab[data-color="purple"] {
  background: rgba(155, 89, 182, 0.35);
  border-color: rgba(136, 78, 160, 0.4);
  color: #3f1551;
}

.tab[data-color="black"] {
  background: rgba(52, 73, 94, 0.35);
  border-color: rgba(44, 62, 80, 0.4);
  color: #1d2227;
}

/* --- SOFT RAINBOW MIX TAB --- */
.tab[data-color="mix"] {
  background: linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.35),
    rgba(255, 165, 0, 0.35),
    rgba(255, 255, 0, 0.35),
    rgba(0, 255, 0, 0.35),
    rgba(0, 128, 255, 0.35),
    rgba(75, 0, 130, 0.35),
    rgba(238, 130, 238, 0.35)
  );
  border: 1px solid rgba(180, 180, 180, 0.4);
  color: white;
  font-weight: 600;
}

/* Unchanged tabs */
.tab[data-color="all"],
.tab[data-color="leader"],
.tab[data-color="event"],
.tab[data-color="stage"],
.tab[data-color="don"] {
  background: rgba(255, 255, 255, 0.6);
  color: #000;
  border: 1px solid #c2cada;
}

/* ---- Responsive grid ---- */
.card-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

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

.card {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 4px solid transparent;
}

.card[data-color="red"]    { border-top-color: #e74c3c; }
.card[data-color="yellow"] { border-top-color: #f1c40f; }
.card[data-color="green"]  { border-top-color: #2ecc71; }
.card[data-color="blue"]   { border-top-color: #3498db; }
.card[data-color="purple"] { border-top-color: #9b59b6; }
.card[data-color="black"]  { border-top-color: #34495e; }
.card[data-color="mix"]    { border-top-color: #34495e; }

.card[data-type="don"] {
  border: 4px solid transparent;
  border-radius: 10px;
  border-image: linear-gradient(
    135deg,
    #d4af37,
    #f5d76e,
    #fff6d1,
    #f5d76e,
    #d4af37
  ) 1;
  padding: 8px;
}

.card[data-type="leader"] {
  border: 4px solid transparent;
  border-image: linear-gradient(
    90deg, red, orange, yellow, green, blue, indigo, violet
  ) 1;
  padding: 8px;
}

.card.swap-selected {
  outline: 3px solid #f1c40f;
  outline-offset: 2px;
}

.card-image {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  background: #e6ecf5;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-info {
  font-size: 14px;
}

.card-name {
  font-weight: 600;
  font-size: 14px;
}

.card-code {
  color: #555;
  font-size: 12px;
  margin-top: 2px;
}

.card-obtain {
  color: #777;
  font-size: 12px;
  margin-top: 2px;
  font-style: italic;
}

.card-price {
  color: #e67300;
  font-weight: 600;
  font-size: 13px;
  margin-top: 4px;
}

.card-sgd-price {
  color: #555;
  font-size: 12px;
  margin-top: -2px;
}

.card-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
}

.counter {
  display: flex;
  align-items: center;
  gap: 6px;
}

.counter button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: #0a7be7;
  color: white;
  font-size: 18px;
  line-height: 0;
  cursor: pointer;
}

.counter.disabled button {
  background: #c0c6d1;
  cursor: not-allowed;
}

.counter span {
  min-width: 20px;
  text-align: center;
  font-size: 14px;
}

/* ---------- Modal (big card view) ---------- */

/* ---------- Modal (big card view) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none; /* shown by JS */
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  position: relative;               /* ✅ anchor close button to modal */
  background: #ffffff;
  border-radius: 12px;
  width: min(900px, 95vw);
  max-height: 90vh;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  gap: 16px;
  overflow: hidden;                 /* ✅ keep close button stable */
}

/* Left image panel (desktop) */
.modal-image {
  flex: 0 0 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e6ecf5;
  border-radius: 10px;
  padding: 12px;
}

.modal-image img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
}

/* Right info panel */
.modal-info {
  flex: 1 1 auto;
  font-size: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 16px;

  position: static;                 /* ✅ IMPORTANT: so close button is NOT anchored here */
}

.modal-info h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.modal-info .modal-code {
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
}

.modal-info .modal-line {
  margin-bottom: 4px;
}

.modal-info .modal-price {
  margin-top: 8px;
  font-weight: 600;
  color: #e67300;
}

/* ✅ Close button stays top-right of the modal (doesn't scroll with info) */
.modal-close-btn {
  position: absolute;               /* anchored to .modal (position:relative) */
  top: 10px;
  right: 10px;
  z-index: 30;

  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  font-size: 26px;
  line-height: 38px;
  cursor: pointer;
}

.modal-close-btn:hover {
  background: rgba(0,0,0,0.7);
  transform: scale(1.05);
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .modal {
    flex-direction: column;
    width: 94vw;
    max-height: 92vh;
  }

  .modal-image {
    flex: 0 0 auto;
    padding: 10px 10px 0;
    border-radius: 0;
  }

  .modal-image img {
    width: 100%;
    max-width: 320px;               /* ✅ smaller image on phone */
    max-height: 36vh;               /* ✅ prevents giant image */
    border-radius: 12px;
  }

  .modal-info {
    padding: 12px 14px 16px;
  }
}

@media (max-width: 480px) {
  .modal-image img {
    max-width: 280px;
    max-height: 32vh;
  }
}



/* Prevent background scroll when modal is open */
body.modal-open {
  overflow: hidden;
  touch-action: none; /* important for mobile */
}



/* ===== Fixed bottom pagination bar (clean) ===== */
#pagination{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;

  margin: 0 !important;
  width: 100%;
  box-sizing: border-box;

  background: rgba(245, 247, 252, 0.97);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 -6px 16px rgba(0,0,0,0.08);

  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

/* keep page content above the bar */
body{
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}



/* Make buttons consistent */
#pagination button {
  border: 1px solid rgba(0,0,0,0.12);
  background: #ffffff;
  color: #111;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
}

#pagination button:disabled {
  opacity: 0.45;
}

/* Page label */
#pagination .page-label,
#pagination span {
  color: #111;
  font-weight: 600;
}


