:root {
  --green: #1d5b3a;
  --green-dark: #123c26;
  --cream: #faf6ec;
  --gold: #c9a13b;
  --red: #a4302a;
  --ink: #25291f;

  /* --- design-system adapter (added by the design-system refresh) --- */
  --ds-primary: var(--green);
  --ds-primary-dark: var(--green-dark);
  --ds-surface: #ffffff;
  --ds-bg: var(--cream);
  --ds-ink: var(--ink);
  --ds-accent: var(--gold);
  --ds-radius: 10px;
  --ds-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --ds-shadow-hover: 0 4px 10px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.08);

  /* accessible muted text (>=4.5:1 on cream/white, replaces #777) */
  --ds-muted: #5f6157;
  /* minimum comfortable touch target */
  --ds-tap: 44px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
}

header {
  background: var(--green);
  color: var(--cream);
  padding: 1.2rem 1rem;
  text-align: center;
}

header h1 {
  margin: 0 0 .25rem;
  font-size: 1.6rem;
}

header p {
  margin: 0;
  font-size: .95rem;
  opacity: .85;
}

nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem;
  background: var(--ds-primary-dark, var(--green-dark));
  padding: .5rem .75rem;
  border-radius: 0 0 var(--ds-radius, 10px) var(--ds-radius, 10px);
}

nav a {
  color: var(--ds-surface, var(--cream));
  text-decoration: none;
  font-size: .95rem;
  font-weight: 600;
  padding: .55rem 1rem;
  border-radius: 999px;
  display: inline-block;
  opacity: .85;
  transition: background .15s ease, opacity .15s ease, transform .08s ease;
}

nav a:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--ds-surface, #fff) 12%, transparent);
}

nav a.active {
  opacity: 1;
  background: var(--ds-accent);
  color: var(--ds-primary-dark, var(--green-dark));
}

nav a:focus-visible {
  outline: 2px solid var(--ds-accent);
  outline-offset: 2px;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

h2 {
  color: var(--green-dark);
  border-bottom: 2px solid var(--gold);
  padding-bottom: .3rem;
  font-size: 1.35rem;
  margin-top: 2rem;
}

h2:first-of-type { margin-top: 0; }

h3 { font-size: 1.15rem; }

.teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.team {
  background: var(--ds-surface, #fff);
  border: 1px solid transparent;
  border-radius: var(--ds-radius, 10px);
  box-shadow: var(--ds-shadow, 0 1px 3px rgba(0,0,0,.08));
  padding: 1.1rem;
  transition: box-shadow .15s ease, transform .08s ease;
}

@media (hover: hover) {
  .team:hover {
    box-shadow: var(--ds-shadow-hover, 0 4px 10px rgba(0,0,0,.10));
    transform: translateY(-2px);
  }
}

.team h3 {
  margin-top: 0;
  color: var(--ds-primary, var(--green));
}

.team input[type="text"] {
  font-size: 1.2rem;
  font-weight: bold;
  min-height: var(--ds-tap);
  border: none;
  border-bottom: 2px solid color-mix(in srgb, var(--ds-ink) 22%, transparent);
  background: transparent;
  width: 100%;
  margin-bottom: 1rem;
  font-family: inherit;
  color: var(--green-dark);
  padding: .3rem 0;
  transition: border-color .15s ease;
}

.team input[type="text"]:focus {
  outline: none;
  border-bottom-color: var(--ds-primary);
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-bottom: .55rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid color-mix(in srgb, var(--ds-ink) 7%, transparent);
  font-size: .92rem;
}

.field-row:last-of-type { border-bottom: none; }

.field-row label { flex: 1; min-width: 0; }

.field-row input[type="number"] {
  width: 4.5rem;
  min-height: var(--ds-tap);
  text-align: right;
  padding: .5rem .6rem;
  font-size: 1.05rem;
  border: 1.5px solid color-mix(in srgb, var(--ds-ink) 22%, transparent);
  border-radius: calc(var(--ds-radius, 10px) * .5);
  background: var(--ds-surface, #fff);
  color: var(--ds-ink);
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field-row input[type="number"]:hover {
  border-color: color-mix(in srgb, var(--ds-ink) 32%, transparent);
}

.field-row input[type="number"]:focus {
  outline: none;
  border-color: var(--ds-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-primary) 18%, transparent);
}

.field-row .hint {
  font-size: .78rem;
  color: var(--ds-muted);
  display: block;
  margin-top: .1rem;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  margin: .85rem 0 .25rem;
  padding: .55rem .65rem;
  font-size: .92rem;
  color: var(--ds-ink);
  background: color-mix(in srgb, var(--ds-accent) 10%, transparent);
  border-radius: calc(var(--ds-radius, 10px) * .5);
}

.checkbox-row input[type="checkbox"] {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--ds-primary);
  cursor: pointer;
}

.checkbox-row label {
  cursor: pointer;
  line-height: 1.35;
  padding-top: .05rem;
}

.score-total {
  margin-top: 1.1rem;
  padding-top: .85rem;
  border-top: 2px solid var(--gold);
  font-size: 1.3rem;
  font-weight: bold;
  text-align: right;
  color: var(--green-dark);
  line-height: 1.3;
}

.round-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.5rem 0;
}

select#teamCount {
  font-family: inherit;
  font-size: 1rem;
  min-height: var(--ds-tap);
  padding: .4rem 2.2rem .4rem .75rem;
  border: 1.5px solid color-mix(in srgb, var(--ds-ink) 22%, transparent);
  border-radius: calc(var(--ds-radius, 10px) * .5);
  background: var(--ds-surface, #fff)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%231d5b3a' d='M1 1l5 5 5-5'/></svg>")
    no-repeat right .8rem center;
  color: var(--ds-ink);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

select#teamCount:focus-visible {
  outline: 2px solid var(--ds-accent);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .round-controls button { flex: 1 1 100%; }
}

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  min-height: var(--ds-tap);
  padding: .65rem 1.3rem;
  border-radius: var(--ds-radius, 10px);
  border: 1px solid transparent;
  background: var(--ds-primary, var(--green));
  color: var(--ds-surface, var(--cream));
  cursor: pointer;
  box-shadow: var(--ds-shadow, 0 1px 3px rgba(0,0,0,.08));
  transition: transform .08s ease, box-shadow .15s ease, opacity .15s ease;
}

