:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --text: #1f2421;
  --muted: #5d655f;
  --border: #dde1dc;
  /* pitch green: neutral on purpose, it's not the color of either club */
  --primary: #1f5c43;
  --primary-dark: #174634;

  /* results — always shown with a letter too, never color alone */
  --win: #0c7a3e;
  --draw: #6b7280;
  --loss: #c0362c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 2rem;
  background: var(--primary);
  color: #fff;
}

.topbar h1 { margin: 0; font-size: 1.5rem; }
.subtitle { margin: 0; opacity: 0.85; font-size: 0.95rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.lang-switch {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  overflow: hidden;
}

.lang-switch button {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.7rem;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.lang-switch button + button { border-left: 1px solid rgba(255, 255, 255, 0.35); }
.lang-switch button:hover { background: rgba(255, 255, 255, 0.12); }
.lang-switch button.active { background: #fff; color: var(--primary); }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: grid;
  gap: 1.5rem;
}

/* Grid items don't shrink below their content by default — learned that one
   in the last project, when a wide table pushed the page sideways on phones. */
.container > *, .two-columns > * { min-width: 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
}

.club-tabs { display: inline-flex; gap: 0.5rem; flex-wrap: wrap; }

.club-tabs button {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.club-tabs button.active { background: var(--text); border-color: var(--text); color: #fff; }

.inline-label { display: flex; align-items: center; gap: 0.5rem; }
.inline-label select { width: auto; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.card .label { color: var(--muted); font-size: 0.85rem; }
.card .value { font-size: 1.6rem; font-weight: 700; }
.card .note { color: var(--muted); font-size: 0.78rem; }
.card.highlight { border-left: 4px solid var(--primary); }

.two-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.panel h2 { margin-top: 0; font-size: 1.2rem; }
.hint { color: var(--muted); margin-top: -0.5rem; font-size: 0.92rem; }

.facts { margin: 0; display: grid; gap: 0.5rem; }
.facts div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 600; }
.mood { margin-bottom: 0; }

.chips { display: inline-flex; gap: 0.25rem; }

.chip {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

.chip.W { background: var(--win); }
.chip.D { background: var(--draw); }
.chip.L { background: var(--loss); }

.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: 0.9rem; margin-bottom: 0.5rem; }
.legend-item { display: inline-flex; align-items: center; }

.swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: -0.05rem;
}

.chart-box { position: relative; }
.chart { display: block; touch-action: pan-y; }
.chart .grid { stroke: #eceee9; }
.chart .axis { stroke: #b9beb8; }
.chart .guide { stroke: #9aa19b; stroke-dasharray: 3 3; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .axis-title { fill: var(--muted); font-size: 12px; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

.tooltip-title { color: var(--muted); font-size: 0.75rem; }
.chart-table { margin-top: 0.75rem; font-size: 0.9rem; }
.chart-table summary { cursor: pointer; color: var(--primary); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
thead th { text-transform: uppercase; }
.nowrap { white-space: nowrap; }
/* On a phone the scoreline was squeezed into a column one word wide. With a
   minimum width the table scrolls sideways inside its box instead. */
.match-cell { min-width: 8rem; }
.btn-icon { display: none; }
.compact td, .compact th { padding: 0.45rem 0.5rem; }
.better strong { color: var(--win); }
.better-tag { color: var(--win); font-size: 0.75rem; }

input, select {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

label { display: grid; gap: 0.25rem; font-size: 0.9rem; color: var(--muted); }
label input, label select { width: 100%; min-width: 0; }

.match-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.match-form .wide { grid-column: span 2; }

.btn {
  font: inherit;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  align-self: end;
}

.btn:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border: 1px solid rgba(255, 255, 255, 0.6); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

.btn-small {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.form-message { min-height: 1.2rem; margin-top: 0.5rem; }
.form-message p { margin: 0.2rem 0; }
.form-message.error { color: var(--loss); }
.form-message.success { color: var(--win); }

.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 0 1rem 2rem; }
.footer a { color: var(--primary); }

@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; padding: 1rem; }
  .match-form .wide { grid-column: auto; }
  .card .value { font-size: 1.35rem; }
  /* Not enough room on a phone: the competition filter is right at the top,
     and the arrow alone already says which club is better. */
  .col-comp { display: none; }
  .better-word { display: none; }
  .btn-label { display: none; }
  .btn-icon { display: inline; }
  th, td { padding: 0.5rem 0.4rem; }
  thead th { font-size: 0.72rem; }
  .match-cell { min-width: 7rem; }
  .compact td, .compact th { padding: 0.45rem 0.3rem; }
}
