:root {
  --bg: #14172e; --card: #22274b; --card2: #2b3160; --line: #3b4180; --ink: #fff; --dim: #9aa1d4;
  --red: #e20613; --yellow: #ffde08; --green: #43b047; --blue: #049cd8; --orange: #ff9f00;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--ink); min-height: 100vh; }
a { color: var(--yellow); }
header { background: #0b0d1f; padding: 14px 16px 10px; text-align: center; }
header .logo { display: block; width: min(460px, 86vw); height: auto; margin: 0 auto 6px; }
header small { color: var(--dim); }
header small a { color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
main.full { max-width: none; padding: 16px 0 0; }
main.full .viewport { border-radius: 0; }
.adminbar { background: var(--yellow); color: #222; padding: 8px 16px; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; font-size: .9rem; font-weight: 600; }
.adminbar a, .adminbar button { color: #222; background: none; border: 0; font: inherit; text-decoration: underline; cursor: pointer; }

nav.tabs { display: flex; gap: 8px; justify-content: center; margin: 0 0 16px; flex-wrap: wrap; }
nav.tabs button, .btn { background: var(--card); color: var(--ink); border: 2px solid transparent; border-radius: 999px; padding: 8px 18px; font-weight: 700; font-size: .95rem; cursor: pointer; font-family: inherit; }
nav.tabs button.on, .btn.primary { background: var(--yellow); color: #222; }
.btn.danger { background: var(--red); }
.btn.small { padding: 5px 12px; font-size: .85rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.panel .btn:not(.primary):not(.danger) { background: var(--card2); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.card { background: var(--card); border-radius: 14px; padding: 14px; overflow-x: auto; }
.card h3 { margin-bottom: 8px; }
h4.sub { margin: 14px 0 6px; color: var(--dim); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.badge { background: var(--green); color: #fff; font-size: .65rem; padding: 2px 8px; border-radius: 99px; vertical-align: middle; }

table.st { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.st th { color: var(--dim); font-weight: 600; text-align: right; padding: 4px 6px; white-space: nowrap; }
table.st td { text-align: right; padding: 6px; border-top: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
table.st th:nth-child(2), table.st td.nm { text-align: left; width: 100%; }
table.st th:first-child, table.st td:first-child { text-align: center; color: var(--dim); }
table.st tr.adv td { background: rgba(67,176,71,.2); }
table.st tr.adv td:first-child { color: var(--green); font-weight: 800; }
table.st tr.adv2 td { background: rgba(255,159,0,.18); }
table.st tr.adv2 td:first-child { color: var(--orange); font-weight: 800; }
td.tot { font-weight: 800; color: var(--yellow); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.dot.adv { background: var(--green); } .dot.adv2 { background: var(--orange); }

.match { background: var(--card2); border-radius: 10px; padding: 8px 10px; margin-top: 6px; border-left: 4px solid var(--blue); }
.match.done { border-left-color: var(--green); }
.match.editable, .bm.editable { cursor: pointer; }
.match.editable:hover { outline: 2px solid var(--yellow); }
.mhead { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--dim); margin-bottom: 4px; }
.mhead b { color: var(--ink); }
.mplayers { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .9rem; }
.mplayers b { color: var(--yellow); }

table.sched { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.sched th { text-align: left; color: var(--dim); font-weight: 600; padding: 6px; }
table.sched td { padding: 8px 6px; border-top: 1px solid rgba(255,255,255,.08); vertical-align: top; }
table.sched tr.done td { opacity: .5; }
td.tm { font-weight: 800; color: var(--yellow); white-space: nowrap; }
.chip { display: inline-block; background: var(--card2); border-radius: 99px; padding: 2px 9px; margin: 1px 0; font-size: .85rem; }
.chip.me { background: var(--yellow); color: #222; font-weight: 700; }
.search { max-width: 360px; margin: 0 auto 14px; display: block; }

/* Turnierbaum */
.viewport { position: relative; height: min(72vh, 720px); background: radial-gradient(circle at 1px 1px, rgba(255,255,255,.07) 1px, transparent 0) 0 0 / 22px 22px, #0f1226;
  border-radius: 16px; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.viewport:active { cursor: grabbing; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
svg.lines { position: absolute; left: 0; top: 0; overflow: visible; }
svg.lines path { fill: none; stroke: var(--line); stroke-width: 2; }
.rh { position: absolute; top: 0; text-align: center; color: var(--yellow); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .85rem; }
.bm { position: absolute; background: var(--card); border-radius: 10px; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.35); border: 2px solid transparent; }
.bm.done { border-color: rgba(67,176,71,.5); }
.bm.editable:hover { border-color: var(--yellow); }
.bh { height: 26px; display: flex; justify-content: space-between; align-items: center; padding: 0 8px; font-size: .7rem; color: var(--dim); background: var(--card2); }
.bp { height: 26px; display: flex; justify-content: space-between; align-items: center; padding: 0 8px; font-size: .85rem; border-top: 1px solid rgba(255,255,255,.06); }
.bp span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp b { min-width: 22px; text-align: right; color: var(--yellow); }
.bp.win { background: rgba(67,176,71,.22); font-weight: 700; }
.bp.out { opacity: .5; }
.bp.pend, .bp.bye { color: var(--dim); font-style: italic; }
.vphint { position: absolute; left: 12px; bottom: 10px; right: 64px; font-size: .75rem; color: var(--dim); pointer-events: none; }
.zoomctl { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.zoomctl button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--card2); color: var(--ink); font-size: 1.2rem; font-weight: 700; cursor: pointer; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin-bottom: 18px; text-align: center; font-weight: 800; }
.podium > div { border-radius: 14px 14px 4px 4px; padding: 12px 10px; min-width: 100px; flex: 0 1 200px; color: #222; }
.podium span { display: block; font-size: 1.8rem; }
.podium .p1 { background: linear-gradient(#fff27a, var(--yellow)); padding-bottom: 34px; font-size: 1.1rem; }
.podium .p2 { background: linear-gradient(#eef1f6, #c3c9d6); padding-bottom: 20px; }
.podium .p3 { background: linear-gradient(#f3c08b, #d98c4a); }

.hint, .empty { color: var(--dim); text-align: center; margin: 12px 0; font-size: .9rem; }
.empty { padding: 40px 0; font-size: 1.1rem; }
.dim { color: var(--dim); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.mbox { background: var(--card); border-radius: 16px; padding: 18px; width: 100%; max-width: 680px; max-height: 90vh; overflow: auto; }
.mbox .btn:not(.primary) { background: var(--card2); }
.mbox h3 { color: var(--yellow); margin-bottom: 6px; }
.mbox .hint { text-align: left; }
.edgrid { overflow-x: auto; }
table.st.edit td, table.st.edit th { text-align: center; }
table.st.edit td.nm, table.st.edit th:first-child { text-align: left; color: var(--ink); }
.score { width: 72px; min-width: 64px; text-align: center; padding: 8px 4px; font-size: 1rem; }
.winrow { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.winrow span { flex: 1; font-weight: 700; }
.winrow input { width: 60px; text-align: center; font-size: 1.2rem; font-weight: 800; }
.winrow button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--card2); color: var(--ink); font-size: 1.3rem; cursor: pointer; }

/* Admin */
.panel { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.panel h2 { margin-bottom: 12px; font-size: 1.1rem; color: var(--yellow); }
.panel h3 { margin: 16px 0 10px; font-size: .95rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--dim); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: .9rem; }
input, select, textarea { background: #0f1226; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; width: 100%; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--green); flex: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.info { background: var(--card2); border-radius: 10px; padding: 10px 12px; font-size: .9rem; line-height: 1.5; margin-top: 12px; }
.warn { background: rgba(255,159,0,.18); border: 1px solid var(--orange); border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 10px 0; }
.plist { margin-top: 12px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid rgba(255,255,255,.06); }
.prow input[type=text] { flex: 1; padding: 6px 8px; }
.grip { cursor: grab; color: var(--dim); font-size: 1.3rem; padding: 4px 6px; touch-action: none; user-select: none; -webkit-user-select: none; line-height: 1; }
.prow .rank { width: 52px; flex: none; text-align: center; padding: 6px 2px; font-weight: 700; color: var(--yellow); -moz-appearance: textfield; }
.prow .rank::-webkit-inner-spin-button { display: none; }
.prow.dragging { background: var(--card2); box-shadow: 0 4px 14px rgba(0,0,0,.4); border-radius: 8px; position: relative; z-index: 2; }
.prow.absent input[type=text] { opacity: .45; text-decoration: line-through; }
.prow button { background: none; border: 0; color: var(--dim); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
table.rounds { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.rounds td, table.rounds th { padding: 6px; text-align: left; }
table.rounds th { color: var(--dim); font-weight: 600; }
#status { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); background: #000d; padding: 8px 16px; border-radius: 99px; font-size: .85rem; z-index: 60; }
#status.err { background: var(--red); }
.login { max-width: 340px; margin: 60px auto; }
footer { text-align: center; color: var(--dim); font-size: .8rem; padding: 16px; }

/* Sieger-Icon */
img.champ { height: 1.1em; width: auto; vertical-align: -0.2em; margin-left: 5px; }
.champbtn { background: none; border: 2px solid transparent; border-radius: 8px; padding: 3px 5px; cursor: pointer; opacity: .3; filter: grayscale(1); }
.champbtn img { height: 22px; width: auto; display: block; pointer-events: none; }
.champbtn.on { opacity: 1; filter: none; border-color: var(--yellow); }

/* Zeitplan verschieben */
table.sched tbody + tbody tr:first-child td { border-top: 2px solid var(--line); }
tr.dragging td { background: var(--card2); }

/* Gruppen bearbeiten */
.pl { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; }
.mv { width: auto; max-width: 55%; padding: 4px 6px; font-size: .85rem; }
details.panel > summary { cursor: pointer; }
details.panel[open] > summary { margin-bottom: 8px; }
#groupEdit .card { background: var(--card2); }
