:root {
  color-scheme: light dark;
  --line: #c9c9c9;
  --panel: #f5f5f4;
  --ink-muted: #55555a;
  --accent: #1f5f46;
  --err: #8d1b1b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --line: #4a4a4f;
    --panel: #232326;
    --ink-muted: #b3b3b8;
    --accent: #7fd0ab;
    --err: #ff9b9b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: Canvas;
  color: CanvasText;
}
main { max-width: 44rem; margin: 0 auto; padding: 1rem 1rem 2rem; }
h1 { font-size: 1.6rem; margin: 0.4rem 0 0.3rem; }
h2 { font-size: 1.2rem; margin: 1.4rem 0 0.4rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 0.4rem; }
.lead { margin: 0 0 1rem; color: var(--ink-muted); }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.92rem; }
textarea, input, select, button {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: Canvas;
  color: CanvasText;
  max-width: 100%;
}
textarea { width: 100%; resize: vertical; line-height: 1.4; }
#p-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
}
input[type="date"], input[type="number"], input[type="time"] { width: 100%; }
input[type="checkbox"] { width: auto; padding: 0.2rem; margin-right: 0.35rem; }
select { width: 100%; }
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 0.9rem;
}
.grid { display: grid; gap: 0.75rem; margin-top: 0.75rem; }
@media (min-width: 34rem) { .grid { grid-template-columns: 1fr 1fr; } }
.field { min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.9rem; }
button {
  cursor: pointer;
  font-weight: 600;
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
@media (prefers-color-scheme: dark) { button { color: #101012; } }
button.ghost { background: transparent; color: CanvasText; border-color: var(--line); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, pre:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.hint { font-size: 0.85rem; color: var(--ink-muted); margin: 0.45rem 0 0; }
.error {
  border: 1px solid var(--err);
  color: var(--err);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin: 1rem 0 0;
  font-weight: 600;
}
.summary { margin: 0 0 0.2rem; color: var(--ink-muted); }
pre#fixtures, pre#csvOut {
  margin: 0.9rem 0 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  max-height: 28rem;
  overflow: auto;
}
#csvBlock { margin-top: 1.4rem; border-top: 1px solid var(--line); padding-top: 0.6rem; }
table.balance { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
table.balance th, table.balance td {
  border-bottom: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  text-align: left;
}
table.balance th:not(:first-child), table.balance td:not(:first-child) { text-align: right; }
.about { margin-top: 1.6rem; border-top: 1px solid var(--line); padding-top: 0.9rem; }
.about p { color: var(--ink-muted); font-size: 0.92rem; }
.hidden { display: none; }
footer {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.9rem;
}
footer a { color: inherit; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Print: keep the fixture list on paper, drop the controls and page furniture.
   The list is never clipped (the on-screen box scrolls, paper does not), and the
   table stays with it so the home/away counts print too. The CSV block and the
   planner's plain-text copy block are screen-only exports, so they are left out
   of the printout. */
@media print {
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .panel, #error, .about, footer, button, #copyStatus, #csvBlock, .print-hint, #p-text-block { display: none !important; }
  h1 { font-size: 1.35rem; margin: 0 0 0.2rem; }
  h2 { font-size: 1.1rem; margin: 0.9rem 0 0.3rem; }
  h3 { font-size: 1rem; margin: 0.9rem 0 0.3rem; }
  .lead { color: #000; margin-bottom: 0.6rem; }
  .row { display: block; margin: 0; }
  .summary { color: #000; }
  .hint { color: #000; }
  pre#fixtures {
    max-height: none;
    overflow: visible;
    border: none;
    background: none;
    padding: 0;
    margin: 0.6rem 0 0;
    font-size: 0.85rem;
    line-height: 1.45;
  }
  table.balance { font-size: 0.85rem; }
  table.balance th, table.balance td { border-bottom: 1px solid #999; }
  /* Keep a round heading with at least the first lines under it. */
  pre#fixtures { break-inside: auto; }
}
