/* =========================================================================
   RTP Live — halaman publik.
   Memakai token tema aktif (tokens.css + theme-*.css) supaya warna mengikuti
   tema yang dipilih admin. Struktur: hero ringkas, podium tiga teratas, lalu
   daftar game yang bisa dicari dan difilter per provider.
   ========================================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100%;
  background: var(--bg-grad, var(--bg-0));
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
}

.rtp-page {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0 12px calc(128px + env(safe-area-inset-bottom, 0px));
}

/* ------------------------------------------------------------------ Header */
.rtp-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 9px;
  height: 60px;
  padding: 0 2px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-0) 88%, transparent);
  backdrop-filter: blur(14px);
}

.rtp-back {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-mid);
  border-radius: 12px;
  background: rgba(var(--surface-2-rgb), .6);
  color: var(--text-soft);
  font-size: 26px;
  line-height: 1;
  text-decoration: none;
}

.rtp-back:active {
  transform: scale(.96);
}

.rtp-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 38px;
  text-decoration: none;
}

.rtp-brand img {
  display: block;
  width: auto;
  height: 30px;
  max-width: 150px;
  object-fit: contain;
}

.rtp-brand strong {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .4px;
  color: var(--text);
}

.rtp-head-cta {
  display: grid;
  place-items: center;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--brand-3);
  border-radius: 10px;
  background: linear-gradient(145deg, var(--brand-2), var(--brand-3));
  color: var(--ink);
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: .6px;
  text-decoration: none;
}

/* -------------------------------------------------------------------- Hero */
.rtp-hero {
  margin-top: 14px;
  padding: 16px 15px 14px;
  border: 1px solid var(--line-mid);
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 130% at 0% 0%, rgba(var(--brand-rgb), .22), transparent 58%),
    linear-gradient(155deg, rgba(var(--bg-2-rgb), .95), rgba(var(--bg-0-rgb), .97));
  box-shadow: var(--sh-md), var(--inset-hi);
}

.rtp-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rtp-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid rgba(74, 222, 128, .38);
  border-radius: var(--r-pill);
  background: rgba(74, 222, 128, .1);
  color: var(--ok-soft, #91eab7);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 1px;
}

.rtp-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 9px rgba(74, 222, 128, .9);
  animation: rtp-blink 1.8s ease-in-out infinite;
}

.rtp-updated {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  white-space: nowrap;
}

.rtp-updated b {
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.rtp-updated span {
  color: var(--brand-2);
  font-variant-numeric: tabular-nums;
}

.rtp-hero h1 {
  margin: 12px 0 5px;
  font-family: var(--font-display);
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.5px;
}

.rtp-hero h1 span {
  color: var(--brand-2);
  text-shadow: 0 0 26px rgba(var(--brand-rgb), .55);
}

.rtp-lead {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.rtp-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 14px;
}

.rtp-stat {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(var(--bg-0-rgb), .45);
}

.rtp-stat small {
  display: block;
  color: var(--muted-dim, var(--muted));
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: .9px;
}

.rtp-stat strong {
  display: block;
  margin-top: 3px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.rtp-stat em {
  font-style: normal;
  font-size: 10px;
  color: var(--brand-2);
  margin-left: 1px;
}

/* ------------------------------------------------------------------ Podium */
.rtp-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.rtp-podium-card {
  position: relative;
  padding: 10px 9px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(160deg, rgba(var(--surface-2-rgb), .85), rgba(var(--bg-0-rgb), .92));
  overflow: hidden;
}

.rtp-podium-card--1 {
  border-color: rgba(var(--brand-rgb), .5);
  box-shadow: 0 10px 26px rgba(var(--brand-rgb), .18);
}

.rtp-podium-card--1::before {
  content: "";
  position: absolute;
  inset: -40% 20% auto;
  height: 90px;
  background: radial-gradient(circle, rgba(var(--brand-rgb), .38), transparent 70%);
  pointer-events: none;
}

/* Artwork asli dari CDN provider. Bila gambar gagal dimuat, img dihapus dan
   inisial nama game tetap tampil di kotak yang sama. */
.rtp-podium-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(var(--brand-rgb), .2), rgba(var(--bg-0-rgb), .88));
  overflow: hidden;
}

