:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --ink: #182018;
  --muted: #5c675c;
  --line: #d7ded0;
  --panel: #ffffff;
  --field: #f9faf6;
  --accent: #176f4a;
  --accent-strong: #0e5538;
  --warn: #9a3b1f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 10% 10%, rgba(23, 111, 74, 0.10), transparent 24rem), var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(18px, 4vw, 48px);
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.match-panel,
.result-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(28, 48, 32, 0.10);
}

.match-panel {
  position: sticky;
  top: 24px;
  padding: 24px;
}

.result-panel {
  padding: clamp(20px, 4vw, 34px);
}

.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

.subtitle {
  max-width: 290px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

h2 {
  margin-bottom: 10px;
  font-size: 16px;
}

.status {
  flex: 0 0 auto;
  min-width: 74px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
}

.status.busy {
  color: var(--accent);
  border-color: rgba(23, 111, 74, 0.38);
}

.status.error {
  color: var(--warn);
  border-color: rgba(154, 59, 31, 0.42);
}

.controls {
  display: grid;
  gap: 16px;
}

.quick-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.chip {
  min-height: 34px;
  border: 1px solid rgba(23, 111, 74, 0.22);
  background: #ffffff;
  color: var(--accent);
  padding: 0 12px;
  font-size: 13px;
}

.chip:hover {
  background: #eef7ef;
  color: var(--accent-strong);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 111, 74, 0.12);
}

.team-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

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

button.secondary:hover {
  background: #eef3ea;
}

.method-card,
.contract-panel,
.weights-panel,
.groups-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.method-card {
  margin-top: 18px;
  padding: 16px;
}

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

.method-grid span {
  min-height: 38px;
  border-radius: 8px;
  background: #ffffff;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
}

.result-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.result-header h2 {
  margin: 0;
  font-size: 24px;
}

.result-header a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.scoreline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.scoreline > div,
.metrics > div {
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 18px;
  display: grid;
  place-items: center;
  text-align: center;
}

.scoreline span,
.metrics span {
  color: var(--muted);
  font-size: 14px;
}

.scoreline strong {
  display: block;
  font-size: clamp(34px, 7vw, 60px);
  line-height: 1;
}

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

.score #predicted-score {
  color: var(--ink);
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 900;
}

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

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}

.metrics > div {
  min-height: 84px;
}

.metrics strong {
  font-size: 28px;
}

.contract-panel,
.weights-panel {
  padding: 16px;
  margin-top: 14px;
}

.contract-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
}

.check.ok {
  background: rgba(23, 111, 74, 0.12);
  color: var(--accent-strong);
}

.check.warn {
  background: rgba(154, 59, 31, 0.12);
  color: var(--warn);
}

.weight-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.weight-row:first-of-type {
  border-top: 0;
}

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

.content-block {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}

ul {
  margin: 0;
  padding-left: 20px;
}

li + li {
  margin-top: 8px;
}

#analysis {
  color: #293329;
  line-height: 1.8;
}

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

.player {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcf8;
}

.player strong {
  display: block;
  margin-bottom: 4px;
}

.player span {
  color: var(--muted);
  font-size: 13px;
}

.raw-box {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

pre {
  overflow: auto;
  max-height: 360px;
  border-radius: 8px;
  background: #111711;
  color: #e8f4e8;
  padding: 16px;
}

.groups-panel {
  grid-column: 1 / -1;
  padding: clamp(20px, 4vw, 28px);
}

.groups-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.group-card {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.group-card strong {
  color: var(--accent);
}

.group-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

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

  .match-panel {
    position: static;
  }

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

@media (max-width: 620px) {
  .app-shell {
    padding: 12px;
  }

  .team-grid,
  .players,
  .metrics,
  .scoreline {
    grid-template-columns: 1fr;
  }

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

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