:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --surface: #ffffff;
  --surface-soft: #f9f6ef;
  --ink: #15211d;
  --muted: #66706b;
  --line: #ded8ca;
  --accent: #0e7c66;
  --accent-dark: #095846;
  --gold: #d7a928;
  --danger: #b6432f;
  --shadow: 0 18px 50px rgba(33, 43, 37, 0.12);
  --match-tile-width: 112px;
  --match-tile-height: 44px;
  --match-flag-size: 44px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(14, 124, 102, 0.12), transparent 40%),
    linear-gradient(315deg, rgba(215, 169, 40, 0.16), transparent 38%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.28), transparent 58%);
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  background: var(--accent-dark);
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #8f2f22;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 28px;
}

.brand-panel,
.login-form,
.panel,
.summary-grid article {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(222, 216, 202, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-panel {
  min-height: 500px;
  padding: clamp(32px, 7vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(rgba(21, 33, 29, 0.18), rgba(21, 33, 29, 0.56)),
    url("https://images.unsplash.com/photo-1518091043644-c1d4457512c6?auto=format&fit=crop&w=1400&q=80") center / cover;
  color: #fff;
}

.brand-mark {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  font-size: 25px;
  font-weight: 900;
  margin-bottom: 40px;
}

.eyebrow {
  margin: 0 0 8px;
  color: inherit;
  opacity: 0.74;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 850;
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(36px, 6vw, 68px);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: 26px;
}

.intro {
  max-width: 560px;
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.55;
}

.login-form {
  padding: 30px;
  display: grid;
  gap: 18px;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.auth-mode {
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.auth-mode:hover,
.auth-mode.active {
  color: #fff;
  background: var(--ink);
}

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

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  outline: 3px solid rgba(14, 124, 102, 0.18);
  border-color: var(--accent);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 52px);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  font-weight: 800;
}

.secondary-button,
.tab {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.secondary-button:hover,
.tab:hover {
  color: #fff;
  border-color: var(--accent-dark);
}

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

.tab.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 12px 0 18px;
}

.summary-grid article {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 22px 18px 16px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  box-shadow: none;
  text-align: center;
  border: 0;
}

.summary-grid article::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 14px;
  opacity: 1;
  border-radius: 8px 8px 0 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
}

.summary-grid article:nth-child(1)::before {
  background-image: linear-gradient(90deg, #d80621 0 28%, #fff 28% 72%, #d80621 72%);
}

.summary-grid article:nth-child(2)::before {
  background-image: linear-gradient(90deg, #006847 0 33%, #fff 33% 66%, #ce1126 66%);
}

.summary-grid article:nth-child(3)::before {
  background-image: repeating-linear-gradient(90deg, #b22234 0 28px, #fff 28px 56px);
}

.summary-grid span,
.match-meta,
.team-label,
.ranking-meta,
.mode-note,
.empty-state {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.summary-grid strong {
  position: relative;
  z-index: 1;
  font-size: 36px;
}

.panel {
  padding: 22px;
}

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

.admin-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-actions input {
  width: min(220px, 46vw);
}

.fixtures-list {
  display: grid;
  gap: 12px;
}

.mode-note,
.empty-state {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  line-height: 1.45;
}

.fixture-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(220px, 1fr) auto minmax(220px, 1fr) var(--match-tile-width) auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.fixture-row.compact {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.fixture-row.locked {
  opacity: 0.72;
}

.team {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 850;
}

.team-home {
  justify-content: flex-end;
  text-align: left;
}

.team-home .flag {
  order: 1;
}

.team-home .team-label {
  order: 2;
}

.team-away {
  justify-content: flex-start;
  text-align: left;
}

.flag {
  width: var(--match-flag-size);
  height: var(--match-flag-size);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  border: 0;
  font-size: 31px;
  line-height: 1;
}

.score-inputs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: var(--match-tile-width);
  height: var(--match-tile-height);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.score-zone {
  display: grid;
  gap: 6px;
  justify-items: center;
  align-self: center;
}

.score-inputs input {
  width: 44px;
  height: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  text-align: center;
  font-weight: 850;
}

.score-inputs span {
  width: 24px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 850;
}

.result-display {
  width: var(--match-tile-width);
  min-width: var(--match-tile-width);
  min-height: var(--match-tile-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 850;
}

.advancer-control {
  min-height: var(--match-tile-height);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.advancer-control select {
  min-height: var(--match-tile-height);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0 10px;
}

.points-pill {
  min-width: 70px;
  justify-self: end;
  border-radius: 999px;
  padding: 7px 10px;
  color: #fff;
  background: var(--accent);
  text-align: center;
  font-size: 13px;
  font-weight: 850;
}

.points-pill.pending {
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
}

.ranking-list {
  display: grid;
  gap: 10px;
}

.accounts-list {
  display: grid;
  gap: 10px;
}

.account-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ranking-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ranking-position {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--ink);
  font-weight: 900;
}

.ranking-points {
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 900;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.rules-grid article {
  min-height: 116px;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
}

.rules-grid strong {
  order: 2;
  font-size: 42px;
  color: var(--accent-dark);
}

.rules-grid span {
  order: 1;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.subsection-heading {
  margin: 26px 0 14px;
}

.subsection-heading.compact {
  margin: 14px 0 6px;
}

.subsection-heading h3,
.tables-layout h3 {
  margin: 0;
  font-size: 20px;
}

.bracket-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.round-column {
  width: min(260px, 74vw);
  flex: 0 0 min(260px, 74vw);
  display: grid;
  gap: 10px;
}

.round-column:nth-child(2) {
  margin-top: 34px;
}

.round-column:nth-child(3) {
  margin-top: 72px;
}

.round-column:nth-child(4) {
  margin-top: 112px;
}

.round-column h4,
.table-card h4 {
  margin: 0;
  font-size: 15px;
}

.tables-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}

.tables-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.table-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 13px;
}

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

th:first-child,
td:first-child {
  text-align: left;
}

tr.qualified td:first-child {
  color: var(--accent-dark);
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 20;
  border-radius: 8px;
  padding: 12px 16px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 750;
}

@media (max-width: 860px) {
  .login-view,
  .summary-grid,
  .rules-grid,
  .tables-layout {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    min-height: 360px;
  }

  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .account-row,
  .account-actions {
    grid-template-columns: 1fr;
    align-items: stretch;
    flex-direction: column;
  }

  .admin-actions input {
    width: 100%;
  }

  .fixture-row {
    grid-template-columns: 1fr;
  }

  .points-pill {
    justify-self: start;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .login-view {
    min-height: calc(100vh - 20px);
  }

  .brand-panel,
  .login-form,
  .panel {
    padding: 18px;
  }

  .user-area {
    width: 100%;
    justify-content: space-between;
  }
}
