:root {
  --bg: #070b12;
  --side: #0b1018;
  --panel: #121a24;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eaf0f7;
  --muted: #8b9bb0;
  --accent: #3dde9d;
  --gold: #f0c75e;
  --pink: #ff4d9a;
  --danger: #ff6b7a;
  --font: "Outfit", sans-serif;
  --display: "Syne", "Outfit", sans-serif;
  --side-w: 220px;
  --top-h: 56px;
  --bottom-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  color: var(--text);
  font-family: var(--font);
  background: var(--bg);
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input, select { -webkit-tap-highlight-color: transparent; }

/* —— H5 default shell —— */
.shell {
  display: block;
  min-height: 100dvh;
  padding-bottom: calc(var(--bottom-h) + var(--safe-b));
}
.main-wrap {
  min-width: 0;
  background:
    radial-gradient(700px 320px at 90% -8%, rgba(255,77,154,0.1), transparent 55%),
    radial-gradient(520px 260px at 0% 30%, rgba(61,222,157,0.06), transparent 50%),
    var(--bg);
}

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}
.shell.is-side-open .scrim { display: block; }

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: min(82vw, 280px);
  height: 100dvh;
  padding: calc(14px + var(--safe-t)) 14px 18px;
  background: linear-gradient(180deg, #121a28, var(--side));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 40;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
}
.shell.is-side-open .sidebar { transform: none; }
.side-collapse { display: none; }
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  font-family: var(--display);
  font-weight: 800;
  margin: 4px 0 10px;
}
.side-brand img { border-radius: 10px; }
.side-login,
.side-signup {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.side-login {
  background: linear-gradient(135deg, #ff4d9a, #b12f7a);
  color: #fff;
}
.side-signup {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--text);
}
.side-nav { display: grid; gap: 6px; margin-top: 8px; }
.side-link {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 12px 12px;
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.side-link.is-active,
.side-link:hover {
  background: rgba(61, 222, 157, 0.1);
  color: var(--text);
}
.side-note {
  margin-top: auto;
  color: #66768a;
  font-size: 11px;
  line-height: 1.4;
  padding-bottom: var(--safe-b);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--top-h);
  padding: calc(8px + var(--safe-t)) 12px 8px;
  backdrop-filter: blur(16px);
  background: rgba(7, 11, 18, 0.88);
  border-bottom: 1px solid var(--line);
}
.menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.brand-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
}
.brand-mini img { border-radius: 8px; flex: none; }
.brand-mini span {
  white-space: nowrap;
}
.balances { display: none; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  font-size: 12px;
}
.pill span { color: var(--muted); }
.pill strong { font-variant-numeric: tabular-nums; }
.pill em {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #062016;
  font-style: normal;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
}
.pill-s strong { color: var(--gold); }

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  margin-left: auto;
  min-width: 0;
  flex: 1 1 auto;
}
.lang-select {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  max-width: 92px;
}
.lang-select:focus { outline: 1px solid rgba(61, 222, 157, 0.45); }
.lang-select option,
.lang-select optgroup {
  color: #111;
  background: #fff;
}
html[dir="rtl"] .shell { direction: rtl; }
html[dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(105%); border-right: 0; border-left: 1px solid var(--line); }
html[dir="rtl"] .shell.is-side-open .sidebar { transform: none; }

