/* ============================================================
   NUSA88 / v4 — production stylesheet for the member portal.

   Token model:
     • New NUSA88 tokens (--bg, --surface, --primary, --primary-grad, etc.)
       are the source of truth. They are set by the active theme file
       (theme-<name>.css) loaded after this stylesheet.
     • Legacy v3 token names (--primary-color, --body-background, etc.)
       are aliased to the NUSA88 tokens at the bottom of this file so
       any inherited shared partials (lottery cards, etc.) keep working.

   Default theme: midnight-gold (mapped from v3's "topaz"/"citrine"/etc.)
   ============================================================ */

:root {
  /* Base canvas */
  --bg: #07090d;
  --bg-2: #0c1118;
  --surface: #131923;
  --surface-2: #1b2330;
  --line: rgba(255,255,255,0.06);
  --line-2: rgba(255,255,255,0.10);
  /* Legacy aliases — some inline styles use --border / --bg-soft (NUSA88
     vocabulary borrowed from v3). Aliasing instead of refactoring all callers
     keeps the existing token model authoritative while preventing border-color
     from falling back to currentColor on dark themes. */
  --border: var(--line-2);
  --bg-soft: var(--surface);

  /* Accent (gold default) */
  --primary: #e8b65a;
  --primary-2: #c8902f;
  --primary-soft: rgba(232,182,90,0.12);
  --primary-grad: linear-gradient(180deg, #f1c876 0%, #b67d20 100%);
  --primary-ink: #1a1308;       /* readable foreground over --primary */

  /* Secondary (teal) */
  --accent: #36c2b4;
  --accent-2: #1d8e83;

  /* Status */
  --success: #4ade80;
  --warn: #f5b942;
  --danger: #f06262;

  /* Text */
  --text: #f3f4f6;
  --text-dim: #9aa3b2;
  --text-mute: #6b7280;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --font-display: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.35);
  --shadow-2: 0 1px 0 rgba(255,255,255,0.06) inset, 0 16px 40px rgba(0,0,0,0.55);

  --shell-max: 1440px;
  --running-text-durasi: 40s;
}

/* ===== legacy v3 token aliases (so shared partials keep rendering) ===== */
:root {
  --primary-color:           var(--primary);
  --heading-color:           var(--primary);
  --body-background:         var(--bg);
  --body-color:              var(--text);
  --header-background:       var(--bg-2);
  --header-menu-color:       var(--text);
  --running-text-background: var(--surface);
  --running-text-color:      var(--text-dim);
  --gamemenu-background:     linear-gradient(180deg, var(--bg-2), var(--surface));
  --btn-game-background:     var(--surface);
  --result-box-background:   var(--surface);
  --result-ball-background:  var(--primary-grad);
  --top-ten-background:      var(--surface);
  --metode-pembayaran-background: var(--bg-2);
  --footer-background:       var(--bg-2);
  --btn-bottom-background:   var(--surface-2);
  --promo-card-background:   var(--surface);
  --pagination-background:   var(--surface);
  --provider-menu-background: var(--surface);
  --product-background:      var(--surface);
  --placebet-background:     var(--accent-2);
  --button-daftar-background: var(--primary-grad);
  --button-masuk-background:  transparent;
  --button-pasaran-background: var(--primary-grad);
  --link-color:              var(--text-dim);
  --link-color-hover:        var(--primary);
}

/* ============ RESET ============ */
* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  /* Belt-and-suspenders: no horizontal scroll on mobile. Marquees / wide
     elements that intentionally exceed viewport width are clipped instead
     of pushing the page wider than the device. (Lesson from v6.) */
  overflow-x: hidden;
  max-width: 100vw;
}
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }

/* ============ LAYOUT SHELL ============ */
.shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 32px;
}
main { min-height: 50vh; }

/* ============ HEADER ============ */
.hdr {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0)), var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.hdr-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  padding: 14px 32px;
  max-width: var(--shell-max);
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--primary-grad);
  display: grid; place-items: center;
  color: var(--primary-ink); font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow-1);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 1px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  pointer-events: none;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800; font-size: 18px; letter-spacing: 0.02em;
  color: var(--text);
}
.brand-name .dot { color: var(--primary); }
.brand-logo-img {
  max-height: 40px; width: auto;
}

