/* ============================================================
   iOS-стиль: глубокий чёрный фон + glassmorphism (жидкое стекло)
   Базовые принципы: системный шрифт SF, мягкие крупные радиусы,
   полупрозрачные слои с backdrop-blur, минимум ярких цветов.
   ============================================================ */
:root {
  --bg: #000;                       /* глубокий чёрный — как iOS dark */
  --bg2: #0a0a0c;
  --surface: rgba(28, 28, 32, 0.72);    /* стекло: серое с прозрачностью */
  --surface-2: rgba(38, 38, 44, 0.7);
  --surface-strong: rgba(20, 20, 24, 0.9);
  --hairline: rgba(255, 255, 255, 0.08); /* тонкие разделители как iOS */
  --hairline-2: rgba(255, 255, 255, 0.05);

  --text: rgba(255, 255, 255, 0.96);
  --text-2: rgba(255, 255, 255, 0.68);
  --muted: rgba(255, 255, 255, 0.42);

  --accent: #0a84ff;                /* iOS systemBlue dark */
  --green: #30d158;                 /* iOS systemGreen dark */
  --red: #ff453a;                   /* iOS systemRed dark */
  --gold: #ffd60a;                  /* iOS systemYellow dark */

  --r-card: 18px;                   /* iOS card radius */
  --r-tile: 14px;
  --r-pill: 999px;

  --safe-top: 0px;
  --safe-bottom: 0px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(60, 60, 80, .25), transparent 60%),
    radial-gradient(700px 400px at 100% 100%, rgba(40, 40, 70, .18), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.01em;
  overscroll-behavior: none;
}

/* ---- main ---- */
#view {
  padding: calc(var(--safe-top) + 18px) 16px calc(var(--safe-bottom) + 110px);
  max-width: 640px; margin: 0 auto;
}
.loading, .empty {
  color: var(--muted); text-align: center; padding: 56px 24px; font-size: 14.5px;
}

/* ---- плавающая кнопка обновить (стекло, верхний угол) ---- */
.refresh-fab {
  position: fixed; top: calc(var(--safe-top) + 14px); right: 14px; z-index: 30;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text); border: 1px solid var(--hairline);
  background: var(--surface-strong);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  cursor: pointer; transition: transform .25s ease, background .15s;
}
.refresh-fab:active { transform: scale(.92); background: var(--surface-2); }

/* ---- секции ---- */
.section-title {
  font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin: 26px 4px 10px; font-weight: 600;
}
.section-title:first-child { margin-top: 6px; }

/* ---- карточки (жидкое стекло) ---- */
.card {
  background: var(--surface);
  backdrop-filter: blur(28px) saturate(160%); -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 16px;
}

/* ---- баланс ---- */
.balance-card {
  position: relative; overflow: hidden; padding: 22px 22px 20px;
  background:
    linear-gradient(135deg, rgba(10, 132, 255, .14), transparent 55%),
    var(--surface);
}
.balance-card::after {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 80, 255, .22), transparent 70%);
  pointer-events: none;
}
.balance-label { font-size: 13px; color: var(--text-2); letter-spacing: -.01em; }
.balance-value { font-size: 38px; font-weight: 700; letter-spacing: -1.2px; margin: 6px 0 4px; }
.balance-row { display: flex; gap: 22px; margin-top: 14px; }
.balance-row .kv .k { font-size: 11.5px; color: var(--muted); }
.balance-row .kv .v { font-size: 17px; font-weight: 600; margin-top: 3px; letter-spacing: -.02em; }

/* ---- плитки ---- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--hairline);
  border-radius: var(--r-tile);
  padding: 14px 16px;
}
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 600; margin-top: 4px; letter-spacing: -.02em; }

.pos { color: var(--green); } .neg { color: var(--red); } .gold { color: var(--gold); }

/* ---- строки (источник/тип/h2h ряды) ---- */
.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-radius: var(--r-tile);
  background: var(--surface);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline);
  margin-bottom: 8px;
}
.row .left { display: flex; flex-direction: column; gap: 4px; }
.row .name { font-weight: 500; font-size: 14.5px; letter-spacing: -.01em; }
.row .meta { font-size: 12px; color: var(--muted); }
.row .right { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- бейджи ---- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; letter-spacing: -.01em;
}
.badge.stats { background: rgba(48, 209, 88, .14); color: var(--green); }
.badge.statslite { background: rgba(255, 214, 10, .14); color: var(--gold); }
.badge.prior { background: rgba(255, 255, 255, .08); color: var(--text-2); }

