  :root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1c1e21;
    --muted: #5f6672;
    --border: #d9dde3;
    --accent: #1f5fbf;
    --accent-soft: #e6eefb;
    --pos: #1a7f4b;
    --neg: #c0392b;
    --input-bg: #ffffff;
    color-scheme: light;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #15171a;
      --card: #1f2226;
      --text: #e8eaed;
      --muted: #a0a6b0;
      --border: #363a41;
      --accent: #6aa0ff;
      --accent-soft: #23304a;
      --pos: #4fcf85;
      --neg: #ff7b6b;
      --input-bg: #16181b;
      color-scheme: dark;
    }
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  }
  header { padding: 28px 16px 8px; max-width: 980px; margin: 0 auto; }
  .brand { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
  .brand .logo img { display: block; width: 56px; height: 56px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
  .brand .logo:hover img { transform: scale(1.04); transition: transform 0.15s; }
  .brand-sub { margin: 0 !important; font-size: 0.85rem; }
  .brand-sub a { color: var(--muted); }
  .brand-sub a:hover { color: var(--accent); }
  h1 { margin: 0 0 4px; font-size: 1.7rem; }
  h1 .tag { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); vertical-align: middle; margin-left: 6px; border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
  header p { margin: 0 0 6px; color: var(--muted); max-width: 70ch; }
  header p.lead { color: var(--text); font-size: 1.05rem; }
  a { color: var(--accent); }
  main { max-width: 980px; margin: 0 auto; padding: 8px 16px 16px; display: grid; gap: 16px; }
  @media (min-width: 820px) {
    main { grid-template-columns: 1fr 1fr; grid-template-areas: "spieler ergebnis" "partien ergebnis"; }
    #spieler { grid-area: spieler; }
    #partien-card { grid-area: partien; }
    #ergebnis { grid-area: ergebnis; align-self: start; position: sticky; top: 16px; }
  }
  .info { max-width: 980px; margin: 0 auto; padding: 0 16px 32px; display: grid; gap: 16px; }
  .info h3 { font-size: 0.95rem; margin: 16px 0 4px; }
  .info h3:first-of-type { margin-top: 0; }
  .info p { margin: 0 0 8px; }
  .info ul { margin: 0 0 8px; padding-left: 20px; }
  .info li { margin-bottom: 4px; }
  .hint { font-size: 0.8rem; color: var(--muted); margin: 8px 0 0; }
  .hint b { color: var(--text); font-weight: 600; }
  .zitat { margin: 18px 0 4px; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--bg); border-radius: 6px; }
  .zitat p { margin: 0 0 6px; font-style: italic; }
  .zitat footer { font-size: 0.8rem; color: var(--muted); }
  .card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
  h2 { margin: 0 0 12px; font-size: 1.05rem; }
  .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
  label span.hint { font-size: 0.78rem; }
  input, select {
    font: inherit; color: var(--text); background: var(--input-bg);
    border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; width: 100%;
  }
  input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
  table { width: 100%; border-collapse: collapse; }
  th { text-align: left; font-weight: 600; font-size: 0.8rem; color: var(--muted); padding: 0 6px 6px 0; }
  td { padding: 3px 6px 3px 0; vertical-align: middle; }
  td.nr { color: var(--muted); width: 2.2em; font-size: 0.85rem; }
  td select.ergebnis { min-width: 7.5em; }
  td input.gegner { min-width: 5em; }
  td.pd { color: var(--muted); font-size: 0.85rem; white-space: nowrap; width: 5em; text-align: right; }
  td.del { width: 2em; text-align: right; }
  button {
    font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--border);
    background: var(--card); color: var(--text); padding: 7px 12px;
  }
  button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  button.icon { border: none; background: transparent; color: var(--muted); font-size: 1.1rem; padding: 2px 6px; line-height: 1; }
  button.icon:hover { color: var(--neg); }
  .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
  .big { font-size: 2.6rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
  .delta { font-size: 1.1rem; font-weight: 600; margin-left: 8px; }
  .delta.pos { color: var(--pos); }
  .delta.neg { color: var(--neg); }
  dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 14px 0 0; }
  dt { color: var(--muted); }
  dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
  dd small, dt small { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
  .sub { font-size: 0.8rem; color: var(--muted); margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
  .sub dl { margin-top: 6px; }
  .sub dd { font-weight: 500; }
  .placeholder { color: var(--muted); }
  .warn { background: var(--accent-soft); border-radius: 6px; padding: 8px 10px; font-size: 0.85rem; margin-top: 10px; }
  tr.invalid input.gegner { border-color: var(--neg); background: color-mix(in srgb, var(--neg) 8%, var(--input-bg)); }
  .chart { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
  .chart .cap { font-size: 0.8rem; color: var(--muted); margin: 0 0 4px; }
  svg.verlauf { width: 100%; height: auto; display: block; }
  svg.verlauf .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
  svg.verlauf .base { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 3; }
  svg.verlauf .dot { fill: var(--accent); }
  svg.verlauf .dot.start { fill: var(--muted); }
  svg.verlauf .lbl { font-size: 9px; fill: var(--muted); }
  svg.verlauf .lbl.strong { fill: var(--text); font-weight: 600; font-size: 10px; }
  .share { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
  .share[hidden] { display: none; }
  #hinweis { font-size: 0.85rem; color: var(--muted); }
  #hinweis ul { margin: 6px 0 0; padding-left: 18px; }
  footer { max-width: 980px; margin: 0 auto; padding: 0 16px 32px; font-size: 0.8rem; color: var(--muted); }
  footer .rules { margin: 0 0 10px; }
  footer .legal a { color: var(--muted); }
  footer .legal a:hover { color: var(--accent); }
  footer .version { margin: 8px 0 0; font-size: 0.75rem; }

  /* Hilfsklassen (kein Inline-Style wegen Content-Security-Policy) */
  .mt12 { margin-top: 12px; }
  th.right { text-align: right; }
  .info .card, .info h3 { scroll-margin-top: 16px; }
  .info h3:target, .info .card:target { animation: mark 2s ease-out; }
  @keyframes mark { from { background: var(--accent-soft); } to { background: transparent; } }
  .warn a, .placeholder a, dd a { color: inherit; text-decoration: underline dotted; }
  .warn a:hover, dd a:hover { color: var(--accent); }

  /* Modus-Umschalter */
  .modus { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
  .modus button { flex: 1; border: none; border-radius: 0; background: var(--bg); color: var(--muted); padding: 8px 10px; font-weight: 500; }
  .modus button + button { border-left: 1px solid var(--border); }
  .modus button[aria-pressed="true"] { background: var(--card); color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
  .modus button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

  /* Ergebnis-Knöpfe 1 / ½ / 0 */
  .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
  .seg button { border: none; border-radius: 0; background: var(--input-bg); color: var(--muted); min-width: 2.3em; padding: 6px 0; font-variant-numeric: tabular-nums; }
  .seg button + button { border-left: 1px solid var(--border); }
  .seg button:hover { background: var(--accent-soft); color: var(--text); }
  .seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
  .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; position: relative; z-index: 1; }
  tr.incomplete td.pd { color: var(--neg); font-size: 0.75rem; }
  .big.placeholder { color: var(--border); }

  /* Vorschau nächste Partie */
  .vorschau { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 0.85rem; }
  .vorschau[hidden] { display: none; }
  .vorschau .kopf { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
  .vorschau .kopf label { flex-direction: row; align-items: center; gap: 6px; font-size: 0.85rem; }
  .vorschau .kopf input { width: 5.5em; padding: 4px 6px; }
  table.vs { width: 100%; }
  table.vs th { font-size: 0.75rem; padding-bottom: 2px; }
  table.vs th:not(:first-child), table.vs td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
  table.vs td { padding: 2px 0; }
  table.vs td:nth-child(2) { font-weight: 600; }
  table.vs td.pos { color: var(--pos); }
  table.vs td.neg { color: var(--neg); }

  /* Kennzahlen-Kacheln (nur ab Desktopbreite, die Liste bleibt auf dem Handy) */
  .tiles { display: none; }
  @media (min-width: 820px) {
    .tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
    .tiles > div { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
    .tiles .l { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
    .tiles .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
    .tiles .v small { font-size: 0.75rem; font-weight: 400; color: var(--muted); }
    #out dl .dup { display: none; }
  }

  /* Dreischritt und Beispieltabelle */
  .schritte { display: grid; gap: 14px; margin: 10px 0 16px; }
  @media (min-width: 820px) { .schritte { grid-template-columns: repeat(3, 1fr); } }
  .schritte > div { background: var(--bg); border-radius: 8px; padding: 12px 14px; }
  .schritte h3 { margin: 0 0 6px !important; display: flex; align-items: center; gap: 8px; }
  .schritte h3 .nr { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 0.8rem; font-weight: 700; }
  .schritte p { margin: 0; font-size: 0.9rem; }
  table.bsp { width: auto; min-width: 60%; margin: 6px 0 10px; }
  table.bsp th, table.bsp td { padding: 4px 18px 4px 0; }
  table.bsp th:not(:first-child), table.bsp td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
  table.bsp td:nth-child(3) { font-weight: 600; }
  table.bsp td.pos { color: var(--pos); font-weight: 600; }
  table.bsp td.neg { color: var(--neg); font-weight: 600; }

  /* Gegner ohne DWZ */
  th.odwz, td.odwz { width: 3.2em; text-align: center; font-size: 0.75rem; line-height: 1.1; }
  td.odwz input { width: auto; padding: 0; margin: 0; vertical-align: middle; accent-color: var(--accent); }
  tr.unrated input.gegner { color: var(--muted); background: var(--bg); font-style: italic; }
  tr.unrated td.pd { font-style: italic; }

  /* Unterseiten (Impressum, Datenschutz) */
  body.narrow header, body.narrow main, body.narrow footer { max-width: 760px; padding-left: 16px; padding-right: 16px; }
  body.narrow header { padding-top: 28px; padding-bottom: 8px; }
  body.narrow header nav a { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
  body.narrow header nav a:hover { text-decoration: underline; }
  body.narrow h1 { margin: 8px 0 4px; }
  body.narrow main { display: block; padding-top: 8px; padding-bottom: 32px; line-height: 1.6; }
  body.narrow .card { padding: 18px 22px; }
  body.narrow .card h2 { font-size: 1.05rem; margin: 22px 0 6px; }
  body.narrow .card h2:first-child { margin-top: 0; }
  body.narrow .card p { margin: 0 0 10px; }
  body.narrow .card ul { margin: 0 0 10px; padding-left: 20px; }
  body.narrow .stand { font-size: 0.85rem; color: var(--muted); margin-top: 18px; }
  body.narrow footer { padding-bottom: 32px; }
  body.narrow footer a { color: var(--muted); }

  /* Druckansicht */
  @media print {
    :root {
      --bg: #ffffff; --card: #ffffff; --text: #000000; --muted: #444444; --border: #999999;
      --accent: #1f5fbf; --accent-soft: #eeeeee; --pos: #1a7f4b; --neg: #c0392b; --input-bg: #ffffff;
      color-scheme: light;
    }
    body { font-size: 11pt; }
    header { padding-top: 0; }
    header p:not(.lead), .brand-sub, h1 .tag { display: none; }
    main { display: block; padding: 0 0 8px; }
    main .card { break-inside: avoid; margin-bottom: 10px; padding: 12px 14px; }
    #ergebnis { position: static; }
    .actions, .share, .hint, .info, footer .legal, td.del, th:last-child, button.icon, #alter-hint, .modus, .vorschau { display: none !important; }
    .seg button { color: var(--muted); }
    .seg button[aria-pressed="true"] { background: transparent; color: #000; font-weight: 700; text-decoration: underline; }
    input, select { border: none; border-bottom: 1px solid var(--border); border-radius: 0; padding: 2px 4px; background: transparent; appearance: none; }
    td.odwz input { border: 1px solid var(--border); }
    .big { font-size: 24pt; }
    svg.verlauf .line { stroke: #1f5fbf; }
    a { color: inherit; text-decoration: none; }
    footer { font-size: 8pt; }
  }
