/* Dart-Lounge – modernes Grau (hell) mit umschaltbarem Dark Mode. Alle Farben stehen oben als Variablen. */
:root {
  color-scheme: light;
  --bg: #cfd4da;
  --dots: rgba(31, 35, 40, .07);
  --paper: #e9ecef;
  --surface: #f6f7f9;
  --hover: #dfe3e8;
  --bubble: #d9dee4;
  --line: #bcc3cc;
  --line-strong: #98a2ae;
  --ink: #1d2126;
  --muted: #566070;
  --faint: #8b94a1;
  --green: #1f7a4f;
  --green-deep: #155c3a;
  --green-soft: #c7e3d4;
  --red: #c23a31;
  --red-deep: #8f2a23;
  --red-soft: #ecc9c5;
  --gold: #bf8a14;
  --gold-soft: #ecdcae;
  --gold-text: #6f5008;
  --on-green: #ffffff;
  --header-bg: #20252b;
  --header-ink: #f1f3f5;
  --header-muted: #aab2bc;
  --radius: 16px;
  --display: "Rockwell", "Roboto Slab", "Cambria", Georgia, serif;
  --shadow: 0 1px 0 rgba(0, 0, 0, .06), 0 10px 28px -14px rgba(20, 25, 35, .4);
  --shadow-sm: 0 4px 10px -6px rgba(20, 25, 35, .45);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417;
  --dots: rgba(255, 255, 255, .04);
  --paper: #1c2024;
  --surface: #14171a;
  --hover: #262b31;
  --bubble: #262b31;
  --line: #2c333a;
  --line-strong: #444d58;
  --ink: #e7eaee;
  --muted: #9aa3ae;
  --faint: #6b7480;
  --green: #35a872;
  --green-deep: #237a52;
  --green-soft: rgba(53, 168, 114, .2);
  --red: #e0554b;
  --red-deep: #a5352d;
  --red-soft: rgba(224, 85, 75, .2);
  --gold: #e0b04a;
  --gold-soft: rgba(224, 176, 74, .16);
  --gold-text: #ecc766;
  --on-green: #ffffff;
  --header-bg: #0c0e10;
  --header-ink: #e7eaee;
  --header-muted: #8b94a0;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 12px 30px -14px rgba(0, 0, 0, .8);
  --shadow-sm: 0 4px 10px -6px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dots) 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--ink);
  font: 16px/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0 0 .6em; line-height: 1.2; letter-spacing: .01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }

/* ---------- Kopfzeile ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 22px 15px; background: var(--header-bg); color: var(--header-ink);
  position: sticky; top: 0; z-index: 5; box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .6);
}
.top::after { /* Streifen wie am Rand einer Dartscheibe */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  background: repeating-linear-gradient(90deg, #15171a 0 22px, #e9e4d6 22px 44px, #c23a31 44px 66px, #e9e4d6 66px 88px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 1.35rem; color: var(--header-ink); }
.brand:hover { text-decoration: none; }
.logo { width: 34px; height: 34px; flex: none; }
nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
nav a, nav button {
  color: var(--header-ink); padding: 6px 13px; border-radius: 99px; background: transparent; border: 0; font: inherit; cursor: pointer;
}
nav a:hover, nav button:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
nav a.active { background: var(--header-ink); color: var(--header-bg); font-weight: 600; }
nav .who { color: var(--header-muted); font-size: .9rem; }
nav .theme { font-size: 1.05rem; line-height: 1; padding: 6px 10px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; padding: 24px; max-width: 1500px; margin: 0 auto; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; padding: 14px; } .top { padding: 10px 14px 15px; } }

