/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg:            #07090f;
  --surface:       #0d1120;
  --surface-2:     #121828;
  --surface-3:     #192135;
  --border:        #1e2d47;
  --border-subtle: #14203a;

  --text:   #eef2ff;
  --text-2: #8896b3;
  --text-3: #4a5f80;

  --primary:         #00c97f;
  --primary-hover:   #00a86a;
  --primary-dim:     rgba(0,201,127,.12);
  --primary-glow:    0 0 24px rgba(0,201,127,.18);
  --primary-contrast:#00120a;

  --telegram:        #229ED9;
  --telegram-hover:  #1a87be;
  --telegram-dim:    rgba(34,158,217,.12);

  --live:        #ff4757;
  --live-dim:    rgba(255,71,87,.15);
  --danger:      #ff4757;
  --danger-bg:   rgba(255,71,87,.1);
  --danger-border:rgba(255,71,87,.3);
  --success-bg:  rgba(0,201,127,.1);
  --warning:     #ffc107;

  --s1:4px; --s2:8px; --s3:12px; --s4:16px;
  --s5:24px; --s6:32px; --s7:48px;

  --r-sm:6px; --r-md:10px; --r-lg:16px; --r-xl:24px;

  --t1:120ms ease-out;
  --t2:220ms ease-out;
  --t3:340ms cubic-bezier(.22,.68,0,1.2);

  --bottom-nav-h: 64px;

  color-scheme: dark;
}

/* ── Hidden attribute fix ───────────────────────────────────────────────────── */
/* Prevents CSS display:flex/grid from overriding the [hidden] attribute       */
[hidden] { display: none !important; }

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button, input, select, textarea { font-family: inherit; }

a:focus-visible, button:focus-visible,
select:focus-visible, input:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Google Fonts import ────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Skeleton shimmer ───────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-card {
  padding: var(--s3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.skeleton-line { height: 12px; }
.skeleton-line--sm  { width: 40%; }
.skeleton-line--md  { width: 70%; }
.skeleton-line--lg  { width: 90%; }
.skeleton-line--xl  { height: 16px; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s3) var(--s5);
  background: rgba(7,9,15,.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}

.app-header__logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary), #00a868);
  color: var(--primary-contrast);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -.5px;
  flex-shrink: 0;
  box-shadow: var(--primary-glow);
}

.app-header__title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.3px;
  white-space: nowrap;
}

.app-header__subtitle {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Desktop nav ────────────────────────────────────────────────────────────── */
.app-nav {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 3px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  border-radius: calc(var(--r-lg) - 3px);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t1), color var(--t1);
  white-space: nowrap;
  min-height: 36px;
}

.nav-tab svg { width: 15px; height: 15px; flex-shrink: 0; }

.nav-tab:hover:not(.nav-tab--active) {
  background: var(--surface-3);
  color: var(--text);
}

.nav-tab--active {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: var(--primary-contrast);
  font-weight: 700;
  box-shadow: var(--primary-glow);
}

/* ── Mobile bottom nav ──────────────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  height: var(--bottom-nav-h);
  background: rgba(13,17,32,.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav__inner {
  display: flex;
  height: 100%;
}

.bottom-nav__tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--t1);
  min-height: 44px;
  padding: 0 var(--s2);
  letter-spacing: .3px;
  text-transform: uppercase;
}

.bottom-nav__tab svg { width: 22px; height: 22px; transition: transform var(--t2); }
.bottom-nav__tab--active { color: var(--primary); }
.bottom-nav__tab--active svg { transform: scale(1.1); }

/* ── Page ───────────────────────────────────────────────────────────────────── */
.page { animation: fadeUp 200ms ease-out; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Layout (3-col) ─────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: minmax(260px,1fr) minmax(300px,1.3fr) minmax(280px,1fr);
  gap: var(--s4);
  padding: var(--s4);
  align-items: start;
  min-height: calc(100dvh - 57px);
}

/* ── Panel ───────────────────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s4) var(--s4) var(--s4);
  margin-bottom: 0;
}

.panel__head h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-2);
}

.panel__body {
  padding: 0 var(--s4) var(--s4);
  flex: 1;
  overflow: hidden;
}

/* ── Back button (mobile) ────────────────────────────────────────────────────── */
.back-btn {
  display: none;
  align-items: center;
  gap: var(--s2);
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: var(--s2) 0;
  min-height: 44px;
  transition: color var(--t1);
}
.back-btn:hover { color: var(--text); }
.back-btn svg { width: 16px; height: 16px; }

