:root {
  --navy: #1a3552;
  --navy-dark: #0f2238;
  --cream: #f7f4ec;
  --gold: #c9962f;
  --ink: #20242b;

  /* --- design-system adapter (added by the design-system refresh) --- */
  --ds-primary: var(--navy);
  --ds-primary-dark: var(--navy-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);
}

* { 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(--navy);
  color: var(--cream);
  padding: 1.4rem 1rem;
  text-align: center;
  border-bottom: 3px solid var(--ds-accent, var(--gold));
}

header h1 { margin: 0 0 .3rem; font-size: 1.7rem; line-height: 1.2; }
header p { margin: 0 auto; max-width: 36rem; font-size: .95rem; opacity: .9; }

nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem;
  background: var(--ds-primary-dark, var(--navy-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(--navy-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(--navy-dark); border-bottom: 2px solid var(--gold);
  padding-bottom: .3rem; font-size: 1.35rem; margin-top: 2.25rem;
}
main > h2:first-of-type { margin-top: .5rem; }

/* muted helper / footer copy — darkened for WCAG AA on cream */
.muted { color: #5c5c5c; }

.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;
}
.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(--navy)); }

.team input[type="text"] {
  font-size: 1.1rem; font-weight: bold; border: none;
  border-bottom: 1.5px solid color-mix(in srgb, var(--ds-ink) 18%, transparent);
  background: transparent; width: 100%; margin-bottom: .75rem; font-family: inherit; color: var(--ink);
  padding: .3rem 0; transition: border-color .15s ease;
}
.team input[type="text"]:focus { outline: none; border-bottom-color: var(--ds-primary); }

.round-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.round-row label { flex: 1; font-size: .92rem; }
.round-row input[type="number"] {
  width: 5.5rem; min-height: 44px; text-align: right; padding: .5rem .6rem;
  font-size: 1.05rem;
  border: 1.5px solid color-mix(in srgb, var(--ds-ink) 18%, 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;
}
.round-row input[type="number"]:hover { border-color: color-mix(in srgb, var(--ds-ink) 32%, transparent); }
.round-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);
}

.score-total {
  margin-top: 1rem; padding-top: .75rem; border-top: 2px solid var(--gold);
  font-size: 1.3rem; font-weight: bold; text-align: right; color: var(--navy-dark);
}

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

/* "Number of players" setup row: a clear, contained setup card */
.setup-row {
  display: flex; align-items: center; justify-content: center;
  gap: .75rem; flex-wrap: wrap;
  background: var(--ds-surface, #fff);
  border: 1px solid color-mix(in srgb, var(--ds-ink) 10%, transparent);
  border-radius: var(--ds-radius, 10px);
  box-shadow: var(--ds-shadow, 0 1px 3px rgba(0,0,0,.08));
  padding: .85rem 1rem; margin: 0 0 1.5rem;
}
.setup-row label { font-weight: 600; color: var(--navy-dark); }

/* Native <select> styled to match buttons/inputs, ~48px tap target */
#teamCount {
  font-family: inherit; font-size: 1.05rem; font-weight: 600;
  color: var(--ds-ink); background-color: var(--ds-surface, #fff);
  min-height: 48px; padding: .55rem 2.4rem .55rem .9rem;
  border: 1.5px solid color-mix(in srgb, var(--ds-ink) 25%, transparent);
  border-radius: calc(var(--ds-radius, 10px) * .6);
  cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%231a3552' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .85rem center;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#teamCount:hover { border-color: color-mix(in srgb, var(--ds-ink) 40%, transparent); }
#teamCount:focus-visible {
  outline: none; border-color: var(--ds-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-primary) 18%, transparent);
}

button {
  font-family: inherit; font-size: 1rem; font-weight: 600;
  min-height: 48px; padding: .7rem 1.4rem;
  border-radius: var(--ds-radius, 10px); border: 1px solid transparent;
  background: var(--ds-primary, var(--navy)); 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;
}
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(--navy));
  border-color: var(--ds-primary, var(--navy)); box-shadow: none;
}
button.secondary:hover { background: color-mix(in srgb, var(--ds-primary) 8%, transparent); box-shadow: none; }
button:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; }

/* Quick-start hint shown above the score controls (empty/initial state) */
.start-hint {
  display: flex; align-items: flex-start; gap: .6rem;
  background: color-mix(in srgb, var(--ds-accent) 12%, var(--ds-surface, #fff));
  border: 1px solid color-mix(in srgb, var(--ds-accent) 35%, transparent);
  border-radius: var(--ds-radius, 10px);
  padding: .8rem 1rem; margin: 0 0 1.5rem;
  font-size: .92rem; color: var(--navy-dark);
}
.start-hint strong { white-space: nowrap; }

table.history { width: 100%; border-collapse: collapse; margin-top: 1rem; background: #fff; border-radius: var(--ds-radius, 10px); overflow: hidden; box-shadow: var(--ds-shadow, 0 1px 3px rgba(0,0,0,.08)); }
table.history th, table.history td { border: 1px solid #e2e2e2; padding: .55rem; text-align: center; }
table.history th { background: var(--navy); color: var(--cream); font-weight: 600; }
table.history tbody tr:nth-child(even) { background: color-mix(in srgb, var(--ds-ink) 3%, #fff); }
table.history td:first-child { font-weight: 600; color: var(--navy-dark); }

.grand-totals {
  display: flex; justify-content: center; gap: .6rem;
  margin-top: 1.25rem; flex-wrap: wrap;
}
.grand-totals span {
  display: inline-flex; align-items: baseline; gap: .4rem;
  background: var(--ds-surface, #fff);
  border: 1px solid color-mix(in srgb, var(--ds-ink) 10%, transparent);
  border-top: 3px solid var(--ds-accent, var(--gold));
  border-radius: calc(var(--ds-radius, 10px) * .6);
  box-shadow: var(--ds-shadow, 0 1px 3px rgba(0,0,0,.08));
  padding: .55rem .9rem; font-size: 1.25rem; font-weight: bold;
  color: var(--navy-dark);
}

.variant-card {
  background: var(--ds-surface, #fff); border: 1px solid transparent;
  border-left: 4px solid var(--ds-accent); border-radius: var(--ds-radius, 10px);
  box-shadow: var(--ds-shadow, 0 1px 3px rgba(0,0,0,.08));
  padding: .8rem 1rem; margin-bottom: 1rem;
}

.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
@media (max-width: 600px) { .game-grid { grid-template-columns: 1fr; } }
.game-card {
  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.2rem; text-decoration: none; color: var(--ink);
  transition: box-shadow .15s ease, transform .08s ease;
}
.game-card h3 { margin-top: 0; color: var(--ds-primary, var(--navy)); }
.game-card:hover {
  box-shadow: var(--ds-shadow-hover, 0 4px 10px rgba(0,0,0,.10));
  transform: translateY(-2px);
}
.game-card.coming-soon { opacity: .55; pointer-events: none; }

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

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