/* ============================================================================
   Top Up Credits — a full-screen overlay opened from the account dropdown and
   removed on ← BACK (topup.js). It opens from the header on EVERY page, so these
   rules are global (loaded in base.html), not per-page.
   ============================================================================ */

/* The scrim: a near-opaque dark cover over the whole app (the header + arcade
   background stay mounted underneath but are obscured). Scrolls if tall. Closed
   ONLY by the ← BACK button — no backdrop-click, no Escape, so a purchase screen
   is never dismissed by accident. */
.topup-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  overflow-y: auto;
  background: rgba(7, 6, 20, .94);
  backdrop-filter: blur(4px);
  animation: topup-rise .2s ease both;
}

/* The centred content column. */
.topup-inner {
  min-height: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 60px;
}

/* ← BACK sits at the top-left of the column (the only close control). */
.topup-back { align-self: flex-start; }

/* Bobbing coin above the heading (reuses the global coin-bob keyframes). */
.topup-coin {
  display: inline-flex;
  margin: 26px 0 6px;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .45));
  animation: coin-bob 2.4s ease-in-out infinite;
}
.topup-coin .coin-icon { width: 46px; height: 46px; }

.topup-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(15px, 5.5vw, 24px);
  color: var(--color-gold);
  text-shadow: 3px 3px 0 #7a5200;
  margin: 14px 0 6px;
}
.topup-balance {
  text-align: center;
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--color-muted);
  margin: 0 0 6px;
}
.topup-balance-count { color: var(--color-gold); }
.topup-subtext {
  text-align: center;
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--color-faint);
  margin: 0 0 30px;
}

/* Responsive pack grid — cards reflow from four across down to one. */
.topup-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
}

/* One pack card (a button, so it's clickable + keyboard-focusable). Clicking it
   toggles .is-selected (topup.js) → gold border + glow. Hover lifts it. */
.pack-card {
  position: relative;
  cursor: pointer;
  text-align: center;
  padding: 22px 14px 18px;
  background: var(--color-ink);
  border: 3px solid var(--color-line);
  box-shadow: 6px 7px 0 rgba(0, 0, 0, .5);
  transition: transform .1s;
  appearance: none;
}
.pack-card:hover { transform: translateY(-3px); }
.pack-card.is-selected {
  background: #1a1642;
  border-color: var(--color-gold);
  box-shadow: 0 0 18px rgba(255, 210, 63, .4), 6px 7px 0 rgba(0, 0, 0, .5);
}
.pack-coins {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--color-gold);
  text-shadow: 2px 2px 0 #7a5200;
}
.pack-coins-word {
  display: block;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--color-muted-2);
  margin: 4px 0 14px;
}
.pack-price {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--color-green);
}
/* The tag badge straddles the top border: green by default, gold for BEST VALUE. */
.pack-tag {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--color-ink);
  background: var(--color-green);
  border: 2px solid var(--color-ink);
  padding: 4px 7px;
}
.pack-tag-best { background: var(--color-gold); }

/* BUY button — full width inside a centred wrapper; the .btn system supplies the
   gold fill + the disabled (grey) state, so no custom button styling here. */
.topup-buy-form {
  width: 100%;
  max-width: 420px;
  margin: 32px auto 0;
}
.topup-demo {
  text-align: center;
  font-family: var(--font-body);
  font-size: 15px;
  color: #4f4b86;
  margin: 18px 0 0;
}

/* Inline error line above the BUY form — one gentle, centred sentence when a buy couldn't start
   (mirrors .auth-error). */
.topup-error {
  margin: 24px 0 -8px;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.3;
  text-align: center;
  color: var(--color-pink-light);
}

/* ---- Purchase history ---- */
.topup-history { width: 100%; margin: 44px 0 0; }
.topup-history-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.topup-history-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--color-cyan);
  text-shadow: 2px 2px 0 #0f5f70;
  white-space: nowrap;
}
.topup-history-rule { flex: 1; height: 2px; background: #2a2758; }

/* The table panel scrolls horizontally on narrow screens (the table keeps a
   min width so the columns never crush). */
.topup-history-panel {
  background: var(--color-panel);
  border: 3px solid var(--color-line);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, .5);
  padding: 20px 18px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.topup-history-table {
  width: 100%;
  min-width: 440px;
  border-collapse: collapse;
}
.topup-history-table th {
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--color-faint);
  padding: 0 14px 12px;
  border-bottom: 2px dashed var(--color-line);
}
.topup-history-table th.th-left { text-align: left; }
.topup-history-table th.th-right { text-align: right; }
.topup-history-table td {
  font-family: var(--font-body);
  font-size: 17px;
  padding: 12px 14px;
  border-bottom: 2px solid var(--color-line);
}
.topup-history-table tr.row-even { background: rgba(255, 255, 255, .02); }
.td-date { color: var(--color-muted-2); white-space: nowrap; }
.td-pack { color: var(--color-text-dim); letter-spacing: .5px; }
.td-coins {
  text-align: right;
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--color-gold);
  white-space: nowrap;
}
.td-paid { text-align: right; color: var(--color-green); white-space: nowrap; }
.td-status { text-align: right; }
.paid-pill {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 7px;
  letter-spacing: 1px;
  color: var(--color-green);
  background: rgba(62, 240, 139, .12);
  border: 2px solid var(--color-green-shadow);
  padding: 4px 7px;
}
.topup-history-empty {
  text-align: center;
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--color-faint);
  background: var(--color-panel);
  border: 3px solid var(--color-line);
  padding: 30px 20px;
  margin: 0;
}

/* The overlay's rise-in: it slides up a touch and fades in as it opens. */
@keyframes topup-rise {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .topup-overlay { animation: none; }
  .topup-coin { animation: none; }
}

/* Small screens: tighten the padding and shrink the coin; the grid + history
   scroll handle the rest. */
@media (max-width: 560px) {
  .topup-inner { padding: 32px 16px 48px; }
  .topup-coin .coin-icon { width: 34px; height: 34px; }
}
