.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  isolation: isolate;
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  background: rgba(5, 13, 25, 0.78);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

body {
  scroll-padding-top: calc(var(--desktop-topbar-height, 70px) + 14px);
}

@media (min-width: 768px) {
  body {
    --desktop-topbar-height: 70px;
    padding-top: var(--desktop-topbar-height);
  }

  .topbar {
    position: fixed;
    right: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
  }

  .sportsbook-sidebar,
  .bet-slip,
  .detail-sidebar,
  .match-detail-page .detail-bet-slip {
    top: calc(var(--desktop-topbar-height) + 14px);
  }
}

@media (min-width: 768px) and (max-width: 1000px) {
  body {
    --desktop-topbar-height: 118px;
  }

  .topbar {
    min-height: var(--desktop-topbar-height);
  }
}

@supports (backdrop-filter: blur(18px)) {
  .topbar {
    background: rgba(5, 13, 25, 0.86);
  }
}

.mobile-menu-btn,
.mobile-bottom-nav {
  display: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--text);
  font-size: 23px;
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}

.brand::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.9);
}

.brand span {
  color: var(--primary);
}

.nav {
  display: flex;
  gap: 6px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 13px;
  border-radius: 999px;
  transition: color 160ms ease, background 160ms ease;
}

.nav a:hover,
.nav a.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.search-box input {
  width: min(24vw, 280px);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: rgba(10, 22, 38, 0.78);
  padding: 10px 14px;
  outline: none;
}

.search-box input::placeholder {
  color: var(--muted-2);
}

.search-box input:focus {
  border-color: rgba(34, 197, 94, 0.56);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.date-filters {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.date-chip {
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.date-chip:hover,
.date-chip.active {
  color: #04100a;
  background: var(--accent);
}

.date-chip.live {
  color: var(--primary);
}

.page {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 32px) 40px;
}

.page-header {
  margin-bottom: 18px;
}

.page-header h1 {
  margin: 0 0 6px;
}

.page-header p {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 1000px) {
  .topbar {
    flex-wrap: wrap;
  }

  .topbar-actions {
    width: 100%;
    margin-left: 0;
  }

  .search-box {
    flex: 1;
  }

  .search-box input {
    width: 100%;
  }
}

@media (max-width: 767px) {
  body {
    --mobile-bottom-nav-height: 68px;
    padding-top: 0;
  }

  .topbar {
    position: sticky;
    min-height: 52px;
    gap: 10px;
    padding: 8px 10px;
  }

  .mobile-menu-btn {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(10, 22, 38, 0.86);
    padding: 0;
  }

  .mobile-menu-btn span {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: var(--primary);
  }

  .mobile-menu-btn span + span {
    margin-top: 4px;
  }

  .brand {
    font-size: 19px;
  }

  .brand::before {
    width: 8px;
    height: 8px;
    margin-right: 5px;
  }

  .nav {
    display: none;
  }

  .topbar.mobile-nav-open .nav {
    position: absolute;
    top: 52px;
    right: 8px;
    left: 8px;
    z-index: 42;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(5, 13, 25, 0.98);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
    padding: 8px;
  }

  .topbar.mobile-nav-open .nav a {
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    padding: 10px;
  }

  .topbar-actions {
    width: auto;
    margin-left: auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .topbar-actions form,
  .topbar-actions .logout-btn,
  .topbar-actions .auth-link:not(.auth-link-primary) {
    display: none;
  }

  .wallet-chip {
    min-height: 34px;
    padding: 5px 8px;
  }

  .wallet-chip span {
    display: none;
  }

  .wallet-chip strong {
    font-size: 12px;
  }

  .date-filters {
    overflow-x: auto;
  }

  .page {
    width: 100%;
    padding: 10px 8px calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom) + 24px);
  }

  .page:has(.mobile-slip-toggle) {
    padding-bottom: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom) + 84px);
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(148, 163, 184, .18);
    background: rgba(5, 13, 25, 0.94);
    padding: 0 4px env(safe-area-inset-bottom);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(14px);
  }

  .mobile-bottom-nav a {
    position: relative;
    display: grid;
    grid-template-rows: 23px auto;
    place-items: center;
    align-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 58px;
    margin: 5px 2px;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 800;
    line-height: 1;
    transition: color 150ms ease, background 150ms ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav a::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 24%;
    right: 24%;
    height: 2px;
    border-radius: 0 0 999px 999px;
    background: transparent;
  }

  .mobile-nav-icon {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-bottom-nav a.active {
    color: var(--primary);
    background: rgba(34, 197, 94, .1);
  }

  .mobile-bottom-nav a.active::before {
    background: var(--primary);
  }

  .mobile-bottom-nav a:not(.active):hover {
    color: var(--text);
    background: rgba(148, 163, 184, .08);
  }

  .mobile-bottom-nav a:focus-visible {
    outline: 2px solid #38bdf8;
    outline-offset: -2px;
  }
}

.profile-menu {
  position: relative;
  flex: 0 0 auto;
}

.profile-menu-trigger {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: rgba(10, 22, 38, 0.86);
  padding: 4px 9px 4px 5px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.profile-menu-trigger:hover,
.profile-menu-trigger[aria-expanded="true"] {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.08);
}

.profile-menu-trigger:focus-visible,
.profile-menu-dropdown a:focus-visible,
.profile-menu-logout:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #04100a;
  background: var(--primary);
}

.profile-avatar svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.profile-menu-username {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu-chevron {
  color: var(--muted);
  font-size: 14px;
  transition: transform 160ms ease;
}

.profile-menu-trigger[aria-expanded="true"] .profile-menu-chevron {
  transform: rotate(180deg);
}

.profile-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  display: grid;
  width: min(280px, calc(100vw - 24px));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(5, 13, 25, 0.98);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.42);
  padding: 7px;
}

.profile-menu-dropdown[hidden] {
  display: none;
}

.profile-menu-identity {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px 9px 9px;
}

.profile-menu-identity strong,
.profile-menu-identity span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu-identity span {
  color: var(--muted);
  font-size: 12px;
}

.profile-menu-dropdown a,
.profile-menu-logout {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  color: #dbe7f3;
  background: transparent;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.profile-menu-dropdown a:hover {
  background: rgba(255, 255, 255, 0.06);
}

.profile-menu-divider {
  height: 1px;
  margin: 5px 3px;
  background: var(--border);
}

.profile-menu-dropdown form {
  display: block;
  margin: 0;
}

.profile-menu-logout {
  color: #fca5a5;
}

.profile-menu-logout:hover {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.11);
}

@media (max-width: 767px) {
  .profile-menu-username {
    display: none;
  }

  .profile-menu-trigger {
    min-height: 38px;
    gap: 4px;
    padding-right: 7px;
  }

  .profile-avatar {
    width: 28px;
    height: 28px;
  }

  .topbar-actions .profile-menu-dropdown form {
    display: block;
  }

  .wallet-chip {
    min-width: 0;
  }
}

@media (max-width: 380px) {
  .wallet-chip {
    padding-inline: 6px;
  }

  .profile-menu-dropdown {
    position: fixed;
    top: 58px;
    right: 8px;
  }
}
