:root {
  --bg: #090b10;
  --panel: #121722;
  --panel-2: #171e2b;
  --line: #273140;
  --text: #f4f7fb;
  --muted: #95a2b3;
  --red: #e6342f;
  --red-dark: #a9211f;
  --blue: #2e5c8a;
  --green: #19a15f;
  --amber: #e2a23a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(180deg, #0f131b 0%, var(--bg) 58%, #07090d 100%);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

.phone-shell {
  position: relative;
  width: min(100vw, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 92px;
  background: rgba(9, 11, 16, 0.9);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: env(safe-area-inset-top);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }
h1 { font-size: 30px; letter-spacing: 0; }
h2 { font-size: 20px; letter-spacing: 0; }
p { color: var(--muted); line-height: 1.5; }

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 20px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions select {
  height: 42px;
  max-width: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 8px;
}

.deeplink-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  padding: 12px;
  border: 1px solid rgba(230, 52, 47, 0.38);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(230, 52, 47, 0.18), rgba(46, 92, 138, 0.12));
}

.splash-ad {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(9,11,16,0.12), rgba(9,11,16,0.92)),
    url("https://images.unsplash.com/photo-1517994112540-009c47ea476b?auto=format&fit=crop&w=1200&q=78") center / cover;
}

.splash-ad[hidden] {
  display: none;
}

.skip-ad {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  background: rgba(0,0,0,0.42);
}

.splash-card {
  display: grid;
  align-content: end;
  width: min(100%, 360px);
  min-height: 520px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.02), rgba(0,0,0,0.76));
}

.splash-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.15;
}

.splash-card em,
.banner-ad em {
  color: var(--muted);
  font-style: normal;
}

.ad-label {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(230, 52, 47, 0.9);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.banner-ad {
  display: grid;
  gap: 4px;
  min-height: 74px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(230, 52, 47, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(230,52,47,0.22), rgba(46,92,138,0.12)),
    #121722;
}

.banner-ad.compact {
  min-height: 58px;
  margin: 10px 0 12px;
}

.deeplink-strip span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 7px rgba(230, 52, 47, 0.16);
}

.series-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.series-bar button,
.segmented button,
.encyclopedia-grid button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.series-bar button.is-active,
.segmented button.is-active {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  font-weight: 800;
}

.content-stack { min-height: 520px; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.status-pill,
.live-chip {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(25, 161, 95, 0.18);
  color: #8dffbd;
  font-size: 12px;
  font-weight: 800;
}

.timeline,
.article-list {
  display: grid;
  gap: 10px;
}

.event-card,
.article-card,
.race-card,
.profile-card,
.stat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.event-card,
.article-card,
.race-card {
  padding: 13px;
}

.event-card header,
.article-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(46, 92, 138, 0.28);
  color: #b9d8ff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.red { background: rgba(230, 52, 47, 0.2); color: #ffaaa6; }
.tag.green { background: rgba(25, 161, 95, 0.18); color: #8dffbd; }
.tag.amber { background: rgba(226, 162, 58, 0.18); color: #ffd28a; }

.race-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 138px;
  padding: 18px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(7,9,13,0.25), rgba(7,9,13,0.78)),
    url("https://images.unsplash.com/photo-1503736334956-4c8f8e92946d?auto=format&fit=crop&w=900&q=75") center / cover;
  border: 1px solid rgba(255,255,255,0.12);
}

.race-hero h2 {
  max-width: 260px;
  margin-bottom: 6px;
  font-size: 24px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.prob-row {
  margin-top: 12px;
}

.prob-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 800;
}

.bar {
  height: 9px;
  border-radius: 99px;
  background: #252f3d;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: var(--w);
  background: linear-gradient(90deg, var(--red), #ff8a66);
}

.leaderboard {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.leader-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-2);
}

.encyclopedia-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--red);
  font-weight: 900;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.stats-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats-grid strong {
  display: block;
  font-size: 24px;
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
}

.primary-action {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  font-weight: 900;
}

.primary-link {
  display: grid;
  place-items: center;
  min-height: 46px;
  margin-top: 18px;
  border-radius: 8px;
  background: var(--red);
  font-weight: 900;
}

.landing {
  display: grid;
  align-content: center;
  gap: 14px;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100vw, 430px);
  transform: translateX(-50%);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(12, 15, 22, 0.96);
  backdrop-filter: blur(14px);
}

.bottom-tabs button {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.bottom-tabs b {
  font-size: 12px;
}

.bottom-tabs button span {
  font-size: 18px;
}

.bottom-tabs button.is-active {
  color: #fff;
  background: rgba(230, 52, 47, 0.16);
}

@media (min-width: 860px) {
  .phone-shell {
    margin-top: 20px;
    margin-bottom: 20px;
    min-height: calc(100vh - 40px);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  }

  .bottom-tabs {
    bottom: 20px;
    border-radius: 0 0 24px 24px;
  }
}