@media (hover: hover) {
  button:hover {
    box-shadow: var(--ds-shadow-hover, 0 4px 10px rgba(0,0,0,.1));
    transform: translateY(-1px);
  }
}

button:active { transform: translateY(0); opacity: .92; }

button.secondary {
  background: transparent;
  color: var(--ds-primary, var(--green));
  border-color: var(--ds-primary, var(--green));
  box-shadow: none;
}

button.secondary:hover {
  background: color-mix(in srgb, var(--ds-primary) 8%, transparent);
  box-shadow: none;
}

button.danger {
  background: transparent;
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 55%, transparent);
  box-shadow: none;
}

button.danger:hover {
  background: color-mix(in srgb, var(--red) 8%, transparent);
  box-shadow: none;
}

button:focus-visible {
  outline: 2px solid var(--ds-accent);
  outline-offset: 2px;
}

table.history {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background: #fff;
}

table.history th, table.history td {
  border: 1px solid #ddd;
  padding: .5rem;
  text-align: center;
}

table.history th {
  background: var(--green);
  color: var(--cream);
}

.grand-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  gap: .5rem;
  margin-top: 1rem;
  font-size: 1.35rem;
  font-weight: bold;
  color: var(--green-dark);
}

.grand-totals div {
  background: var(--ds-surface, #fff);
  border: 1px solid color-mix(in srgb, var(--ds-ink) 10%, transparent);
  border-top: 3px solid var(--gold);
  border-radius: var(--ds-radius, 10px);
  padding: .75rem 1.1rem;
  text-align: center;
  flex: 1 1 auto;
}

.variant-card {
  background: #fff;
  border: 1px solid #ddd;
  border-left: 4px solid var(--gold);
  border-radius: 4px;
  padding: .8rem 1rem;
  margin-bottom: 1rem;
}

footer {
  text-align: center;
  font-size: .82rem;
  color: var(--ds-muted);
  padding: 1.5rem 1rem;
  border-top: 1px solid color-mix(in srgb, var(--ds-ink) 10%, transparent);
  margin-top: 1rem;
}

/* shared empty-state / helper note */
.empty-state {
  text-align: center;
  color: var(--ds-muted);
  background: color-mix(in srgb, var(--ds-accent) 8%, var(--ds-surface));
  border: 1px dashed color-mix(in srgb, var(--ds-ink) 20%, transparent);
  border-radius: var(--ds-radius, 10px);
  padding: 1.25rem 1rem;
  margin: 1rem 0;
  font-size: .95rem;
}

.note {
  color: var(--ds-muted);
  font-size: .85rem;
}

/* CSS-only empty state: hide the placeholder once scorer.js fills #grandTotals */
#grandTotals:not(:empty) + #historyEmpty { display: none; }

@media print {
  header, nav, .round-controls, footer, .no-print { display: none !important; }
  body { background: #fff; }
}