.bonus-btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  color: #241806;
  background: linear-gradient(135deg, #ffe08a, #f0c75e 45%, #3dde9d);
  box-shadow: 0 0 0 0 rgba(240, 199, 94, 0.55);
  animation: pulse 1.8s ease-in-out infinite;
  white-space: nowrap;
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bonus-btn:active { transform: scale(0.97); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 199, 94, 0.45); }
  50% { box-shadow: 0 0 0 7px rgba(240, 199, 94, 0); }
}
.who {
  color: var(--muted);
  font-size: 12px;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 7px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.promo-host {
  position: relative;
  margin: 10px 12px 8px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(140, 190, 255, 0.28);
  box-shadow: 0 10px 28px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.04);
  aspect-ratio: 16 / 9;
  max-height: 210px;
  background: #0a1220;
}
.promo-track { position: absolute; inset: 0; }
.promo-slide {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.45s ease, transform 0.55s ease;
  pointer-events: none;
  text-align: left;
  color: #fff;
  overflow: hidden;
}
.promo-slide.is-on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  z-index: 1;
}
.promo-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: promoKen 8s ease-in-out infinite alternate;
}
@keyframes promoKen {
  from { transform: scale(1.02) translate3d(0,0,0); }
  to { transform: scale(1.08) translate3d(-1.5%, 1%, 0); }
}
.promo-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(4,10,22,0.88) 0%, rgba(4,10,22,0.55) 42%, rgba(4,10,22,0.12) 72%, rgba(4,10,22,0.35) 100%),
    radial-gradient(120% 80% at 70% 50%, transparent 30%, rgba(0,0,0,0.35) 100%);
}
.promo-copy {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  height: 100%;
  padding: 16px 18px 28px;
  max-width: 68%;
}
.promo-brand {
  margin: 0 0 8px;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(240,199,94,0.45);
  color: var(--gold);
  font-family: var(--display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.promo-title {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: clamp(18px, 5.6vw, 28px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow:
    0 0 12px rgba(180, 90, 255, 0.55),
    0 2px 10px rgba(0,0,0,0.65);
}
.promo-sub {
  margin: 0 0 12px;
  color: rgba(230, 240, 255, 0.9);
  font-size: 12px;
  line-height: 1.4;
  text-shadow: 0 1px 6px rgba(0,0,0,0.55);
}
.promo-cta {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe08a, #f0c75e 40%, #3dde9d);
  color: #241806;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 0 16px rgba(240,199,94,0.35);
}
.promo-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}
.promo-dots button {
  pointer-events: auto;
  width: 7px;
  height: 7px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  cursor: pointer;
}
.promo-dots button.is-on {
  background: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.55);
  width: 16px;
  border-radius: 999px;
}

.cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 13px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.cat.is-on {
  color: var(--text);
  border-color: rgba(61, 222, 157, 0.45);
  background: rgba(61, 222, 157, 0.12);
}

main { padding: 4px 0 20px; }
.rail {
  position: relative;
  padding: 12px 0 4px;
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px 8px;
}
.rail-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: -0.02em;
}
.rail-nav {
  display: flex;
  gap: 6px;
  flex: none;
}
.rail-prev,
.rail-next {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.rail-prev:active,
.rail-next:active { transform: scale(0.94); background: rgba(61,222,157,0.16); }
.rail-track-wrap {
  position: relative;
}
.rail-track-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 8px;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(7,11,18,0.92));
  z-index: 2;
}
.rail-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 38vw;
  gap: 10px;
  overflow-x: auto;
  padding: 0 12px 8px;
  padding-right: 36px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.rail-track::-webkit-scrollbar { display: none; }
