:root {
  color-scheme: light;
  --bg: #f3f5f0;
  --ink: #172119;
  --muted: #647063;
  --soft: #879180;
  --line: #dbe2d5;
  --panel: #ffffff;
  --field: #fbfcf8;
  --accent: #176f4a;
  --accent-strong: #0d4e35;
  --accent-soft: #e7f2e9;
  --gold: #b98b2f;
  --gold-soft: #f7edd7;
  --blue: #214f83;
  --warn: #9a3b1f;
  --shadow: 0 24px 70px rgba(28, 48, 32, 0.12);
  --shadow-soft: 0 14px 34px rgba(28, 48, 32, 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-snappy: cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: "PingFang SC", "Microsoft YaHei", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.72) 0 35%, transparent 35%),
    radial-gradient(circle at 16% 8%, rgba(23, 111, 74, 0.13), transparent 24rem),
    radial-gradient(circle at 86% 4%, rgba(185, 139, 47, 0.14), transparent 22rem),
    linear-gradient(180deg, #f8faf5 0%, var(--bg) 48%, #edf2ec 100%);
  color: var(--ink);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(23, 111, 74, 0.18);
}

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

button,
input,
select,
textarea,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.workspace {
  width: min(1240px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.match-panel,
.result-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

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

.match-panel::before,
.result-panel::before,
.groups-panel::before {
  content: "";
  display: block;
  height: 3px;
  margin: -1px -1px 18px;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--blue));
}

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

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

.brand-lockup {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.brand-logo {
  width: 76px;
  height: 112px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 8px;
  box-shadow: var(--shadow-soft);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  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(34px, 4vw, 46px);
  line-height: 0.98;
  letter-spacing: 0;
  white-space: nowrap;
}

.subtitle {
  max-width: 290px;
  margin: 9px 0 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 15px;
}

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

.status {
  flex: 0 0 auto;
  min-width: 74px;
  border: 1px solid rgba(23, 111, 74, 0.20);
  border-radius: 999px;
  background: #ffffff;
  padding: 8px 11px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(28, 48, 32, 0.06);
}

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

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

.signal-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.signal-strip span {
  min-height: 36px;
  border: 1px solid rgba(23, 111, 74, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8faf5);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

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

.quick-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  border: 1px solid rgba(23, 111, 74, 0.13);
  border-radius: 8px;
  background: rgba(246, 248, 244, 0.88);
  padding: 4px;
  box-shadow: inset 0 1px 2px rgba(28, 48, 32, 0.05);
}

.chip {
  min-height: 36px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 13px;
  font-size: 13px;
  box-shadow: none;
  flex: 1 1 0;
  transition:
    transform 180ms var(--ease-snappy),
    border-color 180ms var(--ease),
    background 180ms var(--ease),
    color 180ms var(--ease),
    box-shadow 180ms var(--ease);
}

.chip:hover {
  background: rgba(255, 255, 255, 0.68);
  color: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(28, 48, 32, 0.06);
}

.chip.is-active {
  background: #ffffff;
  border-color: rgba(23, 111, 74, 0.10);
  color: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(28, 48, 32, 0.10);
}

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

label > span {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, var(--field));
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition:
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    background 180ms var(--ease),
    transform 180ms var(--ease);
}

select {
  appearance: none;
  padding-right: 42px;
}

.select-shell {
  position: relative;
}

.select-shell::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--soft);
  border-bottom: 2px solid var(--soft);
  pointer-events: none;
  transform: translateY(-62%) rotate(45deg);
  transition: transform 180ms var(--ease), border-color 180ms var(--ease);
}

.select-shell:hover::after,
.select-shell:focus-within::after {
  border-color: var(--accent-strong);
}

.select-shell:focus-within::after {
  transform: translateY(-40%) rotate(225deg);
}

textarea {
  min-height: 104px;
  resize: vertical;
  font-weight: 600;
  line-height: 1.65;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(23, 111, 74, 0.12), 0 10px 24px rgba(28, 48, 32, 0.06);
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(23, 111, 74, 0.28);
  background: #ffffff;
}

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

.match-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(23, 111, 74, 0.18);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #f8fbf4);
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.match-preview > span {
  color: var(--accent);
  font-weight: 900;
  font-size: 13px;
  min-width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
}

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

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #1c7c55, #0f563a);
  color: #ffffff;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 26px rgba(23, 111, 74, 0.20);
  transition:
    transform 180ms var(--ease-snappy),
    box-shadow 180ms var(--ease),
    background 180ms var(--ease),
    opacity 180ms var(--ease),
    filter 180ms var(--ease);
}

button:hover {
  background: linear-gradient(180deg, #218c60, #0b4a32);
  transform: translateY(-1px) scale(1.005);
  box-shadow: 0 18px 32px rgba(23, 111, 74, 0.24);
}

button:active {
  transform: translateY(0) scale(0.985);
  box-shadow: 0 8px 18px rgba(23, 111, 74, 0.18);
  filter: saturate(0.96);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(33, 79, 131, 0.22);
  outline-offset: 3px;
}

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

button.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.90);
  color: var(--ink);
  box-shadow: 0 10px 22px rgba(28, 48, 32, 0.06);
}

