:root {
  color-scheme: light;
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #f8faf6;
  --text: #17201b;
  --muted: #66716a;
  --line: #d9dfd7;
  --line-strong: #c5cec3;
  --accent: #087a72;
  --accent-soft: #dff1ee;
  --blue: #2f6fbd;
  --blue-soft: #e8eef8;
  --amber: #b77705;
  --amber-soft: #fff2d5;
  --rose: #c83268;
  --shadow: 0 12px 28px rgba(23, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0) 180px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.35;
  overflow-x: hidden;
}

a {
  color: inherit;
}

.topbar {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1360px;
  min-height: 48px;
  padding: 0 16px;
}

.brand {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.nav {
  align-items: center;
  display: flex;
  gap: 2px;
  overflow-x: auto;
}

.nav a {
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  padding: 7px 9px;
  text-decoration: none;
  white-space: nowrap;
}

.nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-form {
  margin: 0;
}

.nav-button {
  background: transparent;
  color: var(--muted);
  min-height: 0;
  padding: 7px 9px;
}

.page {
  margin: 0 auto;
  max-width: 1360px;
  padding: 18px 16px 44px;
}

.page-title {
  font-size: 24px;
  line-height: 1.05;
  margin: 0 0 12px;
}

.section {
  margin-top: 22px;
}

.section h2 {
  font-size: 17px;
  line-height: 1.1;
  margin: 0 0 8px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  overflow: auto;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 640px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 3;
}

tbody tr:nth-child(even) td {
  background: #fbfcfa;
}

tr:last-child td {
  border-bottom: 0;
}

tfoot th {
  background: #eef3ec;
  border-top: 2px solid var(--line-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 820;
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

.player {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 140px;
}

.scorecard-cards {
  display: none;
}

.rank-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  padding: 10px;
}

.rank-card-main {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 48px minmax(0, 1fr) auto;
}

.rank-number {
  color: var(--muted);
  font-size: 18px;
  font-weight: 850;
}

.rank-player {
  align-items: center;
  display: flex;
  gap: 8px;
  font-size: 18px;
  font-weight: 850;
  min-width: 0;
}

.rank-total {
  color: var(--accent);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.rank-breakdown {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 9px;
}

.rank-breakdown span {
  background: #f4f7f2;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 720;
  justify-content: space-between;
  padding: 5px 7px;
}

.rank-breakdown b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.rank-1 {
  border-color: #edcf8a;
}

.rank-1 .rank-total {
  color: var(--amber);
}

.rank-2 {
  border-color: #b7c4d4;
}

.rank-3 {
  border-color: #d6b48f;
}

.empty {
  color: var(--muted);
  padding: 16px;
}

.status {
  background: #f5f7f3;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-block;
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  min-width: 38px;
  padding: 4px 7px;
  text-align: center;
}

.score {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 820;
}

.overview-wrap {
  max-height: none;
}

.overview-table {
  min-width: 760px;
}

.overview-table th,
.overview-table td {
  padding: 6px 8px;
}

.sticky-col {
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
  left: 0;
  position: sticky;
  z-index: 2;
}

tbody tr:nth-child(even) .sticky-col {
  background: #fbfcfa;
}

thead .sticky-col,
tfoot .sticky-col {
  background: var(--surface-soft);
  z-index: 4;
}

.match-col {
  min-width: 210px;
  width: 210px;
}

.group-col {
  min-width: 92px;
  width: 92px;
}

.compact-col {
  color: var(--muted);
  max-width: 92px;
  min-width: 78px;
  width: 78px;
}

.group-letter-col {
  color: var(--muted);
  font-weight: 780;
  min-width: 34px;
  text-align: center;
  width: 34px;
}

.result-col {
  min-width: 58px;
  width: 58px;
}

.match-stack {
  display: grid;
  gap: 2px;
}

.match-number {
  background: #081224;
  border-radius: 5px;
  color: #ffffff;
  display: inline-block;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  margin: 0 0 5px;
  padding: 4px 6px;
}

.team-line,
.match-inline {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  min-width: 0;
}

.team-line {
  display: flex;
}

.team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flag {
  display: inline-block;
  flex: 0 0 20px;
  font-size: 16px;
  line-height: 1;
  text-align: center;
}

.match-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  gap: 6px;
  margin-top: 3px;
}

.tip-head {
  min-width: 72px;
  text-align: center;
  white-space: nowrap;
}

.tip-head span + span {
  margin-left: 3px;
}

.tip-cell {
  font-variant-numeric: tabular-nums;
  min-width: 72px;
  text-align: center;
  white-space: nowrap;
}

.tip-score {
  color: #1f2c26;
  font-weight: 800;
}

.tip-combo {
  align-items: center;
  background: #f7f9f5;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 4px;
  justify-content: center;
  line-height: 1;
  min-height: 25px;
  padding: 2px 3px 2px 7px;
}

.tip-points-0 .tip-combo,
.tip-combo.tip-points-0 {
  opacity: 0.48;
}

.tip-points-0 .tip-score,
.tip-combo.tip-points-0 .tip-score {
  color: #78837b;
}

.tip-points-1 .tip-combo,
.tip-combo.tip-points-1 {
  background: #f7f9fb;
  border-color: #dbe3ec;
}

.tip-points-2 .tip-combo,
.tip-combo.tip-points-2 {
  background: #fff8e8;
  border-color: #edcf8a;
}

.tip-exact .tip-combo,
.tip-combo.tip-exact,
.tip-points-3 .tip-combo,
.tip-combo.tip-points-3 {
  background: #e6fff4;
  border-color: #10b981;
}

.tip-points {
  background: var(--blue-soft);
  border: 1px solid #c8d6ef;
  border-radius: 999px;
  color: var(--blue);
  display: inline-block;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  min-width: 20px;
  padding: 3px 5px;
  text-align: center;
}

.points-0 {
  background: #f1f3ef;
  border-color: #d8ded5;
  color: #78837b;
  opacity: 0.48;
}

.points-1 {
  background: #eef2f7;
  border-color: #d1dce9;
  color: #496177;
}

.points-2 {
  background: var(--amber-soft);
  border-color: #edcf8a;
  color: var(--amber);
}

.points-3 {
  background: #10b981;
  border-color: #047857;
  color: #ffffff;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.tip-exact .tip-points {
  background: #10b981;
  border-color: #047857;
  color: #ffffff;
}

.is-complete .match-col,
.group-overview .is-complete .group-col {
  border-left: 3px solid var(--accent);
}

.group-overview {
  min-width: 1040px;
}

.group-overview .tip-cell,
.group-overview .tip-head {
  min-width: 136px;
}

.group-tip {
  white-space: normal;
}

.group-pair {
  align-items: stretch;
  display: inline-grid;
  gap: 3px;
  min-width: 126px;
  text-align: left;
}

.group-pair span {
  align-items: center;
  background: #f5f7f3;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: flex;
  gap: 5px;
  min-height: 26px;
  padding: 3px 6px;
}

.group-pair b {
  align-items: center;
  background: var(--amber-soft);
  border: 1px solid #edcf8a;
  border-radius: 4px;
  color: var(--amber);
  display: inline-flex;
  flex: 0 0 18px;
  font-size: 11px;
  justify-content: center;
  line-height: 1;
  min-height: 18px;
}

.matchdays {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.matchday {
  border-top: 1px solid var(--line);
  min-width: 0;
  padding-top: 10px;
}

.matchday:first-child {
  border-top: 0;
  padding-top: 0;
}

.matchday-summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  min-height: 38px;
}

.matchday-summary::-webkit-details-marker {
  display: none;
}

.matchday-summary::before {
  color: var(--muted);
  content: "▸";
  font-size: 13px;
  transform: translateY(-1px);
}

.matchday[open] > .matchday-summary::before {
  content: "▾";
}

.matchday-main {
  align-items: baseline;
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 0;
}

.matchday-title {
  font-size: 18px;
  font-weight: 820;
  white-space: nowrap;
}

.matchday-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.day-points {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.day-points span {
  background: #f0f4ef;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-block;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  padding: 4px 7px;
}

.day-table {
  margin-top: 8px;
}

.fixtures-table th,
.fixtures-table td {
  padding: 5px 6px;
}

.fixtures-table .tip-head,
.fixtures-table .tip-cell {
  min-width: 68px;
}

.fixture-card-list {
  display: none;
}

.totals-table {
  box-shadow: none;
}

.group-badge {
  background: var(--accent-soft);
  border: 1px solid #a9d8d1;
  border-radius: 5px;
  color: var(--accent);
  display: inline-flex;
  font-size: 12px;
  font-weight: 850;
  justify-content: center;
  min-width: 26px;
  padding: 3px 6px;
}

.login-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  max-width: 360px;
  padding: 16px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 5px;
}

input,
select {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--text);
  font: inherit;
  min-height: 36px;
  padding: 6px 8px;
}

button {
  background: var(--accent);
  border: 0;
  border-radius: 5px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 760;
  min-height: 36px;
  padding: 6px 10px;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.inline-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.score-input {
  font-variant-numeric: tabular-nums;
  min-height: 32px;
  padding: 4px 6px;
  text-align: center;
  width: 54px;
}

.group-form {
  align-items: center;
}

.rank-select {
  align-items: center;
  display: flex;
  gap: 5px;
}

.rank-select > span {
  align-items: center;
  background: var(--amber-soft);
  border: 1px solid #edcf8a;
  border-radius: 4px;
  color: var(--amber);
  display: inline-flex;
  flex: 0 0 22px;
  font-size: 12px;
  font-weight: 850;
  justify-content: center;
  min-height: 22px;
}

.rank-select select {
  min-width: 170px;
}

.tip-pill {
  background: #f0f4ef;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  margin: 1px;
  padding: 2px 7px;
}

.muted {
  color: var(--muted);
}

.error {
  background: #fff0f3;
  border: 1px solid #f4b5c5;
  border-radius: 6px;
  color: #a51e4e;
  font-weight: 680;
  margin: 0 0 12px;
  padding: 8px 10px;
}

.rules {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  padding: 6px 16px 16px;
}

.rules table {
  min-width: 0;
}

@media (max-width: 760px) {
  body {
    font-size: 13px;
  }

  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
    padding: 10px 12px;
  }

  .nav {
    max-width: 100%;
    width: 100%;
  }

  .page {
    padding: 14px 8px 36px;
  }

  .page-title {
    font-size: 20px;
  }

  .table-wrap {
    border-radius: 6px;
  }

  .scorecard-table {
    display: none;
  }

  .scorecard-cards {
    display: grid;
    gap: 8px;
  }

  th,
  td {
    padding: 7px 8px;
  }

  .overview-wrap {
    max-height: none;
  }

  .day-table {
    display: none;
  }

  .fixture-card-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
    min-width: 0;
  }

  .fixture-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 7px;
    max-width: 100%;
    overflow: hidden;
    padding: 9px;
    width: 100%;
  }

  .fixture-card.is-complete {
    border-left: 3px solid var(--accent);
  }

  .fixture-card-head {
    align-items: flex-start;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
  }

  .fixture-card-head > div {
    min-width: 0;
  }

  .fixture-card-teams {
    align-items: center;
    display: grid;
    font-size: 15px;
    font-weight: 800;
    gap: 5px;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    min-width: 0;
  }

  .fixture-card-teams > span:not(.muted) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fixture-card-result {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-start;
    white-space: nowrap;
  }

  .mobile-tip-grid {
    display: grid;
    gap: 5px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 9px;
  }

  .mobile-tip {
    align-items: center;
    background: #f7f9f5;
    border: 1px solid var(--line);
    border-radius: 5px;
    display: flex;
    gap: 6px;
    justify-content: space-between;
    min-width: 0;
    padding: 5px 6px;
  }

  .mobile-tip > span:last-child {
    flex: 0 0 auto;
  }

  .mobile-player {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .matchday-summary {
    align-items: flex-start;
    display: grid;
    gap: 7px;
    grid-template-columns: auto minmax(0, 1fr);
    justify-content: stretch;
  }

  .matchday-summary::before {
    grid-column: 1;
    grid-row: 1;
    padding-top: 2px;
  }

  .matchday-main {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    grid-column: 2;
    grid-row: 1;
  }

  .matchday-title {
    font-size: 16px;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .day-points {
    grid-column: 2;
    grid-row: 2;
    justify-content: flex-start;
    min-width: 0;
    width: 100%;
  }

  .day-points span {
    font-size: 11px;
    padding: 3px 6px;
  }

  .totals-table table {
    min-width: 0;
  }

  .totals-table tfoot tr {
    display: grid;
    gap: 5px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
  }

  .totals-table tfoot th {
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 6px 8px;
    text-align: left;
  }

  .totals-table tfoot th:first-child {
    grid-column: 1 / -1;
  }

  .group-overview {
    min-width: 760px;
  }

  .group-overview .tip-cell,
  .group-overview .tip-head {
    min-width: 118px;
  }

  .rank-select select {
    min-width: 150px;
  }
}

@media (max-width: 520px) {
  .mobile-tip-grid {
    grid-template-columns: 1fr;
  }

  .mobile-tip {
    justify-content: flex-start;
  }

  .mobile-player {
    flex: 0 1 auto;
  }

  .fixture-card-teams {
    font-size: 14px;
    grid-template-columns: 1fr;
  }

  .fixture-card-teams .muted {
    display: none;
  }

  .fixture-card-result {
    justify-content: flex-start;
  }
}
