/* FanPulse — мини-приложение Telegram.
   Цвета берутся из темы Telegram (переменные --tg-theme-*), запасные значения — для светлой темы.
   Единственный «громкий» элемент — билет ближайшего матча; цифры набраны Unbounded, как на табло. */

@font-face {
  font-family: "Unbounded";
  font-weight: 700;
  font-display: swap;
  src: url("fonts/unbounded-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2212;
}
@font-face {
  font-family: "Unbounded";
  font-weight: 700;
  font-display: swap;
  src: url("fonts/unbounded-cyrillic-700-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff3);
  --section: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #0f1419);
  --hint: var(--tg-theme-hint-color, #8b9097);
  --section-header: var(--tg-theme-section-header-text-color, var(--hint));
  --accent: var(--tg-theme-button-color, #2a7bd8);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --accent-ink: var(--tg-theme-accent-text-color, var(--accent));
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --separator: var(--tg-theme-section-separator-color, rgba(60, 60, 67, 0.18));
  --bar: var(--tg-theme-bottom-bar-bg-color, var(--section));
  --tint: rgba(42, 123, 216, 0.12);
  --tint: color-mix(in srgb, var(--accent) 13%, transparent);
  --muted: rgba(120, 120, 128, 0.16);
  --muted: color-mix(in srgb, var(--hint) 18%, transparent);

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Unbounded", var(--font-ui);
  --radius: 14px;
  --tabbar-h: 56px;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: var(--tg-viewport-stable-height, 100vh);
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.view {
  padding: 4px 0 calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- билет ближайшего матча ---------- */

.ticket {
  --stub: 78px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--stub);
  margin: 12px 16px 6px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-text);
}
/* полукруглые вырезы на линии отрыва */
.ticket::before,
.ticket::after {
  content: "";
  position: absolute;
  right: var(--stub);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg);
  transform: translateX(50%);
}
.ticket::before { top: -9px; }
.ticket::after { bottom: -9px; }

.ticket__main { padding: 18px 14px 16px 18px; }
.ticket__teams {
  display: flex;
  flex-direction: column;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.ticket__teams span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket__time {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-top: 16px;
}
.ticket__clock {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.ticket__count { font-size: 14px; opacity: 0.85; }
.ticket__league { margin-top: 12px; font-size: 13px; opacity: 0.8; }

.ticket__stub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 14px 4px;
  border-left: 2px dashed rgba(255, 255, 255, 0.5);
  border-left-color: color-mix(in srgb, var(--accent-text) 50%, transparent);
  text-align: center;
}
.ticket__wd, .ticket__mon { font-size: 13px; opacity: 0.85; }
.ticket__day { font-family: var(--font-num); font-weight: 700; font-size: 30px; line-height: 1.05; }
.ticket__sport { margin-top: 8px; font-size: 20px; line-height: 1; }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.live__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

@media (prefers-reduced-motion: no-preference) {
  .ticket--enter { animation: ticket-in 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .ticket--enter .ticket__stub { animation: stub-in 0.55s 0.12s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .live__dot { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes ticket-in { from { opacity: 0; transform: translateY(10px); } }
  @keyframes stub-in { from { opacity: 0; transform: translateX(12px) rotate(5deg); } }
  @keyframes pulse { 50% { opacity: 0.3; } }
}

/* ---------- секции и списки (родной для Telegram стиль) ---------- */

.section { margin-top: 22px; }
.section__title {
  margin: 0 32px 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--section-header);
}

.list {
  list-style: none;
  margin: 0 16px;
  padding: 0;
  background: var(--section);
  border-radius: var(--radius);
  overflow: hidden;
}
.list > li { position: relative; }
.list > li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  border-top: 0.5px solid var(--separator);
}
.list--avatars > li + li::before { left: 68px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
}
.row--stack { flex-direction: column; align-items: stretch; gap: 4px; }
.row__body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row__title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { font-size: 13px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__end { flex: none; font-size: 18px; line-height: 1; }

.event__time {
  flex: none;
  width: 58px;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.event__live { flex: none; width: 58px; color: var(--danger); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }

.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.result__team { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result__team--home { text-align: right; }
.result__score {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 17px;
  padding: 5px 10px 4px;
  border-radius: 8px;
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.result__meta { text-align: center; }

/* ---------- новости ---------- */

.news__link {
  display: flex;
  gap: 12px;
  padding: 12px 16px 10px;
  color: inherit;
  text-decoration: none;
}
.news__text { flex: 1; min-width: 0; }
.news__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--hint);
}
.news__source { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news__meta time { flex: none; }
.news__img {
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--tint);
}
.chip--edit { font-size: 13px; padding: 4px 4px 4px 11px; }
.chip--edit button {
  border: 0;
  background: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  line-height: 1;
  font-size: 16px;
  color: inherit;
}

/* ---------- подписки ---------- */

.sub__head {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
}
.sub__chevron { flex: none; width: 18px; height: 18px; color: var(--hint); transition: transform 0.2s; }
.sub--open .sub__chevron { transform: rotate(180deg); }
.sub__body { padding: 0 16px 14px 68px; }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 22px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: contain; }

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 6px 0;
}
.list > .field { padding: 6px 16px; }
.list > .field + .field { border-top: 0.5px solid var(--separator); }

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 999px;
  background: var(--muted);
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

.kw { margin-top: 8px; }
.kw__title { font-size: 13px; color: var(--hint); margin-bottom: 8px; }
.kw__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kw__add { display: flex; gap: 8px; margin-top: 10px; }
.kw__add input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--bg);
  font-size: 16px; /* 16px — iOS не масштабирует страницу при фокусе */
}

.select { position: relative; display: inline-flex; align-items: center; color: var(--hint); }
.select select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  color: inherit;
  text-align: right;
  padding: 6px 20px 6px 4px;
  max-width: 190px;
}
.select svg { position: absolute; right: 0; width: 14px; height: 14px; pointer-events: none; }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: 10px 12px;
  padding: 2px;
  border-radius: 10px;
  background: var(--bg);
}
.segmented button {
  border: 0;
  border-radius: 8px;
  background: none;
  padding: 8px 4px;
  font-size: 13px;
  font-weight: 500;
}
.segmented button[aria-checked="true"] { background: var(--section); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }

/* ---------- поиск ---------- */

.kinds {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px 2px;
  scrollbar-width: none;
}
.kinds::-webkit-scrollbar { display: none; }
.kind {
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  background: var(--section);
}
.kind[aria-selected="true"] { background: var(--text); color: var(--section); }

.search { position: relative; margin: 12px 16px 0; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--hint); }
.search input {
  width: 100%;
  padding: 11px 14px 11px 38px;
  border: 0;
  border-radius: 12px;
  background: var(--section);
  font-size: 16px;
}
.search input::-webkit-search-cancel-button { display: none; }
#results .list { margin-top: 12px; }

