/* ==========================================================================
   Merkato Bet Win — mobile-first PWA theme
   Midnight Navy #0D1117 / #161B22 · Dark Slate cards #21262D
   Vivid Blue #2563EB accents · Red #EF4444 badges · borders #30363D
   ========================================================================== */

:root {
  --bg: #0D1117;
  --bg-2: #161B22;
  --card: #21262D;
  --border: #30363D;
  --accent: #2563EB;
  --accent-2: #3B82F6;
  --red: #EF4444;
  --text: #E6EDF3;
  --muted: #8B949E;
  --radius: 16px;
  --header-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: calc(72px + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }

.accent { color: var(--accent-2); }
.muted { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }

/* ---- Header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 14px;
  background: rgba(13, 17, 23, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-badge {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.45);
}
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: 0.3px; }

.header-actions { display: flex; align-items: center; gap: 9px; }

.balance-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-2);
  font-weight: 700;
  font-size: 0.9rem;
}
.balance-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.balance-eye { color: var(--muted); }
.balance-eye .eye-slash { display: none; }
.balance-widget.is-hidden .eye-slash { display: block; }
.balance-widget.is-hidden .balance-eye { color: var(--accent-2); }

.deposit-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.4);
  transition: transform 0.12s ease, background 0.12s ease;
}
.deposit-btn:active { transform: scale(0.94); }
.deposit-btn:hover { background: var(--accent-2); }

/* ---- Install banner ---- */
.install-banner {
  position: sticky;
  top: var(--header-h);
  z-index: 29;
  margin: 10px 14px 0;
  padding: 10px 13px;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.install-banner__body { display: flex; align-items: center; gap: 10px; flex: 1; }
.install-banner__body p { font-size: 0.85rem; }
.install-banner__close { color: var(--muted); font-size: 1.3rem; padding: 0 4px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 700;
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 10px; }

/* ---- Views ---- */
.view { display: none; }
.view--active { display: block; animation: fadeIn 0.2s ease; }

/* ---- Hero banner slider ---- */
.hero { padding: 12px 14px 0; }
.hero__track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: var(--radius);
}
.hero__track::-webkit-scrollbar { display: none; }
.hero__slide { flex: 0 0 100%; scroll-snap-align: center; padding: 0 3px; }
.hero__slide-inner {
  position: relative;
  min-height: 158px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.hero__tag {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.hero__title { font-size: 1.45rem; font-weight: 800; color: #fff; }
.hero__sub { font-size: 0.85rem; color: rgba(230, 237, 243, 0.8); margin-top: 4px; }

.hero__dots { display: flex; justify-content: center; gap: 6px; padding: 10px 0 2px; }
.hero__dot {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--border);
  transition: width 0.2s ease, background 0.2s ease;
}
.hero__dot--active { width: 20px; background: var(--accent); }

/* ---- Live wins marquee ---- */
.live-wins {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  overflow: hidden;
}
.live-wins__pulse {
  width: 8px; height: 8px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.live-wins__label { flex: 0 0 auto; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); }
.live-wins__strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.live-wins__strip::-webkit-scrollbar { display: none; }
.win-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.78rem;
}
.win-chip__amount { color: var(--accent-2); font-weight: 800; }

/* ---- Filters ---- */
.filters { padding: 6px 14px 4px; }
.pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pill--active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pills--providers { padding-top: 8px; }

/* ---- Game grid ---- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 12px 14px 24px;
}
.game-card {
  position: relative;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.game-card:active { transform: scale(0.97); }
.game-card:hover { border-color: var(--accent-2); }
.game-thumb {
  position: relative;
  height: 112px;
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.game-thumb__label {
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}
.featured-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
}
.game-card__meta { padding: 10px 12px 12px; }
.game-card__title { font-size: 0.86rem; font-weight: 700; }
.game-card__sub { font-size: 0.7rem; color: var(--muted); margin-top: 3px; }

.empty { padding: 30px 14px; text-align: center; color: var(--muted); }

/* ---- Bottom navigation ---- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(13, 17, 23, 0.97);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  backdrop-filter: blur(10px);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--muted);
  transition: color 0.15s;
}
.nav-item svg { width: 23px; height: 23px; }
.nav-label { font-size: 0.62rem; font-weight: 600; }
.nav-item--active { color: var(--accent-2); }
.nav-item--active .nav-label { font-weight: 800; }

/* ---- Drawer ---- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  animation: fadeIn 0.2s ease;
}
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 51;
  width: min(84vw, 320px);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
  overflow-y: auto;
}
.drawer--open { transform: translateX(0); }
.drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer__head .modal__close { position: static; }

/* User info card */
.drawer__user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.user-avatar {
  width: 44px; height: 44px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
}
.user-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; flex: 1; min-width: 0; }
.user-name { font-weight: 700; font-size: 0.92rem; }
.vip-badge {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #1a1300;
  background: #ECC94B;
  padding: 2px 8px;
  border-radius: 5px;
}

/* Nav groups */
.drawer__nav { display: flex; flex-direction: column; padding: 0 0 16px; }
.drawer__section {
  margin: 16px 16px 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.72;
}
.drawer__section:first-of-type { border-top: none; margin-top: 6px; padding-top: 0; }

/* Item button cards */
.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  margin: 4px 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.drawer-item:hover { border-color: var(--accent-2); }
.drawer-item:active {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.14);
}
.drawer-item__icon { flex: 0 0 auto; font-size: 1.15rem; line-height: 1; }
.drawer-item__label { flex: 1; min-width: 0; }
.drawer-item__chevron { flex: 0 0 auto; color: var(--muted); font-size: 1.15rem; font-weight: 400; }
.soon-badge {
  flex: 0 0 auto;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #fff;
  background: var(--red);
  padding: 3px 8px;
  border-radius: 999px;
}

