:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --text: #121417;
  --muted: #626a73;
  --panel: #ffffff;
  --line: #dde2e7;
  --accent: #c3162f;
  --accent-dark: #8f1023;
  --gold: #d9a31f;
  --green: #13795b;
  --blue: #174ea6;
  --shadow: 0 20px 48px rgba(18, 20, 23, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 0 0, rgba(195, 22, 47, 0.08), transparent 34%),
    linear-gradient(135deg, rgba(18, 20, 23, 0.04), transparent 40%, rgba(23, 78, 166, 0.07)),
    var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav a,
.link-button {
  color: var(--muted);
  text-decoration: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.nav a:hover,
.link-button:hover {
  color: var(--text);
}

.page {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.flash {
  border: 1px solid rgba(19, 121, 91, 0.22);
  background: rgba(19, 121, 91, 0.08);
  color: var(--green);
  padding: 12px 14px;
  border-radius: 8px;
}

.login-shell {
  min-height: calc(100vh - 132px);
  display: grid;
  place-items: center;
}

.login-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(430px, 100%);
  padding: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
}

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

h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.02;
  margin-bottom: 18px;
}

h2 {
  font-size: 1.12rem;
  margin-bottom: 0;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 16px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

input:focus {
  outline: 3px solid rgba(195, 22, 47, 0.18);
  border-color: var(--accent);
}

button,
.primary-button {
  border: 0;
  border-radius: 6px;
  padding: 11px 14px;
  background: var(--text);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-weight: 800;
}

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

.primary-button {
  background: var(--accent);
}

.primary-button.inline {
  display: inline-block;
  margin-top: 8px;
}

.dashboard-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.dashboard-head h1 {
  margin: 0;
}

.score-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.score-rules span {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.9rem;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.admin-grid {
  grid-template-columns: minmax(360px, 0.85fr) minmax(520px, 1.15fr);
}

.panel {
  padding: 22px;
}

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

.settings-panel h2 {
  margin: 0;
}

.toggle-form {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mode-state {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef1f4;
  color: var(--muted);
  font-weight: 900;
}

.mode-state.is-on {
  background: rgba(19, 121, 91, 0.12);
  color: var(--green);
}

.panel.narrow {
  width: min(620px, 100%);
  margin: 8vh auto;
}

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

.section-title span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.match-list,
.admin-list {
  display: grid;
  gap: 14px;
}

.match-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  position: relative;
  overflow: hidden;
}

.match-card.bonus-match {
  border-color: rgba(195, 22, 47, 0.32);
  box-shadow: inset 4px 0 0 var(--accent);
}

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

.match-meta {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.teams {
  font-size: 1.25rem;
  font-weight: 800;
}

.teams strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.teams span {
  color: var(--muted);
  font-weight: 900;
}

.team-badge {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 1.2rem;
  line-height: 1;
  overflow: hidden;
}

.flag-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.bonus-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: rgba(195, 22, 47, 0.09);
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 900;
}

.venue,
.empty-state,
.locked {
  color: var(--muted);
}

.tipline span {
  color: var(--green);
  font-weight: 800;
}

.tip-form {
  display: grid;
  grid-template-columns: minmax(76px, 90px) minmax(76px, 90px) auto;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.leaderboard {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.leaderboard li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0 0 10px;
}

.leaderboard strong {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
}

.leaderboard li.visual-override span {
  color: var(--accent-dark);
  font-weight: 900;
}

.leaderboard li.visual-override strong {
  background: var(--text);
  color: #fff;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.result-inputs {
  display: grid;
  grid-template-columns: 64px 64px auto;
  gap: 8px;
  align-items: end;
}

.result-match,
.unlock-meta {
  display: grid;
  gap: 4px;
}

.result-match strong {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.versus {
  color: var(--muted);
  font-weight: 900;
}

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

.result-row .team-badge {
  width: 28px;
  height: 28px;
  font-size: 1rem;
}

.admin-archive {
  margin-top: 20px;
}

.knockout-panel {
  margin-top: 20px;
}

.round-list,
.unlock-list {
  display: grid;
  gap: 14px;
}

.round-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.round-group.locked {
  background: #f7f8f9;
}

.round-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.round-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.round-head > span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.unlock-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(150px, 1fr) minmax(150px, 1fr) 120px;
  gap: 10px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

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

.archive-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 70px 90px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.archive-row div {
  display: grid;
  gap: 4px;
}

.archive-row span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

@media (max-width: 820px) {
  body {
    background:
      linear-gradient(180deg, rgba(195, 22, 47, 0.08), transparent 220px),
      var(--bg);
  }

  .topbar,
  .dashboard-head,
  .match-meta,
  .teams,
  .tipline,
  .result,
  .locked {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    gap: 12px;
    min-height: auto;
    padding: 14px 16px;
  }

  .page {
    width: min(100% - 20px, 640px);
    padding: 20px 0 32px;
  }

  .dashboard-head {
    gap: 16px;
    margin-bottom: 18px;
  }

  .layout-grid,
  .admin-grid,
  .form-grid,
  .result-row,
  .unlock-row,
  .archive-row {
    grid-template-columns: 1fr;
  }

  .settings-panel,
  .toggle-form {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel {
    padding: 16px;
  }

  .match-card {
    padding: 14px;
  }

  .teams {
    gap: 4px;
    font-size: 1.08rem;
  }

  .tip-form {
    grid-template-columns: 1fr 1fr;
  }

  .tip-form button {
    grid-column: 1 / -1;
  }

  .leaderboard-panel {
    order: -1;
  }

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

  .leaderboard li {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 8px;
  }

  .score-rules {
    justify-content: flex-start;
  }

  .nav {
    flex-wrap: wrap;
  }

  .login-panel {
    padding: 22px;
  }
}

@media (max-width: 420px) {
  .topbar {
    align-items: stretch;
  }

  .nav {
    gap: 12px;
    justify-content: space-between;
  }

  .score-rules span {
    font-size: 0.82rem;
  }

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

  .leaderboard strong {
    width: 32px;
    height: 32px;
  }
}
