:root {
  --ink: #10201c;
  --muted: #60746d;
  --line: #dce7e1;
  --panel: #ffffff;
  --field: #0c6b4e;
  --field-dark: #084231;
  --blue: #2257a8;
  --red: #c64132;
  --gold: #d59b21;
  --bg: #f5f7f3;
  --shadow: 0 18px 48px rgba(20, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(12, 107, 78, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(12, 107, 78, 0.06) 1px, transparent 1px),
    var(--bg);
  background-size: 56px 56px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  min-height: 206px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 28px;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(8, 66, 49, 0.96), rgba(12, 107, 78, 0.9)),
    radial-gradient(circle at 85% 20%, rgba(213, 155, 33, 0.34), transparent 34%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 12px;
  color: #cfe5dc;
  font-size: clamp(0.98rem, 1.6vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-block {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) 190px;
  gap: 34px;
  align-items: center;
  min-width: 0;
}

.brand-copy {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: none;
  font-size: clamp(3.1rem, 5vw, 6rem);
  line-height: 0.9;
  letter-spacing: 0;
  white-space: nowrap;
}

.logo-mark {
  display: block;
  width: 190px;
  height: 142px;
  object-fit: contain;
  border-radius: 8px;
  background: #020403;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(84px, 1fr));
  gap: 10px;
}

.top-actions {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.icon-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.2rem;
}

.summary div {
  min-height: 76px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.summary strong {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
}

.summary span {
  display: block;
  margin-top: 7px;
  color: #dbebe5;
  font-size: 0.78rem;
}

.controls,
.layout {
  margin-top: 16px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) 180px 210px minmax(280px, 1.6fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 24px rgba(16, 32, 28, 0.06);
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

input,
select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0 12px;
}

input[type="range"] {
  min-height: 24px;
  padding: 0;
  accent-color: var(--field);
}

button {
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
}

.weights {
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  gap: 10px;
}

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

.board-mode .layout {
  grid-template-columns: 1fr;
}

.board-mode .panel {
  display: none;
}

.panel,
.matches {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 26px rgba(16, 32, 28, 0.07);
}

.panel {
  position: sticky;
  top: 14px;
  padding: 16px;
}

.panel-head,
.matches-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#resetWeights {
  width: 42px;
  padding: 0;
  color: var(--field);
}

.meter-list {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.meter {
  display: grid;
  gap: 7px;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee9;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--field), var(--gold));
}

.insight {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  align-items: start;
  margin: 16px 0 18px;
  padding: 12px;
  border-left: 4px solid var(--gold);
  background: #fff9ea;
  color: #594a25;
  font-size: 0.86rem;
  line-height: 1.4;
}

.dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--gold);
}

.player-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.prediction-card {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.prediction-card strong {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.1rem;
}

.prediction-card span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.scorer-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
}

.scorer {
  display: grid;
  grid-template-columns: 28px 34px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.scorer b {
  color: var(--muted);
  font-size: 0.82rem;
}

.scorer strong {
  display: block;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scorer span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.scorer .flag {
  display: grid;
}

.scorer em {
  color: var(--blue);
  font-style: normal;
  font-weight: 850;
}

.odds-box {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
}

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

#saveOdds,
#refreshOdds,
#refreshForm {
  background: var(--field);
  color: #fff;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 18px;
}

.modal.open {
  display: grid;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 32, 28, 0.48);
}

.settings-dialog {
  position: relative;
  width: min(880px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.settings-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.settings-head .icon-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

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

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(16, 32, 28, 0.56);
}

.busy-overlay.open {
  display: grid;
}

.busy-box {
  display: grid;
  gap: 12px;
  width: min(440px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.busy-box strong {
  font-size: 1.05rem;
}

.busy-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee9;
}

.busy-track i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--field), var(--gold));
  transition: width 0.25s ease;
}

.busy-box p {
  color: var(--muted);
  font-size: 0.88rem;
}

