:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #767c88;
  --border: #e6e8ec;
  --accent: #2563eb;
  --live: #dc2626;
  --win: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans Thai", Tahoma, sans-serif;
  font-size: 15px;
}

header.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

header.topbar h1 {
  font-size: 18px;
  margin: 0;
}

.search-form {
  display: flex;
  align-items: center;
  flex: 1 1 160px;
  order: 3;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 6px 4px 12px;
}

.search-form input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  flex: 1;
  min-width: 0;
  color: var(--text);
}

.search-form button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
}

header.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
}

header.topbar nav a.active,
header.topbar nav a:hover {
  color: var(--accent);
  background: #eaf1ff;
}

main {
  max-width: 900px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

h2.date-heading {
  font-size: 16px;
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
}

h2.date-heading:first-child { margin-top: 0; }

.league-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}

.league-group h2 {
  font-size: 14px;
  margin: 0;
  padding: 10px 14px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
}

.match-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.match-row:last-child { border-bottom: none; }

.match-time {
  width: 56px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.match-status {
  font-size: 11px;
  font-weight: 700;
}

.match-status.live { color: var(--live); }
.match-status.finished { color: var(--muted); }

.match-teams {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.team-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.team-name { font-weight: 500; }
.team-score { font-weight: 700; min-width: 20px; text-align: right; }

.empty-note {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs a {
  padding: 7px 14px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

table.standings {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

table.standings th, table.standings td {
  padding: 9px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

table.standings th {
  background: #fafbfc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

table.standings td.team {
  text-align: left;
  font-weight: 600;
}

table.standings td.rank { color: var(--muted); width: 30px; }
table.standings td.pts { font-weight: 800; color: var(--accent); }
table.standings tr:last-child td { border-bottom: none; }

.updated-note {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 14px;
}

a.match-row-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

a.match-row-link:hover .match-row {
  background: #f7f9fc;
}

.match-detail-header {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
  text-align: center;
}

.mdh-league {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.mdh-teams {
  max-width: 320px;
  margin: 0 auto 12px;
}

.mdh-team-line {
  display: flex;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 600;
  padding: 4px 0;
}

.mdh-score {
  font-weight: 800;
  color: var(--accent);
}

.mdh-meta {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.table-scroll {
  overflow-x: auto;
}

table.raw-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  white-space: nowrap;
}

table.raw-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

table.raw-table tr.hdr td {
  color: var(--muted);
  font-weight: 700;
  background: #fafbfc;
}

.lineup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.lineup-col {
  padding: 10px 12px;
  border-right: 1px solid var(--border);
}

.lineup-col:last-child { border-right: none; }

.lineup-team-name {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--muted);
}

.player-row {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
}

.player-no {
  color: var(--muted);
  width: 22px;
  flex-shrink: 0;
  text-align: right;
}

.country-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.country-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.country-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
}

.country-block .tabs { margin-bottom: 0; }

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.team-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
}

.team-logo { width: 44px; height: 44px; object-fit: contain; margin-bottom: 6px; }
.team-logo-big { width: 60px; height: 60px; object-fit: contain; margin-bottom: 8px; }

.team-card-name { font-size: 12px; font-weight: 600; line-height: 1.3; }
.team-card-count { font-size: 11px; color: var(--muted); margin-top: 4px; }

table.squad-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  font-size: 13px;
}

table.squad-table th, table.squad-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

table.squad-table th {
  background: #fafbfc;
  color: var(--muted);
  font-size: 11px;
}

.player-photo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.player-photo-big {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
}

.stat-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
}

.stat-chip {
  flex: 1;
  min-width: 70px;
  text-align: center;
}

.stat-chip-value { font-size: 18px; font-weight: 800; color: var(--accent); }
.stat-chip-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
