:root {
  --ink: #12201d;
  --muted: #6d7774;
  --paper: #f4f6f3;
  --white: #ffffff;
  --green-950: #052823;
  --green-900: #093b34;
  --green-700: #087a62;
  --green-500: #12a67e;
  --mint: #dff6ed;
  --lime: #d9f451;
  --yellow: #ffc84a;
  --coral: #f45b52;
  --blue: #4f7cff;
  --line: #dce3df;
  --shadow: 0 14px 36px rgba(16, 48, 40, .11);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100dvh; padding-bottom: 74px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 60px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(244, 246, 243, .92);
  border-bottom: 1px solid rgba(220, 227, 223, .8);
  backdrop-filter: blur(18px);
}
.brand, .top-actions, .hero-meta, .section-head, .row, .team-line, .fixture-top,
.prob-labels, .segmented, .filters, .metric-row, .tabs, .page-title, .factor {
  display: flex;
  align-items: center;
}
.brand { min-height: 44px; border: 0; background: transparent; padding: 0; gap: 9px; color: var(--ink); text-align: left; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; background: var(--green-900); border-radius: 50%; font-size: 19px; }
.brand b { display: block; font: 800 17px/1 "Segoe UI", sans-serif; }
.brand small { display: block; margin-top: 4px; font: 700 8px/1 "Segoe UI", sans-serif; color: var(--green-700); letter-spacing: 1.4px; }
.top-actions { gap: 8px; }
.icon-btn, .avatar-btn, .back-btn, .swap-btn {
  position: relative;
  width: 44px; height: 44px; border: 1px solid var(--line); background: var(--white); border-radius: 50%;
}
.notify-dot { position: absolute; right: 8px; top: 7px; width: 7px; height: 7px; border: 2px solid white; background: var(--coral); border-radius: 50%; }
.avatar-btn { background: var(--yellow); border-color: transparent; }

