:root {
  color-scheme: light;
  --app-width: 100vw;
  --controls-width: 100%;
  --controls-height: 0px;
  --page: #f4f2ec;
  --surface: #fffdfa;
  --surface-strong: #ffffff;
  --ink: #20221f;
  --muted: #6e736a;
  --line: #dedbd2;
  --green: #0f7b4f;
  --green-soft: #dcefe5;
  --red: #b73a2f;
  --gold: #c58a1d;
  --blue: #255e9e;
  --shadow: 0 16px 38px rgba(32, 34, 31, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 123, 79, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(197, 138, 29, 0.08), transparent 280px),
    var(--page);
  background-size: 56px 56px, auto, auto;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(32, 34, 31, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--surface) 0 24%, transparent 25%),
    conic-gradient(from 20deg, var(--green), var(--blue), var(--red), var(--gold), var(--green));
  border: 2px solid var(--surface-strong);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 8px;
  min-width: min(420px, 50vw);
}

.summary div {
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.78);
}

.summary strong,
.summary span {
  display: block;
}

.summary strong {
  font-size: 1.35rem;
  line-height: 1.1;
}

.summary span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

main {
  width: min(1160px, calc(100% - 32px));
  max-width: 100vw;
  overflow-x: hidden;
  margin: 0 auto;
  padding: calc(var(--controls-height) + 20px) 0 48px;
}

.controls {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 5;
  width: min(100%, var(--controls-width));
  max-width: min(100%, var(--controls-width));
  min-width: 0;
  overflow: hidden;
  contain: inline-size;
  transform: translateX(-50%);
  padding: 14px 0 16px;
  background: rgba(244, 242, 236, 0.92);
  backdrop-filter: blur(14px);
}

button {
  font: inherit;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  contain: inline-size;
}

.control-row > * {
  min-width: 0;
  max-width: 100%;
}

.tabs,
.segmented {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  contain: inline-size;
}

.tabs {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.tabs button,
.segmented button {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.tabs button.active,
.segmented button.active {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.team-filter {
  display: grid;
  gap: 7px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  contain: inline-size;
  margin-top: 10px;
  overflow: hidden;
  max-height: 520px;
  opacity: 1;
  transform: translateY(0);
  transition: max-height 180ms ease, opacity 160ms ease, margin-top 180ms ease, transform 180ms ease;
}

.team-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  contain: inline-size;
  overflow: visible;
}

.team-strip.collapsed {
  position: relative;
  max-height: 120px;
  overflow: hidden;
}

.team-strip.collapsed::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 34px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(244, 242, 236, 0), rgba(244, 242, 236, 0.96));
  content: "";
}

.team-toggle {
  justify-self: start;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--green);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.team-chip {
  display: inline-flex;
  align-items: center;
  height: 36px;
  flex: 0 1 188px;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  overflow: hidden;
}

