:root {
  color-scheme: light;
  --bg: #eef3f7;
  --bg-deep: #07111f;
  --panel: #ffffff;
  --panel-2: #f3f7fb;
  --panel-3: #e8f6f2;
  --text: #101827;
  --muted: #667085;
  --line: #d9e2ec;
  --line-strong: #b8c6d8;
  --accent: #2167e8;
  --accent-2: #10a37f;
  --accent-3: #e7b94f;
  --danger: #c2410c;
  --ok: #0f7a5f;
  --shadow: 0 18px 48px rgba(15, 25, 44, .12);
  --soft-shadow: 0 10px 28px rgba(15, 25, 44, .08);
  --dark-panel: rgba(7, 17, 31, .72);
  --dark-line: rgba(255, 255, 255, .18);
}

* { box-sizing: border-box; }

html {
  min-width: 0;
  background: var(--bg);
}

body {
  min-width: 0;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.88) 0%, rgba(238,243,247,.96) 42%, #eaf1f6 100%);
  color: var(--text);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 11px 15px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--soft-shadow);
}

button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 2px;
}

a { color: inherit; }

.site-shell {
  min-height: var(--app-height, 100vh);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px clamp(14px, 4vw, 44px);
  background: rgba(246, 250, 253, .88);
  border-bottom: 1px solid rgba(184, 198, 216, .72);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  font-weight: 900;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(255,255,255,.18), transparent 38%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 22px rgba(33, 103, 232, .22);
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero {
  min-height: min(760px, calc(var(--app-height, 100vh) - 68px));
  position: relative;
  display: grid;
  align-content: center;
  gap: 30px;
  overflow: hidden;
  padding: 76px clamp(16px, 5vw, 70px) 42px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(7, 17, 31, .94) 0%, rgba(7, 17, 31, .78) 48%, rgba(7, 17, 31, .44) 100%),
    linear-gradient(180deg, rgba(7, 17, 31, .18), rgba(7, 17, 31, .78)),
    url("/games-hub/backgrounds/hub-menu-dark.png") center / cover no-repeat;
  isolation: isolate;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 148px;
  background: linear-gradient(180deg, transparent, rgba(238,243,247,.96));
  pointer-events: none;
  z-index: -1;
}

.hero-content {
  width: min(780px, 100%);
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--dark-line);
  border-radius: 999px;
  padding: 5px 12px;
  color: rgba(255,255,255,.88);
  background: rgba(7, 17, 31, .45);
  backdrop-filter: blur(12px);
  font-weight: 900;
}

.hero h1 {
  margin: 16px 0 0;
  max-width: 820px;
  font-size: 86px;
  line-height: .96;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 690px;
  margin: 22px 0 0;
  color: rgba(255,255,255,.82);
  font-size: 18px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.hero .secondary {
  background: rgba(255,255,255,.94);
  color: #101827;
  border-color: rgba(255,255,255,.28);
}

.visual-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: min(860px, 100%);
}

.hero-metrics {
  align-self: end;
}

.mini-stat {
  min-height: 98px;
  border: 1px solid var(--dark-line);
  border-radius: 8px;
  padding: 14px;
  color: #fff;
  background: rgba(7, 17, 31, .62);
  backdrop-filter: blur(12px);
}

.mini-stat strong {
  display: block;
  font-size: 25px;
  line-height: 1;
}

.mini-stat span {
  display: block;
  margin-top: 8px;
  color: rgba(255,255,255,.75);
}

.section {
  padding: 52px clamp(16px, 5vw, 70px);
}

.section-head {
  width: min(760px, 100%);
  margin-bottom: 18px;
}

.section h2 {
  margin: 0 0 16px;
  font-size: 31px;
  line-height: 1.12;
  letter-spacing: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.feature {
  position: relative;
  min-width: 0;
  background: var(--panel);
  border: 1px solid rgba(184, 198, 216, .78);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--soft-shadow);
}

.feature::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: .9;
}

.feature img {
  width: 100%;
  height: 168px;
  object-fit: cover;
  display: block;
}

.feature-body {
  padding: 17px;
}

.feature h3 {
  margin: 0 0 7px;
  font-size: 18px;
  line-height: 1.22;
}

.ops-section {
  padding-top: 16px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ops-item {
  min-height: 116px;
  display: grid;
  align-content: space-between;
  gap: 16px;
  border: 1px solid rgba(184, 198, 216, .78);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(16, 163, 127, .09), transparent 48%),
    #fff;
  box-shadow: var(--soft-shadow);
}

.ops-item strong {
  color: var(--accent);
  font-size: 23px;
  line-height: 1;
}

.ops-item span {
  font-weight: 900;
}

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

.small-note {
  margin: 4px 0 0;
  font-size: 13px;
}

