:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #007aff);
  --button: var(--tg-theme-button-color, #007aff);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary: var(--tg-theme-secondary-bg-color, #efeff4);
  --section: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --separator: color-mix(in srgb, var(--text) 10%, transparent);
  --glass: color-mix(in srgb, var(--section) 62%, transparent);
  --glass-strong: color-mix(in srgb, var(--section) 78%, transparent);
  --glass-border: color-mix(in srgb, #ffffff 55%, transparent);
  --glass-shadow: 0 8px 28px color-mix(in srgb, #000000 12%, transparent);
  --accent-soft: color-mix(in srgb, var(--button) 18%, transparent);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: calc(56px + var(--safe-bottom));
  color-scheme: light dark;
}

html[data-theme="light"] {
  --bg: #f2f2f7;
  --text: #000000;
  --hint: #8e8e93;
  --link: #007aff;
  --button: #007aff;
  --button-text: #ffffff;
  --secondary: #e5e5ea;
  --section: #ffffff;
  --separator: rgba(60, 60, 67, 0.12);
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --accent-soft: rgba(0, 122, 255, 0.14);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0e1621;
  --text: #ffffff;
  --hint: #8b98a5;
  --link: #5ac8fa;
  --button: #2aabee;
  --button-text: #ffffff;
  --secondary: #17212b;
  --section: #1c2733;
  --separator: rgba(255, 255, 255, 0.1);
  --glass: rgba(28, 39, 51, 0.55);
  --glass-strong: rgba(28, 39, 51, 0.78);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  --accent-soft: rgba(42, 171, 238, 0.18);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
}

.ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 12% -10%, color-mix(in srgb, var(--button) 28%, transparent), transparent 55%),
    radial-gradient(90% 70% at 100% 8%, color-mix(in srgb, #af52de 22%, transparent), transparent 50%),
    radial-gradient(80% 60% at 50% 110%, color-mix(in srgb, var(--button) 18%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--secondary));
}

.ambient::before,
.ambient::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: floatOrb 12s ease-in-out infinite;
}

.ambient::before {
  width: 220px;
  height: 220px;
  left: -40px;
  top: 18%;
  background: color-mix(in srgb, var(--button) 40%, transparent);
}

.ambient::after {
  width: 260px;
  height: 260px;
  right: -60px;
  bottom: 22%;
  background: color-mix(in srgb, #af52de 35%, transparent);
  animation-delay: -4s;
}

@keyframes floatOrb {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(18px, -24px, 0) scale(1.08);
  }
}

.content,
.tabbar {
  position: relative;
  z-index: 1;
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: 14px 14px calc(var(--tabbar-h) + 18px);
  scroll-behavior: smooth;
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: pageIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.glass {
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 12px;
  animation: rise 0.35s ease both;
}

.avatar {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--secondary) 80%, var(--button) 20%);
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 8px 20px var(--accent-soft);
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.stat-card {
  padding: 14px 14px 16px;
  animation: rise 0.45s ease both;
}

.stat-label {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 22px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.banner-slider {
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
  animation: rise 0.35s ease both;
}

.banner-track {
  display: flex;
  width: 100%;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.banner-slide {
  min-width: 100%;
  padding: 22px 18px 34px;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
}

.banner-a {
  background:
    linear-gradient(135deg, rgba(8, 18, 32, 0.15), rgba(8, 18, 32, 0.55)),
    radial-gradient(120% 120% at 0% 0%, #2aabee 0%, transparent 55%),
    linear-gradient(135deg, #1b2735, #0f1722);
}

.banner-b {
  background:
    linear-gradient(135deg, rgba(8, 18, 32, 0.15), rgba(8, 18, 32, 0.55)),
    radial-gradient(120% 120% at 100% 0%, #af52de 0%, transparent 55%),
    linear-gradient(135deg, #241a33, #12161f);
}

.banner-c {
  background:
    linear-gradient(135deg, rgba(8, 18, 32, 0.15), rgba(8, 18, 32, 0.55)),
    radial-gradient(120% 120% at 50% 0%, #20b26c 0%, transparent 55%),
    linear-gradient(135deg, #163028, #101820);
}

.banner-kicker {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.banner-title {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
}

.banner-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.35;
}

.banner-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.banner-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.35);
  padding: 0;
  cursor: pointer;
}

.banner-dot.active {
  background: #fff;
  transform: scale(1.15);
}

.chart-card {
  padding: 12px;
  margin-bottom: 12px;
  animation: rise 0.4s ease both;
}

.asset-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.asset-btn {
  border: none;
  border-radius: 12px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 720;
  color: var(--hint);
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.asset-btn.active {
  color: var(--button-text);
  background: var(--button);
}

.asset-btn:active {
  transform: scale(0.96);
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.promo-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 4px;
  animation: rise 0.45s ease both;
}

.promo-media {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.promo-media img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.promo-copy {
  min-width: 0;
}

.promo-title {
  font-size: 14px;
  font-weight: 760;
  margin-bottom: 3px;
}

.promo-text {
  font-size: 12px;
  color: var(--hint);
  line-height: 1.35;
}

.chart-pair {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 4px;
}

.chart-price {
  font-size: 22px;
  font-weight: 780;
  letter-spacing: -0.02em;
}

.chart-change {
  font-size: 14px;
  font-weight: 740;
  padding: 6px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, #20b26c 16%, transparent);
  color: #20b26c;
}

.chart-change.is-down {
  background: color-mix(in srgb, #ef454a 16%, transparent);
  color: #ef454a;
}

.chart-change.is-up {
  background: color-mix(in srgb, #20b26c 16%, transparent);
  color: #20b26c;
}

#home-chart {
  width: 100%;
  height: 180px;
  display: block;
}

.profile-info {
  min-width: 0;
}

.name {
  font-size: 19px;
  font-weight: 720;
  margin-bottom: 2px;
}

.username {
  color: var(--hint);
  font-size: 14px;
}

.balance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  margin-bottom: 12px;
  animation: rise 0.4s ease both;
  animation-delay: 0.04s;
}

.balance-main {
  min-width: 0;
}

.balance-label {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 6px;
}

.balance-value {
  font-size: 28px;
  font-weight: 780;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, var(--text), color-mix(in srgb, var(--button) 70%, var(--text)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.withdraw-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 700;
  color: var(--button-text);
  background: linear-gradient(145deg, var(--button), color-mix(in srgb, var(--button) 55%, #af52de));
  box-shadow: 0 8px 18px var(--accent-soft);
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.withdraw-btn:active {
  transform: scale(0.96);
  opacity: 0.92;
}

.gift-card.is-pressing {
  transform: scale(0.94);
}

.toast-layer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  display: flex;
  justify-content: center;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 0;
  pointer-events: none;
  background: transparent;
}

.toast-layer[hidden] {
  display: none !important;
}

.toast-card {
  width: min(100%, 420px);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  transform: translateY(-120%);
  opacity: 0;
  transition:
    transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.38s ease;
}

.toast-layer.is-open .toast-card {
  transform: translateY(0);
  opacity: 1;
}

.toast-layer.is-closing .toast-card {
  transform: translateY(-120%);
  opacity: 0;
  transition:
    transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.45s ease;
}

.toast-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  background: #ff3b30;
  box-shadow: 0 8px 18px rgba(255, 59, 48, 0.28);
}

.toast-text {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.info-list {
  overflow: hidden;
  animation: rise 0.45s ease both;
  animation-delay: 0.08s;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  font-size: 15px;
  border-bottom: 1px solid var(--separator);
}

.info-row:last-child {
  border-bottom: none;
}

.info-row span:last-child {
  color: var(--hint);
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 8px;
}

.gift-card {
  padding: 10px 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: cardIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.gift-card:nth-child(1) { animation-delay: 0.02s; }
.gift-card:nth-child(2) { animation-delay: 0.04s; }
.gift-card:nth-child(3) { animation-delay: 0.06s; }
.gift-card:nth-child(4) { animation-delay: 0.08s; }
.gift-card:nth-child(5) { animation-delay: 0.1s; }
.gift-card:nth-child(6) { animation-delay: 0.12s; }
.gift-card:nth-child(7) { animation-delay: 0.14s; }
.gift-card:nth-child(8) { animation-delay: 0.16s; }
.gift-card:nth-child(n + 9) { animation-delay: 0.18s; }

.gift-card:active {
  transform: scale(0.97);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gift-image-wrap {
  width: 100%;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  background: color-mix(in srgb, var(--secondary) 55%, transparent);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--glass-border) 70%, transparent);
}

.gift-image {
  width: 70px;
  height: 70px;
  object-fit: contain;
  transition: transform 0.25s ease;
}

.gift-card:active .gift-image {
  transform: scale(1.06);
}

.gift-name {
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  margin-bottom: 4px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gift-pct {
  font-size: 13px;
  font-weight: 760;
  color: var(--button);
}

.gift-pct.is-down {
  color: #ff3b30;
}

.gift-pct.is-up {
  color: #34c759;
}

.settings-block {
  overflow: hidden;
  animation: rise 0.35s ease both;
}

.settings-gap {
  margin-top: 12px;
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 11px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--separator);
  text-align: left;
  transition: background 0.18s ease;
}

.lang-option:last-child {
  border-bottom: none;
}

.lang-option:active {
  background: var(--accent-soft);
}

.lang-option.active .theme-check {
  border-color: var(--button);
  background: var(--button);
  transform: scale(1.05);
}

.support-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.18s ease;
}

.support-link:active {
  background: var(--accent-soft);
}

.support-user {
  color: var(--button);
  font-weight: 650;
}

.settings-title {
  padding: 14px 16px 8px;
  font-size: 13px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.theme-options {
  display: flex;
  flex-direction: column;
}

.theme-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 11px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--separator);
  text-align: left;
  transition: background 0.18s ease;
}

.theme-option:last-child {
  border-bottom: none;
}

.theme-option:active {
  background: var(--accent-soft);
}

.theme-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--hint);
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.theme-option.active .theme-check {
  border-color: var(--button);
  background: var(--button);
  transform: scale(1.05);
}

.theme-option.active .theme-check::after,
.lang-option.active .theme-check::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--button-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.deals-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: rise 0.35s ease both;
}

.deal-card {
  position: relative;
  padding: 14px 14px 14px 16px;
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.deal-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.deal-card-title {
  font-size: 15px;
  font-weight: 720;
  line-height: 1.25;
}

.deal-card-id {
  margin-top: 4px;
  font-size: 12px;
  color: var(--hint);
}

.deal-status {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 4px 8px;
  border-radius: 999px;
  line-height: 1;
}

.deal-status.open {
  color: #1f8f4e;
  background: color-mix(in srgb, #34c759 18%, transparent);
}

.deal-status.paid {
  color: #b15c00;
  background: color-mix(in srgb, #ff9f0a 20%, transparent);
}

.deal-status.closed {
  color: var(--hint);
  background: color-mix(in srgb, var(--hint) 16%, transparent);
}

html[data-theme="dark"] .deal-status.open {
  color: #4cd964;
}

html[data-theme="dark"] .deal-status.paid {
  color: #ffd60a;
}

.deal-chat-btn {
  display: inline-flex;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--button);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.deal-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
  font-size: 13px;
  line-height: 1.35;
  margin-top: 6px;
}

.deal-row-label {
  color: var(--hint);
}

.deal-row-value {
  word-break: break-word;
}

.deal-row-value a {
  color: var(--link);
  text-decoration: none;
}

.empty-state {
  padding: 28px 18px;
  text-align: center;
  animation: rise 0.35s ease both;
}

.empty-title {
  font-size: 18px;
  font-weight: 720;
  margin-bottom: 8px;
}

.empty-text {
  font-size: 14px;
  color: var(--hint);
  line-height: 1.4;
}

.tabbar {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(8px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  padding: 5px;
  background: var(--glass-strong);
  backdrop-filter: saturate(190%) blur(30px);
  -webkit-backdrop-filter: saturate(190%) blur(30px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--glass-shadow);
  z-index: 30;
}

.tab {
  position: relative;
  border: none;
  background: transparent;
  color: var(--hint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 1px;
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 14px;
  transition: color 0.2s ease, background 0.2s ease, transform 0.18s ease;
}

.tab svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.tab.active {
  color: var(--button);
  background: var(--accent-soft);
}

.tab.active svg {
  transform: translateY(-1px) scale(1.06);
}

.tab:active {
  transform: scale(0.96);
}

@media (prefers-reduced-motion: reduce) {
  .ambient::before,
  .ambient::after,
  .page.active,
  .gift-card,
  .profile,
  .balance-card,
  .info-list,
  .settings-block,
}