main { max-width: 1180px; margin: 0 auto; }
.page { padding: 18px 16px 34px; animation: pageIn .25s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(5px); } }
.page-title { justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-title h1 { margin: 0; font-size: 25px; letter-spacing: 0; line-height: 1.2; }
.page-title p { margin: 5px 0 0; font-size: 12px; color: var(--muted); }
.page-title .back-btn { flex: 0 0 auto; }

.hero {
  position: relative;
  overflow: hidden;
  padding: 22px;
  color: white;
  background: var(--green-950);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero::after {
  content: "⚽";
  position: absolute;
  right: -22px;
  bottom: -55px;
  font-size: 150px;
  opacity: .07;
  transform: rotate(-18deg);
  pointer-events: none;
}
.eyebrow { margin: 0 0 8px; color: var(--lime); font: 800 11px/1.2 "Segoe UI", sans-serif; text-transform: uppercase; }
.hero h1 { max-width: 590px; margin: 0 0 9px; font-size: clamp(25px, 7vw, 42px); line-height: 1.08; letter-spacing: 0; }
.hero > p { max-width: 620px; margin: 0; color: #bed4cc; font-size: 13px; line-height: 1.7; }
.hero-meta { margin-top: 22px; justify-content: space-between; gap: 10px; }
.live-pill, .tag, .score-chip, .trend-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 700;
}
.live-pill { background: var(--coral); color: white; }
.tag { background: var(--mint); color: var(--green-900); }
.tag.hot { background: #fff0d2; color: #985e00; }
.tag.red { background: #ffe3e1; color: #a9342d; }
.tag.dark { background: rgba(255,255,255,.12); color: white; }
.score-chip { background: var(--lime); color: var(--green-950); }
.trend-pill { background: #e9efff; color: #315ec7; }

.featured-match { margin-top: 14px; padding: 16px; background: white; color: var(--ink); border-radius: var(--radius); }
.fixture-top { justify-content: space-between; color: var(--muted); font-size: 11px; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin: 20px 0; text-align: center; }
.team-hero { min-width: 0; }
.flag { font-size: 34px; line-height: 1; }
.team-hero b { display: block; margin-top: 8px; font-size: 17px; }
.team-hero small { color: var(--muted); }
.vs-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--green-950); color: white; font: 800 12px "Segoe UI", sans-serif; }
.probability { margin-top: 12px; }
.prob-labels { justify-content: space-between; gap: 8px; margin-bottom: 7px; font-size: 10px; font-weight: 700; }
.prob-track { height: 8px; display: flex; overflow: hidden; border-radius: 999px; background: #edf0ee; }
.prob-track span:nth-child(1) { background: var(--green-500); }
.prob-track span:nth-child(2) { background: var(--yellow); }
.prob-track span:nth-child(3) { background: var(--coral); }

.section { margin-top: 26px; content-visibility: auto; contain-intrinsic-size: auto 420px; }
.section-head { justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 17px; letter-spacing: 0; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.text-btn { min-height: 44px; border: 0; background: transparent; color: var(--green-700); font-weight: 700; font-size: 12px; }
.primary-btn, .secondary-btn {
  min-height: 44px; padding: 0 14px; border-radius: 6px; font-weight: 800; border: 1px solid transparent;
}
.primary-btn { background: var(--lime); color: var(--green-950); }
.secondary-btn { background: white; color: var(--ink); border-color: var(--line); }
.wide-btn { width: 100%; }

.date-strip, .horizontal-scroll { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-inline: contain; scroll-snap-type: x proximity; scrollbar-width: none; }
.date-strip::-webkit-scrollbar, .horizontal-scroll::-webkit-scrollbar { display: none; }
.date-btn { flex: 0 0 58px; height: 62px; scroll-snap-align: start; border: 1px solid var(--line); background: white; border-radius: 6px; color: var(--muted); }
.date-btn b, .date-btn small { display: block; }
.date-btn.active { background: var(--green-900); color: white; border-color: transparent; }
.date-btn.active small { color: var(--lime); }

.match-list, .stack { display: grid; gap: 10px; }
.match-card, .list-panel, .group-card, .team-card, .stat-card, .control-panel, .model-card {
  background: white; border: 1px solid var(--line); border-radius: var(--radius);
}
.match-card { padding: 14px; }
.match-card:hover, .group-card:hover, .team-card:hover { border-color: #a8c4b9; }
.match-card .team-line { justify-content: space-between; margin: 13px 0; }
.team-name { display: flex; align-items: center; gap: 7px; font-weight: 800; }
.team-name.reverse { flex-direction: row-reverse; }
.mini-score { font: 800 19px "Segoe UI", sans-serif; }
.reason { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

.quick-grid, .metric-grid, .group-grid, .team-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-action { min-height: 92px; padding: 14px; text-align: left; border: 1px solid var(--line); background: white; border-radius: var(--radius); }
.quick-action span { display: block; font-size: 24px; }
.quick-action b { display: block; margin-top: 9px; font-size: 13px; }
.quick-action small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }

.segmented { width: 100%; padding: 3px; gap: 3px; overflow-x: auto; background: #e7ece9; border-radius: 7px; }
.segmented button { flex: 1 0 auto; min-height: 44px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; }
.segmented button.active { background: white; color: var(--ink); box-shadow: 0 2px 7px rgba(20,45,37,.07); }

.list-panel { overflow: hidden; }
.list-row { padding: 14px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.row { justify-content: space-between; gap: 12px; }
.row-main { min-width: 0; }
.row-main b { display: block; font-size: 13px; }
.row-main small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.rank { width: 26px; color: var(--muted); font: 800 13px "Segoe UI", sans-serif; }
.progress { height: 6px; margin-top: 9px; overflow: hidden; background: #edf1ef; border-radius: 99px; }
.progress span { display: block; height: 100%; background: var(--green-500); border-radius: inherit; }

.metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card { padding: 13px; }
.stat-card small { display: block; color: var(--muted); font-size: 10px; }
.stat-card b { display: block; margin-top: 8px; font: 800 21px "Segoe UI", sans-serif; }
.stat-card em { display: block; margin-top: 5px; color: var(--green-700); font-size: 9px; font-style: normal; font-weight: 700; }

.group-card, .team-card { padding: 14px; text-align: left; }
button.group-card, button.team-card { width: 100%; color: inherit; }
.group-card h3, .team-card h3 { margin: 8px 0 5px; font-size: 15px; }
.group-card p, .team-card p { margin: 0; color: var(--muted); font-size: 10px; }
.flags { margin-top: 12px; font-size: 22px; letter-spacing: 2px; }
.group-score { font: 800 22px "Segoe UI", sans-serif; color: var(--green-700); }

.control-panel { padding: 14px; }
.select-card { width: 100%; min-height: 74px; padding: 12px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); background: white; border-radius: 6px; text-align: left; }
.select-card .flag { font-size: 30px; }
.select-card b, .select-card small { display: block; }
.select-card small { color: var(--muted); font-size: 10px; }
.swap-wrap { height: 24px; display: grid; place-items: center; }
.swap-btn { z-index: 1; background: var(--green-900); color: white; border-color: white; }
.filters { gap: 8px; flex-wrap: wrap; }
.filter-btn { min-height: 44px; padding: 0 11px; border: 1px solid var(--line); background: white; border-radius: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.filter-btn.active { background: var(--green-900); border-color: var(--green-900); color: white; }

.prediction-result { margin-top: 14px; padding: 18px; color: white; background: var(--green-950); border-radius: var(--radius); }
.prediction-result h2 { margin: 0 0 4px; font-size: 17px; }
.prediction-result > p { margin: 0; color: #aac7be; font-size: 11px; }
.prediction-result .probability { margin: 20px 0; }
.prediction-result .prob-track { height: 12px; background: rgba(255,255,255,.12); }
.prediction-result .prob-labels { color: white; }
.factor-list { display: grid; gap: 8px; margin-top: 14px; }
.factor { align-items: flex-start; gap: 8px; padding: 10px; background: rgba(255,255,255,.07); border-radius: 6px; font-size: 11px; }

.comparison { display: grid; gap: 10px; }
.comparison-row { display: grid; grid-template-columns: 45px 1fr 42px 1fr 45px; align-items: center; gap: 7px; font-size: 10px; font-weight: 700; text-align: center; }
.bar { height: 7px; background: #e9eeeb; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--green-500); border-radius: inherit; }
.bar.right span { margin-left: auto; background: var(--coral); }

.chart-box { min-height: 180px; padding: 16px; position: relative; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.chart-lines { height: 120px; display: flex; align-items: end; gap: 8px; border-bottom: 1px solid var(--line); }
.chart-lines span { flex: 1; min-width: 9px; background: var(--green-500); border-radius: 4px 4px 0 0; opacity: .85; }
.chart-lines span:nth-child(3n) { background: var(--yellow); }
.chart-lines span:nth-child(4n) { background: var(--coral); }
.chart-caption { margin-top: 10px; color: var(--muted); font-size: 10px; }

.bracket { display: grid; gap: 10px; overflow-x: auto; }
.round { min-width: 280px; padding: 14px; scroll-snap-align: start; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.round h3 { margin: 0 0 12px; font-size: 13px; }
.bracket-match { margin-top: 8px; padding: 9px; background: var(--paper); border-left: 3px solid var(--green-500); border-radius: 4px; font-size: 10px; }

.settings-list .list-row { min-height: 58px; }
.toggle { position: relative; width: 48px; height: 44px; padding: 13px 3px; flex: 0 0 48px; border: 0; border-radius: 99px; background: transparent; }
.toggle::before { content: ""; position: absolute; width: 42px; height: 24px; margin: -3px 0 0; transform: translateX(-3px); border-radius: 99px; background: #cbd4d0; }
.toggle::after { content: ""; display: block; width: 18px; height: 18px; background: white; border-radius: 50%; transition: .2s; }
.toggle.on::before { background: var(--green-500); }
.toggle.on::after { transform: translateX(18px); }
.search-box { width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--line); background: white; border-radius: 6px; outline: none; }
.search-box:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(18,166,126,.12); }

.admin-bar { padding: 12px 14px; background: #17201e; color: white; border-radius: var(--radius); }
.admin-bar small { color: #aebbb7; }
.status-ok { color: var(--green-700); font-weight: 800; }
.status-warn { color: #af6f00; font-weight: 800; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(64px + env(safe-area-inset-bottom));
  padding: 5px 8px env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(18px);
}
.bottom-nav button { min-height: 52px; border: 0; background: transparent; color: #87918e; }
.bottom-nav span, .bottom-nav b { display: block; }
.bottom-nav span { font-size: 19px; filter: grayscale(1); }
.bottom-nav b { margin-top: 2px; font-size: 9px; }
.bottom-nav button.active { color: var(--green-900); }
.bottom-nav button.active span { filter: none; transform: translateY(-1px); }

#toast { position: fixed; left: 50%; bottom: 86px; z-index: 50; max-width: calc(100% - 32px); padding: 10px 14px; color: white; background: var(--ink); border-radius: 6px; font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: grid; align-items: end;
  padding: 16px; background: rgba(5,40,35,.62); backdrop-filter: blur(5px);
}
.team-selector-modal {
  width: min(620px, 100%); max-height: min(760px, 86dvh); margin: 0 auto; padding: 18px;
  overflow: hidden; background: white; border-radius: 8px; box-shadow: var(--shadow);
}
.team-selector-modal > .row { justify-content: space-between; margin-bottom: 12px; }
.team-selector-modal h2 { margin: 0; font-size: 18px; }
.team-selector-modal p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.selector-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px;
  max-height: calc(86dvh - 105px); margin-top: 12px; overflow-y: auto;
}
.selector-team {
  min-height: 68px; padding: 10px; display: grid; grid-template-columns: 32px 1fr; align-items: center;
  gap: 2px 8px; text-align: left; border: 1px solid var(--line); border-radius: 6px; background: white;
}
.selector-team span { grid-row: span 2; font-size: 24px; }
.selector-team b { font-size: 12px; }
.selector-team small { color: var(--muted); font-size: 9px; }
.selector-team:hover { border-color: var(--green-500); background: var(--mint); }

[data-route] { cursor: pointer; }
[data-route]:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(18,166,126,.3);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (min-width: 760px) {
  .topbar { padding-left: max(24px, calc((100vw - 1180px) / 2)); padding-right: max(24px, calc((100vw - 1180px) / 2)); }
  .page { padding: 28px 24px 52px; }
  .hero { padding: 30px; }
  .hero-layout { display: grid; grid-template-columns: 1fr 430px; gap: 28px; align-items: center; }
  .featured-match { margin: 0; }
  .group-grid { grid-template-columns: repeat(3, 1fr); }
  .team-grid { grid-template-columns: repeat(4, 1fr); }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .content-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 24px; align-items: start; }
  .bottom-nav { left: 50%; right: auto; width: 420px; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; box-shadow: var(--shadow); }
  .bracket { grid-template-columns: repeat(4, 1fr); }
  .modal-backdrop { align-items: center; }
  .selector-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
