/* Turnierplaner */
[hidden] { display: none !important; }

.stack { display: grid; gap: 1rem; }
main.page > .stack, main.page > section { margin-bottom: 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.mono { font-family: var(--mono); font-size: .85rem; }
.msg.err, .err { color: var(--bad); }
h2, h3, h4, h5 { margin: 0; }
h3 { font-size: 1.3rem; letter-spacing: -0.02em; }
h4 { font-size: 1.05rem; }
h5 { font-size: .95rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; }
.count { color: var(--muted); font-weight: 600; }
.banner { border-color: var(--ball); }
[tabindex="-1"]:focus { outline: none; }

/* Liste „Meine Turniere“ */
.tlist { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.tlist li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; padding: .7rem .9rem; border: 2px solid var(--line); border-radius: 14px; }
.tl-text { display: grid; min-width: 0; overflow-wrap: anywhere; }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--ball); outline-offset: 2px; }

/* Einrichten */
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; counter-reset: none; }
.players li { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) 5.2rem auto; gap: .4rem; align-items: center; }
.players .num { font-family: var(--mono); font-size: .8rem; color: var(--muted); text-align: right; }
.players .input { font-size: 1rem; padding: .4rem .55rem; }
.add-row { display: grid; grid-template-columns: minmax(0, 1fr) 5.2rem; gap: .5rem; align-items: end; }
.add-row .btn { grid-column: 1 / -1; justify-self: start; }
@media (min-width: 560px) {
  .add-row { grid-template-columns: minmax(0, 1fr) 6rem auto; }
  .add-row .btn { grid-column: auto; }
}
.bulk summary { cursor: pointer; font-weight: 600; padding: .25rem 0; }
.bulk[open] { display: grid; gap: .6rem; }
textarea.input { resize: vertical; font-weight: 500; font-size: 1rem; }