.rtp-podium-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rtp-podium-thumb b {
  position: relative;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--brand-2);
}

.rtp-podium-rank {
  position: relative;
  display: inline-block;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  color: var(--brand-2);
  letter-spacing: .5px;
}

.rtp-podium-name {
  position: relative;
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 27px;
}

.rtp-podium-provider {
  position: relative;
  margin-top: 3px;
  color: var(--muted);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rtp-podium-value {
  position: relative;
  margin-top: 7px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.rtp-podium-value small {
  font-size: 10px;
  color: var(--brand-2);
  margin-left: 1px;
}

.rtp-podium-card .rtp-pattern {
  position: relative;
  margin-top: 7px;
}

/* ----------------------------------------------------------------- Filters */
.rtp-controls {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
}

.rtp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-mid);
  border-radius: var(--r-md);
  background: rgba(var(--surface-2-rgb), .55);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.rtp-search:focus-within {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .16);
}

.rtp-search svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  color: var(--muted);
}

.rtp-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 11.5px;
}

.rtp-search input::placeholder {
  color: var(--muted-dim, var(--muted));
}

.rtp-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .5px;
}

.rtp-chips {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-bottom: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.rtp-chips::-webkit-scrollbar {
  display: none;
}

.rtp-chip {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: rgba(var(--bg-2-rgb), .55);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .55px;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}

.rtp-chip:hover {
  color: var(--text-soft);
  border-color: var(--line-strong);
}

.rtp-chip.is-active {
  border-color: var(--brand-3);
  background: linear-gradient(145deg, rgba(var(--brand-rgb), .3), rgba(var(--brand-3-rgb), .16));
  color: var(--text);
  box-shadow: 0 4px 14px rgba(var(--brand-rgb), .18);
}

/* -------------------------------------------------------------------- List */
.rtp-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 11px;
}

.rtp-row {
  display: grid;
  grid-template-columns: 20px 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: linear-gradient(150deg, rgba(var(--surface-2-rgb), .5), rgba(var(--bg-1-rgb), .72));
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
  /* Katalog bisa berisi >200 game: baris di luar layar tidak dirender sampai
     dibutuhkan, sehingga paint awal tetap ringan. */
  content-visibility: auto;
  contain-intrinsic-size: auto 60px;
}

/* `hidden` dari filter/search harus menang atas display:grid di atas. */
.rtp-row[hidden] {
  display: none;
}

.rtp-row:hover {
  border-color: var(--line-strong);
  background: linear-gradient(150deg, rgba(var(--surface-2-rgb), .72), rgba(var(--bg-1-rgb), .85));
}

.rtp-rank {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted-dim, var(--muted));
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.rtp-row:nth-child(1) .rtp-rank,
.rtp-row:nth-child(2) .rtp-rank,
.rtp-row:nth-child(3) .rtp-rank {
  color: var(--brand-2);
}

.rtp-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(150deg, rgba(var(--brand-rgb), .18), rgba(var(--bg-0-rgb), .86));
  overflow: hidden;
}

.rtp-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rtp-thumb b {
  position: relative;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-2);
  letter-spacing: .3px;
}

.rtp-meta {
  min-width: 0;
}

.rtp-name {
  display: block;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rtp-meta-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  min-width: 0;
}

.rtp-provider {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .25px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rtp-bar {
  height: 3px;
  margin-top: 6px;
  border-radius: var(--r-pill);
  background: rgba(var(--brand-rgb), .12);
  overflow: hidden;
}

.rtp-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-3), var(--brand-2), var(--accent));
  box-shadow: 0 0 10px rgba(var(--brand-rgb), .45);
  transition: width .55s cubic-bezier(.22, 1, .36, 1);
}

.rtp-figure {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-self: end;
}

