:root {
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --line: #E5E9F0;
  --text: #0F172A;
  --muted: #64748B;
  --green: #059669;
  --green-2: #10B981;
  --green-soft: #ECFDF5;
  --green-mid: #D1FAE5;
  --red: #EF4444;
  --red-soft: #FEF2F2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 12px rgba(15, 23, 42, 0.04);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Plus Jakarta Sans", "Inter", "Segoe UI", system-ui, sans-serif;
  --display: "Outfit", "Plus Jakarta Sans", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100%; }
body { padding-bottom: calc(76px + var(--safe-bot)); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { display: block; max-width: 100%; }
a { color: var(--green); }

#progress {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 8px 16px 10px;
  display: flex; align-items: center; gap: 12px;
}
#progress[hidden] { display: none !important; }
#progress-bar {
  flex: 1; height: 7px; background: var(--green-soft);
  border-radius: 99px; overflow: hidden; position: relative;
}
#progress-bar::after {
  content: ""; display: block; height: 100%; width: var(--pct, 0%);
  background: linear-gradient(90deg, var(--green), var(--green-2));
  border-radius: 99px; transition: width .25s ease;
}
#progress-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }

.top {
  padding: calc(14px + var(--safe-top)) 18px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon {
  width: 40px; height: 40px; border-radius: 12px;
  box-shadow: var(--shadow-sm); background: var(--green); flex-shrink: 0;
}
.brand-name {
  font-family: var(--display); font-weight: 800; letter-spacing: 0.04em;
  font-size: 18px; line-height: 1.1; color: var(--text);
}
.brand-sub { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; letter-spacing: 0.01em; }

.league-switch, .pills, .seg-row {
  display: inline-flex; background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; box-shadow: var(--shadow-sm); gap: 2px;
}
.seg, .pill {
  border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 13px;
  color: var(--muted); transition: .15s ease;
}
.seg.active, .pill.active {
  background: var(--green); color: #fff;
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.28);
}
.seg:hover:not(.active), .pill:hover:not(.active) { color: var(--text); background: var(--green-soft); }

#app { max-width: 1100px; margin: 0 auto; padding: 4px 16px 24px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 14px; flex-wrap: wrap; }
.page-title { font-family: var(--display); font-weight: 800; font-size: 22px; }
.page-note { font-size: 12px; color: var(--muted); font-weight: 500; }

