:root {
  --bg: #000000;
  --bg-elev: #16181c;
  --border: #2f3336;
  --text: #e7e9ea;
  --muted: #71767b;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --green: #00ba7c;
  --red: #f4212e;
  --yellow: #ffd400;
  --max: 600px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.3;
}

.app {
  max-width: var(--max);
  margin: 0 auto;
  min-height: 100vh;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  position: relative;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 53px;
  padding: 0 16px;
}
.logo { font-size: 22px; margin: 0 auto; }
.icon-btn {
  background: none; border: none; color: var(--text);
  cursor: pointer; padding: 6px; border-radius: 999px; display: grid; place-items: center;
}
.icon-btn:active { background: var(--bg-elev); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; }
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 15px; font-weight: 600; padding: 16px 0; cursor: pointer; position: relative;
}
.tab.active { color: var(--text); font-weight: 700; }
.tab.active::after {
  content: ""; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 56px; height: 4px; border-radius: 999px; background: var(--accent);
}

/* ---------- Avatars ---------- */
.avatar {
  width: 44px; height: 44px; border-radius: 999px; flex: 0 0 44px;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--accent), #794bc4);
  user-select: none;
}
.avatar-sm { width: 32px; height: 32px; flex-basis: 32px; font-size: 12px; }
.avatar.me { background: linear-gradient(135deg, #ffd400, #f4212e); color: #000; }

/* ---------- Feed / tweet cards ---------- */
.feed { display: flex; flex-direction: column; }

.banner {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px;
}
.banner b { color: var(--text); }

.tweet {
  display: grid;
  grid-template-columns: 28px 44px 1fr;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  outline: none;
  transition: background .12s;
}
.tweet:hover, .tweet:focus { background: #080808; }
.tweet.top1 { background: linear-gradient(90deg, rgba(255,212,0,.06), transparent 60%); }

.tw-rank {
  font-weight: 800; font-size: 17px; color: var(--muted);
  padding-top: 10px; text-align: center;
}
.tweet.top1 .tw-rank, .tweet.top2 .tw-rank, .tweet.top3 .tw-rank { color: var(--yellow); }

.tw-body { min-width: 0; }
.tw-head { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 15px; }
.tw-name { font-weight: 700; color: var(--text); }
.tw-handle, .tw-dot, .tw-meta { color: var(--muted); font-weight: 400; font-size: 14px; }

.tw-teams { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; }
.team-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 10px;
}
.team-flag { font-size: 18px; line-height: 1; flex: 0 0 auto; }
.team-name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.team-pts small { color: var(--muted); font-weight: 500; font-size: 11px; }
.form { display: flex; gap: 3px; }
.f { width: 16px; height: 16px; border-radius: 4px; font-size: 10px; font-weight: 800; color: #000; display: grid; place-items: center; }
.f.W { background: var(--green); }
.f.D { background: var(--muted); color: #fff; }
.f.L { background: var(--red); color: #fff; }

.tw-actions { display: flex; justify-content: space-between; max-width: 340px; margin-top: 6px; color: var(--muted); font-size: 13px; }
.act { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.act::before { font-size: 14px; }
.act-pts { color: var(--accent); font-weight: 700; }
.act-pts::before { content: "🏅"; }
.act-pl::before { content: "⚽"; }
.act-gd::before { content: "±"; }
.act-rec::before { content: "📊"; }

/* ---------- Matches tab ---------- */
.match {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.match-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.match-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.m-team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.m-team.right { justify-content: flex-end; }
.m-team .team-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-score { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; padding: 2px 10px; background: var(--bg-elev); border-radius: 8px; }
.m-score.vs { color: var(--muted); font-size: 13px; font-weight: 600; background: none; }
.owner-tag { font-size: 10px; color: var(--accent); font-weight: 700; }

/* ---------- Skeleton / states ---------- */
.skeleton-wrap { padding: 8px 0; }
.skel-card { height: 96px; margin: 8px 16px; border-radius: 14px; background: linear-gradient(90deg, #0e0e0e, #1a1a1a, #0e0e0e); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty b { color: var(--text); display: block; font-size: 18px; margin-bottom: 6px; }
.error { color: var(--red); }