.add {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: none;
  color: var(--accent-ink);
}
.add svg { width: 18px; height: 18px; }
.add[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.add[aria-busy="true"], .tile[aria-busy="true"] { opacity: 0.5; }

.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 16px 0;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 86px;
  padding: 12px 6px;
  border: 0;
  border-radius: var(--radius);
  background: var(--section);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
}
.tile__icon { font-size: 28px; line-height: 1; }
.tile[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

/* ---------- кнопки, подсказки, пустые состояния ---------- */

.btn {
  border: 0;
  border-radius: 12px;
  padding: 13px 20px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 600;
}
.btn--small { padding: 9px 14px; border-radius: 10px; font-size: 14px; }
.btn--quiet { background: var(--section); color: var(--accent-ink); }
.btn-danger {
  display: block;
  margin-top: 14px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--danger);
  font-weight: 500;
}

.note { margin: 10px 32px 0; font-size: 13px; line-height: 1.45; color: var(--hint); }
.note--lead { margin: 16px 32px 0; font-size: 15px; }
.note--inset { margin: 8px 0 0; }
.more { display: flex; justify-content: center; margin-top: 14px; }

.empty { display: flex; flex-direction: column; align-items: center; padding: 48px 32px 0; text-align: center; }
.empty__ticket {
  display: grid;
  grid-template-columns: 1fr 34px;
  width: 168px;
  height: 78px;
  margin-bottom: 22px;
  border: 2px dashed var(--hint);
  border-radius: 16px;
  color: var(--hint);
  opacity: 0.7;
}
.empty__ticket span { display: grid; place-items: center; font-family: var(--font-num); font-weight: 700; font-size: 22px; }
.empty__ticket i { border-left: 2px dashed var(--hint); }
.empty__title { margin: 0; font-size: 19px; font-weight: 700; }
.empty__text { margin: 8px 0 20px; color: var(--hint); max-width: 32ch; }

.skeleton { margin: 12px 16px 0; padding: 4px 16px; border-radius: var(--radius); background: var(--section); }
.skeleton i { display: block; height: 12px; margin: 14px 0; border-radius: 6px; background: var(--muted); }
.skeleton i:nth-child(odd) { width: 72%; }
.skeleton i:nth-child(even) { width: 48%; }

/* ---------- нижняя панель и уведомления ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-bottom);
  background: var(--bar);
  border-top: 0.5px solid var(--separator);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: var(--tabbar-h);
  padding: 7px 0 6px;
  border: 0;
  background: none;
  color: var(--hint);
  font-size: 11px;
  font-weight: 500;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent-ink); }
.tab[aria-current="page"] svg { stroke-width: 2.1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--section);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }

.is-fatal .tabbar { display: none; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