/* Marquee — matches v3 baseline: plain running text, no icon decoration.
   The previous ::before 📣 emoji rendered as a flame on systems without a
   color-emoji font (visually overlapping the leading letters of the running
   text and clashing with the brand logo's flame design). Removed; plain
   horizontal padding now provides breathing room. */
.marquee {
  position: relative;
  flex: 1;
  height: 34px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.2));
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  display: flex; align-items: center;
  padding: 0 16px;
}
.marquee-track {
  display: inline-flex; gap: 48px;
  white-space: nowrap;
  animation: marquee var(--running-text-durasi) linear infinite;
  color: var(--text-dim);
  font-size: 12.5px;
}
.marquee-track strong { color: var(--primary); font-weight: 600; }
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.hdr-actions { display: flex; align-items: center; gap: 8px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; }
.btn-primary {
  background: var(--primary-grad);
  color: var(--primary-ink);
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 6px 14px rgba(0,0,0,0.35);
}
.btn-primary:hover { color: var(--primary-ink); filter: brightness(1.05); }
.btn-outline {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 11px 20px; font-size: 14px; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-success { background: var(--success); color: #07090d; border-color: transparent; }

/* Auth pill */
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 12px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
}
.user-pill .name { font-size: 13px; font-weight: 600; }
.user-pill .balance {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
}
.user-pill .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-grad);
  display: grid; place-items: center;
  color: var(--primary-ink); font-weight: 700; font-size: 12px;
  text-transform: uppercase;
}

/* Inline guest login form */
.login-inline {
  display: flex; gap: 6px; align-items: center;
}
.login-inline input {
  width: 130px; padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: 12.5px;
  outline: 0;
}
.login-inline input:focus { border-color: var(--primary); }
.login-inline .err { color: var(--danger); font-size: 11px; margin-left: 8px; }

/* ============ ICON NAV ============ */
.iconnav {
  display: grid;
  /* Auto-fit so tenants with N enabled categories (5–10) all fit in one row.
     The hard `repeat(8, 1fr)` previously wrapped a 9th item (e.g. Promosi)
     to a 2nd row alone, leaving 7 empty cells. minmax(108px, 1fr) gives
     each item enough room to read the label while filling the bar. */
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.iconnav-item {
  background: var(--bg-2);
  padding: 14px 8px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
  color: var(--text-dim);
  text-decoration: none;
}
.iconnav-item:hover { background: var(--surface); color: var(--text); }
.iconnav-item.active { color: var(--primary); background: var(--surface); }
.iconnav-item.active::after {
  content: "";
  position: absolute; bottom: 0; left: 12%; right: 12%; height: 2px;
  background: var(--primary-grad);
  border-radius: 2px 2px 0 0;
}
.iconnav-item svg { width: 22px; height: 22px; stroke-width: 1.6; }
.iconnav-item .label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ============ HEADINGS / EYEBROWS ============ */
.h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 8px;
}
.section-head {
  display: flex; align-items: end; justify-content: space-between;
  margin-bottom: 16px; gap: 16px;
}
.section-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
}
.section-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.section-link { color: var(--primary); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.section-link:hover { text-decoration: underline; }

/* ============ HERO ============ */
.hero {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}
.hero-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  aspect-ratio: 16 / 7;
  background-image:
    radial-gradient(1200px 280px at 80% -40%, var(--primary-soft), transparent 60%),
    repeating-linear-gradient(135deg, var(--surface-2) 0px, var(--surface-2) 18px, var(--surface) 18px, var(--surface) 36px);
  padding: 28px 32px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.hero-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--primary); font-weight: 600;
}
.hero-title {
  font-family: var(--font-display);
  font-size: 38px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.05;
  max-width: 560px;
  text-wrap: pretty;
}
.hero-title em { font-style: normal; color: var(--primary); }
.hero-sub { color: var(--text-dim); font-size: 14px; max-width: 520px; margin: 0; }
.hero-foot { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.hero-decor {
  position: absolute; top: 0; right: -40px; width: 280px; height: 100%;
  background: radial-gradient(circle, var(--primary-soft) 0%, transparent 70%);
  pointer-events: none;
}
.hero-pager {
  position: absolute; bottom: 16px; right: 18px;
  display: flex; gap: 6px;
  z-index: 2;
}
.hero-pager span {
  width: 18px; height: 3px; border-radius: 2px;
  background: rgba(255,255,255,0.18);
  cursor: pointer;
  transition: background 0.3s;
}
.hero-pager span.active { background: var(--primary); }

/* === HERO CAROUSEL — fade-cycled slides === */
.hero-carousel { position: relative; }
.hero-carousel-slide {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 0.7s ease-in-out;
  pointer-events: none;
}
.hero-carousel-slide.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}
/* The first slide stays in flow so the container has height; subsequent slides overlay it. */
.hero-carousel-slide:first-child { position: relative; }