.team-chip.active {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.team-chip-select {
  display: inline-grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 0 8px 0 6px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.team-chip-flag {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  overflow: hidden;
  border-radius: 50%;
  background: #ece9df;
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 800;
}

.team-chip.active .team-chip-flag {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.team-chip-flag img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.team-chip-label {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 750;
}

.team-chip-goals {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f2ead9;
  color: #6f531a;
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.team-chip.active .team-chip-goals {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.team-calendar-button,
.icon-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.team-calendar-button {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-width: 0 0 0 1px;
  border-color: rgba(32, 34, 31, 0.12);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.42);
}

.team-chip.active .team-calendar-button {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.icon-button {
  width: 28px;
  height: 28px;
}

.team-calendar-button svg,
.icon-button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.team-calendar-button:hover,
.icon-button:hover {
  border-color: var(--green);
  color: var(--green);
}

.schedule {
  display: grid;
  gap: 18px;
}

.date-section {
  display: grid;
  gap: 8px;
}

.date-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 0 2px;
}

.date-heading h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0;
}

.date-heading span {
  color: var(--muted);
  font-size: 0.9rem;
}

.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.match-card {
  min-height: 146px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: 0 8px 20px rgba(32, 34, 31, 0.07);
  scroll-margin-block: 150px;
}

.match-card.latest-play {
  border-color: rgba(15, 123, 79, 0.62);
  box-shadow: 0 0 0 3px rgba(15, 123, 79, 0.16), 0 8px 20px rgba(32, 34, 31, 0.07);
}

.match-meta,
.match-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.match-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.match-number,
.competition-label,
.match-footer {
  color: var(--muted);
  font-size: 0.76rem;
}

.match-number {
  margin-right: 8px;
  color: var(--ink);
  font-weight: 700;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-chip.scheduled {
  background: #f4ead1;
  color: #81570d;
}

.teams {
  display: grid;
  gap: 5px;
  margin: 8px 0 8px;
}

.team {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(30px, auto);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 5px 7px;
  border-radius: 6px;
  background: #f8f7f2;
}

.team.winner {
  outline: 2px solid rgba(15, 123, 79, 0.28);
  background: #f1f8f4;
}

.team-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.flag-slot {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(32, 34, 31, 0.12);
  border-radius: 50%;
  background: #ece9df;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
}

.flag-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.team-name,
.team-code {
  display: block;
  min-width: 0;
}

.team-name {
  overflow: hidden;
  font-size: 0.9rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-code {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.score {
  justify-self: end;
  min-width: 24px;
  font-size: 1.18rem;
  font-weight: 900;
  line-height: 1;
  text-align: right;
}

.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 10px;
}

.divider span {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 14px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
}

.venue {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

@media (max-width: 820px) {
  .topbar,
  .control-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .summary {
    min-width: 0;
    width: 100%;
  }

  .control-row {
    display: grid;
    width: 100%;
    min-width: 0;
  }

  .tabs {
    display: grid;
    grid-auto-columns: max-content;
    grid-auto-flow: column;
    order: 2;
    min-width: 0;
    overflow-x: auto;
  }

  .segmented {
    order: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .segmented button {
    width: 100%;
    min-width: 0;
    padding: 0 6px;
  }
}

.is-mobile-ui .topbar,
.is-mobile-ui .control-row {
  grid-template-columns: 1fr;
}

.is-mobile-ui .topbar {
  display: grid;
}

.is-mobile-ui .summary {
  min-width: 0;
  width: 100%;
}

.is-mobile-ui .control-row {
  display: grid;
  width: 100%;
  min-width: 0;
}

.is-mobile-ui .tabs {
  display: grid;
  grid-auto-columns: max-content;
  grid-auto-flow: column;
  order: 2;
  min-width: 0;
  overflow-x: auto;
}

.is-mobile-ui .segmented {
  order: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
}

.is-mobile-ui .segmented button {
  width: 100%;
  min-width: 0;
  padding: 0 6px;
}

@media (max-width: 460px) {
  main {
    width: 100%;
    padding-right: 10px;
    padding-left: 10px;
    padding-bottom: 28px;
  }

  .controls {
    width: min(100%, calc(100vw - 20px));
    max-width: min(100%, calc(100vw - 20px));
  }

  .control-row,
  .team-filter,
  .team-strip,
  .tabs,
  .segmented {
    width: 100%;
    max-width: 100%;
  }

  .topbar {
    padding: 18px 10px;
  }

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

  .summary div {
    min-height: 58px;
    padding: 9px 8px;
  }

  .match-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    max-width: 100%;
  }

  .tabs button {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .team-filter {
    gap: 6px;
    min-width: 0;
  }

  .team-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: min(46vh, 360px);
    overflow-y: auto;
    padding-right: 1px;
  }

  .team-strip.collapsed {
    max-height: 0;
    padding: 0;
    overflow: hidden;
  }

  .team-strip.collapsed::after {
    display: none;
  }

  .team-toggle {
    position: sticky;
    top: 0;
    z-index: 2;
    justify-self: stretch;
    min-height: 42px;
    background: var(--green);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(32, 34, 31, 0.12);
  }

  .team-chip {
    width: 100%;
    min-width: 0;
    height: 38px;
  }

  .team-chip-select {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 5px;
    height: 36px;
    padding: 0 5px;
  }

  .team-chip-flag {
    width: 22px;
    height: 22px;
  }

  .team-chip-label {
    font-size: 0.74rem;
  }

  .team-chip-goals {
    min-width: 22px;
    height: 20px;
    padding: 0 5px;
    font-size: 0;
  }

  .team-chip-goals::after {
    font-size: 0.68rem;
    content: attr(data-short-label);
  }

  .team-calendar-button {
    width: 28px;
    height: 36px;
  }

  .team-calendar-button svg {
    width: 14px;
    height: 14px;
  }

  .match-card {
    min-height: 142px;
    padding: 10px;
  }

  .team-name {
    font-size: 0.88rem;
  }
}

.is-phone-ui main {
  width: min(var(--app-width), 100%);
  padding-right: 10px;
  padding-left: 10px;
  padding-bottom: 28px;
}

.is-phone-ui .controls {
  width: min(100%, calc(var(--app-width) - 20px));
  max-width: min(100%, calc(var(--app-width) - 20px));
}

.is-phone-ui .control-row,
.is-phone-ui .team-filter,
.is-phone-ui .team-strip,
.is-phone-ui .tabs,
.is-phone-ui .segmented {
  width: 100%;
  max-width: 100%;
}

.is-phone-ui .topbar {
  padding: 18px 10px;
}

.is-phone-ui .summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.is-phone-ui .summary div {
  min-height: 58px;
  padding: 9px 8px;
}

.is-phone-ui .match-grid {
  grid-template-columns: 1fr;
}

.is-phone-ui .tabs {
  max-width: 100%;
}

.is-phone-ui .tabs button {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.is-phone-ui .team-filter {
  gap: 6px;
  min-width: 0;
}

.is-phone-ui .team-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: min(46vh, 360px);
  overflow-y: auto;
  padding-right: 1px;
}

.is-phone-ui .team-strip.collapsed {
  max-height: 0;
  padding: 0;
  overflow: hidden;
}

.is-phone-ui .team-strip.collapsed::after {
  display: none;
}

.is-phone-ui .team-toggle {
  position: sticky;
  top: 0;
  z-index: 2;
  justify-self: stretch;
  min-height: 42px;
  background: var(--green);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(32, 34, 31, 0.12);
}

.is-phone-ui .team-chip {
  width: 100%;
  min-width: 0;
  height: 38px;
}

.is-phone-ui .team-chip-select {
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 5px;
  height: 36px;
  padding: 0 5px;
}

.is-phone-ui .team-chip-flag {
  width: 22px;
  height: 22px;
}

.is-phone-ui .team-chip-label {
  font-size: 0.74rem;
}

.is-phone-ui .team-chip-goals {
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  font-size: 0;
}

.is-phone-ui .team-chip-goals::after {
  font-size: 0.68rem;
  content: attr(data-short-label);
}

.is-phone-ui .team-calendar-button {
  width: 28px;
  height: 36px;
}

.is-phone-ui .team-calendar-button svg {
  width: 14px;
  height: 14px;
}

.is-phone-ui .match-card {
  min-height: 142px;
  padding: 10px;
}

.is-phone-ui .team-name {
  font-size: 0.88rem;
}
