:root {
  --bg: #0d0f1a;
  --panel: #161a2e;
  --accent: #ffb703;
  --accent-dark: #c98a00;
  --ink: #f4f4f8;
  --muted: #aab0d0;

  /* --- design-system adapter (added by the design-system refresh) --- */
  --ds-primary: var(--accent);
  --ds-primary-dark: var(--accent-dark);
  --ds-surface: var(--panel);
  --ds-bg: var(--bg);
  --ds-ink: var(--ink);
  --ds-accent: var(--accent);
  --ds-radius: 10px;
  --ds-shadow: 0 1px 4px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.35);
  --ds-shadow-hover: 0 6px 16px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

header {
  background: var(--panel);
  color: var(--ink);
  padding: 1.4rem 1rem;
  text-align: center;
  border-bottom: 3px solid var(--accent);
}

header h1 { margin: 0 0 .25rem; font-size: 2rem; letter-spacing: .02em; }
header p { margin: 0; font-size: 1rem; color: var(--muted); }

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

nav a {
  color: var(--ds-ink);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  padding: .55rem 1rem;
  border-radius: 999px;
  display: inline-block;
  opacity: .8;
  transition: background .15s ease, opacity .15s ease;
}
nav a:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--ds-ink) 10%, transparent);
}
nav a.active {
  opacity: 1;
  background: var(--ds-accent);
  color: #1a1300;
}
nav a:focus-visible {
  outline: 2px solid var(--ds-accent);
  outline-offset: 2px;
}

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

h2 { color: var(--accent); border-bottom: 2px solid var(--accent-dark); padding-bottom: .3rem; font-size: 1.5rem; letter-spacing: .01em; }

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 700px) { .teams { grid-template-columns: 1fr; } }

.team {
  background: var(--ds-surface, var(--panel));
  border: 1px solid #262b4a;
  border-radius: var(--ds-radius, 10px);
  box-shadow: var(--ds-shadow);
  padding: 1.1rem;
  transition: box-shadow .15s ease, transform .08s ease;
}
.team:hover { box-shadow: var(--ds-shadow-hover); transform: translateY(-2px); }
.team h3 { margin-top: 0; color: var(--ds-primary, var(--accent)); font-size: 1.1rem; }

.team input[type="text"] {
  font-size: 1.2rem; font-weight: bold; border: none; border-bottom: 1px solid #393f66;
  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: .5rem; }
.round-row label { flex: 1; font-size: 1rem; color: var(--muted); }
.round-row input[type="number"] {
  width: 5.5rem; min-height: 44px; padding: .5rem .6rem; border: 1px solid #393f66;
  border-radius: calc(var(--ds-radius, 10px) * .6);
  font-family: inherit; background: #0d0f1a; color: var(--ink); font-size: 1.2rem;
  text-align: center; transition: border-color .15s ease, box-shadow .15s ease;
}

/* Number-of-teams selector: give it a real affordance + a 44px mobile tap target */
#teamCount {
  min-height: 44px; padding: .5rem 2rem .5rem .8rem; font-family: inherit; font-size: 1.1rem;
  font-weight: 600; color: var(--ink); background: #0d0f1a; border: 1px solid #393f66;
  border-radius: calc(var(--ds-radius, 10px) * .6); cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23ffb703' stroke-width='2'/></svg>");
  background-repeat: no-repeat; background-position: right .7rem center;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#teamCount:hover { border-color: var(--muted); }
#teamCount:focus-visible {
  outline: none; border-color: var(--ds-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-primary) 25%, transparent);
}
.round-controls label { font-weight: 600; }
.round-row input[type="number"]:hover { border-color: var(--muted); }
.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) 25%, transparent);
}

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

.round-controls { display: flex; justify-content: center; gap: 1rem; margin: 1.5rem 0; flex-wrap: wrap; align-items: center; }
/* Cast toggle is a headline feature — give it a touch more presence in the setup view */
.cast-toggle { margin-top: .25rem; margin-bottom: .25rem; }
.cast-toggle button.secondary { border-color: var(--ds-primary); }