/* Promo / kicker card */
.promo-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.promo-card .badge {
  align-self: flex-start;
  background: var(--primary-soft); color: var(--primary);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px;
}
.promo-card .kicker { font-size: 12.5px; color: var(--text-dim); }
.promo-card h4 { font-size: 22px; font-weight: 800; }
.promo-card .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kv {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim);
  display: inline-flex; gap: 6px; align-items: center;
}
.kv strong { color: var(--text); font-weight: 600; }

/* ============ LOTTERY ============ */
.lotto { margin-bottom: 32px; }
.lotto-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.lotto.layout-grid .lotto-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
.lotto.layout-stack .lotto-grid { display: flex; flex-direction: column; gap: 8px; }
.lotto-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  text-decoration: none; color: inherit;
}
.lotto-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.lotto-card .market {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-dim); font-weight: 600;
}
.lotto-card .number {
  font-family: var(--font-mono);
  font-size: 28px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--text);
  display: flex; gap: 4px;
}
.lotto-card .balls { display: flex; gap: 6px; }
.ball {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  color: var(--primary-ink);
  background: var(--primary-grad);
  box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset, 0 4px 8px rgba(0,0,0,0.35);
}
.ball:nth-child(2) { background: linear-gradient(180deg, #6cd8fb, #1d7ba8); color: #fff; }
.ball:nth-child(3) { background: linear-gradient(180deg, #5fe8b0, #138056); color: #fff; }
.ball:nth-child(4) { background: linear-gradient(180deg, #ff9eb4, #c44d7f); color: #fff; }
.lotto-card .date { font-size: 10.5px; color: var(--text-mute); font-family: var(--font-mono); }
.lotto.layout-stack .lotto-card { flex-direction: row; justify-content: space-between; padding: 12px 16px; }
.lotto.layout-stack .lotto-card .number { font-size: 22px; }
.lotto.layout-stack .lotto-card .balls .ball { width: 22px; height: 22px; font-size: 11px; }

/* ============ LOTTO RESULT CARDS — /games/Lottery rich pasaran view ============
   Mirrors v3's lottery-markets functional behavior (open/closed status, draw
   times, colored result balls) with v4 design tokens. Ball graphics are
   reused from /v3/img/ — no asset duplication needed. */
.lotto-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.lotto-tab {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 8px 18px;
  border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.lotto-tab:hover { border-color: var(--primary); color: var(--text); }
.lotto-tab.active {
  background: var(--primary-grad);
  color: var(--primary-ink);
  border-color: transparent;
}
.lotto-grid-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.lotto-result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.lotto-result-card:hover { border-color: var(--primary); box-shadow: var(--shadow-1); }
.lotto-result-card.is-closed { opacity: 0.7; background: var(--bg-2); }
.lotto-result-head { display: flex; flex-direction: column; gap: 2px; }
.lotto-result-name {
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  color: var(--primary); letter-spacing: 0.04em; text-transform: uppercase;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.lotto-result-hot {
  background: linear-gradient(180deg, #ff5a78, #c41a3e);
  color: #fff; padding: 1px 6px; font-size: 9px; border-radius: 3px;
  font-family: var(--font-mono); font-weight: 700;
}
.lotto-result-fullbadge {
  background: var(--primary-soft); color: var(--primary);
  padding: 1px 6px; font-size: 9px; border-radius: 3px;
  font-family: var(--font-mono); font-weight: 700;
}
.lotto-result-round {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
}
.lotto-result-date {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-mute);
  padding: 6px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line);
}
.lotto-prize-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-mute); margin-top: 2px;
}
.lotto-ball-row {
  display: flex; gap: 4px; justify-content: center; flex-wrap: nowrap;
}
.lotto-ball {
  width: 32px; height: 32px;
  background-position: 50%;
  background-repeat: no-repeat;
  background-size: contain;
  display: inline-block;
  filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.5));
}
.lotto-ball-x { background-image: url(/v3/img/x.webp); }
.lotto-ball-0 { background-image: url(/v3/img/0.webp); }
.lotto-ball-1 { background-image: url(/v3/img/1.webp); }
.lotto-ball-2 { background-image: url(/v3/img/2.webp); }
.lotto-ball-3 { background-image: url(/v3/img/3.webp); }
.lotto-ball-4 { background-image: url(/v3/img/4.webp); }
.lotto-ball-5 { background-image: url(/v3/img/5.webp); }
.lotto-ball-6 { background-image: url(/v3/img/6.webp); }
.lotto-ball-7 { background-image: url(/v3/img/7.webp); }
.lotto-ball-8 { background-image: url(/v3/img/8.webp); }
.lotto-ball-9 { background-image: url(/v3/img/9.webp); }
.lotto-result-times {
  display: flex; gap: 4px; justify-content: center; flex-wrap: wrap;
}
.lotto-time-badge {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary);
  padding: 3px 8px; border-radius: 4px;
}
.lotto-status-row { display: flex; justify-content: center; }
.lotto-status {
  font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.lotto-status.open  { background: rgba(74,222,128,0.15); color: #4ade80; border: 1px solid rgba(74,222,128,0.4); }
.lotto-status.closed { background: rgba(240,98,98,0.15); color: #f06262; border: 1px solid rgba(240,98,98,0.4); }
.lotto-launch { margin-top: auto; }
.lotto-play {
  width: 100%; padding: 8px 12px; font-size: 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* ============ FILTER + SEARCH + GAME GRID ============ */
.filter-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--text-dim);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.pill:hover { color: var(--text); border-color: var(--primary); }
.pill.active {
  background: var(--primary-soft); color: var(--primary);
  border-color: var(--primary);
}
.search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 6px 10px;
  width: 220px;
}
.search input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--text); font: inherit; font-size: 12.5px;
}
.search input::placeholder { color: var(--text-mute); }

.game-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 12px;
}
.game-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
.game-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.game-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.game-tile {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  text-decoration: none; color: inherit;
}
.game-tile:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
}
.game-tile .stripe { height: 4px; background: var(--primary-grad); }
.game-tile .art {
  flex: 1;
  background:
    repeating-linear-gradient(45deg, var(--surface-2) 0px, var(--surface-2) 8px, var(--bg-2) 8px, var(--bg-2) 16px);
  display: grid; place-items: center;
  color: var(--text-mute);
  font-family: var(--font-mono); font-size: 10px;
  position: relative;
}
.game-tile .art img { width: 100%; height: 100%; object-fit: cover; }
.game-tile .art::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.08), transparent 60%);
  pointer-events: none;
}
.game-tile .meta {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0; /* allow children's ellipsis to truncate inside the flex column */
}
.game-tile .meta .title {
  font-size: 12px; font-weight: 600;
  line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.game-tile .meta .prov {
  font-size: 10px; color: var(--text-mute);
  font-family: var(--font-mono);
  line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.game-tile .tag {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--line-2);
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 6px; border-radius: 4px;
  color: var(--primary);
}
.game-tile.hot .stripe { background: linear-gradient(90deg, #ff8a3d, #f06262); }
.game-tile.new .stripe { background: linear-gradient(90deg, #36c2b4, #4cc9f0); }
.game-tile.fav .stripe { background: linear-gradient(90deg, #b385ff, #ff7fb1); }

/* ============ PROVIDER WALL ============ */
/* Hide duplicate (aria-hidden) provider tiles on desktop. They exist only
   so the mobile marquee scroll loop is seamless. Re-enabled inside the
   marquee container at mobile breakpoint below. */
.prov-tile[aria-hidden="true"] { display: none; }

.provider-wall {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  margin-bottom: 32px;
}
.provider-wall.cols-6 { grid-template-columns: repeat(6, 1fr); }
/* Provider tile: fixed height (consistent grid alignment), flexible width
   via auto-fit grid. No aspect-ratio constraint so portrait/square/landscape
   logos all render at their natural shape inside the box. Image height fills
   the tile minus padding; width follows aspect (max 100%). */
.prov-tile {
  height: 56px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: all 0.15s;
  text-decoration: none;
  padding: 8px 10px;
  overflow: hidden;
}
.prov-tile:hover { border-color: var(--primary); color: var(--primary); }
.prov-tile.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.prov-tile img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: brightness(0.95);
  transition: filter 0.15s;
}
.prov-tile:hover img,
.prov-tile.active img { filter: brightness(1.1) drop-shadow(0 0 4px var(--primary)); }
.prov-tile-text { /* fallback for providers without an image */ font-weight: 600; }

/* ============ HISTORY TABLES ============ */
.history {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}
.history-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
/* On mobile the 5-col history table is wider than the wrapper; the wrapper
   was clipping the right-side columns (Jumlah, Status). Switch to horizontal
   scroll on mobile so users can swipe to see all columns. */
@media (max-width: 720px) {
  .history-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .history-card .history-table { min-width: 480px; }
}
.history-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.history-head .title {
  font-family: var(--font-display); font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.history-head .live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--success);
}
.history-head .live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74,222,128,0.6); }
  70% { box-shadow: 0 0 0 8px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}
.history-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.history-table th, .history-table td {
  padding: 9px 18px; text-align: left;
  border-bottom: 1px solid var(--line);
}
.history-table th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 600; color: var(--text-mute);
  background: var(--bg-2);
}
.history-table tr:last-child td { border-bottom: 0; }
.history-table .amt { font-family: var(--font-mono); color: var(--primary); font-weight: 600; }
.history-table .user { color: var(--text-dim); font-family: var(--font-mono); }
.history-table .when { color: var(--text-mute); font-family: var(--font-mono); font-size: 11px; }

/* ============ FORMS ============ */
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 520px;
  margin: 0 auto;
}
.form-card.wide { max-width: 720px; }
.form-card .form-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800;
  margin-bottom: 4px;
}
.form-card .form-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.form-row {
  display: grid; grid-template-columns: 1fr 2fr; gap: 12px; align-items: center;
  margin-bottom: 14px;
}
.form-row.stack { grid-template-columns: 1fr; }
.form-row label {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit; font-size: 13px;
  outline: 0;
  transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--text-mute); }