.rail-track.is-wrap {
  grid-auto-flow: dense;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-columns: unset;
  overflow: visible;
  gap: 10px;
  padding-right: 12px;
}
.rail-track-wrap:has(.is-wrap)::after { display: none; }
.game {
  scroll-snap-align: start;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.game:active { transform: scale(0.98); }
.game-art {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #0a1119;
}
.game-cover {
  position: absolute;
  inset: -8%;
  width: 116%;
  height: 116%;
  object-fit: cover;
  animation: ken 10s ease-in-out infinite alternate;
  will-change: transform;
}
.game:nth-child(even) .game-cover { animation-duration: 9s; animation-delay: -3s; }
@keyframes ken {
  from { transform: scale(1.05) translate3d(-1%, -1%, 0); }
  to { transform: scale(1.16) translate3d(2%, 1%, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .game-cover, .bonus-btn { animation: none !important; }
}
.game-tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 1;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,0.55);
  font-size: 10px;
  font-weight: 700;
}
.game-name {
  display: block;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 32;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  min-height: var(--bottom-h);
  padding: 6px 4px calc(6px + var(--safe-b));
  background: rgba(10, 14, 22, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.bnav {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  cursor: pointer;
  border-radius: 10px;
}
.bnav span {
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: transparent;
}
.bnav.is-on {
  color: var(--accent);
}
.bnav.is-on span { background: var(--accent); }
.bnav-cta {
  color: #241806;
  background: linear-gradient(135deg, #ffe08a, #3dde9d);
  margin: 2px;
  font-weight: 800;
}
.bnav-cta span { display: none; }

.mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(8px);
}
.modal {
  position: relative;
  width: 100%;
  max-height: min(92dvh, 640px);
  overflow: auto;
  padding: 22px 18px calc(18px + var(--safe-b));
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, #1a2231, #0e151e);
  border: 1px solid var(--line);
  border-bottom: 0;
  box-shadow: 0 -18px 50px rgba(0,0,0,0.45);
  animation: sheet 0.28s ease both;
}
@keyframes sheet {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
.close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
  width: 40px;
  height: 40px;
}
.badge {
  display: inline-flex;
  margin: 0 0 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(240, 199, 94, 0.14);
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}
.modal h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 24px;
}
.tip { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.tip strong { color: var(--gold); }
#reg-form { display: grid; gap: 12px; }
#reg-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
#reg-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.28);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
  font: inherit;
  font-size: 16px;
  outline: none;
}
#reg-form input:focus { border-color: rgba(61, 222, 157, 0.5); }
.err { margin: 0; color: var(--danger); font-size: 13px; }
.primary {
  border: 0;
  border-radius: 12px;
  min-height: 48px;
  background: linear-gradient(135deg, #3dde9d, #1fa86c);
  color: #04140d;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.foot { margin: 14px 0 0; text-align: center; color: #6a7b8f; font-size: 12px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-h) + var(--safe-b) + 14px);
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100vw - 28px);
  padding: 12px 16px;
  border-radius: 12px;
  background: #152031;
  border: 1px solid var(--line);
  font-size: 13px;
}

.load-mask {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}
.load-mask[hidden] { display: none !important; }
.load-box {
  display: grid;
  justify-items: center;
  gap: 14px;
  min-width: 140px;
  padding: 28px 32px;
  border-radius: 18px;
  background: linear-gradient(180deg, #1a2231, #0e151e);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0,0,0,0.45);
}
.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-right-color: var(--gold);
  animation: spin 0.85s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.load-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

/* —— Desktop enhancement —— */
@media (min-width: 900px) {
  .shell {
    display: grid;
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    padding-bottom: 0;
  }
  .shell.is-collapsed { --side-w: 78px; }
  .shell.is-collapsed .side-brand span,
  .shell.is-collapsed .side-note,
  .shell.is-collapsed .side-link,
  .shell.is-collapsed .side-login,
  .shell.is-collapsed .side-signup { display: none; }

  .scrim, .menu-btn, .brand-mini, .bottom-nav { display: none !important; }
  .side-collapse { display: grid; place-items: center; align-self: flex-end; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
  .sidebar {
    position: sticky;
    transform: none;
    width: auto;
    height: 100vh;
    padding: 16px 14px;
  }
  .shell.is-side-open .sidebar { transform: none; }

  .topbar {
    display: flex;
    justify-content: space-between;
    padding: 12px 18px;
  }
  .balances { display: flex; gap: 8px; }
  .top-actions { gap: 10px; }
  .lang-select { max-width: 140px; padding: 8px 28px 8px 12px; font-size: 12px; }
  .bonus-btn { max-width: none; padding: 10px 16px; font-size: 13px; }
  .who { max-width: 90px; font-size: 13px; }
  .ghost { padding: 8px 12px; font-size: 12px; }

  .promo-host {
    margin: 16px 18px 10px;
    max-height: 260px;
    border-radius: 18px;
  }
  .promo-copy { padding: 22px 24px 34px; max-width: 52%; }
  .promo-title { font-size: clamp(26px, 3vw, 36px); }
  .promo-sub { font-size: 14px; }
  .promo-cta { min-height: 34px; padding: 0 14px; font-size: 12px; }
  .cats { padding: 10px 18px 4px; }
  .rail-head { padding: 0 18px 10px; }
  .rail-head h2 { font-size: 20px; }
  .rail-prev,
  .rail-next {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.04);
  }
  .rail-track {
    grid-auto-columns: 148px;
    gap: 12px;
    padding: 0 18px 8px;
    padding-right: 40px;
  }
  .rail-track-wrap::after { width: 36px; }
  .rail-track.is-wrap {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  }
  .game:hover {
    transform: translateY(-3px);
    border-color: rgba(61, 222, 157, 0.35);
  }
  .game-name { font-size: 13px; padding: 10px; }

  .mask {
    align-items: center;
    padding: 18px;
  }
  .modal {
    width: min(400px, 100%);
    max-height: none;
    border-radius: 20px;
    border-bottom: 1px solid var(--line);
    padding: 28px 22px 22px;
    animation: rise 0.25s ease both;
  }
  @keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
  }
  .toast { bottom: 22px; }
}