.back {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 13px; color: var(--green);
  padding: 6px 0;
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.card + .card { margin-top: 14px; }
.card-title {
  font-family: var(--display); font-weight: 700; font-size: 15px;
  margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.muted { color: var(--muted); }
.tiny { font-size: 11px; color: var(--muted); line-height: 1.45; font-weight: 500; }
.center { text-align: center; }

.game-list { display: flex; flex-direction: column; gap: 10px; }
.game {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 14px 16px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.game:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: #d5dde8; }
.game:active { transform: translateY(0); }
.teams { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.team-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 32px; height: 32px; object-fit: contain; flex-shrink: 0;
  background: #fff; border-radius: 8px;
}
.logo.lg { width: 48px; height: 48px; }
.abbr { font-weight: 800; font-size: 14px; letter-spacing: 0.02em; }
.name { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.time { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 14px; }
.status {
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--bg); border-radius: 999px; padding: 2px 8px;
}
.status.live { color: #b45309; background: #FFFBEB; }
.status.final { color: var(--muted); }
.score { font-weight: 800; font-variant-numeric: tabular-nums; margin-left: auto; font-size: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--green-soft); color: var(--green);
  font-weight: 800; font-size: 12px; letter-spacing: 0.01em;
  border-radius: 999px; padding: 5px 9px; font-variant-numeric: tabular-nums;
  border: 1px solid var(--green-mid);
}
.badge.wait { background: var(--bg); color: var(--muted); border-color: var(--line); font-weight: 600; }
.badge.hot { background: var(--green); color: #fff; border-color: transparent; }

.empty, .error, .loading-card {
  text-align: center; padding: 28px 16px; color: var(--muted);
}
.empty h3, .error h3 { color: var(--text); font-family: var(--display); margin-bottom: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green); color: #fff; font-weight: 700;
  border-radius: 999px; padding: 10px 16px; margin-top: 12px;
  box-shadow: 0 6px 16px rgba(5,150,105,.25);
}
.btn.ghost { background: #fff; color: var(--green); border: 1px solid var(--green-mid); box-shadow: none; }
.btn.danger { background: #fff; color: #b91c1c; border: 1px solid #FECACA; box-shadow: none; }

.match-hero { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.match-side { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 0; text-align: center; }
.match-side .abbr { font-size: 18px; }
.at { font-family: var(--display); font-weight: 800; color: var(--muted); font-size: 13px; padding-top: 10px; }

.prob-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.prob-item { background: var(--bg); border-radius: 14px; padding: 12px 14px; }
.prob-item .lab { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.prob-item .val {
  font-family: var(--display); font-weight: 800; font-size: 28px;
  font-variant-numeric: tabular-nums; color: var(--green); letter-spacing: -0.02em;
}
.bar-track { height: 8px; background: #E2E8F0; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--green-2)); border-radius: 99px; }

.seg-wrap { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.seg-wrap .label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.seg-row { display: flex; flex-wrap: wrap; width: 100%; }
.seg-row .seg { flex: 1; text-align: center; padding: 8px 8px; font-size: 12px; min-width: 0; }

.line-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 14px; flex-wrap: wrap; }
.line-ctrl { display: flex; align-items: center; gap: 4px; }
.step {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font-weight: 800; font-size: 18px; color: var(--green);
}
.line-val { font-family: var(--display); font-weight: 800; font-size: 22px; min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 10px; font-size: 12px; font-weight: 700; color: var(--muted);
}
.chip.active { background: var(--green-soft); color: var(--green); border-color: var(--green-mid); }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px 8px; text-align: center; }
.stat b { display: block; font-family: var(--display); font-size: 16px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); font-weight: 600; }

.chart { position: relative; height: 180px; display: flex; align-items: stretch; gap: 5px; padding: 8px 0 22px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; min-width: 0; }
.col-bar {
  width: 100%; max-width: 36px; border-radius: 7px 7px 4px 4px;
  background: var(--green); transition: height .25s ease;
}
.col-bar.miss { background: var(--red); }
.col-bar.na { background: #CBD5E1; }
.col-val { font-size: 10px; font-weight: 800; font-variant-numeric: tabular-nums; margin-bottom: 4px; color: var(--text); }
.col-lab { position: absolute; bottom: -18px; font-size: 9px; color: var(--muted); font-weight: 600; }
.threshold {
  position: absolute; left: 0; right: 0; border-top: 2px dashed #94A3B8;
  pointer-events: none; z-index: 2;
}
.threshold span {
  position: absolute; right: 0; top: -9px; background: var(--card);
  font-size: 10px; font-weight: 800; color: var(--muted); padding: 0 4px;
}

.h2h { display: flex; flex-direction: column; gap: 8px; }
.h2h-row {
  display: grid; grid-template-columns: 76px 1fr auto auto; gap: 8px; align-items: center;
  background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 13px;
}
.h2h-date { font-size: 11px; color: var(--muted); font-weight: 600; }
.h2h-score { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.h2h-ok { color: var(--green); font-weight: 800; font-size: 12px; }
.h2h-no { color: var(--muted); font-weight: 700; font-size: 12px; }

.search {
  width: 100%; border: 1px solid var(--line); background: #fff;
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.search:focus { outline: 2px solid var(--green-mid); border-color: var(--green); }
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-sm);
}
.team-item:hover { border-color: #d5dde8; }
.team-item .meta { font-size: 12px; color: var(--muted); }

.pick { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: end; }
.pick label { display: flex; flex-direction: column; gap: 6px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.pick select, .field input {
  width: 100%; border: 1px solid var(--line); background: #fff;
  border-radius: 12px; padding: 10px 10px; font-weight: 600;
}
.field { margin: 10px 0; }
.field label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + var(--safe-bot));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; font-size: 11px; font-weight: 700; color: var(--muted);
}
.tab.active { color: var(--green); }
.tab svg { opacity: 0.85; }

@media (min-width: 800px) {
  body { padding-bottom: 0; }
  .tabbar {
    position: static; max-width: 1100px; margin: 0 auto 8px;
    border: 1px solid var(--line); border-radius: 999px;
    padding: 4px; background: #fff; box-shadow: var(--shadow-sm);
    display: flex; justify-content: center; gap: 6px; width: calc(100% - 32px);
  }
  .tab { flex-direction: row; gap: 8px; padding: 10px 22px; border-radius: 999px; font-size: 13px; }
  .tab.active { background: var(--green-soft); }
  #app { padding-top: 8px; }
  .prob-grid { grid-template-columns: 1fr 1fr; }
  .prob-item.span2 { grid-column: 1 / -1; }
  .desktop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .desktop-grid .span2 { grid-column: 1 / -1; }
  .game { padding: 16px 18px; }
}