select.form-control {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}
.field-err { color: var(--danger); font-size: 11px; margin-top: 4px; }
.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid;
}
.alert-info { background: rgba(54,194,180,0.08); border-color: var(--accent); color: var(--accent); }
.alert-warning { background: rgba(245,185,66,0.1); border-color: var(--warn); color: var(--warn); }
.alert-success { background: rgba(74,222,128,0.1); border-color: var(--success); color: var(--success); }
.alert-danger { background: rgba(240,98,98,0.1); border-color: var(--danger); color: var(--danger); }

/* ============ TAB NAV ============ */
.tabnav {
  display: flex; gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.tabnav-item {
  padding: 10px 16px;
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.tabnav-item:hover { color: var(--text); }
.tabnav-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ============ TRUST + PAYMENTS + FOOTER ============ */
.trust-block {
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  padding: 32px 0;
}
.trust-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.trust-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
}
.trust-tile .icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; flex: 0 0 auto;
}
.trust-tile .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute);
  font-weight: 600;
}
.trust-tile .value { font-size: 13px; font-weight: 700; margin-top: 2px; }

.payments {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}
/* Payment tile (footer): same fixed-height pattern as .prov-tile so logos
   of varying aspect ratios fit cleanly without distortion or cropping. */
.pay-tile {
  height: 48px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  padding: 6px 8px;
  overflow: hidden;
}
.pay-tile img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.pay-tile-text { font-weight: 600; }