/* ---------- Karten, Formulare ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

input[type=text], input[type=password], select {
  width: 100%; padding: 10px 12px; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: 10px; font: inherit;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 28%, transparent); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .8rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
label.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); }

.btn {
  display: inline-block; background: var(--green); color: var(--on-green); border: 0; border-radius: 10px; padding: 10px 18px;
  font: inherit; font-weight: 600; cursor: pointer; box-shadow: 0 3px 0 var(--green-deep); transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--green-deep); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line-strong); box-shadow: 0 3px 0 var(--line-strong); }
.btn.ghost:hover { background: var(--hover); filter: none; }
.btn.danger { background: var(--red); color: #fff; box-shadow: 0 3px 0 var(--red-deep); }
.btn.small { padding: 5px 12px; font-size: .85rem; box-shadow: 0 2px 0 var(--green-deep); }
.btn.ghost.small { box-shadow: 0 2px 0 var(--line-strong); }
.btn.danger.small { box-shadow: 0 2px 0 var(--red-deep); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700; letter-spacing: .03em; }
.badge.running { background: var(--green-soft); color: var(--green); }
.badge.finished { background: var(--gold-soft); color: var(--gold-text); }

.tlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tcard {
  display: block; background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--green); border-radius: 14px; padding: 15px 16px;
  color: var(--ink); transition: transform .12s, box-shadow .12s;
}
.tcard.finished { border-top-color: var(--gold); }
.tcard:hover { transform: translateY(-3px); box-shadow: 0 14px 26px -16px rgba(0, 0, 0, .6); text-decoration: none; }
.tcard h3 { margin: 0 0 8px; font-size: 1.15rem; }
.tcard p { margin: 8px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1.5px solid var(--line-strong);
  border-radius: 99px; padding: 3px 4px 3px 13px; font-size: .92rem;
}
.chip.add { cursor: pointer; }
.chip.add:hover { border-color: var(--green); background: var(--green-soft); }
.chip.used { opacity: .4; pointer-events: none; }
.chip button { background: transparent; border: 0; color: var(--muted); cursor: pointer; width: 22px; height: 22px; border-radius: 50%; font-size: 1rem; line-height: 1; }
.chip button:hover { background: var(--red); color: #fff; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; }
tr:hover td { background: var(--hover); }
tr:last-child td { border-bottom: 0; }

.error { color: var(--red); margin: 8px 0 0; min-height: 1.2em; font-weight: 500; }

/* ---------- Turnierbaum ---------- */
.bracket-wrap { overflow-x: auto; padding: 4px 4px 12px; }
.bracket { display: flex; gap: 28px; min-width: min-content; align-items: stretch; }
.round { display: flex; flex-direction: column; min-width: 220px; flex: 1; }
.round h4 { margin: 0 0 10px; text-align: center; font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-family: inherit; }
.round h4 b { display: block; font-family: var(--display); color: var(--ink); font-size: 1.1rem; text-transform: none; letter-spacing: 0; }
.col { display: flex; flex-direction: column; flex: 1; }
.mwrap { flex: 1; display: flex; align-items: center; padding: 8px 0; min-height: 86px; }
.pair { flex: 1; display: flex; flex-direction: column; position: relative; }
.pair::after { /* Klammer, die zwei Spiele zusammenführt */
  content: ""; position: absolute; right: -14px; top: 25%; bottom: 25%; width: 14px;
  border: 2px solid var(--line-strong); border-left: 0; border-radius: 0 8px 8px 0;
}
.pair::before { content: ""; position: absolute; right: -28px; top: 50%; width: 14px; border-top: 2px solid var(--line-strong); transform: translateY(-1px); }

.match { position: relative; width: 100%; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.round:last-child .match { border-color: var(--gold); }
.slot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 10px 14px; background: transparent; color: var(--ink); border: 0; font: inherit; text-align: left;
  border-left: 5px solid transparent;
}
.slot + .slot { border-top: 1px solid var(--line); }
button.slot { cursor: pointer; }
button.slot:hover { background: var(--green-soft); }
.slot.empty { color: var(--faint); font-style: italic; }
.slot.win { border-left-color: var(--green); background: var(--green-soft); font-weight: 700; color: var(--ink); }
.slot.lose { border-left-color: var(--red-soft); color: var(--faint); }
.undo { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: var(--surface); border: 1px solid var(--line-strong); color: var(--muted); border-radius: 8px; font-size: .8rem; padding: 2px 7px; cursor: pointer; }
.undo:hover { color: var(--green); border-color: var(--green); }

.champion {
  text-align: center; padding: 26px 20px; margin-bottom: 18px; border-radius: var(--radius);
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--gold) 28%, var(--paper)), var(--gold-soft) 75%); border: 1.5px solid var(--gold); box-shadow: var(--shadow);
  color: var(--gold-text);
}
.champion .name { font-family: var(--display); font-size: 2.2rem; font-weight: 700; color: var(--ink); }

/* ---------- Chat ---------- */
.chat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; height: calc(100vh - 120px); position: sticky; top: 90px; overflow: hidden; }
@media (max-width: 900px) { .chat { height: 420px; position: static; } }
.chat header { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; background: var(--hover); }
.chat header h2 { margin: 0; }
.chat .online { color: var(--green); font-size: .8rem; font-weight: 600; }
.msgs { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { background: var(--bubble); border-radius: 4px 14px 14px 14px; padding: 7px 12px; align-self: flex-start; max-width: 92%; }
.msg .meta { font-size: .72rem; color: var(--muted); }
.msg .meta b { color: var(--green); font-size: .85rem; }
.msg .meta button { background: none; border: 0; color: var(--muted); cursor: pointer; }
.msg .meta button:hover { color: var(--red); }
.msg .text { overflow-wrap: anywhere; }
.chat form { padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; background: var(--hover); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; padding: 11px 20px; border-radius: 12px; z-index: 20; max-width: 90vw; box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .6); }
.toast.ok { background: var(--green-deep); }

/* ---------- Spielerbilder, Archiv ---------- */
.hidden { display: none; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  background: var(--green); color: var(--on-green); font-family: var(--display); font-weight: 700;
  border: 2px solid var(--gold);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 28px; height: 28px; font-size: .8rem; border-width: 1.5px; }
.avatar.xl { width: 130px; height: 130px; font-size: 3.2rem; border-width: 5px; margin-bottom: 10px; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .6); }
.btn.small input { display: none; }
label.btn { display: inline-block; }
.card.archived { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-text); }
.archived-badge { background: var(--gold-soft); color: var(--gold-text); margin-left: 8px; }