/* ---- ставки ---- */
.bet {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-radius: var(--r-tile);
  background: var(--surface);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline);
  margin-bottom: 8px;
}
.bet .status { width: 4px; height: 40px; border-radius: 2px; flex: none; }
.bet .status.open { background: var(--accent); }
.bet .status.won { background: var(--green); }
.bet .status.lost { background: var(--red); }
.bet .status.void { background: var(--muted); }
.bet .body { flex: 1; min-width: 0; }
.bet .q { font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bet .sub { font-size: 12px; color: var(--text-2); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bet .pnl { font-size: 14.5px; font-weight: 600; flex: none; text-align: right; min-width: 60px; font-variant-numeric: tabular-nums; }
.bet.clickable { cursor: pointer; transition: background .15s; }
.bet.clickable:active { background: var(--surface-2); }
.bet .pnl .chev { color: var(--muted); font-size: 18px; font-weight: 400; margin-top: 2px; }

/* ---- матчи (список) ---- */
.match {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-radius: var(--r-tile);
  background: var(--surface);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline);
  margin-bottom: 8px; cursor: pointer; transition: background .15s;
}
.match:active { background: var(--surface-2); }
.match .teams { flex: 1; min-width: 0; }
.tline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.match .tline { gap: 8px; }
.match .tname { font-size: 14.5px; font-weight: 500; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match .tname.win { color: var(--green); font-weight: 600; }
.match .tscore { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; flex: none; }
.match .league { font-size: 11.5px; color: var(--muted); margin-top: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match .chev, .chev { color: var(--muted); font-size: 18px; flex: none; font-weight: 300; }

/* ---- деталь матча ---- */
.detail-head { text-align: center; padding: 20px 0 10px; }
.detail-vs { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 6px; }
.detail-vs .t { font-size: 17px; font-weight: 600; max-width: 38vw; letter-spacing: -.02em; }
.detail-vs .t.win { color: var(--green); }
.detail-vs .sc { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.detail-meta { color: var(--text-2); font-size: 12.5px; margin-top: 8px; letter-spacing: -.01em; }

.pickrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.hero { width: 48px; height: 27px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--hairline); background: var(--surface-2); }
.hero.ban { filter: grayscale(1) brightness(.5); }
.side-label { font-size: 12.5px; font-weight: 600; margin: 16px 4px 4px; letter-spacing: -.01em; }
.side-label.radiant { color: var(--green); }
.side-label.dire { color: var(--red); }

.ptable { width: 100%; border-collapse: collapse; margin-top: 6px; }
.ptable td { padding: 9px 4px; border-bottom: 1px solid var(--hairline-2); font-size: 13.5px; }
.ptable tr:last-child td { border-bottom: none; }
.ptable .ph { display: flex; align-items: center; gap: 10px; }
.ptable .ph img { width: 36px; height: 20px; border-radius: 5px; }
.ptable .pn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; font-weight: 500; }
.ptable .kda { font-variant-numeric: tabular-nums; color: var(--text-2); }
.ptable .nw { text-align: right; font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 600; }

.backbtn {
  display: inline-flex; align-items: center; gap: 4px; color: var(--accent);
  font-size: 16px; font-weight: 500; background: none; border: none;
  padding: 6px 0; cursor: pointer; margin-bottom: 8px; letter-spacing: -.01em;
}

/* ---- анализ: бар + диверг. бары героев ---- */
.wpbar { height: 8px; border-radius: 4px; background: rgba(255,69,58,.6); overflow: hidden; margin-top: 6px; }
.wpfill { height: 100%; background: linear-gradient(90deg, var(--green), #27c06a); }

.mrow { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.mrow .hero { width: 42px; height: 24px; flex: none; }
.mname { font-size: 13px; width: 92px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.mbar { position: relative; flex: 1; height: 14px; background: var(--hairline); border-radius: 4px; }
.mcenter { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,.12); }
.mfill { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; }
.mfill.pos { background: var(--green); } .mfill.neg { background: var(--red); }
.mscore { width: 42px; flex: none; text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- форма команд / синергия ---- */
.formgrid { display: flex; gap: 18px; }
.formcol { flex: 1; min-width: 0; }
.formteam { font-size: 13px; font-weight: 600; margin-bottom: 10px; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.formteam.radiant { color: var(--green); } .formteam.dire { color: var(--red); }
.formstat { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; padding: 4px 0; }
.formstat span { color: var(--muted); }
.formstat b { font-variant-numeric: tabular-nums; font-weight: 600; }
.synval { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0; letter-spacing: -.03em; }

/* ---- h2h ---- */
.h2hhead { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; letter-spacing: -.01em; }
.h2hrow { display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-top: 1px solid var(--hairline-2); font-size: 13px; }
.h2hrow .hn { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h2hrow .hn.r { text-align: right; }
.h2hrow .hn.win { color: var(--green); font-weight: 600; }
.h2hrow .hsc { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; }
.h2hrow .hago { flex: none; width: 64px; text-align: right; font-size: 11px; color: var(--muted); }

/* ---- live-карточка ---- */
.livecard { cursor: pointer; transition: background .15s; }
.livecard:active { background: var(--surface-2); }
.livemore { margin-top: 12px; text-align: center; font-size: 13px; font-weight: 500; color: var(--accent); }

/* ---- блок ставок внутри матча ---- */
.betsbox { padding: 4px 16px; }
.betline { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--hairline-2); }
.betline:last-child { border-bottom: none; }
.betline .betmain { min-width: 0; }
.betline .betmain b { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.betline .betstatus { flex: none; font-size: 13.5px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ---- полная диагностика (под капотом) ---- */
.diag-toggle-card { padding: 0; }
.diag-toggle {
  width: 100%; padding: 14px 16px; background: none; border: none;
  color: var(--accent); font-size: 14.5px; font-weight: 500; letter-spacing: -.01em;
  text-align: left; cursor: pointer; border-radius: var(--r-card);
  transition: background .15s;
}
.diag-toggle:active { background: rgba(10,132,255,.08); }
.diag-container {
  max-height: 0; overflow: hidden; transition: max-height .35s ease;
  padding: 0 16px;
}
.diag-container.open { max-height: 20000px; padding-bottom: 16px; }

.diag { padding-top: 6px; }
.diag-sec { font-size: 13.5px; color: var(--text-2); margin: 6px 0 14px; letter-spacing: -.01em; line-height: 1.55; }
.diag-sec b { color: var(--text); }
.diag-sec-title {
  font-size: 11.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; font-weight: 600; margin: 18px 0 8px;
}

.diag-rosters { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.diag-roster-side { min-width: 0; }
.diag-player { padding: 7px 0; border-bottom: 1px solid var(--hairline-2); }
.diag-player:last-child { border-bottom: none; }
.diag-pname { font-size: 13px; font-weight: 500; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diag-pname .meta { font-weight: 400; font-size: 11px; }

.diag-poh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.diag-poh-side { min-width: 0; }
.diag-poh { padding: 8px 0; border-bottom: 1px solid var(--hairline-2); }
.diag-poh:last-child { border-bottom: none; }
.diag-poh-h { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; letter-spacing: -.01em; }
.diag-pohline { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 2px 0; }
.diag-pohline span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diag-pohline b { font-variant-numeric: tabular-nums; font-weight: 500; flex: none; }

.diag-mu { display: flex; flex-direction: column; gap: 12px; }
.diag-murow { padding: 8px 0; border-bottom: 1px solid var(--hairline-2); }
.diag-murow:last-child { border-bottom: none; }
.diag-mu-hero { font-size: 13.5px; margin-bottom: 6px; }
.diag-mu-hero b { letter-spacing: -.01em; }
.diag-mu-cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(95px, 1fr)); gap: 6px; }
.diag-mucell { background: rgba(255,255,255,.04); border: 1px solid var(--hairline-2);
  border-radius: 8px; padding: 6px 8px; font-size: 11.5px; }
.diag-mucell.pos { background: rgba(48,209,88,.08); border-color: rgba(48,209,88,.2); }
.diag-mucell.neg { background: rgba(255,69,58,.08); border-color: rgba(255,69,58,.2); }
.diag-mu-vs { color: var(--text-2); font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diag-mu-val { font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

.diag-synline { display: flex; justify-content: space-between; gap: 8px;
  font-size: 12.5px; padding: 4px 0; }
.diag-synline span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diag-synline b { font-variant-numeric: tabular-nums; font-weight: 500; flex: none; }

/* ---- tabbar (iOS glass) ---- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(var(--safe-bottom) + 8px);
  background: rgba(8, 8, 10, 0.72);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-top: 1px solid var(--hairline);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--muted); font-size: 10.5px; font-weight: 500;
  letter-spacing: -.01em; padding: 8px 0 4px; cursor: pointer; border-radius: 12px;
  transition: color .2s ease; }
.tab svg { opacity: .9; transition: transform .25s ease, opacity .2s ease; }
.tab.active { color: var(--text); }
.tab.active svg { color: var(--accent); opacity: 1; transform: scale(1.08); }
.tab:active svg { transform: scale(.94); }

/* ---- сегментированный переключатель (iOS) ---- */
.segmented {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline);
  border-radius: 12px; margin-bottom: 14px;
}
.segmented button { flex: 1; padding: 9px 6px; border: none; background: none;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  border-radius: 9px; cursor: pointer; transition: all .15s; letter-spacing: -.01em; }
.segmented button.active {
  background: var(--surface-2); color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}

/* ---- турниры ---- */
.trow {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border-radius: var(--r-tile);
  background: var(--surface);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline);
  margin-bottom: 8px; cursor: pointer; transition: background .15s;
}
.trow:active { background: var(--surface-2); }
.trow .left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.trow .name { font-weight: 500; font-size: 14.5px; letter-spacing: -.01em; }
.trow .meta { font-size: 12px; color: var(--muted); }
.trow .right { display: flex; align-items: center; gap: 8px; flex: none; font-size: 13px; font-weight: 600; }
.livedot { color: var(--red); font-weight: 600; font-size: 12px; }

.skeleton {
  height: 70px; border-radius: var(--r-tile); margin-bottom: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.07) 37%, rgba(255,255,255,.04) 63%);
  background-size: 400% 100%; animation: sh 1.4s ease infinite;
  border: 1px solid var(--hairline);
}
@keyframes sh { 0% { background-position: 100% 0 } 100% { background-position: -100% 0 } }