.rtp-figure strong {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.rtp-figure strong small {
  font-size: 8.5px;
  color: var(--brand-2);
  margin-left: 1px;
}

.rtp-trend {
  width: 10px;
  font-size: 8px;
  line-height: 1;
  text-align: center;
}

.rtp-trend--up {
  color: var(--ok);
}

.rtp-trend--down {
  color: var(--bad);
}

.rtp-trend--flat {
  color: var(--muted-dim, var(--muted));
}

/* ----------------------------------------------------------------- Pattern */
.rtp-pattern {
  display: inline-flex;
  align-items: center;
  height: 15px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: 6.5px;
  font-weight: 900;
  letter-spacing: .5px;
  white-space: nowrap;
}

.rtp-pattern--gacor {
  border-color: rgba(74, 222, 128, .42);
  background: rgba(74, 222, 128, .12);
  color: var(--ok-soft, #91eab7);
}

.rtp-pattern--stabil {
  border-color: rgba(var(--brand-rgb), .42);
  background: rgba(var(--brand-rgb), .13);
  color: var(--brand-2);
}

.rtp-pattern--normal {
  border-color: var(--line-mid);
  background: rgba(255, 255, 255, .04);
  color: var(--text-soft);
}

.rtp-pattern--rendah {
  border-color: rgba(255, 133, 141, .38);
  background: rgba(255, 133, 141, .1);
  color: var(--bad);
}

/* -------------------------------------------------------------- Empty state */
.rtp-empty {
  margin-top: 11px;
  padding: 34px 16px;
  border: 1px dashed var(--line-mid);
  border-radius: var(--r-lg);
  background: rgba(var(--bg-1-rgb), .6);
  text-align: center;
}

.rtp-empty strong {
  display: block;
  font-size: 10px;
  letter-spacing: .6px;
  color: var(--text-soft);
}

.rtp-empty span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 9.5px;
}

/* -------------------------------------------------------------------- Note */
.rtp-note {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: rgba(var(--bg-1-rgb), .66);
}

.rtp-note strong {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .7px;
  color: var(--brand-2);
  text-transform: uppercase;
}

.rtp-note strong::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 8px rgba(var(--brand-rgb), .8);
}

.rtp-note p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.75;
}

.rtp-note-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 11px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .4px;
  text-decoration: none;
}

.rtp-note-link:hover {
  border-color: var(--brand-2);
  color: var(--text);
}

/* ------------------------------------------------------------------ Motion */
@keyframes rtp-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.8); }
}

@media (prefers-reduced-motion: reduce) {
  .rtp-live i {
    animation: none;
  }
  .rtp-row,
  .rtp-bar span,
  .rtp-chip {
    transition: none;
  }
}

/* ----------------------------------------------------------------- Desktop */
@media (min-width: 720px) {
  .rtp-page {
    padding: 0 20px calc(120px + env(safe-area-inset-bottom, 0px));
  }
  .rtp-header {
    height: 66px;
  }
  .rtp-hero {
    margin-top: 18px;
    padding: 20px 20px 18px;
  }
  .rtp-lead {
    font-size: 12px;
  }
  .rtp-stat {
    padding: 11px 13px;
  }
  .rtp-stat strong {
    font-size: 18px;
  }
  .rtp-podium {
    gap: 11px;
    margin-top: 12px;
  }
  .rtp-podium-card {
    padding: 13px 13px 12px;
  }
  .rtp-podium-thumb {
    width: 52px;
    height: 52px;
    border-radius: 14px;
  }
  .rtp-podium-name {
    font-size: 12.5px;
    min-height: 32px;
  }
  .rtp-podium-value {
    font-size: 23px;
  }
  .rtp-row {
    grid-template-columns: 24px 46px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 11px 13px;
  }
  .rtp-thumb {
    width: 46px;
    height: 46px;
  }
  .rtp-name {
    font-size: 12.5px;
  }
  .rtp-provider {
    font-size: 8.5px;
  }
  .rtp-figure strong {
    font-size: 16px;
  }
  .rtp-pattern {
    height: 16px;
    font-size: 7px;
  }
}

@media (max-width: 360px) {
  .rtp-row {
    grid-template-columns: 16px 34px minmax(0, 1fr) auto;
    gap: 7px;
  }
  .rtp-thumb {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }
  .rtp-hero-top {
    flex-wrap: wrap;
  }
}