/* ── Badge ─────────────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px var(--s2);
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 44px;
  padding: 0 var(--s4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t1), transform var(--t1), opacity var(--t1), box-shadow var(--t1);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn:active:not(:disabled) { transform: scale(.97); }

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: var(--primary-contrast);
}
.btn--primary:hover:not(:disabled) {
  box-shadow: var(--primary-glow);
  filter: brightness(1.05);
}

.btn--ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover:not(:disabled) { background: var(--surface-3); }

.btn--danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--live);
}
.btn--danger:hover:not(:disabled) { background: rgba(255,71,87,.18); }

.btn--telegram {
  background: linear-gradient(135deg, var(--telegram), var(--telegram-hover));
  color: #fff;
  border: none;
}
.btn--telegram:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 0 20px rgba(34,158,217,.3);
}

.btn--sm { min-height: 34px; padding: 0 var(--s3); font-size: 12px; }
.btn--full { width: 100%; }

/* Spinner inside button */
.btn--loading { pointer-events: none; }
.btn--loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

/* ── Icon button ─────────────────────────────────────────────────────────────── */
.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t1), color var(--t1);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

/* ── Status / empty ──────────────────────────────────────────────────────────── */
.status {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--text-3);
  font-size: 13px;
  padding: var(--s3) 0;
}

.status svg { width: 16px; height: 16px; flex-shrink: 0; }

.status--spin svg { animation: spin .8s linear infinite; }

.empty-state {
  padding: var(--s6) var(--s4);
  text-align: center;
}

.empty-state__icon {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--s3);
  color: var(--text-3);
}

.empty-state__icon svg { width: 100%; height: 100%; }

.empty-state p {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.6;
}

/* ── Alert ──────────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert--error { background: var(--danger-bg); color: #ffb3b3; border: 1px solid var(--danger-border); }
.alert--success { background: var(--success-bg); color: var(--primary); border: 1px solid rgba(0,201,127,.3); }
.alert--warn { background: rgba(255,193,7,.08); color: var(--warning); border: 1px solid rgba(255,193,7,.25); }

/* ── Toast system ────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--s3));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--s2);
  align-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  animation: toastIn 280ms var(--t3) both;
  pointer-events: all;
}

.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast--success { color: var(--primary); border-color: rgba(0,201,127,.3); }
.toast--error   { color: #ffb3b3; border-color: var(--danger-border); }
.toast--info    { color: var(--telegram); border-color: rgba(34,158,217,.3); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(.9); }
}

/* ── Game list ───────────────────────────────────────────────────────────────── */
.game-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: calc(100dvh - 200px);
  overflow-y: auto;
  padding-right: 2px;
}

/* ── League group ──────────────────────────────────────────────────────────────── */
.league-group {
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: var(--s2);
}

.league-group__header {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
  border: none;
  width: 100%;
  text-align: left;
  color: var(--text-2);
  transition: background var(--t1);
  min-height: 36px;
}

.league-group__header:hover { background: var(--surface-3); }

.league-group__icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  flex-shrink: 0;
}

.league-group__name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  flex: 1;
}

.league-group__count {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 1px 7px;
}

.league-group__chevron {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform 200ms ease;
}

.league-group--collapsed .league-group__chevron {
  transform: rotate(-90deg);
}

.league-group__games {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border-subtle);
}

.league-group--collapsed .league-group__games {
  display: none;
}

/* ── Game card ─────────────────────────────────────────────────────────────────── */
.game-card {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: none;
  padding: var(--s2) var(--s3);
  color: var(--text);
  cursor: pointer;
  transition: background var(--t1);
  min-height: 44px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: var(--s3);
}

.game-card:hover { background: var(--surface-2); }

.game-card[aria-pressed="true"] {
  background: rgba(0,201,127,.07);
  box-shadow: inset 3px 0 0 var(--primary);
}

.game-card__teams {
  font-size: 13px;
  font-weight: 600;
  grid-column: 1;
  grid-row: 1;
}

.game-card__teams--score {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.game-card__team {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.game-card__team--right { text-align: right; }

.game-card__score {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--live);
  font-variant-numeric: tabular-nums;
  background: var(--live-dim);
  padding: 2px var(--s2);
  border-radius: var(--r-sm);
}

.game-card__meta {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-3);
  grid-column: 1;
  grid-row: 2;
}

.game-card__time {
  grid-column: 2;
  grid-row: 1 / 3;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
  align-self: center;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--live);
  font-weight: 700;
}

.live-dot__pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  position: relative;
  flex-shrink: 0;
}

.live-dot__pulse::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--live);
  opacity: .4;
  animation: livePulse 1.4s ease-out infinite;
}

@keyframes livePulse {
  0%   { transform: scale(1); opacity: .4; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ── Markets ─────────────────────────────────────────────────────────────────── */
.selected-game-info {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s3);
  padding: var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  min-height: 0;
}

.selected-game-info svg { width: 14px; height: 14px; color: var(--primary); flex-shrink: 0; }

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-3);
  margin-bottom: var(--s2);
}

