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;
  margin-bottom: 8px;
}

#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;
}

/* ---- Add Card Panel ---- */
.add-card-panel {
  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 ---- */
.tabs {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 16px;
  scrollbar-width: none;
  overflow-x: visible !important; /* allow outer glow to show */
  overflow-y: visible !important;
}

.tabs::-webkit-scrollbar {
  display: none;
}

/* Base tab */
.tab {
  flex-shrink: 0;
  padding: 8px 14px;
  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); /* subtle glass effect */
}

/* ACTIVE TAB — THICK GOLD OUTER GLOW */
.tab.active {
  font-weight: 700;
  border-color: #d4af37; /* gold border */
  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="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;
}

.own-toggle label {
  display: flex;
  align-items: center;
  gap: 0px;
  cursor: pointer;
  font-size: 12px;
  margin-left: -8px;
}

.own-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #0a7be7;
}

.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-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #ffffff;
  border-radius: 12px;
  max-width: 900px;
  width: 95%;
  max-height: 90vh;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  gap: 16px;
  overflow: hidden;
}

.modal-image {
  flex: 0 0 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e6ecf5;
  border-radius: 10px;
}

.modal-image img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.modal-info {
  flex: 1 1 auto;
  font-size: 14px;
  overflow-y: auto;
  position: relative;
}

.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;
}

.modal-close-btn {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 34px;
  font-weight: 700;
  line-height: 34px;
  border: none;
  background: none;
  cursor: pointer;
  color: #444;
  text-shadow: 0 0 4px rgba(255,255,255,0.8);
  z-index: 20;
}

.modal-close-btn:hover {
  color: #000;
  transform: scale(1.15);
}

@media (max-width: 640px) {
  .modal {
    flex-direction: column;
    max-height: 95vh;
  }

  .modal-image {
    flex: 0 0 auto;
  }
}
