:root {
  color-scheme: light;
  --bg: #eef5ef;
  --surface: #ffffff;
  --surface-2: #e3efe7;
  --text: #102018;
  --muted: #607268;
  --line: rgba(16, 32, 24, 0.14);
  --green: #0b7a4b;
  --green-2: #0fb56b;
  --gold: #e0b14a;
  --red: #d84a4a;
  --shadow: 0 16px 40px rgba(19, 48, 34, 0.14);
}

:root.dark {
  color-scheme: dark;
  --bg: #071d17;
  --surface: #10271f;
  --surface-2: #15382c;
  --text: #f3fbf6;
  --muted: #a5b8af;
  --line: rgba(244, 251, 247, 0.15);
  --green: #27c97f;
  --green-2: #67e6a6;
  --gold: #f0c766;
  --red: #ff7878;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, transparent 49.5%, rgba(255, 255, 255, 0.12) 50%, transparent 50.5%),
    radial-gradient(circle at top, rgba(15, 181, 107, 0.24), transparent 35rem),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -16px -14px 12px;
  padding: max(16px, env(safe-area-inset-top)) 14px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1;
}

h2 {
  font-size: 21px;
  margin-bottom: 12px;
}

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

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

.top-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button,
.chip {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  box-shadow: none;
}

.icon-button {
  width: 44px;
  font-size: 20px;
}

.primary-button {
  padding: 0 16px;
  color: #04140d;
  background: var(--green-2);
  border-color: transparent;
  font-weight: 800;
}

.secondary-button,
.danger-button,
.chip {
  padding: 0 14px;
  font-weight: 750;
}

.danger-button {
  color: var(--red);
}

.chip.is-active {
  background: var(--green);
  color: #fff;
}

.view-stack {
  display: grid;
  gap: 14px;
}

.section,
.hero-panel,
.form-panel {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  gap: 14px;
  color: #fff;
  background:
    linear-gradient(rgba(4, 30, 19, 0.42), rgba(4, 30, 19, 0.62)),
    repeating-linear-gradient(90deg, #0d6b42 0 34px, #0b5c39 34px 68px);
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-tile {
  min-height: 86px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.stat-value {
  display: block;
  font-size: 26px;
  font-weight: 900;
}

.stat-label {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.match-list,
.date-group,
.history-list,
.fact-list {
  display: grid;
  gap: 10px;
}

.match-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
}

.match-card.live {
  border-left-color: var(--red);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 34%, transparent);
}

.match-meta,
.mini-row,
.setting-row,
.table-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 800;
}

.pill.live {
  color: #fff;
  background: var(--red);
}

.teams {
  display: grid;
  gap: 8px;
}

.team-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 17px;
}

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

.venue,
.muted,
.last-updated {
  color: var(--muted);
}

.venue {
  margin-bottom: 0;
  font-size: 13px;
}

.source-banner {
  display: inline-flex;
  max-width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 13px;
  font-weight: 750;
}

.source-banner.live {
  background: rgba(15, 181, 107, 0.34);
}

.source-banner.manual,
.source-banner.sample {
  background: rgba(224, 177, 74, 0.34);
}

.source-banner.offline {
  background: rgba(216, 74, 74, 0.34);
}

.empty-state {
  padding: 16px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
}

.tabs-inline {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

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

table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

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

th:first-child,
td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.bracket {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.round {
  display: grid;
  align-content: start;
  gap: 10px;
}

.round-title {
  margin-bottom: 0;
  color: var(--green);
  font-weight: 900;
}

.bracket-match {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.winner {
  color: var(--green);
  font-weight: 900;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea {
  resize: vertical;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(8, minmax(62px, 1fr));
  width: min(100%, 760px);
  transform: translateX(-50%);
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  gap: 6px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
  overflow-x: auto;
}

.tab {
  min-height: 48px;
  padding: 6px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 850;
}

.tab.is-active {
  color: #04140d;
  background: var(--green-2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  z-index: 8;
  width: min(calc(100% - 28px), 520px);
  padding: 12px 14px;
  color: #fff;
  background: #17251f;
  border-radius: 8px;
  transform: translateX(-50%);
  box-shadow: var(--shadow);
}

@media (min-width: 720px) {
  .app-shell {
    padding-inline: 22px;
  }

  .topbar {
    margin-inline: -22px;
    padding-inline: 22px;
  }

  .hero-grid,
  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}
