:root {
  --bg: var(--tg-theme-secondary-bg-color, #0d1117);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #171e27));
  --card2: rgba(138, 150, 163, .08);
  --text: var(--tg-theme-text-color, #e9eef4);
  --hint: var(--tg-theme-hint-color, #8b97a4);
  --link: var(--tg-theme-link-color, #5aaff0);
  --accent: var(--tg-theme-button-color, #3a8ee6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #ec5b5b);
  --head: var(--tg-theme-section-header-text-color, var(--hint));
  --sep: rgba(138, 150, 163, .18);
  --gold: #e8b64c;
  --epic: #a77bf3;
  --rare: #4fa3f7;
  --good: #35b97a;
  --warn: #f0904a;
  --r: 16px;
  --tabbar-h: 62px;
  color-scheme: dark light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
img { display: block; }
.num { font-variant-numeric: tabular-nums; }

.view {
  min-height: 100vh;
  padding: 12px 12px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--sep);
}
.tab {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--hint); font-size: 11px; font-weight: 500; cursor: pointer; padding: 0;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tab.active { color: var(--accent); }
.tab.active svg { stroke-width: 2.2; }

/* ---------- cards & sections ---------- */
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card.flush { padding: 4px 0; }
.sec-title {
  margin: 18px 4px 8px; font-size: 13px; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--head); display: flex; justify-content: space-between; align-items: baseline;
}
.sec-title .more { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--link); font-size: 13px; }
.hint { color: var(--hint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.muted-box { background: var(--card2); border-radius: 12px; padding: 10px 12px; }
.center { text-align: center; }
.row-flex { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.spacer { height: 8px; }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 600; cursor: pointer;
  background: var(--card2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.link { background: none; color: var(--link); padding: 6px 4px; font-weight: 500; }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }

/* ---------- inputs ---------- */
.input {
  width: 100%; border: 1px solid var(--sep); background: var(--card); border-radius: 12px; padding: 11px 12px;
  outline: none; font-size: 16px;
}
.input:focus { border-color: var(--accent); }
.search { position: relative; }
.search .input { padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); stroke: var(--hint); fill: none; stroke-width: 2; }
.field { display: flex; gap: 8px; }
.field .input { flex: 1; min-width: 0; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 500;
  background: var(--card); color: var(--text); cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-text); }
.chip .c { opacity: .65; margin-left: 4px; }

/* ---------- list rows ---------- */
.list { background: var(--card); border-radius: var(--r); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; position: relative; cursor: pointer;
}
.item + .item::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; border-top: 1px solid var(--sep); }
.item:active { background: var(--card2); }
.item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { color: var(--hint); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .side { text-align: right; flex: none; font-size: 13px; }

.thumb {
  position: relative; flex: none; width: 92px; height: 43px; border-radius: 8px; overflow: hidden;
  background: linear-gradient(135deg, rgba(58, 142, 230, .35), rgba(167, 123, 243, .25));
}
.thumb::before {
  content: attr(data-l); position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 700; color: rgba(255, 255, 255, .8); font-size: 18px;
}
.thumb img { position: relative; width: 100%; height: 100%; object-fit: cover; }
.thumb.sq { width: 44px; height: 44px; border-radius: 10px; }
.thumb.ach { width: 48px; height: 48px; border-radius: 10px; }
.thumb.ach.locked img { filter: grayscale(1); opacity: .55; }
.thumb.avatar { width: 68px; height: 68px; border-radius: 50%; }

/* ---------- progress ---------- */
.bar { height: 6px; border-radius: 6px; background: var(--card2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar.gold > i { background: var(--gold); }
.bar.thin { height: 4px; margin-top: 5px; }
.pct { font-weight: 700; }
.pct.full { color: var(--gold); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 3px; border-radius: 6px; padding: 2px 6px; font-size: 11px;
  font-weight: 600; background: var(--card2); color: var(--hint); white-space: nowrap; vertical-align: middle;
}
.badge.gold { background: rgba(232, 182, 76, .16); color: var(--gold); }
.badge.good { background: rgba(53, 185, 122, .16); color: var(--good); }
.badge.warn { background: rgba(240, 144, 74, .16); color: var(--warn); }
.badge.bad { background: rgba(236, 91, 91, .14); color: var(--danger); }
.badge.acc { background: rgba(58, 142, 230, .16); color: var(--accent); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 14px; align-items: center; }
.profile-head h1 { font-size: 21px; margin: 0; line-height: 1.2; }
.online { color: var(--good); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px 10px; }
.stat b { display: block; font-size: 20px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { color: var(--hint); font-size: 12px; }
.stat.gold b { color: var(--gold); }

.hero { text-align: center; padding: 26px 18px 20px; }
.logo {
  width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 22px; display: grid; place-items: center;
  font-size: 38px; font-weight: 800; color: #fff;
  background: linear-gradient(140deg, #3a8ee6, #7b5cf0 70%, #c35cf0);
  box-shadow: 0 10px 30px rgba(90, 100, 240, .35);
}
.hero h1 { margin: 0 0 6px; font-size: 24px; }
.hero p { margin: 0 0 18px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--hint); font-size: 13px; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--sep); }
.features { display: grid; gap: 10px; }
.features div { display: flex; gap: 10px; align-items: flex-start; }
.features i { font-style: normal; font-size: 20px; width: 26px; text-align: center; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 28px; background: var(--sep); transition: .2s; cursor: pointer;
}
.switch span::after {
  content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%;
  background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ---------- game page ---------- */
.cover { width: 100%; aspect-ratio: 460 / 215; border-radius: var(--r); overflow: hidden; position: relative;
  background: linear-gradient(135deg, rgba(58, 142, 230, .35), rgba(167, 123, 243, .25)); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.game-title { font-size: 22px; font-weight: 700; margin: 12px 2px 6px; line-height: 1.2; }
.kv { display: flex; flex-wrap: wrap; gap: 6px; }
.kv .badge { font-size: 12px; padding: 4px 8px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button {
  border: 0; border-radius: 10px; padding: 9px 4px; background: var(--card2); color: var(--text); font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.seg button.on { background: var(--accent); color: var(--accent-text); }
.seg button.on.done { background: var(--good); color: #fff; }
.ach-big { display: flex; align-items: baseline; gap: 8px; }
.ach-big b { font-size: 28px; font-variant-numeric: tabular-nums; }

.ach { align-items: flex-start; }
.ach .title { white-space: normal; }
.ach .desc { color: var(--hint); font-size: 13px; margin-top: 2px; }
.ach .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.rar { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 8px; background: var(--card2); color: var(--hint); }
.rar.leg { color: var(--gold); background: rgba(232, 182, 76, .15); }
.rar.epic { color: var(--epic); background: rgba(167, 123, 243, .15); }
.rar.rare { color: var(--rare); background: rgba(79, 163, 247, .14); }
.howto { margin-top: 8px; padding: 10px; border-radius: 12px; background: var(--card2); font-size: 13px; }
.howto .links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.howto .links .btn { padding: 7px 10px; font-size: 13px; background: var(--card); }

/* ---------- prices ---------- */
.verdict { border: 1.5px solid var(--good); }
.verdict .big { font-size: 16px; font-weight: 600; }
.region { display: flex; align-items: center; gap: 10px; padding: 9px 12px; position: relative; }
.region + .region::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; border-top: 1px solid var(--sep); }
.region.home { background: rgba(58, 142, 230, .08); }
.region .flag { font-size: 20px; width: 26px; text-align: center; }
.region .rub { font-weight: 700; font-variant-numeric: tabular-nums; }
.offer { display: block; padding: 12px; cursor: pointer; position: relative; }
.offer + .offer::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; border-top: 1px solid var(--sep); }
.offer:active { background: var(--card2); }
.offer .top { display: flex; align-items: center; gap: 8px; }
.offer .price { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.offer .src { margin-left: auto; font-size: 12px; color: var(--hint); font-weight: 600; }
.offer .otitle { margin-top: 4px; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.offer .meta { color: var(--hint); font-size: 12px; margin-top: 4px; }
.offer.best { background: rgba(53, 185, 122, .07); }
.source-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; }
.source-line + .source-line { border-top: 1px solid var(--sep); }

/* ---------- misc ---------- */
.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--card) 0%, var(--card2) 50%, var(--card) 100%);
  background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { text-align: center; padding: 36px 16px; color: var(--hint); }
.empty .e { font-size: 40px; margin-bottom: 8px; }
.error { text-align: center; padding: 28px 16px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s;
  background: rgba(20, 24, 30, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.sticky { position: sticky; top: 0; z-index: 5; background: var(--bg); margin: -12px -12px 0; padding: 12px 12px 4px; }
.scan { display: flex; gap: 10px; align-items: center; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--sep); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.date-input { border: 1px solid var(--sep); background: var(--card); border-radius: 10px; padding: 8px 10px; }
.goal { display: flex; gap: 10px; align-items: center; padding: 8px 0; }
.goal + .goal { border-top: 1px solid var(--sep); }

/* ---------- оценка профиля ---------- */
.rating { position: relative; overflow: hidden; }
.rating::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: radial-gradient(120% 80% at 100% 0%, rgba(167, 123, 243, .22), transparent 60%);
}
.rate-top { display: flex; align-items: center; gap: 12px; position: relative; }
.rate-emoji { font-size: 40px; line-height: 1; width: 52px; text-align: center; }
.rate-title { font-size: 19px; font-weight: 800; line-height: 1.2; }
.rate-index { text-align: right; flex: none; }
.rate-index b { font-size: 28px; font-weight: 800; }
.rate-index span { color: var(--hint); font-size: 13px; }
.bar.heat > i { background: linear-gradient(90deg, #35b97a, #e8b64c 55%, #ec5b5b); }
.rbadges { margin-top: 12px; display: grid; gap: 8px; position: relative; }
.rbadge { display: flex; gap: 10px; align-items: flex-start; background: var(--card2); border-radius: 12px; padding: 8px 10px; }
.rbadge .re { font-size: 22px; width: 28px; text-align: center; line-height: 1.2; }
.life { margin-top: 12px; position: relative; display: grid; gap: 2px; }

/* ---------- жанры и вкус ---------- */
.chip.ghost { background: transparent; color: var(--hint); border: 1px dashed var(--sep); display: inline-flex; align-items: center; gap: 6px; }
.spin.mini { width: 12px; height: 12px; border-width: 2px; }
.taste { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.tchip span { font-size: 13px; font-weight: 600; }
.sec-title .more.btn { padding: 0; }

/* ---------- статистика ---------- */
.seg.two { grid-template-columns: 1fr 1fr; }
.rank { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.medal { position: relative; width: 44px; height: 44px; flex: none; }
.medal img { position: absolute; inset: 0; width: 100%; height: 100%; }
.thumb.hero { width: 62px; height: 35px; border-radius: 6px; }
.item.match { border-left: 3px solid transparent; }
.item.match.win { border-left-color: var(--good); }
.item.match.loss { border-left-color: var(--danger); }
.wtext { color: var(--good); }
.ltext { color: var(--danger); }
.stat.good b { color: var(--good); }
.stat.bad b { color: var(--danger); }
.bar.good > i { background: var(--good); }
.bar.bad > i { background: var(--danger); }
.verdict-card { font-weight: 600; }
.linkrow { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.flag { font-size: 18px; }
.lvl { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800;
  font-size: 14px; border: 2.5px solid currentColor; }
.lvl.l1 { color: #d9d9d9; }
.lvl.l2 { color: #1ce400; }
.lvl.l4 { color: #ffc800; }
.lvl.l8 { color: #ff6309; }
.lvl.l10 { color: #fe1f00; }
.smurf { border: 1.5px solid var(--good); }
.smurf.mid { border-color: #e8b64c; }
.smurf.warn { border-color: var(--warn); }
.smurf.bad { border-color: var(--danger); }
.smurf .big { font-size: 17px; }
.reasons { margin-top: 10px; display: grid; gap: 4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-weight: 600; color: var(--hint); font-size: 12px; padding: 8px 12px; }
.tbl td { padding: 8px 12px; border-top: 1px solid var(--sep); }
.tbl td:not(:first-child), .tbl th:not(:first-child) { text-align: right; }
.kvrow { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; }
.kvrow + .kvrow { border-top: 1px solid var(--sep); }
.kvrow span { color: var(--hint); }
.tab span { white-space: nowrap; }