.auth-panel, .dashboard, .chat-picker {
  width: min(1180px, calc(100% - 28px));
  margin: 24px auto;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  align-items: center;
  gap: 18px;
  border-color: rgba(33, 103, 232, .24);
  background:
    linear-gradient(135deg, rgba(33, 103, 232, .08), transparent 38%),
    var(--panel);
}

.state-screen {
  min-height: calc(var(--app-height, 100vh) - 64px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.state-card {
  width: min(420px, 100%);
  text-align: center;
}

.state-card h1 {
  margin: 12px 0 4px;
}

.loader {
  width: 34px;
  height: 34px;
  display: inline-block;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-pad { padding: 18px; }

.telegram-login-box {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.login-domain-note {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  padding: 11px 15px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.miniapp-fullscreen-button {
  position: fixed;
  top: calc(72px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  z-index: 80;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.miniapp-fullscreen-button span,
.miniapp-fullscreen-button span::before,
.miniapp-fullscreen-button span::after {
  position: absolute;
  inset: 11px;
  display: block;
  content: "";
}

.miniapp-fullscreen-button span::before,
.miniapp-fullscreen-button span::after {
  inset: 0;
  border-color: currentColor;
  border-style: solid;
}

.miniapp-fullscreen-button span::before {
  border-width: 2px 0 0 2px;
}

.miniapp-fullscreen-button span::after {
  border-width: 0 2px 2px 0;
}

.chat-picker .panel {
  overflow: hidden;
}

.chat-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  background:
    linear-gradient(135deg, rgba(33,103,232,.06), transparent),
    var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  min-height: 112px;
}

.chat-card:hover {
  border-color: color-mix(in srgb, var(--accent) 44%, var(--line));
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 14px;
}

.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
  padding: 14px;
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(33,103,232,.18), transparent 42%),
    var(--bg-deep);
  border-color: rgba(255,255,255,.14);
}

.sidebar .muted {
  color: rgba(255,255,255,.62);
}

.tabs {
  display: grid;
  gap: 7px;
}

.tab {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: rgba(255,255,255,.78);
  border: 1px solid transparent;
}

.tab:hover:not(:disabled) {
  background: rgba(255,255,255,.07);
  box-shadow: none;
}

.tab.active {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.22);
  color: #fff;
}

.dashboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  border-color: rgba(184, 198, 216, .72);
}

.dashboard-head h1 {
  margin: 4px 0;
  font-size: 27px;
  line-height: 1.1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--ok);
  background: var(--panel-3);
  font-size: 13px;
  font-weight: 900;
}

.status-line {
  color: var(--ok);
  font-weight: 900;
}

.dirty-notice {
  margin-bottom: 12px;
  border: 1px solid color-mix(in srgb, var(--accent-2) 36%, transparent);
  background: color-mix(in srgb, var(--accent-2) 10%, #fff);
  color: #0d6f58;
  border-radius: 8px;
  padding: 12px;
  font-weight: 900;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 17px;
  box-shadow: none;
}

.metric::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
}

.metric strong {
  display: block;
  font-size: 31px;
  line-height: 1;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

label.setting:first-of-type { border-top: 0; }

.setting-text {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.setting-text small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--accent-2);
}

input[type="number"], select {
  width: 156px;
  max-width: 52vw;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
  color: var(--text);
}

.savebar {
  position: sticky;
  bottom: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(14px);
}

.alert {
  display: none;
  margin-bottom: 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  color: var(--danger);
  border-radius: 8px;
  padding: 12px;
}

.top-users {
  display: grid;
  gap: 8px;
}

.top-user {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

@media (max-width: 900px) {
  .hero {
    min-height: min(680px, calc(var(--app-height, 100vh) - 64px));
    padding-top: 58px;
  }

  .hero h1 {
    font-size: 64px;
  }

  .cards, .ops-grid, .chat-list, .dash-grid, .settings-grid {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    grid-template-columns: 1fr;
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .dashboard-head {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .nav { display: none; }

  .hero {
    min-height: auto;
    padding-top: 42px;
    padding-bottom: 34px;
  }

  .hero h1 {
    font-size: 48px;
  }

  .hero-copy {
    font-size: 16px;
  }

  .hero-actions > button,
  .dashboard-head button,
  .savebar button {
    width: 100%;
  }

  .visual-panel {
    grid-template-columns: 1fr;
  }

  .dashboard-head,
  .savebar {
    flex-direction: column;
    align-items: stretch;
  }

  .savebar {
    position: static;
  }

  label.setting {
    align-items: flex-start;
    flex-direction: column;
  }

  input[type="number"], select {
    width: min(220px, 100%);
    max-width: 100%;
  }
}
