:root {
  --ink: #121418;
  --muted: #5b6574;
  --line: #d9dee6;
  --panel: #ffffff;
  --paper: #f5f7fa;
  --red: #d93b45;
  --green: #12835f;
  --yellow: #f3c14b;
  --cyan: #0e8ea8;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.12);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.94);
}

button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.danger {
  color: #a51f2b;
}

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

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 2.5vw, 2.35rem);
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.45rem, 3vw, 2.5rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
  word-break: normal;
}

h3 {
  margin-bottom: 14px;
  font-size: 1.05rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(420px, auto);
  align-items: center;
  gap: 24px;
  padding: 16px clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.fifa-logo {
  width: min(210px, 28vw);
  max-height: 48px;
  object-fit: contain;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.tab {
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  white-space: normal;
}

.tab.active {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.08);
}

main {
  width: min(1220px, calc(100% - 32px));
  margin: 22px auto 54px;
}

.intro {
  position: relative;
  min-height: 360px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  align-items: end;
  gap: 24px;
  padding: clamp(24px, 5vw, 54px);
  color: #fff;
  background:
    linear-gradient(90deg, rgba(7, 19, 24, 0.94), rgba(7, 19, 24, 0.72)),
    #0a171c;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.intro::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(243, 193, 75, 0.26), transparent 24%),
    linear-gradient(180deg, transparent 58%, rgba(18, 131, 95, 0.28));
  pointer-events: none;
}

.hero-flags {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(12, minmax(64px, 1fr));
  grid-auto-rows: 54px;
  gap: 8px;
  padding: 16px;
  opacity: 0.34;
  transform: rotate(-4deg) scale(1.08);
  transform-origin: center;
  pointer-events: none;
}

.hero-flag {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.hero-logo {
  width: min(220px, 100%);
  justify-self: end;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.intro p {
  max-width: 720px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.intro-copy,
.score-rules {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--cyan);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.intro .eyebrow {
  color: var(--yellow);
}

.score-rules {
  display: grid;
  gap: 10px;
}

.score-rules span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 50px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  overflow-wrap: anywhere;
}

.score-rules strong {
  font-size: 1.4rem;
}

.panel {
  display: none;
  margin-top: 22px;
  padding: clamp(18px, 3vw, 32px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.07);
}

.panel.active {
  display: block;
}

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

.section-head.compact {
  margin-top: 28px;
  margin-bottom: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 24px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 24px;
}

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

.player-row,
.leader-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.player-row button {
  min-height: 34px;
  padding: 0 12px;
}

.hint {
  color: var(--muted);
  line-height: 1.45;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
}

.hidden {
  display: none !important;
}

.workspace {
  display: block;
}

.bet-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.admin-gate {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 420px) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.admin-login {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.admin-locked .result-editable {
  opacity: 0.68;
}

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

.group-card,
.round-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.group-card header,
.round-card header {
  padding: 12px 14px;
  background: #edf7f4;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.matches {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(86px, 1fr) 54px 18px 54px minmax(86px, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 48px;
}

.match-row .team-a {
  text-align: right;
}

.match-row .team-b {
  text-align: left;
}

.team {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.team-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.team-a .team-badge {
  justify-content: flex-end;
}

.flag {
  width: 26px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid rgba(18, 20, 24, 0.18);
  border-radius: 3px;
  object-fit: cover;
  background: #fff;
}

.score {
  min-height: 38px;
  text-align: center;
  padding: 4px;
}

.separator {
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.standings {
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

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

.bracket {
  display: grid;
  grid-template-columns: repeat(5, minmax(230px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.round-card {
  min-width: 230px;
}

.round-card .match-row {
  grid-template-columns: minmax(90px, 1fr) 48px 16px 48px minmax(90px, 1fr);
}

.placements {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.leaderboard {
  display: grid;
  gap: 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.summary-card {
  min-height: 110px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.summary-card span {
  color: var(--muted);
  font-weight: 700;
}

.admin-table {
  display: grid;
  gap: 10px;
}

.leader-row {
  grid-template-columns: 44px minmax(120px, 1fr) repeat(5, minmax(80px, auto));
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(5, minmax(76px, auto)) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-name {
  display: grid;
  gap: 6px;
}

.admin-name small {
  color: var(--muted);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.admin-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.travel-panel {
  position: relative;
  margin-top: 22px;
  padding: clamp(18px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(237, 247, 244, 0.95)),
    repeating-linear-gradient(135deg, rgba(14, 142, 168, 0.08) 0 10px, rgba(18, 131, 95, 0.08) 10px 20px);
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.07);
  overflow: hidden;
}

.travel-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    url("https://flagcdn.com/w80/br.png"),
    url("https://flagcdn.com/w80/ar.png"),
    url("https://flagcdn.com/w80/fr.png"),
    url("https://flagcdn.com/w80/de.png"),
    url("https://flagcdn.com/w80/jp.png"),
    url("https://flagcdn.com/w80/mx.png");
  background-position: 8% 12%, 24% 28%, 42% 10%, 62% 32%, 80% 14%, 92% 38%;
  background-repeat: no-repeat;
  background-size: 86px auto;
  opacity: 0.08;
  pointer-events: none;
}

.travel-panel > * {
  position: relative;
  z-index: 1;
}

.selection-passport {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.selection-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 66px;
  padding: 10px;
  border: 1px solid rgba(217, 222, 230, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.selection-card img {
  width: 42px;
  height: 30px;
  border: 1px solid rgba(18, 20, 24, 0.16);
  border-radius: 4px;
  object-fit: cover;
}

.selection-card strong,
.selection-card span {
  display: block;
  overflow-wrap: anywhere;
}

.selection-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.source-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.metric {
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
  }

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

  .fifa-logo {
    width: 190px;
  }

  .intro,
  .split,
  .group-grid,
  .placements {
    grid-template-columns: 1fr;
  }

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

  .leader-row {
    grid-template-columns: 36px 1fr;
  }

  .summary-grid,
  .admin-gate,
  .admin-row {
    grid-template-columns: 1fr;
  }

  .admin-login {
    grid-template-columns: 1fr;
  }

  .admin-actions {
    justify-content: flex-start;
  }

  .metric {
    text-align: left;
  }
}

@media (max-width: 540px) {
  main {
    width: min(100% - 20px, 1220px);
    margin-top: 12px;
  }

  .topbar {
    padding: 12px 10px;
  }

  .tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .tab {
    padding: 0 8px;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.94rem;
  }

  .intro {
    padding: 22px 16px;
  }

  .hero-flags {
    grid-template-columns: repeat(5, minmax(58px, 1fr));
    grid-auto-rows: 42px;
    gap: 6px;
    opacity: 0.25;
    transform: rotate(-5deg) scale(1.16);
  }

  .intro h2 {
    max-width: 320px;
    overflow-wrap: anywhere;
  }

  .intro p {
    max-width: 320px;
  }

  .hero-logo {
    width: min(180px, 100%);
    justify-self: start;
  }

  .score-rules span {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    justify-items: stretch;
  }

  .panel {
    padding: 16px 12px;
  }

  .match-row,
  .round-card .match-row {
    grid-template-columns: minmax(70px, 1fr) 42px 12px 42px minmax(70px, 1fr);
    gap: 4px;
  }
}
