:root {
  color-scheme: dark;
  --bg: #101318;
  --panel: #171b22;
  --panel-2: #1f242d;
  --text: #f2f5f7;
  --muted: #9aa6b2;
  --line: #2b323d;
  --green: #4cc38a;
  --red: #ff6b6b;
  --yellow: #f7c948;
  --cyan: #52c7e8;
  --blue: #6892ff;
  --orange: #ff9d42;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
  font-family: "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

html {
  font-size: 16px;
  text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-width: 390px;
  width: 100%;
  background:
    linear-gradient(180deg, rgba(82, 199, 232, 0.08), transparent 360px),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1680px;
  min-height: 96px;
  min-width: 0;
  padding: 24px 32px;
  width: 100%;
}

.eyebrow {
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

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

h1 {
  font-size: 40px;
  line-height: 1.1;
  margin-bottom: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.header-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
}

.icon-button,
.primary-button,
.segment {
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  transition: 160ms ease;
}

.icon-button {
  align-items: center;
  background: var(--panel);
  border-radius: 8px;
  display: grid;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.primary-button {
  background: var(--green);
  border-color: transparent;
  border-radius: 8px;
  color: #08120d;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
}

.secondary-button {
  background: #11151b;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

.full-button {
  justify-content: center;
  margin-top: 12px;
  width: 100%;
}

.icon-button:hover,
.segment:hover,
.match-card:hover {
  border-color: var(--cyan);
}

.layout {
  align-items: start;
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(300px, 320px) minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1680px;
  padding: 22px 32px 12px;
  width: 100%;
}

.sidebar,
.panel,
.metric,
.match-hero {
  background: rgba(23, 27, 34, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  align-self: start;
  min-width: 0;
  padding: 18px;
  position: sticky;
  top: 16px;
}

.data-source {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 18px;
}

.compact-source {
  display: grid;
  gap: 10px;
}

.source-details {
  display: grid;
  gap: 10px;
}

.source-details summary {
  color: var(--cyan);
  cursor: pointer;
  font-size: 13px;
  list-style-position: inside;
  margin-top: 2px;
}

.source-details[open] summary {
  margin-bottom: 12px;
}

.source-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.sub-title {
  margin-top: 2px;
}

.data-source label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 6px;
}

.data-source input,
.data-source select {
  background: #11151b;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 38px;
  padding: 0 10px;
  width: 100%;
}

.source-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.source-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 10px 0 0;
  overflow-wrap: anywhere;
}

.panel-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-title h2,
.panel-title h3 {
  font-size: 18px;
  margin: 0;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.segmented {
  background: #11151b;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 16px;
  padding: 4px;
}

.segment {
  background: transparent;
  border-color: transparent;
  border-radius: 6px;
  min-height: 34px;
}

.segment.active {
  background: var(--panel-2);
  color: var(--cyan);
}

.match-list {
  display: grid;
  gap: 10px;
  max-height: 720px;
  overflow-y: auto;
  padding-right: 4px;
}

.match-card {
  background: #12161c;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 14px;
  text-align: left;
}

.match-card.active {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

.match-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.match-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  border-radius: 999px;
  color: #08120d;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
}

.tag.hot {
  background: var(--orange);
}

.tag.live {
  background: var(--cyan);
}

.tag.safe {
  background: var(--green);
}

.workspace {
  align-content: start;
  align-self: start;
  display: grid;
  gap: 18px;
  grid-auto-rows: max-content;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.workspace > * {
  height: auto;
  min-height: 0;
}

.mobile-match-switcher {
  display: none;
}

.match-hero {
  align-self: start;
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 142px;
  max-height: 220px;
  height: auto;
  overflow: hidden;
  padding: 24px;
}

.status-pill {
  background: rgba(82, 199, 232, 0.14);
  border: 1px solid rgba(82, 199, 232, 0.45);
  border-radius: 999px;
  color: var(--cyan);
  display: inline-block;
  font-size: 12px;
  margin-bottom: 12px;
  padding: 5px 10px;
}

.match-hero h2 {
  font-size: 36px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
  margin-bottom: 0;
}

.confidence {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 130px;
}

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

.confidence strong {
  color: var(--green);
  font-size: 34px;
}

.metric-grid {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  min-height: 112px;
  padding: 18px;
}

.metric span,
.metric small {
  color: var(--muted);
  display: block;
}

.metric strong {
  display: block;
  font-size: 24px;
  margin: 10px 0 8px;
}

.two-column {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  align-self: start;
  height: auto;
  min-width: 0;
  overflow: hidden;
  padding: 18px;
}

.chart-panel {
  height: auto;
  max-height: none;
}

.chart-panel canvas {
  background: #11151b;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: 220px;
  max-height: 220px;
  min-height: 220px;
  width: 100%;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.legend span {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 7px;
}

.legend i {
  border-radius: 999px;
  display: block;
  height: 9px;
  width: 9px;
}

.home {
  background: var(--green);
}

.draw {
  background: var(--yellow);
}

.away,
.line {
  background: var(--blue);
}

.water {
  background: var(--red);
}

.kelly-table {
  display: grid;
  gap: 8px;
}

.kelly-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 96px repeat(3, minmax(0, 1fr));
}

.kelly-cell {
  background: #11151b;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 42px;
  padding: 9px;
}

.kelly-cell.low {
  border-color: rgba(76, 195, 138, 0.65);
  color: var(--green);
}

.kelly-cell.high {
  border-color: rgba(255, 107, 107, 0.65);
  color: var(--red);
}

.analysis {
  display: grid;
  gap: 12px;
}

.analysis-block {
  background: #11151b;
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
  padding: 13px 14px;
}

.analysis-block strong {
  display: block;
  margin-bottom: 5px;
}

.analysis-block p {
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 0;
}

.alerts {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.alert-item,
.media-item,
.h2h-item,
.injury-item {
  background: #11151b;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.alert-item strong,
.media-item strong,
.h2h-item strong,
.injury-item strong {
  color: var(--yellow);
  display: block;
  margin-bottom: 8px;
}

.alert-item p,
.media-item p,
.h2h-item p,
.injury-item p {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.media-grid,
.h2h-grid,
.injury-grid {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.media-item a,
.h2h-item a,
.injury-item a {
  color: var(--text);
  display: block;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.media-item a:hover,
.h2h-item a:hover,
.injury-item a:hover {
  color: var(--cyan);
}

.media-meta,
.h2h-meta,
.injury-meta {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 10px;
}

.media-meta a,
.h2h-meta a,
.injury-meta a {
  color: var(--cyan);
  display: inline;
  font-weight: 600;
  margin: 0;
  text-decoration: none;
}

.media-summary {
  border-left: 4px solid var(--cyan);
  grid-column: 1 / -1;
}

.disclaimer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 10px 32px 24px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .metric-grid,
  .alerts,
  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-header,
  .match-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-header,
  .layout,
  .disclaimer {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: 26px;
    line-height: 1.15;
  }

  .match-hero h2 {
    font-size: 24px;
  }

  .header-actions {
    width: 100%;
  }

  .primary-button {
    flex: 1;
  }

  .layout {
    gap: 14px;
    padding-top: 14px;
  }

  .workspace {
    order: 1;
  }

  .mobile-match-switcher {
    background: rgba(23, 27, 34, 0.96);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    padding: 14px;
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .mobile-match-switcher label {
    color: var(--cyan);
    display: grid;
    font-size: 15px;
    font-weight: 700;
    gap: 9px;
  }

  .mobile-match-switcher select {
    background: #11151b;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    min-height: 50px;
    padding: 0 12px;
    width: 100%;
  }

  .mobile-update-button {
    margin-top: 12px;
    min-height: 50px;
  }

  .sidebar {
    display: none;
    order: 2;
    padding: 14px;
  }

  .data-source {
    margin-bottom: 14px;
    padding-bottom: 14px;
  }

  .source-details:not([open]) {
    margin-bottom: 0;
  }

  .match-list {
    max-height: 360px;
  }

  .match-card {
    padding: 12px;
  }

  .match-card strong {
    font-size: 14px;
  }

  .panel,
  .metric,
  .match-hero {
    padding: 14px;
  }

  .metric {
    min-height: 92px;
  }

  .metric strong {
    font-size: 20px;
  }

  .metric-grid,
  .two-column,
  .alerts,
  .media-grid,
  .h2h-grid,
  .injury-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel canvas {
    height: 190px;
    max-height: 190px;
    min-height: 190px;
  }

  .panel-title {
    gap: 8px;
  }

  .panel-title span {
    white-space: normal;
    text-align: right;
  }

  .kelly-row {
    grid-template-columns: 78px repeat(3, minmax(0, 1fr));
  }
}