.modes { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
.modes legend { margin-bottom: .4rem; }
.radio { display: flex; gap: .65rem; align-items: flex-start; padding: .65rem .8rem; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; line-height: 1.35; }
.radio:has(input:checked) { border-color: var(--table); background: color-mix(in srgb, var(--table) 8%, transparent); }
.radio input, .check input { accent-color: var(--ball); width: 1.15rem; height: 1.15rem; margin: .15rem 0 0; flex: none; }
.check { display: inline-flex; gap: .55rem; align-items: center; font-weight: 600; cursor: pointer; }
.grid2 { display: grid; gap: .8rem; }
@media (min-width: 560px) { .grid2 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .span2 { grid-column: 1 / -1; } }
.grid2 p { margin: 0; }

/* Laufendes Turnier */
.run-head { display: grid; gap: .5rem; }
.run-head h2 { font-size: clamp(1.6rem, 5vw, 2.2rem); letter-spacing: -0.04em; overflow-wrap: anywhere; }
.run-head p { margin: 0; }
.share { display: grid; gap: .6rem; margin-top: .4rem; }
.champion { background: var(--table); color: #fff; border-radius: var(--radius); padding: 1rem 1.3rem; font-weight: 800; font-size: 1.3rem; letter-spacing: -0.02em; }
.champion::before { content: "🏆 "; }

.table-scroll { overflow-x: auto; margin-inline: -.25rem; }
.standings { width: 100%; border-collapse: collapse; font-size: .9rem; }
.standings th, .standings td { padding: .45rem .3rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.standings thead th { font-family: var(--mono); font-size: .68rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.standings tbody th { font-weight: 700; white-space: normal; overflow-wrap: break-word; min-width: 4.5rem; }
@media (min-width: 560px) { .standings { font-size: .95rem; } .standings th, .standings td { padding: .45rem .45rem; } }
.standings .num { text-align: right; font-variant-numeric: tabular-nums; }
.standings thead th:not(:nth-child(2)) { text-align: right; }
.standings .strong { font-weight: 800; }
.standings tr.q th, .standings tr.q td:first-child { box-shadow: inset 4px 0 0 var(--good); }
.standings tr.q td:first-child { color: var(--good); font-weight: 800; }
.standings tr.q th { box-shadow: none; }
.gnotes p { margin: 0 0 .3rem; }
.gnotes { display: grid; gap: .3rem; justify-items: start; }

.plan { display: grid; gap: .8rem; }
.round { display: grid; gap: .35rem; }
.matches { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.matches li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .3rem .5rem; align-items: center;
  padding: .4rem .5rem .4rem .7rem; border-radius: 12px; background: var(--paper);
}
.matches .pa { text-align: right; overflow-wrap: break-word; min-width: 0; }
.matches .pb { overflow-wrap: break-word; min-width: 0; }
.matches .win { font-weight: 800; }
.matches .res { font-family: var(--mono); font-weight: 500; min-width: 2.6rem; text-align: center; padding: .1rem .35rem; border-radius: 8px; background: var(--card); }
.matches li.done .res { background: var(--table); color: #fff; }
.matches .detail { grid-column: 1 / 3; grid-row: 2; font-family: var(--mono); font-size: .75rem; align-self: center; }
.matches .btn { grid-column: 3; grid-row: 2; justify-self: end; }
@media (min-width: 560px) {
  .matches li { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; }
  .matches .detail { grid-column: 1 / 4; text-align: center; }
  .matches .btn { grid-column: 4; grid-row: 1 / span 2; }
}
.free { margin: 0; }

/* KO-Baum */
.bracket-scroll { overflow-x: auto; padding-bottom: .5rem; -webkit-overflow-scrolling: touch; }
.bracket { display: flex; gap: 1.6rem; min-width: min-content; }
.col { display: flex; flex-direction: column; min-width: 11.5rem; max-width: 14rem; }
.col-h { font-family: var(--mono); font-size: .72rem; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: .5rem; }
.col-matches { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; justify-content: space-around; flex: 1; gap: .6rem; }
.slot { position: relative; }
.col:not(:last-child) .slot::after { content: ""; position: absolute; right: -1.6rem; top: 50%; width: 1.6rem; border-top: 2px solid var(--line); }
.ko-match { border: 2px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; }
.ko-match.done { border-color: color-mix(in srgb, var(--table) 55%, var(--line)); }
.ko-line { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem .6rem; font-size: .95rem; }
.ko-line + .ko-line { border-top: 1px solid var(--line); }
.ko-line.win { font-weight: 800; background: color-mix(in srgb, var(--table) 12%, transparent); }
.ko-line.win .ko-score { color: var(--table); }
.ko-line.bye .ko-name, .ko-line.tbd .ko-name { color: var(--muted); font-style: italic; font-weight: 500; }
.ko-name { overflow-wrap: anywhere; min-width: 0; }
.ko-score { font-family: var(--mono); font-weight: 500; }
.ko-detail { padding: 0 .6rem .25rem; font-family: var(--mono); font-size: .7rem; }
.ko-btn { margin: .2rem .4rem .4rem; }
.third { display: grid; gap: .5rem; max-width: 14rem; }
@media (prefers-color-scheme: dark) {
  .ko-line.win .ko-score { color: #8fb4ff; }
  .radio:has(input:checked) { border-color: #8fb4ff; }
}

/* Dialoge */
.dlg {
  width: min(32rem, calc(100% - 1.5rem)); max-height: calc(100% - 1.5rem); overflow: auto;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 1.2rem;
}
.dlg::backdrop { background: rgb(13 19 32 / .6); }
.dlg h2 { font-size: 1.35rem; }
.dlg p { margin: 0; }
.pair-names { overflow-wrap: anywhere; }
.dlg fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.dlg legend { margin-bottom: .45rem; }
.set-grid { display: grid; grid-template-columns: auto minmax(0, 5rem) auto minmax(0, 5rem); gap: .35rem .45rem; align-items: center; justify-content: start; }
.sg-h { font-size: .8rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-l { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.sg-c { font-weight: 800; }
.set-in { text-align: center; padding: .35rem .3rem; font-family: var(--mono); }
.quick .actions { gap: .4rem; }

/* Druck */
@media print {
  :root { --paper: #fff; --card: #fff; --text: #000; --muted: #444; --line: #999; color-scheme: light; }
  body { font-size: 10.5pt; background: #fff; color: #000; }
  .top, .foot, .skip-link, .lede, #status, #liste, #einrichten, #geteilt, .rules, .no-print, .matches .btn, .ko-btn, dialog { display: none !important; }
  main.page { padding: 0; width: 100%; }
  .page h1 { font-size: 14pt; margin-bottom: .3rem; }
  .card { border: 1px solid #999; border-radius: 6px; padding: .5rem .7rem; }
  .group, .ko, .round, .ko-match, tr { break-inside: avoid; }
  .bracket-scroll { overflow: visible; }
  .bracket { gap: .9rem; }
  .col { min-width: 0; flex: 1; }
  .col:not(:last-child) .slot::after { right: -.9rem; width: .9rem; }
  .matches li { background: none; border-bottom: 1px solid #ccc; border-radius: 0; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .matches li.done .res { background: none; color: #000; font-weight: 700; }
  .matches .detail { grid-column: 1 / -1; }
  .champion { background: none; color: #000; border: 2px solid #000; }
  .standings tr.q th, .standings tr.q td:first-child { box-shadow: none; }
  .standings tr.q td:first-child { color: #000; text-decoration: underline; }
}
