:root { --bg: #17181b; --card: #24252a; --line: #3a3b42; --text: #f1f1f4; --muted: #a2a3ab; --accent: #33b5f5; --good: #6fd08a; --bad: #ff8a8a; }
* { box-sizing: border-box; }
/* Die Fußzeile steht am unteren Bildschirmrand, bei viel Inhalt weiter unten: der Inhalt füllt den Platz dazwischen */
body { min-height: 100vh; display: flex; flex-direction: column; margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, sans-serif; }
header { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
header h1 { margin: 0; font-size: 22px; }
header h1 small.ver { opacity: .6; }
header h1 a.home { color: inherit; text-decoration: none; }
header h1 a.home:hover { color: var(--accent); }
/* Benutzermenü oben rechts */
.umenu { position: relative; flex: none; align-self: flex-start; }   /* bleibt immer oben rechts */
header h1 { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
.ubtn { display: flex; align-items: center; padding: 6px; border-radius: 50%; }
.ubtn.admin { border-color: var(--accent); color: var(--accent); }
.drop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; flex-direction: column; gap: 8px; min-width: 190px; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 30px #000; }
.drop span { font-size: 13px; padding: 0 4px; }
.drop button { text-align: left; white-space: nowrap; }
header h1 small { color: var(--muted); font-weight: 400; font-size: 15px; margin-left: 8px; }
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 18px 16px 30px; }
footer { width: 100%; max-width: 1200px; margin: 0 auto; padding: 14px 16px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; text-align: center; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
/* Anmeldung über den Einladungslink */
main.join { max-width: 640px; }
main.join h2 { font-size: 20px; margin: 0 0 6px; }
.err { color: var(--bad); min-height: 1.2em; }
/* Datenschutz: Lesetext in schmaler Spalte */
main.legal { max-width: 800px; }
main.legal h1 { font-size: 26px; margin: 8px 0 4px; }
main.legal h2 { font-size: 18px; margin: 28px 0 6px; }
main.legal p, main.legal ul { margin: 0 0 10px; }
main.legal a { color: var(--accent); }
a.btn { padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line); background: #2f3037; color: var(--text); text-decoration: none; }
a.btn:hover { background: #3a3b44; }
button { font: inherit; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line); background: #2f3037; color: var(--text); cursor: pointer; }
button:hover { background: #3a3b44; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06222f; font-weight: 600; }
button.danger { color: var(--bad); }
button.small { padding: 3px 9px; font-size: 14px; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select { font: inherit; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line); background: #111214; color: var(--text); min-width: 0; }
input.score { width: 58px; text-align: center; font-size: 18px; font-weight: 700; }
.card { background: var(--card); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; background: none; border-bottom: 3px solid transparent; border-radius: 0; padding: 9px 16px; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Zeilen abwechselnd getönt, damit man in der Zeile bleibt */
tbody tr:nth-child(even) td, #matches > .match:nth-child(even), #list > .item:nth-child(even) { background: #2c2d34; }
#matches > .match, #list > .item, #pGames > .match { padding-left: 10px; padding-right: 10px; }
#pGames > .match:nth-child(even) { background: #2c2d34; }
/* Persönliche Seite eines Spielers */
a.plink { color: var(--text); font-weight: 700; text-decoration: none; cursor: pointer; }
a.plink:hover { color: var(--accent); text-decoration: underline; }
h2.pname { margin: 0 0 12px; font-size: 24px; }
h3.sub { margin: 0 0 8px; font-size: 17px; color: var(--accent); }
#tab-player > .row { margin-bottom: 12px; }
.match { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.match > div { overflow-wrap: anywhere; }
.match .tbl { color: var(--muted); font-weight: 700; }
.match .tbl { white-space: nowrap; }
/* "Spiel eintragen" als schwebender ＋-Knopf unten rechts über dem Inhalt, bleibt beim Blättern stehen */
#gOpen.fab { position: fixed; right: max(18px, calc((100vw - 1200px) / 2 + 18px)); bottom: 22px; z-index: 5; width: 64px; height: 48px;
  padding: 0; border-radius: 24px; font-size: 26px; line-height: 1; box-shadow: 0 4px 16px rgba(0, 0, 0, .55); }
#tab-games { padding-bottom: 64px; }   /* damit der Knopf am Ende der Liste nichts verdeckt */
.match .tbl small { margin-left: 6px; font-weight: 400; font-size: 12px; }   /* Datum und Uhrzeit neben "Spiel N" */
.match .b { text-align: right; }
.match .win { color: var(--good); font-weight: 700; }
.match .me { color: #ffd166; font-weight: 700; }   /* persönliche Seite: der Spieler selbst, auch wenn er gewonnen hat */
.match .tot { font-size: 18px; font-weight: 700; white-space: nowrap; }
.match small { color: var(--muted); }
#gameForm .side { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
#gameForm .fmt { margin-bottom: 10px; }
#noteForm textarea { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 8px 10px; border-radius: 7px;
  border: 1px solid var(--line); background: #111214; color: var(--text); resize: vertical; }
/* Reiter Sprüche: der Text groß, darunter klein das Spiel dazu */
.note { padding: 10px 0; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: none; }
.note q { display: block; font-size: 17px; quotes: "„" "“"; }
.note { display: flex; gap: 10px; align-items: flex-start; }
.note > div { flex: 1; min-width: 0; }
.note > .nbtn { flex: none; white-space: nowrap; }   /* die Knöpfe nur so breit wie nötig, der Spruch bekommt den Rest */
#noteForm .row { margin-top: 8px; }
.note small { display: block; margin-top: 3px; color: var(--muted); }
.note small .win { color: var(--good); font-weight: 700; }
/* 6er mit 3 Paaren: die drei Paare untereinander, rechts die Kugeln des Paars */
.match.many .teams { grid-column: 2 / 5; display: flex; flex-direction: column; gap: 3px; }
.match.many .teams b { margin-left: 8px; }
#gameForm .side .tbl { color: var(--muted); font-weight: 700; width: 58px; flex: none; }
#gameForm .side input:not(.score):not([type=radio]) { flex: 1 1 90px; }
#gameForm input.bad { border-color: var(--bad); color: var(--bad); }
#gameForm input.score { width: 62px; }
th.sort { cursor: pointer; }
th.sort:hover, th.sort.on { color: var(--text); }
th.sort.on::after { content: " ▼"; color: var(--accent); }
th.sort.on.up::after { content: " ▲"; }
td.txt { color: var(--muted); white-space: nowrap; }
.best { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.best > div { background: #1c1d21; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.best small { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.best b { display: block; font-size: 19px; margin: 3px 0; color: var(--good); }
.best span { color: var(--muted); }
/* Persönliche Seite: jede Zahl in einer Zeile – Bezeichnung, Wert, Zusatz */
#pStats { display: block; }
#pStats > div { display: flex; align-items: baseline; gap: 4px 10px; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 7px 2px; }
#pStats > div:last-child { border-bottom: 0; }
#pStats small { display: inline; flex: 0 0 210px; font-size: 14px; }
#pStats b { display: inline; margin: 0; font-size: 17px; }
#pStats span { min-width: 0; }
@media (max-width: 640px) { #pStats small { flex-basis: 130px; } }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:hover b { color: var(--accent); }
/* Passwort eines Lagers, nur für den Admin, rechts im Eintrag der Liste */
.item .pw { display: flex; gap: 6px; align-items: center; margin-left: auto; cursor: default; }
.item .pw input { width: 210px; padding: 4px 8px; font-size: 14px; }
#msg.ok { background: #1f5a34; }
#msg { position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); background: #5a2328; color: #fff; padding: 10px 18px; border-radius: 8px; max-width: 90vw; }
#offBar { border: 1px solid #8a6d1f; background: #3a3117; }
#offBar b { color: #ffd166; }
#closedBar { border: 1px solid #8a6d1f; background: #3a3117; padding: 10px 14px; }
#closedBar b { color: #ffd166; }
#lock, .overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; z-index: 10; }
#lockForm, #campForm { display: flex; flex-direction: column; gap: 12px; width: min(340px, 90vw); margin: 0; box-shadow: 0 10px 40px #000; }
#lockErr, #campErr { color: var(--bad); min-height: 1.4em; }
[hidden] { display: none !important; }
/* Ohne Admin: nur ansehen und ein neues Spiel eintragen */
body.readonly :is(#newForm, #playerForm, #rankRows button, .match button, .note button) { display: none !important; }
body.readonly :is(input, select):disabled { opacity: 1; color: var(--text); border-color: transparent; background: none; }
body.readonly input[type=number] { appearance: textfield; -moz-appearance: textfield; }   /* ohne die Pfeile zum Hoch- und Runterzählen */
body.readonly input[type=number]::-webkit-inner-spin-button, body.readonly input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; display: none; margin: 0; }
/* Handy: Spiel eintragen untereinander. Je Paar/Team oben der Name der Reihe mit "Sieger", darunter je Spieler
   eine Zeile aus Name und Kugeln; große Felder zum Tippen. Die Spielliste: Spiel-Nummer und Knöpfe oben, die Paare darunter. */
@media (max-width: 640px) {
  main { padding: 12px 10px 24px; }
  header { padding: 10px 12px; gap: 8px; }
  header h1 { font-size: 19px; }
  .card { padding: 12px 10px; }
  .tabs { overflow-x: auto; }
  .tabs button { padding: 9px 11px; white-space: nowrap; }
  #gameForm .fmt select { flex: 1; }
  #gameForm .side { flex-wrap: wrap; gap: 8px; padding: 10px 0; margin: 0; border-bottom: 1px solid var(--line); }
  #gameForm .side .tbl { order: 0; flex: 1 1 100%; width: auto; color: var(--text); }   /* eigene Zeile über den Spielern */
  #gameForm .side > span:not(.tbl) { display: none; }   /* das "&" zwischen den Spielern */
  #gameForm .side > input { order: 2; padding: 10px; font-size: 17px; }
  #gameForm .side input:not(.score):not([type=radio]) { flex: 1 1 calc(100% - 80px); min-width: 0; }   /* Name und Kugeln: eine Zeile je Spieler */
  #gameForm input.score { width: 70px; flex: none; }
  #gameForm .row:last-child { margin-top: 12px; }
  #gameForm .row:last-child button { flex: 1; padding: 11px; }
  .match { grid-template-columns: 1fr auto; gap: 4px 8px; }
  .match .tbl { grid-column: 1; grid-row: 1; }
  .match > div:last-child { grid-column: 2; grid-row: 1; }
  .match > div:not(.tbl):not(:last-child) { grid-column: 1 / 3; text-align: left; }
  .match.many .teams { grid-column: 1 / 3; }
  /* zwei Paare/Teams: oben "Spiel N" und die Knöpfe; darunter nebeneinander die Spieler des ersten untereinander,
     das Ergebnis und die Spieler des zweiten untereinander */
  body .match:not(.many) { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  body .match:not(.many) > .tbl { grid-column: 1 / 3; grid-row: 1; }
  body .match:not(.many) > div:last-child { grid-column: 3; grid-row: 1; justify-self: end; }
  body .match:not(.many) > div:nth-child(2) { grid-column: 1; grid-row: 2; }
  body .match:not(.many) > .tot { grid-column: 2; grid-row: 2; text-align: center; }
  body .match:not(.many) > .b { grid-column: 3; grid-row: 2; text-align: right; }
  .match:not(.many) .pl { display: block; }
  .match:not(.many) .amp { display: none; }
  /* Tabellen passen auf den Bildschirm; reicht es nicht, schiebt sich nur die Tabelle seitlich, nicht die Seite */
  th, td { padding: 6px 4px; font-size: 14px; }
  th { font-size: 12px; }
  .card:has(> table), .card:has(> h3 + table) { overflow-x: auto; }
  .item .pw { margin-left: 0; flex-wrap: wrap; }
  .item .pw input { width: 100%; }
  #newForm { flex-wrap: wrap; }
  #newForm input, #newForm button { flex: 1 1 100%; }   /* Name, Passwort und Knopf untereinander */
}
@media print {
  body { display: block; min-height: 0; background: #fff; color: #000; }
  header, .tabs, button, form, .noprint, #msg, #lock, .overlay { display: none !important; }
  .card { background: none; padding: 0; }
  th, td, .match { border-color: #999; }
  th, .muted, .match .tbl, .match small, td.txt, .best small, .best span { color: #333; }
  .best > div { background: none; border-color: #999; }
  .best b { color: #000; }
  th.sort.on::after { color: #000; }
  input.score { border: none; background: none; color: #000; }
  .match .win { color: #000; }
  .match .me { color: #000; text-decoration: underline; }
  h2.print { display: block !important; }
  tbody tr:nth-child(even) td, #matches > .match:nth-child(even) {
    background: #e8e8e8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
h2.print { display: none; }