.select {
  width: 100%;
  min-height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 0 var(--s3);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--t1);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238896b3' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
}

.select:focus { border-color: var(--primary); }

.markets-list {
  margin-top: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  max-height: calc(100dvh - 320px);
  overflow-y: auto;
  padding-right: 2px;
}

.market-block {
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: var(--s3);
  background: var(--surface-2);
}

.market-block__name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  margin-bottom: var(--s3);
}

.market-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.option-btn {
  min-height: 48px;
  min-width: 56px;
  padding: 0 var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: border-color var(--t1), background var(--t1), box-shadow var(--t1);
}

.option-btn:hover { border-color: var(--border); background: rgba(255,255,255,.05); }

.option-btn[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-dim);
  box-shadow: 0 0 0 1px var(--primary) inset;
}

.option-btn__odd {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* ── Link panel ──────────────────────────────────────────────────────────────── */
.selection-summary {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
}

.selection-summary__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-3);
  margin-bottom: var(--s1);
}

.selection-summary__text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

/* ── Progress bar ────────────────────────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3) 0;
}

.progress-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #00f5a0);
  border-radius: 99px;
  transition: width 400ms ease-out;
  width: 0%;
}

.progress-label {
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
}

/* ── Link result ─────────────────────────────────────────────────────────────── */
.link-result__row {
  display: flex;
  gap: var(--s2);
  margin-bottom: var(--s3);
}

.text-input {
  width: 100%;
  min-height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 0 var(--s3);
  font-size: 13px;
  transition: border-color var(--t1);
}

.text-input:focus { border-color: var(--primary); }
.text-input[readonly] { color: var(--text-2); cursor: default; }

.copy-feedback {
  font-size: 12px;
  color: var(--primary);
  min-height: 18px;
  margin-bottom: var(--s2);
}

/* ── Textarea ────────────────────────────────────────────────────────────────── */
.textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: var(--s3);
  font-size: 13px;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  resize: vertical;
  line-height: 1.65;
  transition: border-color var(--t1);
}

.textarea:focus { border-color: var(--primary); }

/* ── Channels page ───────────────────────────────────────────────────────────── */
.channels-page {
  padding: var(--s5);
  max-width: 800px;
  margin: 0 auto;
}

.channels-page__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s5);
}

.channels-page__head h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.4px;
}

.channels-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.channel-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  transition: border-color var(--t1);
}

.channel-card:hover { border-color: var(--border); }

.channel-card__info {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}

.channel-card__thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.channel-card__avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--telegram), var(--telegram-hover));
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.channel-card__name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.channel-card__meta {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
}

.channel-card__meta code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  font-size: 10px;
  color: var(--text-2);
}

.channel-card__actions {
  display: flex;
  gap: var(--s2);
  flex-shrink: 0;
}

/* ── Config page ─────────────────────────────────────────────────────────────── */
.config-page {
  padding: var(--s5);
  max-width: 560px;
  margin: 0 auto;
}

.config-page h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.4px;
  margin-bottom: var(--s5);
}

.config-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s5);
}

.config-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: var(--s2);
}

.config-hint {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: var(--s4);
}

.token-row {
  display: flex;
  gap: var(--s2);
}

.token-row .text-input { flex: 1; }

.token-status {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 12px;
  font-weight: 600;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  margin-bottom: var(--s4);
}
.token-status--ok {
  background: var(--success-bg);
  color: var(--primary);
  border: 1px solid rgba(0,201,127,.3);
}
.token-status svg { width: 14px; height: 14px; }

.copy-feedback { font-size: 12px; color: var(--primary); min-height: 18px; }

/* ── Modals ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
}

.modal-overlay:not([hidden]) { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  animation: modalIn 240ms var(--t3);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.modal__title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.3px;
}

.modal__close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background var(--t1), color var(--t1);
  line-height: 1;
}

.modal__close:hover { background: var(--surface-3); color: var(--text); }

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
  padding-top: var(--s2);
  border-top: 1px solid var(--border-subtle);
}

/* ── Form helpers ─────────────────────────────────────────────────────────────── */
.field-hint {
  font-size: 11px;
  color: var(--text-3);
  margin: 3px 0 var(--s2);
  line-height: 1.5;
}

.field-hint code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--primary);
}

.form-row { margin-top: var(--s3); }

.verify-row { display: flex; gap: var(--s2); }
.verify-row .text-input { flex: 1; }

