:root {
  --teal: #1b8a7a;
  --teal-dark: #136b5f;
  --line: #d9e8e5;
  --card: #f3f4f4;
  --text: #111;
  --app-width: 500px;
  --nav-height: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background: #e6ecea;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
img { display: block; max-width: 100%; }

.app {
  max-width: var(--app-width);
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  padding-bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  min-height: 62px;
  background: #cfeee6 url("assets/header.gif") center / cover no-repeat;
  border-bottom: 3px solid #eee;
}
.logo img { height: 46px; width: auto; }
.partner img { height: 46px; width: auto; }

/* ---------- Carousel ---------- */
.carousel { position: relative; margin-top: 10px; }
.carousel-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.carousel-track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: start; aspect-ratio: 2 / 1; }
.slide img { width: 100%; height: 100%; object-fit: cover; }
.carousel-dots { position: absolute; bottom: 6px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.carousel-dots button { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .6); }
.carousel-dots button.active { background: var(--teal); }

.static-banner img { width: 100%; height: auto; }

/* ---------- Cards ---------- */
.card { margin: 12px 10px 0; border-radius: 14px; background: var(--card); overflow: hidden; }

.img-btn { display: block; padding: 0; cursor: pointer; transition: transform .1s, filter .15s; }
.img-btn img { width: 100%; height: auto; }
.img-btn:hover { filter: brightness(1.08); }
.img-btn:active { transform: scale(.97); }

.account { padding: 14px 12px; }
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wallet { display: flex; gap: 12px; padding-top: 12px; align-items: flex-start; }
.wallet-info { flex: 1; font-size: 15px; line-height: 1.6; }
.wallet-label { font-size: 17px; }
.wallet-amount { font-size: 28px; font-weight: 800; color: var(--teal); margin: 6px 0; }
.wallet-actions { flex: 0 0 160px; display: grid; gap: 6px; }

/* ---------- Referral ---------- */
.referral { background: #fff; border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
.referral > img { width: 100%; height: auto; }
.ref-actions { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.ref-actions > * { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; font-size: 13px; font-weight: 600; color: #333; border-left: 1px solid var(--line); }
.ref-actions > :first-child { border-left: 0; }
.ref-actions svg { width: 22px; height: 22px; fill: var(--teal); }
.ref-actions > :hover { background: #f4faf9; }

/* ---------- Promo banners ---------- */
.promo { display: block; margin: 12px 10px 0; }
.promo img { width: 100%; height: auto; border-radius: 12px; }

/* ---------- Games ---------- */
.games { margin-top: 14px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 10px 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 calc((100% - 24px) / 4.6); }
.tab img { width: 100%; height: auto; }
.tab.on img { filter: brightness(.9) saturate(1.3); }
.game-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 12px; }
.game img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.tab, .game { transition: transform .1s, filter .15s; }
.game:hover { filter: brightness(1.08); }
.game:active { transform: scale(.97); }

/* ---------- Lucky draw ---------- */
.lucky { position: relative; margin: 12px 10px 0; }
.lucky > img { width: 100%; height: auto; border-radius: 14px; }
.lucky .img-btn { position: absolute; left: 5%; top: 85%; width: 41%; }

/* ---------- Keyword text + guide pages ---------- */
.seo { margin: 22px 10px 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #f7fbfa; font-size: 14px; line-height: 1.6; }
.seo h1 { font-size: 19px; margin-bottom: 8px; }
.seo h2 { font-size: 16px; color: var(--teal); margin: 18px 0 6px; }
.seo a { color: var(--teal-dark); text-decoration: underline; }
.seo ol, .seo ul { padding-left: 20px; }
.seo ul { list-style: disc; }
.seo li { margin-bottom: 6px; }
.guide { margin-top: 14px; }
.guide .crumbs { font-size: 12px; color: #667; margin-bottom: 8px; }
.guide .auth-row { padding: 18px 0 0; }

/* Long sections fold to a preview; collapse.js adds the toggle button. */
.collapsible { position: relative; max-height: 320px; overflow: hidden; }
.collapsible:not(.open)::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 90px; background: linear-gradient(rgba(247, 251, 250, 0), #f7fbfa); pointer-events: none; }
.collapsible.open { max-height: none; }
.toggle-btn { display: block; margin: 10px auto 0; padding: 8px 22px; border: 1px solid var(--teal); border-radius: 20px; color: var(--teal); font-size: 14px; font-weight: 700; }
.toggle-btn:hover { background: rgba(27, 138, 122, .08); }

/* ---------- Footer ---------- */
.footer { padding: 26px 14px 20px; }
.footer .pagcor { max-width: 120px; margin: 0 0 10px; }
.footer .resp { max-width: 120px; margin: 10px 0; }
.label { font-size: 12px; font-weight: 800; font-style: italic; margin: 8px 0 4px; }
.icons { display: flex; flex-wrap: wrap; gap: 6px; }
.icons img { width: 30px; height: 25px; object-fit: contain; }
.icons.wide img { width: 55px; height: 30px; }
.copyright { margin-top: 24px; font-size: 13px; font-weight: 800; font-style: italic; }

/* ---------- Floating tabs ---------- */
.side-tabs { position: fixed; right: max(0px, calc(50% - var(--app-width) / 2)); top: 50%; transform: translateY(-50%); z-index: 20; display: grid; gap: 4px; }
.side-tab { writing-mode: vertical-rl; padding: 12px 5px; font-size: 12px; font-weight: 800; letter-spacing: 1px; border-radius: 8px 0 0 8px; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.side-tab.telegram { background: #fff; color: #229ed9; border: 1px solid #229ed9; border-right: 0; }
.side-tab.gold { background: #8d8f93; color: #f5c400; border: 1px solid #b8860b; border-right: 0; }
.float-tips { position: fixed; right: max(4px, calc(50% - var(--app-width) / 2 + 4px)); top: 70px; z-index: 25; width: 58px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 40;
  width: 100%;
  max-width: var(--app-width);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding: 4px 0 env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fff;
  border-top: 4px solid var(--teal);
}
.bottom-nav a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px; font-weight: 800; color: var(--teal); transition: filter .15s, transform .1s; }
.bottom-nav a.on { background: var(--teal); color: #fff; border-radius: 6px; margin: -10px 4px 0; }
.bottom-nav img { height: 38px; width: auto; }
.bottom-nav a:active { transform: scale(.95); }
.badge { position: absolute; top: 0; right: 14%; min-width: 22px; height: 22px; border-radius: 50%; background: #e53935; color: #fff; font-size: 13px; display: grid; place-items: center; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-height) + 24px); transform: translateX(-50%); z-index: 50; background: rgba(0, 0, 0, .85); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }

@media (max-width: 380px) {
  .logo img, .partner img { height: 38px; }
  .wallet-actions { flex-basis: 136px; }
  .wallet-info { font-size: 14px; }
}