.providers-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--text-mute); font-weight: 600; margin-bottom: 12px;
}

.footer-bar {
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 18px 32px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; color: var(--text-mute);
  max-width: var(--shell-max); margin: 0 auto;
  flex-wrap: wrap; gap: 12px;
}
.footer-bar .links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-bar .links a { color: var(--text-dim); text-decoration: none; }
.footer-bar .links a:hover { color: var(--primary); }

/* ============ TOAST ============ */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 12.5px;
  box-shadow: var(--shadow-2);
  animation: slideup 0.3s ease;
}
@keyframes slideup {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============ DASHBOARD: 4-card row when logged in ============ */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
/* 1fr 2fr split (avatar/balance + info table) — used on profile page.
   Mobile rule below in @media collapses to single column. */
.dash-grid.profile-split { grid-template-columns: 1fr 2fr; }
/* Collapsible state for the authenticated dashboard's 4-card detail panel.
   Specificity of .dash-grid.is-collapsed (0,2,0) beats .dash-grid (0,1,0)
   so display:none wins over the default display:grid. */
.dash-grid.is-collapsed { display: none; }
.dash-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.dash-card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 700;
  color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--bg-2);
}
.dash-card-body { padding: 14px 16px; font-size: 12.5px; flex: 1; }
.dash-card-body .row { display: flex; justify-content: space-between; padding: 4px 0; }
.dash-card-body .row.divide { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.dash-card-body .empty { color: var(--text-mute); font-style: italic; padding: 12px 0; text-align: center; }

.balance-banner {
  background: linear-gradient(90deg, var(--primary-soft), transparent);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.balance-banner .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--primary); font-weight: 700;
}
.balance-banner .amount {
  font-family: var(--font-mono); font-size: 22px; font-weight: 700; margin-top: 2px;
}

