/* Gemeinsames Styling fuer Benutzer- und Admin-Seite. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e4e6eb;
  --gold: #d4a017;
  --danger: #d64545;
  --c1: #e05252;
  --c2: #4d7fd6;
  --c3: #3fa66a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1e2126;
    --text: #f0f1f3;
    --muted: #9aa1ab;
    --line: #2d3138;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px 14px 48px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 600px; margin: 0 auto; }

h1 { font-size: 22px; margin: 4px 0 2px; }
h2 {
  font-size: 14px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 28px 0 10px;
}
.sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.empty {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; color: var(--muted); text-align: center;
}

/* --- Team-Ranking (Benutzerseite) --- */
.team {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 10px;
}
.team.lead { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.rank {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #fff;
}
.name {
  flex: 1; font-size: 17px; font-weight: 600; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pts { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- Tabelle --- */
.tablecard {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); }
thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.gname { font-weight: 500; }
tbody tr:last-child td { border-bottom: none; }
tfoot td { border-top: 1px solid var(--line); border-bottom: none; font-weight: 700; }

/* --- Formulare / Buttons (Adminseite) --- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 10px;
}
.row { display: flex; gap: 8px; align-items: center; }
.row + .row { margin-top: 10px; }

input[type="text"], input[type="number"] {
  flex: 1; min-width: 0; width: 100%;
  padding: 10px 12px; font-size: 16px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
}
input[type="number"] { flex: none; width: 78px; text-align: right; }
input:focus { outline: 2px solid var(--c2); outline-offset: 1px; }

button {
  flex: none; padding: 10px 14px; font-size: 15px; font-weight: 600;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--c2); border-color: var(--c2); color: #fff; }
button.danger { color: var(--danger); }
button.icon { padding: 10px 12px; line-height: 1; }

.swatch { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.gamehead { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.scorerow { display: flex; gap: 8px; align-items: center; }
.scorerow + .scorerow { margin-top: 8px; }
.scorerow + .row { margin-top: 14px; }
.scorerow .label {
  flex: 1; min-width: 0; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav { display: flex; gap: 14px; font-size: 14px; margin-bottom: 16px; }
.nav a { color: var(--c2); text-decoration: none; }

/* Kurze Rueckmeldung nach dem Speichern */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }

/* --- Details-Knopf und Ergebniszeile (Benutzerseite) --- */
.detailbtn {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 0; margin: 0;
  background: none; border: none; border-radius: 6px;
  font: inherit; font-weight: 500; color: var(--text);
  text-align: left; cursor: pointer;
}
.detailbtn:hover { border: none; color: var(--c2); }
.detailbtn:focus-visible { outline: 2px solid var(--c2); outline-offset: 3px; }
.detailbtn .chev {
  flex: none; color: var(--muted); font-size: 18px; line-height: 1;
  transition: transform .15s;
}
.detailbtn[aria-expanded="true"] .chev { transform: rotate(90deg); }

tr.detail td {
  padding-top: 4px; padding-bottom: 12px;
  font-size: 13px; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
tr.detail td.gname { padding-left: 30px; font-weight: 400; }

/* Spielzeile und ihre aufgeklappte Ergebniszeile als ein Block: keine Linie dazwischen,
   und am Ende der Tabelle keine doppelte Linie zur Gesamtzeile. */
tbody tr:has(+ tr.detail:not([hidden])) td { border-bottom: none; }
tbody tr:nth-last-child(2) td { border-bottom: none; }

.legend {
  margin: 10px 2px 0;
  font-size: 12.5px; line-height: 1.5; color: var(--muted);
}

/* --- Wertung neben dem Ergebnisfeld (Adminseite) --- */
.award {
  flex: none; min-width: 42px; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-align: center; font-variant-numeric: tabular-nums;
}

/* Auf schmalen Displays enger setzen, damit alle drei Teams ohne Scrollen passen. */
@media (max-width: 430px) {
  th, td { padding: 10px 8px; font-size: 14px; }
  thead th.num { white-space: normal; }
  td.gname, th.gname { max-width: 120px; }
}
