:root {
  color-scheme: light;
  --bg: #eef6fb;
  --ink: #17211b;
  --muted: #607182;
  --line: #d7e3eb;
  --panel: #ffffff;
  --accent: #2f78c4;
  --accent-2: #0f8f79;
  --accent-3: #e85d3f;
  --soft: #e8f2ff;
  --gold: #fff4cf;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(47, 120, 196, 0.16), rgba(238, 246, 251, 0) 290px),
    var(--bg);
  color: var(--ink);
}

button, input, select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 0;
  align-items: center;
  padding: 10px clamp(16px, 4vw, 44px);
  background: rgba(238, 246, 251, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brandHeader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  text-align: center;
}

.worldCupBall {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex: 0 0 auto;
}

.worldCupLogo {
  width: 28px;
  height: 46px;
  object-fit: contain;
  flex: 0 0 auto;
}

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

h1 {
  color: #2f78c4;
  font-size: clamp(24px, 3.4vw, 40px);
  font-weight: 850;
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

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

button, .importBtn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
}

button:hover, .importBtn:hover {
  border-color: var(--accent);
}

.importBtn input {
  display: none;
}

main {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto 48px;
}

.summaryGrid {
  display: grid;
  grid-template-columns: minmax(340px, 1.35fr) minmax(300px, 0.85fr);
  gap: 16px;
  margin: 0 0 16px;
  padding: 12px 0;
  position: sticky;
  top: 67px;
  z-index: 10;
  background:
    linear-gradient(180deg, rgba(238, 246, 251, 0.98), rgba(238, 246, 251, 0.96)),
    var(--bg);
  box-shadow: 0 12px 22px rgba(42, 77, 105, 0.08);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 16px 38px rgba(42, 77, 105, 0.1);
}

.standingsPanel {
  background: linear-gradient(135deg, #ffffff 0%, #f4f9ff 62%, #eaf5ff 100%);
}

.rulesPanel {
  background: linear-gradient(135deg, #ffffff 0%, #f6fffb 100%);
}

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

.matchesHeader {
  flex-direction: row;
  align-items: center;
}

.matchesHeader h2 {
  white-space: nowrap;
}

.matchesHeader select {
  width: 150px;
  flex: 0 0 150px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 800;
  white-space: nowrap;
}

.standingsActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.editScoresBtn {
  min-height: 30px;
  padding: 5px 10px;
  background: #ffffff;
  color: var(--accent);
  font-size: 12px;
}

.editScoresBtn.active {
  border-color: var(--accent-2);
  background: #dcfce7;
  color: #15803d;
}

.passwordOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 33, 27, 0.32);
  backdrop-filter: blur(6px);
}

.passwordDialog {
  display: grid;
  gap: 18px;
  width: min(420px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(23, 33, 27, 0.22);
}

.passwordRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.passwordToggle,
.secondaryBtn {
  background: #f7fbff;
  color: var(--accent);
}

.passwordActions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.standings {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style-position: inside;
}

.standings li {
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 4px 0 var(--accent);
}

.standings li.rank1 {
  background: var(--gold);
  border-color: #f2cf6b;
  box-shadow: inset 0 4px 0 #d99a18;
}

.standings li.rank2 {
  box-shadow: inset 0 4px 0 var(--accent-2);
}

.standings li.rank3 {
  box-shadow: inset 0 4px 0 var(--accent-3);
}

.standings strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.standings span {
  color: var(--muted);
}

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

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

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

.ruleItem {
  display: grid;
  gap: 6px;
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.ruleItem span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ruleItem strong {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

input:disabled {
  background: #f3f6f1;
  color: var(--ink);
  cursor: not-allowed;
  opacity: 1;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

input[type="number"] {
  appearance: textfield;
}

input:focus, select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.checkLine {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.checkLine input {
  width: 18px;
  min-height: 18px;
}

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

.groupSection {
  display: grid;
  grid-template-columns: minmax(220px, 0.28fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.groupTitle {
  margin: 0 0 10px;
  font-size: 18px;
}

.groupSidebar {
  position: sticky;
  top: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: 0 10px 24px rgba(42, 77, 105, 0.08);
}

.groupTabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.groupTab {
  min-height: 30px;
  padding: 5px 6px;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

.groupTab.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--soft), #e7fff8);
  color: var(--accent);
}

.groupStandings {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.groupStandings th,
.groupStandings td {
  padding: 7px 5px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.groupStandings th:nth-child(2),
.groupStandings td:nth-child(2) {
  text-align: left;
}

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

.groupStandings th[colspan="2"] {
  text-align: center;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.groupStandings tbody td:nth-child(4) {
  border-left: 1px solid var(--line);
}

.groupStandings tbody td:nth-child(5) {
  border-right: 1px solid var(--line);
}

.groupStandings tbody tr:last-child td {
  border-bottom: 0;
}

.groupMatches {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.matchCard {
  display: grid;
  grid-template-columns: minmax(210px, 0.75fr) minmax(180px, 0.45fr) minmax(420px, 1.4fr);
  gap: 12px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(42, 77, 105, 0.06);
}

.matchInfo {
  display: grid;
  gap: 8px;
  align-content: center;
}

.matchMeta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 850;
}

.versus {
  color: var(--accent-3);
  font-size: 13px;
}

.scoreGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.scoreGrid input {
  text-align: center;
  font-weight: 850;
}

.predGrid {
  display: grid;
  grid-template-columns: repeat(5, minmax(86px, 1fr));
  gap: 8px;
}

.predBox {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfdff;
}

.predBox header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.predBox .points {
  min-width: 28px;
  padding: 2px 6px;
  border-radius: 999px;
  text-align: center;
  font-weight: 900;
}

.pointsFull {
  background: #dcfce7;
  color: #15803d;
}

.pointsPartial {
  background: #fef3c7;
  color: #a16207;
}

.pointsZero {
  background: #fee2e2;
  color: #b91c1c;
}

@media (max-width: 980px) {
  .panelHeader {
    align-items: flex-start;
    flex-direction: column;
  }

  .matchesHeader {
    align-items: center;
    flex-direction: row;
  }

  .summaryGrid {
    grid-template-columns: 1fr;
    position: static;
  }

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

  .groupSidebar {
    position: static;
  }

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

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

@media (max-width: 640px) {
  main {
    width: min(100% - 20px, 1440px);
    margin-top: 0;
  }

  .panel {
    padding: 14px;
  }

  .matchesHeader {
    align-items: flex-start;
    flex-direction: column;
  }

  .matchesHeader h2 {
    white-space: normal;
  }

  .matchesHeader select {
    width: 150px;
    flex: 0 0 auto;
  }

  .brandHeader {
    gap: 10px;
  }

  .worldCupLogo {
    width: 24px;
    height: 40px;
  }

  .worldCupBall {
    width: 38px;
    height: 38px;
  }

  .standings, .rulesGrid, .namesGrid, .predGrid {
    grid-template-columns: 1fr;
  }
}