button {
  font-family: inherit; font-size: 1.1rem; padding: .7rem 1.4rem;
  border-radius: var(--ds-radius, 10px);
  border: 1px solid var(--ds-primary, var(--accent)); background: var(--ds-primary, var(--accent));
  color: #1a1300; cursor: pointer; font-weight: bold;
  box-shadow: var(--ds-shadow); transition: transform .08s ease, box-shadow .15s ease, opacity .15s ease;
}
button:hover { box-shadow: var(--ds-shadow-hover); transform: translateY(-1px); }
button:active { transform: translateY(0); opacity: .9; }
button.secondary { background: transparent; color: var(--ds-primary, var(--accent)); box-shadow: none; }
button.secondary:hover { background: color-mix(in srgb, var(--ds-primary) 12%, transparent); box-shadow: none; }
button:focus-visible { outline: 2px solid var(--ds-ink); outline-offset: 2px; }

table.history { width: 100%; border-collapse: collapse; margin-top: 1rem; background: var(--panel); }
table.history th, table.history td { border: 1px solid #262b4a; padding: .6rem; text-align: center; font-size: 1.05rem; }
table.history th { background: #0a0c16; color: var(--accent); }

.grand-totals {
  display: flex; justify-content: space-around; gap: .75rem 1.5rem; margin-top: 1.5rem;
  font-size: 1.8rem; font-weight: bold; flex-wrap: wrap; color: var(--accent);
}
.grand-totals span {
  background: var(--ds-surface, var(--panel)); border: 1px solid #262b4a;
  border-radius: var(--ds-radius, 10px); padding: .5rem 1rem; box-shadow: var(--ds-shadow);
}
body.cast-mode .grand-totals span { background: none; border: none; box-shadow: none; padding: 0; }

.variant-card {
  background: var(--ds-surface, var(--panel)); border: 1px solid #262b4a;
  border-left: 4px solid var(--ds-accent); border-radius: var(--ds-radius, 10px);
  box-shadow: var(--ds-shadow); padding: .9rem 1.1rem; margin-bottom: 1rem;
}

footer { text-align: center; font-size: .85rem; color: var(--muted); padding: 1.5rem 1rem; }

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

/* Fullscreen / TV-cast mode: hide host chrome, blow up the live scoreboard */
/* Hide host chrome while casting, but NOT the running-score table: it is .no-print yet
   it is the centerpiece of the TV view. Its empty/visible state is controlled inline by
   the tracker JS, so we exclude it here and let that inline display win. */
body.cast-mode header, body.cast-mode nav,
body.cast-mode .no-print:not(#historyTable) { display: none; }
/* Hide the per-team round-entry inputs and the host action buttons while casting —
   the TV view should show standings only, not editable host controls. */
body.cast-mode .teams,
body.cast-mode .round-controls:not(.cast-toggle) { display: none; }
body.cast-mode main > h2:not(#historyHeading) { display: none; }
body.cast-mode main { max-width: 100%; padding: 2.5rem 2rem 2rem; }
/* #historyHeading visibility is toggled inline by JS; only restyle it for the TV view. */
body.cast-mode #historyHeading { font-size: 2.4rem; text-align: center; border: none; color: var(--accent); margin: 0 0 1.5rem; }
body.cast-mode .grand-totals {
  font-size: clamp(2.5rem, 7vw, 5rem); gap: 1rem 2.5rem; line-height: 1.15; margin-top: 2.5rem;
}
body.cast-mode .grand-totals span { white-space: nowrap; }
body.cast-mode table.history { font-size: 1.8rem; }
body.cast-mode table.history th, body.cast-mode table.history td { font-size: clamp(1.4rem, 3vw, 2.2rem); padding: 1.1rem; }
/* Exit affordance: keep it findable, not a faint ghost a panicked host can't see */
body.cast-mode .cast-toggle { position: fixed; top: .75rem; right: .75rem; opacity: .6; margin: 0; z-index: 10; }
body.cast-mode .cast-toggle:hover, body.cast-mode .cast-toggle:focus-within { opacity: 1; }
body.cast-mode .cast-toggle button { font-size: .95rem; padding: .55rem 1rem; }