/* ============ PASARAN GRID (lottery markets) ============ */
.pasaran-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.pasaran-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.pasaran-tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.pasaran-tile .name {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.pasaran-tile .when {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-mute);
}
.pasaran-tile .tier {
  display: flex; gap: 4px;
}
.pasaran-tile .tier .ball { width: 18px; height: 18px; font-size: 10px; }
.pasaran-tile .pasang {
  margin-top: auto;
  padding: 8px 12px;
  background: var(--primary-grad);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--primary-ink);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  text-align: center;
}

/* ============ EMPTY / ERROR ============ */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-mute);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--bg-2);
}
.empty-state .big {
  font-family: var(--font-display); font-size: 64px; font-weight: 800;
  color: var(--primary); letter-spacing: -0.03em; line-height: 1;
}
.empty-state .msg { margin-top: 14px; font-size: 14px; color: var(--text-dim); }

/* ============ MOBILE BOTTOM BAR ============ */
.mobile-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 0;
  display: none;
}
.mobile-bottom .item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10px; color: var(--text-dim);
  text-decoration: none; cursor: pointer;
}
.mobile-bottom .item.active { color: var(--primary); }
.mobile-bottom svg { width: 18px; height: 18px; }

/* ============ LOGIN FORM (mobile inline header) ============ */
.login-form-mobile {
  display: grid; gap: 8px;
  padding: 12px 14px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
/* minmax(0, 1fr) — without this, inputs' default min-content (~150px) forces the
   row past the viewport on phones. Probe showed 442px row in 390px viewport. */
.login-form-mobile .row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; min-width: 0; }
.login-form-mobile .row > * { min-width: 0; }
.login-form-mobile input {
  padding: 9px 10px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius); color: var(--text); font: inherit; font-size: 13px;
  outline: 0;
}
.login-form-mobile input:focus { border-color: var(--primary); }