.verify-result {
  font-size: 12px;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  margin-top: var(--s2);
}
.verify-result--ok   { background: var(--success-bg); color: var(--primary); border: 1px solid rgba(0,201,127,.3); }
.verify-result--warn { background: rgba(255,193,7,.08); color: var(--warning); border: 1px solid rgba(255,193,7,.25); }
.verify-result--error{ background: var(--danger-bg); color: #ffb3b3; border: 1px solid var(--danger-border); }

/* ── Image upload ─────────────────────────────────────────────────────────────── */
.image-upload-area { display: flex; align-items: center; gap: var(--s3); }

.image-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 34px;
  padding: 0 var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t1), color var(--t1);
}
.image-upload-btn:hover { background: var(--surface-3); color: var(--text); }

.image-preview { position: relative; display: inline-block; }

.image-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

.image-preview__remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.send-image-preview { margin-top: var(--s2); }
.send-image-preview img {
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  object-fit: cover;
}

/* ── Spin animation ──────────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spin { animation: spin .8s linear infinite; }

/* ── Refresh button ──────────────────────────────────────────────────────────── */
.refresh-btn-icon { transition: transform var(--t2); }
.refreshing .refresh-btn-icon { animation: spin .8s linear infinite; }

/* ── Divider ─────────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--s3) 0;
}

/* ── Game filters ────────────────────────────────────────────────────────────── */
.games-filter {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: 0 var(--s4) var(--s4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s4);
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 14px;
  height: 14px;
  color: var(--text-3);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  min-height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 0 32px 0 34px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--t1);
}

.search-input:focus {
  border-color: var(--primary);
  outline: none;
}

.search-input::placeholder { color: var(--text-3); }

.search-clear {
  position: absolute;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--t1), color var(--t1);
}
.search-clear:hover { background: var(--border); color: var(--text); }

.filter-row {
  display: flex;
  gap: var(--s3);
  align-items: center;
  flex-wrap: wrap;
}

.chips {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  flex: 1;
}

.chip {
  min-height: 30px;
  padding: 0 var(--s3);
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--t1), color var(--t1), background var(--t1);
}

.chip:hover { border-color: var(--border); color: var(--text-2); }

.chip--active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}

.chip--live.chip--active {
  background: var(--live-dim);
  border-color: var(--live);
  color: var(--live);
}

.league-select {
  min-height: 30px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-2);
  padding: 0 24px 0 var(--s2);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--t1);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234a5f80' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 12px;
  max-width: 140px;
}

.league-select:focus { border-color: var(--primary); outline: none; color: var(--text); }

.no-results {
  padding: var(--s5) var(--s4);
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile-first
═══════════════════════════════════════════════════════════════════════════════ */

/* ── Tablet / small desktop ─ */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(240px,.9fr) minmax(280px,1.2fr) minmax(260px,.9fr);
  }
}

/* ── Mobile (≤768px) ─ */
@media (max-width: 768px) {
  /* Show bottom nav, hide desktop nav */
  .app-nav { display: none; }
  .bottom-nav { display: flex; }

  /* Adjust header */
  .app-header {
    padding: var(--s2) var(--s3);
  }

  .app-header__subtitle { display: none; }

  /* Stack layout as single column */
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
    padding-bottom: var(--bottom-nav-h);
  }

  /* Mobile stepped panels */
  .panel {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
  }

  /* Only show active panel on mobile */
  #page-jogos[data-step="1"] .panel--markets,
  #page-jogos[data-step="1"] .panel--link { display: none; }

  #page-jogos[data-step="2"] .panel--games,
  #page-jogos[data-step="2"] .panel--link { display: none; }

  #page-jogos[data-step="3"] .panel--games,
  #page-jogos[data-step="3"] .panel--markets { display: none; }

  /* Show back buttons on mobile */
  .back-btn { display: flex; }

  /* Full height game list on mobile */
  .game-list {
    max-height: calc(100dvh - 140px);
  }

  .markets-list {
    max-height: calc(100dvh - 280px);
  }

  /* Panels fill screen height */
  .panel--markets,
  .panel--link {
    min-height: calc(100dvh - 57px - var(--bottom-nav-h));
  }

  /* Toast above bottom nav */
  .toast-container {
    bottom: calc(var(--bottom-nav-h) + var(--s3));
  }

  /* Channels / config full padding adjustment */
  .channels-page,
  .config-page {
    padding: var(--s4);
    padding-bottom: calc(var(--bottom-nav-h) + var(--s4));
  }

  /* Modal becomes bottom sheet on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }

  .modal {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92dvh;
    animation: sheetIn 280ms var(--t3);
  }

  @keyframes sheetIn {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* Option buttons: more space on mobile */
  .option-btn { min-height: 52px; }

  /* Channels */
  .channel-card { flex-wrap: wrap; }
  .channel-card__actions { margin-left: auto; }
}

/* ── Very small (375px) ─ */
@media (max-width: 400px) {
  .app-header__title { font-size: 13px; }
  .channels-page__head { flex-wrap: wrap; gap: var(--s2); }
}
