:root {
  --bg: #f5f6f2;
  --ink: #17201a;
  --muted: #667066;
  --line: #d8ddd4;
  --panel: #ffffff;
  --green: #237a57;
  --blue: #2e5f8f;
  --amber: #b36b13;
  --gold: #d4a017;
  --gold-dark: #9a6a00;
  --red: #a43f3f;
  --shadow: 0 12px 35px rgba(24, 32, 26, 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 {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcf8;
  position: sticky;
  top: 0;
  z-index: 5;
}

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

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

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.actions {
  display: flex;
  gap: 10px;
}

button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--green);
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 430px) 1fr;
  gap: 18px;
  padding: 18px;
}

.panel,
.third-panel,
.bracket-panel,
.status-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.bracket-panel {
  overflow: hidden;
}

.groups-panel {
  position: sticky;
  top: 91px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

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

.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 12px 16px;
}

.tabs button {
  min-height: 34px;
  padding: 0;
}

.tabs button.active {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

#groupDetail {
  padding: 0 16px 16px;
}

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

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

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

.rank-qual {
  color: var(--green);
  font-weight: 800;
}

.rank-third {
  color: var(--amber);
  font-weight: 800;
}

.netherlands-highlight {
  background: #fff2df;
  border-color: rgba(220, 112, 19, 0.55) !important;
  box-shadow: 0 0 0 2px rgba(220, 112, 19, 0.12);
}

.netherlands-text {
  color: #c96012;
  font-weight: 900;
}

.flag-fallback {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 16px;
  margin-right: 7px;
  border: 1px solid rgba(23, 32, 26, 0.14);
  border-radius: 2px;
  background: linear-gradient(135deg, #d4a017 0 50%, #2e5f8f 50%);
  color: white;
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
  position: relative;
  vertical-align: -3px;
}

.flag-fallback::before {
  content: attr(data-code);
  position: absolute;
  z-index: 0;
}

.flag {
  display: inline-block;
  width: 22px;
  height: 16px;
  object-fit: cover;
  position: relative;
  z-index: 1;
}

.matches {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.match-row {
  display: grid;
  grid-template-columns: 1fr 44px 44px 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.match-row .away {
  text-align: right;
}

.match-row input {
  width: 44px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  text-align: center;
  background: white;
}

.match-row input:disabled {
  background: #edf0ea;
  color: var(--muted);
}

.locked {
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.status-grid article {
  padding: 14px 16px;
}

.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
}

.third-ranking {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
  padding: 14px 16px 16px;
}

.third-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcf8;
  min-height: 72px;
}

.third-card.in {
  border-color: rgba(35, 122, 87, 0.45);
  background: #eef8f1;
}

.third-card.netherlands-highlight {
  background: #fff2df;
}

.third-card strong {
  display: block;
  font-size: 14px;
}

.third-card span {
  color: var(--muted);
  font-size: 12px;
}

.bracket {
  display: grid;
  grid-template-columns: repeat(9, 230px);
  gap: 136px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 24px 96px;
  position: relative;
  scrollbar-gutter: stable;
  scroll-padding: 96px;
  width: 100%;
}

.bracket::-webkit-scrollbar {
  height: 12px;
}

.bracket::-webkit-scrollbar-track {
  background: #edf0ea;
  border-radius: 999px;
}

.bracket::-webkit-scrollbar-thumb {
  background: rgba(46, 95, 143, 0.45);
  border: 3px solid #edf0ea;
  border-radius: 999px;
}

.round {
  display: grid;
  align-content: center;
  gap: 18px;
  min-width: 230px;
  position: relative;
  z-index: 1;
}

.round-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.final-round {
  align-content: center;
}

.ko-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 8px;
  position: relative;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.ko-card:hover {
  border-color: rgba(46, 95, 143, 0.48);
}

.ko-card.selected {
  background: #fff7dc;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.22), var(--shadow);
  transform: translateY(-1px);
}

.ko-card.path-selected {
  border-color: rgba(212, 160, 23, 0.62);
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.14);
}

.connector-layer {
  inset: 0;
  overflow: visible;
  pointer-events: none;
  position: absolute;
  z-index: 0;
}

.connector-layer path {
  fill: none;
  stroke: rgba(46, 95, 143, 0.46);
  stroke-linecap: round;
  stroke-width: 2.5;
}

.connector-layer path.selected {
  stroke: var(--gold-dark);
  stroke-width: 4;
}

.ko-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 4px;
}

.game-key {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 6px;
  border: 1px solid rgba(46, 95, 143, 0.22);
  border-radius: 5px;
  background: rgba(46, 95, 143, 0.07);
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.team-line {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 6px;
  align-items: center;
  min-height: 29px;
}

.team-line + .team-line {
  margin-top: 4px;
}

.team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-name.placeholder {
  color: var(--muted);
}

.team-line input {
  width: 34px;
  height: 27px;
  border: 1px solid var(--line);
  border-radius: 7px;
  text-align: center;
}

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

.note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .groups-panel {
    position: static;
    max-height: none;
  }

  .status-grid,
  .third-ranking {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .topbar {
    gap: 14px;
    padding: 16px;
    position: static;
  }

  h1 {
    font-size: 30px;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .actions button {
    width: 100%;
  }

  .layout {
    gap: 12px;
    padding: 10px;
  }

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

  .tabs {
    grid-template-columns: repeat(4, 1fr);
    padding: 10px 12px;
  }

  #groupDetail {
    padding: 0 12px 12px;
  }

  .standings {
    font-size: 12px;
  }

  .standings th,
  .standings td {
    padding: 7px 3px;
  }

  .match-row {
    grid-template-columns: 1fr 38px 38px 1fr;
    gap: 6px;
    padding: 8px;
    font-size: 12px;
  }

  .match-row input {
    width: 38px;
    height: 34px;
  }

  .status-grid {
    gap: 8px;
  }

  .status-grid article {
    padding: 11px 12px;
  }

  .status-grid strong {
    font-size: 22px;
  }

  .third-panel,
  .bracket-panel,
  .panel,
  .status-grid article {
    border-radius: 7px;
  }

  .third-ranking {
    gap: 6px;
    padding: 10px 12px 12px;
  }

  .third-card {
    min-height: 0;
    padding: 8px;
  }

  .bracket-panel {
    margin-left: -10px;
    margin-right: -10px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .bracket {
    grid-template-columns: repeat(9, 210px);
    gap: 72px;
    padding: 18px 28px;
    scroll-padding: 28px;
  }

  .round {
    gap: 14px;
    min-width: 210px;
  }

  .round-title {
    font-size: 11px;
    position: sticky;
    left: 0;
  }

  .ko-card {
    padding: 7px;
  }

  .ko-meta {
    font-size: 9px;
  }

  .game-key {
    font-size: 10px;
    margin-bottom: 5px;
    padding: 2px 5px;
  }

  .team-line {
    grid-template-columns: minmax(0, 1fr) 32px;
    min-height: 28px;
  }

  .team-line input {
    height: 28px;
    width: 32px;
  }

  .team-name {
    font-size: 12px;
  }

  .note {
    font-size: 9px;
    line-height: 1.2;
  }

  .flag-fallback,
  .flag {
    height: 14px;
    width: 20px;
  }
}
