:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #687386;
  --line: #d7dfeb;
  --accent: #1f64ad;
  --accent-2: #bd3850;
  --match: #f7faff;
  --match-head: #ebf3fc;
  --soft: #eaf3fc;
  --winner: #dcefe8;
  --winner-line: #64a894;
  --warn: #fff4d6;
  --shadow: 0 10px 28px rgba(26, 52, 83, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 4vw, 40px);
  background: rgba(244, 247, 251, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 36px);
}

main {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 32px) 42px;
}

.actions,
.account-actions,
.tools-list,
.tabs,
.score,
.match-flags,
.qualified-row,
.view-toolbar,
.group-jump {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

button,
.import,
.tools-menu summary {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

summary {
  list-style: none;
}

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

button[hidden],
[hidden] {
  display: none !important;
}

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

button.ghost {
  background: transparent;
  color: var(--accent);
}

.account-status {
  max-width: 220px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  justify-content: flex-end;
}

.account-actions {
  justify-content: flex-end;
}

.tools-menu {
  position: relative;
}

.tools-menu summary {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.tools-menu summary::after {
  content: "▾";
  margin-left: 8px;
  font-size: 11px;
}

.tools-menu[open] summary::after {
  content: "▴";
}

.tools-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: min(290px, calc(100vw - 28px));
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(26, 52, 83, 0.16);
}

.tools-list button,
.tools-list .import {
  display: inline-flex;
  align-items: center;
  flex: 1 1 100%;
  justify-content: center;
  text-align: center;
}

.import input {
  display: none;
}

.app-message {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.app-message[data-kind="error"] {
  background: #fdecec;
  border-color: #f1b5b5;
  color: #7c2020;
}

.app-message[data-kind="share"] {
  background: #eef6ff;
  border-color: #b9d8f7;
}

.summary-panel {
  margin-bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.summary-panel summary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 12px 16px;
  cursor: pointer;
}

.summary-panel summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-panel summary strong {
  color: var(--ink);
  font-size: 15px;
  text-align: right;
}

.summary-panel summary::after {
  content: "Afficher";
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.summary-panel[open] summary::after {
  content: "Masquer";
}

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

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

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.tabs {
  position: sticky;
  top: 78px;
  z-index: 10;
  margin: 0;
  padding: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.tabs,
.group-jump,
.round-jump {
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar,
.group-jump::-webkit-scrollbar,
.round-jump::-webkit-scrollbar {
  display: none;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.group-jump,
.round-jump {
  position: sticky;
  top: 137px;
  z-index: 9;
  margin: 0 0 18px;
  padding: 8px;
  background: rgba(244, 247, 251, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.round-jump {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.group-jump a,
.round-jump a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--accent);
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.group-jump a:hover,
.group-jump a:focus,
.round-jump a:hover,
.round-jump a:focus {
  border-color: var(--accent);
  outline: none;
}

.round-jump::-webkit-scrollbar {
  display: none;
}

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

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

.group-panel {
  scroll-margin-top: 190px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #f8faff;
  border-bottom: 1px solid var(--line);
}

.panel-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

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

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

tr.promoted {
  background: var(--soft);
}

tr.third-ok {
  background: #eef6ff;
}

.group-matches,
.match-list,
.round-grid {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.match-card {
  border: 1px solid #ccd9e8;
  border-radius: 8px;
  background: var(--match);
  box-shadow: 0 4px 14px rgba(26, 52, 83, 0.05);
  overflow: hidden;
}

.match-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--match-head);
  border-bottom: 1px solid #d2deed;
  font-size: 13px;
}

.match-body {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff 0%, var(--match) 100%);
}

.team {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  border-radius: 7px;
  padding: 6px 8px;
  font-weight: 800;
  line-height: 1.25;
}

.team.away {
  flex-direction: row-reverse;
  text-align: right;
}

.team.winner {
  background: var(--winner);
  box-shadow: inset 0 0 0 1px var(--winner-line);
}

.team.winner::after {
  content: "✓";
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--winner-line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.team.away.winner::after {
  right: auto;
  left: -7px;
}

.flag {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
}

.placeholder {
  color: var(--muted);
  font-weight: 700;
}

.score {
  flex-wrap: nowrap;
}

.score.has-winner strong {
  color: var(--accent);
}

.score-input {
  width: 48px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.score-input.winner-score {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.match-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.match-foot label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.match-foot select {
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px;
  background: #fff;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.badge.prediction {
  background: var(--warn);
  color: #8a5a00;
}

.thirds-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(320px, 0.7fr);
  gap: 14px;
}

.qualified-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
}

.qualified-row:last-child {
  border-bottom: 0;
}

.list-panel {
  padding: 14px 16px;
}

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

.round {
  margin-bottom: 18px;
  scroll-margin-top: 190px;
}

.round h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.round-grid {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  padding: 0;
}

.filters {
  margin-bottom: 14px;
}

.filters input,
.filters select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
}

.notice {
  padding: 14px 16px;
  background: var(--warn);
  border: 1px solid #edd184;
  border-radius: 8px;
  color: #674600;
  font-weight: 700;
}

.auth-dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.auth-dialog::backdrop {
  background: rgba(23, 32, 27, 0.48);
}

.auth-card {
  margin: 0;
  background: var(--panel);
}

.auth-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.otp-code-step {
  display: grid;
  gap: 12px;
}

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

.auth-body input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.loading-gif {
  display: none;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -3px;
}

button.loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.loading .loading-gif {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .actions,
  .account-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .tools-menu {
    width: 100%;
  }

  .tools-menu summary {
    width: max-content;
  }

  .tools-list {
    position: static;
    width: 100%;
    margin-top: 8px;
    box-shadow: none;
  }

  .tabs {
    top: 0;
  }

  .group-jump,
  .round-jump {
    top: 56px;
  }

  .summary,
  .thirds-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  main {
    padding-top: 14px;
  }

  .summary-panel summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .summary-panel summary strong {
    text-align: left;
  }

  .summary-panel summary::after {
    position: absolute;
    right: 16px;
  }

  .tabs,
  .group-jump,
  .round-jump {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .tab,
  .group-jump a,
  .round-jump a {
    flex: 0 0 auto;
  }

  th,
  td {
    padding: 8px 6px;
    font-size: 13px;
  }

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

  .team.away {
    flex-direction: row;
    text-align: left;
  }

  .team.away.winner::after {
    right: -7px;
    left: auto;
  }

  .score {
    justify-content: center;
  }
}