/* ---- Promotions ---- */
.promo-redeem { display: flex; gap: 8px; margin: 14px 14px 12px; padding: 8px; }
.promo-redeem__input {
  flex: 1; min-width: 0;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.promo-grid { display: grid; gap: 12px; padding: 0 14px 24px; }
.promo-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
}
.promo-card__banner { height: 110px; display: flex; align-items: flex-end; padding: 12px; }
.promo-card__body { padding: 14px; }
.promo-card__headline { font-size: 1.05rem; font-weight: 800; }
.promo-card__desc { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }

/* ---- Search modal ---- */
.modal__card--search { padding: 16px; }
.search-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.search-bar input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.search-bar .modal__close { position: static; }
.game-grid--search { padding: 12px 0 0; }

/* ---- Sport modal ---- */
.modal__card--sport { text-align: center; }
.sport-title { font-size: 1.45rem; font-weight: 800; margin: 8px 0 6px; }
.notify-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.notify-form input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.notify-msg { margin-top: 12px; color: var(--accent-2); font-weight: 600; }

/* ---- Modals ---- */
.modal { position: fixed; inset: 0; z-index: 60; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); animation: fadeIn 0.2s ease; }
.modal__card {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 400px);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  animation: popIn 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.modal__title { font-size: 1.25rem; font-weight: 800; margin-bottom: 4px; }
.modal__close {
  position: absolute; top: 10px; right: 12px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 1.3rem;
  color: var(--muted);
}
.modal__close:hover { background: var(--card); color: var(--text); }
.modal form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.modal form input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.modal__card--game {
  width: min(96vw, 760px);
  height: 84vh;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.game-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.game-modal__title { font-weight: 700; }
.game-modal__head .modal__close { position: static; }
.game-frame { flex: 1; width: 100%; border: 0; background: #010409; }
.game-modal__hint { padding: 8px 14px; font-size: 0.74rem; text-align: center; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(76px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 70;
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
  font-size: 0.85rem;
  max-width: 88vw;
  animation: popIn 0.2s ease;
}

/* ---- Phone input + auth ---- */
.phone-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.15s;
}
.phone-field:focus-within { border-color: var(--accent); }
.phone-prefix {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 12px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.flag { font-size: 1rem; line-height: 1; }
.modal form .phone-field input {
  flex: 1;
  min-width: 0;
  padding: 12px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.field-error {
  margin: -4px 2px 0;
  font-size: 0.78rem;
  color: var(--red);
}
.modal form .terms {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0;
}
.modal form .terms input {
  width: 16px; height: 16px;
  flex: 0 0 auto;
  padding: 0;
  margin: 2px 0 0;
  border: 1px solid var(--border);
  accent-color: var(--accent);
}
.auth-switch { margin-top: 14px; text-align: center; font-size: 0.85rem; color: var(--muted); }
.link { color: var(--accent-2); font-weight: 700; }
.link:hover { text-decoration: underline; }

/* ---- Header auth states ---- */
.header-guest { display: flex; align-items: center; gap: 8px; }
.header-auth { display: flex; align-items: center; gap: 9px; }
.profile-avatar {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.15s;
}
.profile-avatar:hover { border-color: var(--accent-2); }
.profile-avatar svg { width: 20px; height: 20px; }

/* ---- Profile panel ---- */
.profile-panel {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 51;
  width: min(84vw, 320px);
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
  overflow-y: auto;
  display: flex; flex-direction: column;
  padding-bottom: 16px;
}
.profile-panel--open { transform: translateX(0); }
.profile-panel__head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar--lg { width: 48px; height: 48px; flex: 0 0 auto; }
.profile-id { flex: 1; min-width: 0; }
.profile-name { font-weight: 700; font-size: 0.9rem; }
.profile-phone { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.profile-panel__head .modal__close { position: static; }
.profile-balance {
  margin: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.profile-balance__amount { font-size: 1.4rem; font-weight: 800; color: var(--accent-2); }
.profile-links { display: flex; flex-direction: column; padding: 0 12px; }
.profile-link {
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  padding: 13px 14px;
  margin: 4px 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
}
.profile-link:hover { border-color: var(--accent-2); }
.profile-link__icon { flex: 0 0 auto; }
.profile-link__chevron { flex: 0 0 auto; margin-left: auto; color: var(--muted); }
.btn-danger { background: var(--red); color: #fff; margin: 6px 14px 0; }
.btn-danger:hover { background: #dc2626; }

/* ---- Desktop ---- */
@media (min-width: 768px) {
  .app-header, .hero, .live-wins, .filters, .game-grid, .promo-redeem, .promo-grid { max-width: 1080px; margin-left: auto; margin-right: auto; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .hero__slide-inner { min-height: 200px; }
  .promo-grid { grid-template-columns: repeat(2, 1fr); }
  .bottom-nav { display: none; }
  body { padding-bottom: 24px; }
}