.status-text {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.player {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 9px;
  align-items: center;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.flag {
  display: grid;
  place-items: center;
  width: 34px;
  height: 28px;
  border-radius: 6px;
  background: #eef4f1;
  font-size: 1.25rem;
}

.flag-england,
.flag-scotland {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(16, 32, 28, 0.14);
}

.flag-england {
  background:
    linear-gradient(90deg, transparent 0 42%, #c8102e 42% 58%, transparent 58%),
    linear-gradient(0deg, transparent 0 38%, #c8102e 38% 62%, transparent 62%),
    #fff;
}

.flag-scotland {
  background: #005eb8;
}

.flag-scotland::before,
.flag-scotland::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 12px;
  width: 48px;
  height: 5px;
  border-radius: 999px;
  background: #fff;
}

.flag-scotland::before {
  transform: rotate(36deg);
}

.flag-scotland::after {
  transform: rotate(-36deg);
}

.player strong,
.team strong {
  display: block;
  font-size: 0.94rem;
}

.player span,
.meta,
.date,
.prediction small {
  color: var(--muted);
  font-size: 0.78rem;
}

.player em {
  color: var(--blue);
  font-style: normal;
  font-weight: 850;
}

.matches {
  min-width: 0;
  padding: 16px;
}

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

.view-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.view-toggle button {
  min-height: 36px;
  border: 0;
  border-radius: 0;
  color: var(--muted);
}

.view-toggle button.active {
  background: var(--field);
  color: #fff;
}

#matches {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.group-board {
  display: grid;
  gap: 18px;
  padding: 16px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 84, 160, 0.96), rgba(8, 66, 49, 0.92)),
    radial-gradient(circle at 52% 38%, rgba(255, 255, 255, 0.18), transparent 22%);
  overflow-x: auto;
}

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

.group-card,
.ko-card {
  display: grid;
  grid-template-rows: 52px repeat(6, 1fr);
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #00529f;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.group-card header,
.ko-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 8px 12px;
  background: #243d91;
  color: #fff;
  font-weight: 900;
}

.group-card header span:last-child {
  display: flex;
  gap: 5px;
}

.group-row,
.ko-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 7px;
  min-height: 74px;
  padding: 7px;
}

.date-pill {
  display: grid;
  place-items: center;
  min-height: 60px;
  border-radius: 8px;
  background: #35ad3f;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
}

.poster-match {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 60px;
  padding: 6px 8px;
  border-radius: 7px;
  background: #eef2ef;
  color: var(--ink);
}

.poster-team {
  min-width: 0;
}

.poster-team strong {
  display: block;
  overflow: hidden;
  font-size: 0.9rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poster-team small {
  display: none;
  color: var(--muted);
  font-size: 0.68rem;
}

.poster-team.away {
  text-align: right;
}

.poster-score {
  display: grid;
  grid-template-columns: 1fr 12px 1fr;
  gap: 4px;
  align-items: center;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.score-box {
  display: grid;
  place-items: center;
  min-height: 32px;
  border: 1px solid #aab6b0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.knockout-board {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 0.8fr 0.8fr 1.3fr;
  grid-auto-rows: 1fr;
  gap: 12px;
  align-items: start;
  padding-top: 18px;
  border-top: 2px solid rgba(255, 255, 255, 0.65);
}

.ko-card {
  grid-template-rows: 52px;
  align-content: start;
  background: rgba(0, 82, 159, 0.78);
}

.ko-card.final-card header {
  background: var(--red);
}

.ko-row {
  grid-template-columns: 48px minmax(0, 1fr);
}

.match {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.match-main {
  min-width: 0;
}

.date {
  margin-bottom: 9px;
  font-weight: 800;
}

.teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.team {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-width: 0;
}

.team.away {
  direction: rtl;
  text-align: right;
}

.team.away > * {
  direction: ltr;
}

.team small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score {
  display: grid;
  place-items: center;
  min-height: 48px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 1.42rem;
  font-weight: 900;
}

.score small {
  display: block;
  margin-top: 2px;
  color: #cfe5dc;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.1;
}

.meta {
  margin-top: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prediction {
  display: grid;
  align-content: center;
  gap: 9px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.prob-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
}

.prob-track {
  height: 8px;
  border-radius: 999px;
  background: #e8eee9;
  overflow: hidden;
}

.prob-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.home-prob i {
  background: var(--blue);
}

.draw-prob i {
  background: var(--gold);
}

.away-prob i {
  background: var(--red);
}

.explain {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.detail .explain {
  display: grid;
}

.chip {
  padding: 8px;
  border-radius: 8px;
  background: #f3f7f4;
  color: var(--muted);
  font-size: 0.75rem;
}

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

footer {
  padding: 18px 2px 0;
  color: var(--muted);
  font-size: 0.82rem;
}

footer a {
  color: var(--blue);
  font-weight: 800;
}

@media (max-width: 1000px) {
  .topbar,
  .controls,
  .layout,
  .match {
    grid-template-columns: 1fr;
  }

  .brand-block {
    grid-template-columns: 1fr;
  }

  .logo-mark {
    width: 160px;
    height: 120px;
  }

  h1 {
    white-space: normal;
  }

  .summary,
  .weights {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .group-grid,
  .knockout-board {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .panel {
    position: static;
  }

  .prediction {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .topbar {
    padding: 20px;
  }

  .summary,
  .weights,
  .teams,
  .explain {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-items: stretch;
  }

  .score {
    min-height: 42px;
  }

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

  .matches-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .view-toggle {
    width: 100%;
  }

  .group-grid,
  .knockout-board {
    grid-template-columns: 1fr;
  }
}