button.secondary:hover {
  background: #ffffff;
  box-shadow: 0 12px 24px rgba(28, 48, 32, 0.08);
}

.method-card,
.contract-panel,
.weights-panel,
.groups-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 252, 248, 0.88);
}

.method-card {
  margin-top: 18px;
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

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

.method-grid span {
  min-height: 38px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(23, 111, 74, 0.10);
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.result-header h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
}

.result-header a {
  min-height: 34px;
  border: 1px solid rgba(33, 79, 131, 0.18);
  border-radius: 999px;
  background: #ffffff;
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(28, 48, 32, 0.06);
  transition:
    transform 180ms var(--ease-snappy),
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    background 180ms var(--ease);
}

.result-header a:hover {
  border-color: rgba(33, 79, 131, 0.28);
  background: #f8fbff;
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(33, 79, 131, 0.10);
}

.result-header a:active {
  transform: scale(0.98);
}

.brief-panel {
  border: 1px solid rgba(185, 139, 47, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, #fffdf8, var(--gold-soft));
  padding: 16px;
  margin-bottom: 16px;
}

.brief-panel h2 {
  color: #7d5e1f;
}

.brief-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.scoreline > div,
.metrics > div {
  min-height: 122px;
  border: 1px solid rgba(23, 111, 74, 0.15);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbf5);
  padding: 18px;
  display: grid;
  place-items: center;
  text-align: center;
  box-shadow: var(--shadow-soft);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
}

.scoreline > div:hover,
.metrics > div:hover,
.player:hover {
  border-color: rgba(23, 111, 74, 0.26);
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(28, 48, 32, 0.10);
}

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

.team-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  color: var(--ink);
  font-weight: 800;
}

.team-badge .flag {
  width: 38px;
  height: 28px;
  flex: 0 0 auto;
  border: 1px solid rgba(24, 32, 24, 0.16);
  border-radius: 4px;
  object-fit: cover;
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(28, 48, 32, 0.10);
}

.team-badge.stacked {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.team-badge.stacked .flag {
  width: 68px;
  height: 46px;
}

.team-badge.compact {
  min-width: 0;
  width: 100%;
  justify-content: center;
}

.team-badge.compact span:last-child,
.team-badge.group-team span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.score {
  color: var(--accent);
  background: linear-gradient(180deg, #102417, #173722) !important;
  border-color: rgba(23, 111, 74, 0.28) !important;
}

.score #predicted-score {
  color: #ffffff;
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 900;
  text-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.score small {
  color: rgba(255, 255, 255, 0.70);
  font-weight: 800;
}

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

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

.metrics strong {
  color: var(--blue);
  font-size: 28px;
}

.contract-panel,
.weights-panel {
  padding: 16px;
  margin-top: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

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

.check {
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 800;
  border: 1px solid transparent;
}

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

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

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

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

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

.weight-row strong {
  min-width: 48px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-strong);
  padding: 5px 8px;
  text-align: center;
}

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

.content-block h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content-block h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(185, 139, 47, 0.14);
}

ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

li {
  position: relative;
  padding-left: 18px;
  line-height: 1.7;
}

li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.75em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

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

#analysis {
  color: #293329;
  line-height: 1.9;
  font-size: 15px;
}

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

.player {
  border: 1px solid rgba(23, 111, 74, 0.14);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbf5);
  box-shadow: var(--shadow-soft);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
}

.player strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-strong);
}

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

.groups-panel {
  grid-column: 2 / 3;
  padding: clamp(20px, 4vw, 28px);
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

.group-card {
  min-height: 104px;
  border: 1px solid rgba(23, 111, 74, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 14px;
  box-shadow: 0 10px 24px rgba(28, 48, 32, 0.06);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
}

.group-card:hover {
  border-color: rgba(23, 111, 74, 0.28);
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(28, 48, 32, 0.10);
}

.group-card strong {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.group-card strong::after {
  content: "";
  width: 28px;
  height: 2px;
  border-radius: 999px;
  background: var(--gold);
}

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

.team-badge.group-team {
  min-width: 0;
  width: 100%;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8faf5);
  border: 1px solid rgba(23, 111, 74, 0.08);
  padding: 8px;
  color: var(--muted);
  font-size: 14px;
  transition: background 180ms var(--ease), color 180ms var(--ease);
}

.group-card:hover .team-badge.group-team {
  background: #ffffff;
  color: var(--ink);
}

.team-badge.group-team .flag {
  width: 30px;
  height: 22px;
}

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

  .match-panel {
    position: static;
  }

  .groups-panel {
    grid-column: 1 / -1;
  }

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

  .match-panel,
  .result-panel,
  .groups-panel {
    backdrop-filter: none;
  }
}

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

  .topbar {
    display: grid;
  }

  .brand-lockup {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .brand-logo {
    width: 58px;
    height: 86px;
  }

  h1 {
    font-size: 32px;
  }

  .subtitle {
    font-size: 14px;
  }

  .signal-strip {
    grid-template-columns: 1fr;
  }

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

  .match-preview {
    grid-template-columns: 1fr;
  }

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

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
