:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ebe7dc;
  --ink: #151715;
  --muted: #6b6f69;
  --line: #d7d1c2;
  --green: #176b58;
  --blue: #245f73;
  --red: #a33b2f;
  --gold: #b7842f;
  --shadow: 0 10px 28px rgba(35, 31, 24, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 14px 14px 88px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.72), rgba(244, 241, 234, 0.94)),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -14px -14px 14px;
  padding: 16px 14px 12px;
  background: rgba(244, 241, 234, 0.94);
  border-bottom: 1px solid rgba(215, 209, 194, 0.72);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.sync-state {
  flex: 0 0 auto;
  max-width: 42vw;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  line-height: 1.25;
  text-align: right;
}

.app-shell {
  display: grid;
  gap: 14px;
  max-width: 1180px;
  margin: 0 auto;
}

.section {
  display: grid;
  gap: 14px;
}

.panel,
.card,
.match-card,
.team-row,
.standing-table,
.team-detail,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
}

.hero-grid {
  display: grid;
  gap: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.kpi {
  min-height: 74px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9f7f1;
}

.kpi span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.kpi strong {
  font-size: 22px;
  line-height: 1;
}

.chart-panel {
  overflow: hidden;
}

.chart-panel img {
  display: block;
  width: 100%;
  height: auto;
}

.home-chart {
  max-width: 760px;
  margin: 0 auto;
}

.algorithm-panel {
  display: grid;
  gap: 10px;
}

.formula-list {
  display: grid;
  gap: 8px;
}

.formula-list p {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf6;
  font-size: 13px;
  line-height: 1.45;
}

.toolbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-btn,
.small-btn,
.team-link {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.filter-btn {
  flex: 0 0 auto;
  padding: 0 12px;
}

.filter-btn.is-active,
.small-btn.is-active {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.match-list,
.team-list,
.groups-grid,
.standings-grid {
  display: grid;
  gap: 10px;
}

.match-card {
  overflow: hidden;
}

.match-main {
  width: 100%;
  padding: 13px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.match-head,
.match-teams,
.prob-row,
.team-meta,
.standing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.match-head {
  color: var(--muted);
  font-size: 12px;
}

.match-action-row {
  display: flex;
  align-items: center;
  padding: 0 13px 12px;
  border-bottom: 1px solid var(--line);
}

.match-status-strip {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
  min-width: 0;
  margin: 0 0 7px;
}

.summary-chip {
  padding: 3px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.summary-chip.user.is-empty,
.tab-badge.is-empty {
  color: var(--red);
  font-weight: 900;
}

.summary-chip.user.is-filled,
.tab-badge.is-filled {
  color: var(--green);
  font-weight: 900;
}

.match-teams {
  margin: 10px 0;
  font-size: 16px;
  font-weight: 800;
}

.score {
  flex: 0 0 auto;
  min-width: 58px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  text-align: center;
}

.status {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.status.played {
  color: var(--red);
}

.prob-row {
  margin-top: 8px;
  align-items: stretch;
}

.prob {
  flex: 1 1 0;
  min-width: 0;
}

.prob label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.match-detail {
  display: none;
  padding: 12px 13px 13px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.match-card.is-open .match-detail {
  display: block;
}

.match-tabs {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.match-tab {
  min-height: 28px;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.match-tab.is-active {
  background: var(--green);
  color: white;
}

.tab-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.15;
}

.match-tab.is-active .tab-badge {
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.match-tab-panels {
  display: grid;
  gap: 12px;
}

.match-tab-panel {
  display: none;
}

.match-tab-panel.is-active {
  display: block;
}

.match-tab-panel > section {
  min-width: 0;
}

.history-list {
  display: grid;
  gap: 7px;
  margin-top: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.history-row {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf6;
}

.history-date {
  color: var(--muted);
  font-size: 11px;
}

.history-score {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.history-score span {
  overflow-wrap: anywhere;
}

.history-score span:last-child {
  text-align: right;
}

.history-score strong {
  padding: 4px 5px;
  border-radius: 6px;
  background: var(--surface-2);
  text-align: center;
  white-space: nowrap;
}

.group-card {
  padding: 13px;
}

.confed-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 14px;
}

.confed-legend span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf6;
  color: var(--muted);
  font-size: 12px;
}

.confed-legend strong {
  color: var(--green);
}

.team-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  box-shadow: none;
}

.team-row strong {
  display: block;
  margin-bottom: 3px;
}

.team-row span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.team-link {
  align-self: center;
  padding: 0 10px;
}

.standing-table {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

td:last-child,
th:last-child {
  text-align: right;
}

.team-detail {
  padding: 14px;
}

.detail-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.back-btn {
  min-width: 108px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
}

.title-chart {
  display: grid;
  gap: 9px;
}

.title-bar {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) minmax(110px, 2fr) 52px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.title-bar strong {
  text-align: right;
}

.scoreline-block {
  margin-top: 8px;
}

.scoreline-list {
  display: grid;
  gap: 6px;
  margin-top: 7px;
}

.scoreline-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf6;
}

.user-predict-box {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.user-predict-box.is-locked {
  border-color: rgba(23, 107, 88, 0.34);
  background: rgba(23, 107, 88, 0.08);
}

.user-predict-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lock-state {
  padding: 4px 7px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
}

.lock-state.is-open {
  background: rgba(163, 59, 47, 0.1);
  color: var(--red);
}

.lock-state.is-locked {
  background: rgba(23, 107, 88, 0.14);
  color: var(--green);
}

.predict-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}

.predict-inputs label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.predict-inputs input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  text-align: center;
  font: inherit;
  font-weight: 800;
}

.predict-inputs input:disabled {
  background: rgba(23, 107, 88, 0.08);
  color: var(--ink);
  opacity: 1;
}

.predict-sep {
  padding-bottom: 7px;
  font-weight: 800;
  text-align: center;
}

.predict-actions {
  display: flex;
  gap: 8px;
}

.prediction-locked {
  padding: 7px 9px;
  border: 1px solid rgba(23, 107, 88, 0.28);
  border-radius: 7px;
  background: rgba(23, 107, 88, 0.12);
  color: var(--green);
  font-weight: 900;
}

.tree-scroll {
  display: grid;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.tree-stage {
  min-width: 920px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tree-stage h3,
.tree-stage h4 {
  margin: 0 0 10px;
}

.tree-groups,
.tree-stage-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 10px;
}

.tree-group {
  display: grid;
  align-content: start;
  gap: 8px;
}

.tree-match {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.tree-match-title {
  display: grid;
  gap: 4px;
}

.tree-match-title span {
  color: var(--muted);
  font-size: 11px;
}

.tree-result {
  display: grid;
  grid-template-columns: 58px minmax(54px, 1fr);
  gap: 7px;
  align-items: center;
  font-size: 12px;
}

.tree-result span {
  color: var(--muted);
}

.tree-result b {
  padding: 4px 5px;
  border-radius: 6px;
  background: var(--surface-2);
  text-align: center;
}

.tree-result.user b {
  background: rgba(23, 107, 88, 0.14);
  color: var(--green);
}

.tree-result.actual b {
  background: rgba(163, 59, 47, 0.12);
  color: var(--red);
}

.recent-match-row {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.recent-date {
  color: var(--muted);
  font-size: 12px;
}

.recent-scoreline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

.recent-scoreline span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.recent-scoreline span:last-child {
  text-align: right;
}

.recent-scoreline strong {
  padding: 5px 6px;
  border-radius: 7px;
  background: var(--surface-2);
  text-align: center;
  white-space: nowrap;
}

.recent-scoreline .winner {
  color: var(--green);
  font-weight: 800;
}

.split-grid {
  display: grid;
  gap: 12px;
}

.lineup-panel {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.lineup-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.lineup-head h3 {
  margin: 0;
}

.lineup-head span {
  color: var(--muted);
  font-size: 12px;
}

.pitch {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(23, 107, 88, 0.25);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 50%, transparent 50%),
    linear-gradient(180deg, rgba(23, 107, 88, 0.16), rgba(36, 95, 115, 0.16));
}

.lineup-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.lineup-player {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 112px;
  min-width: 0;
  text-align: center;
}

.lineup-player strong {
  font-size: 11px;
  line-height: 1.2;
}

.lineup-player span {
  color: var(--muted);
  font-size: 10px;
}

.roster-group {
  margin-top: 14px;
}

.roster-list {
  display: grid;
  gap: 7px;
}

.player-row {
  display: grid;
  grid-template-columns: 38px 34px 42px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf6;
}

.player-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(23, 107, 88, 0.24);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(23, 107, 88, 0.18), rgba(36, 95, 115, 0.2));
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
}

.player-avatar span {
  line-height: 1;
}

.player-row small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.bottom-nav {
  position: fixed;
  right: 10px;
  bottom: 10px;
  left: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-width: 520px;
  margin: 0 auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.nav-btn {
  height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav-btn.is-active {
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.loading,
.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 430px) {
  .match-status-strip {
    gap: 7px;
  }

  .summary-chip {
    font-size: 10px;
  }

  .match-tab {
    padding-inline: 5px;
    font-size: 10px;
  }
}

@media (min-width: 760px) {
  body {
    padding: 20px 22px 110px;
  }

  .topbar {
    margin: -20px -22px 20px;
    padding: 18px 22px 14px;
  }

  h1 {
    font-size: 30px;
  }

  .hero-grid,
  .split-grid {
    grid-template-columns: 1fr 1fr;
  }

  .groups-grid,
  .standings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-detail-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .bottom-nav {
    position: sticky;
    top: 76px;
    right: auto;
    bottom: auto;
    left: auto;
    margin-bottom: 16px;
  }
}

@media (min-width: 1100px) {
  .hero-grid {
    grid-template-columns: 0.9fr 1.1fr;
  }

  .groups-grid,
  .standings-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