/* ============ MEDIA QUERIES (mobile fallback for desktop pages) ============ */
@media (max-width: 768px) {
  body { font-size: 13px; }
  .shell { padding: 14px; }
  /* Brand on the left, auth pill (avatar + balance) on the right edge.
     Switching from grid to flex with justify-content:space-between because
     `auto 1fr auto` only had 2 grid items so .hdr-actions ended up auto-
     placed in column 2 (the 1fr) and stayed left-aligned next to the brand. */
  .hdr-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    gap: 10px;
    grid-template-columns: none;  /* defeat desktop grid declaration */
  }
  .marquee { display: none; }
  .iconnav { grid-template-columns: repeat(4, 1fr); }
  .iconnav-item .label { font-size: 9px; }
  .hero { grid-template-columns: 1fr; }
  .hero-card { aspect-ratio: 16 / 9; padding: 18px; }
  .hero-title { font-size: 22px; }
  .lotto-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .game-grid { grid-template-columns: repeat(3, 1fr); }
  /* Promo cards (cols-4 desktop variant) stack vertically on mobile so the
     image + content + CTA are readable. The 3-col game-grid above is fine
     for compact game thumbnails but cramps full-width promo banners.
     Image renders at natural aspect (no cover-crop) so wide promo banners
     show in full instead of having the brand text clipped on the sides. */
  .game-grid.cols-4 { grid-template-columns: 1fr; gap: 14px; }
  .game-grid.cols-4 .dash-card img { width: 100%; height: auto; aspect-ratio: auto; object-fit: contain; }
  .history { grid-template-columns: 1fr; }
  .trust-row { grid-template-columns: repeat(2, 1fr); }

  /* === MOBILE PROVIDER WALL — auto-scrolling 3-row marquee (lesson from v6) ===
     Wide grids of providers (~30+) become 3 rows of horizontally-streaming pills
     instead of a tall vertical wall. The .ejs renders the cells twice so the
     translateX(0→-50%) loop is seamless. Pauses on hover/touch; respects
     prefers-reduced-motion. */
  .provider-wall-marquee {
    overflow: hidden;
    margin: 12px -14px 18px;
    padding: 4px 0;
  }
  /* Re-enable duplicate tiles for marquee seamless loop on mobile only */
  .provider-wall-marquee .prov-tile[aria-hidden="true"] { display: flex; }

  /* Sparse categories (≤8 providers): render as a normal wrap grid with no
     animation. Without enough cells to fill the marquee track, the original
     and duplicate sets sat side-by-side and looked like accidental duplicates
     (e.g. LiveCasino's 6 providers showing as 4×3 with Pragmatic appearing
     twice). The .is-static modifier disables the marquee entirely. */
  .provider-wall-marquee.is-static {
    overflow: visible;
    margin: 12px 0 18px;
    padding: 0;
  }
  .provider-wall-marquee.is-static .provider-wall {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    grid-template-rows: none;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    width: 100%;
    gap: 6px;
    padding: 0;
    animation: none;
    transform: none;
  }
  .provider-wall-marquee .provider-wall {
    display: grid;
    grid-template-columns: none;
    grid-template-rows: repeat(3, 1fr);
    grid-auto-flow: column;
    grid-auto-columns: 92px;
    gap: 6px;
    padding: 4px 14px 8px;
    width: max-content;
    margin-bottom: 0;
    animation: v4-prov-marquee 35s linear infinite;
    will-change: transform;
  }
  .provider-wall-marquee:hover .provider-wall,
  .provider-wall-marquee:focus-within .provider-wall,
  .provider-wall-marquee:active .provider-wall { animation-play-state: paused; }
  @media (prefers-reduced-motion: reduce) {
    .provider-wall-marquee .provider-wall { animation: none; }
  }
  @keyframes v4-prov-marquee {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
  }
  .provider-wall-marquee .prov-tile {
    aspect-ratio: auto;
    height: auto;
    padding: 8px 6px;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .provider-wall { grid-template-columns: repeat(4, 1fr); }
  .payments { grid-template-columns: repeat(4, 1fr); }
  .pasaran-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid.profile-split { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-card { padding: 18px; }
  .footer-bar { padding: 14px; flex-direction: column; align-items: flex-start; }
  body.is-mobile .mobile-bottom { display: grid; }
  body.is-mobile { padding-bottom: 60px; }
}
