:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #15803d;
    --success-bg: #dcfce7;
    --error: #b91c1c;
    --error-bg: #fee2e2;
    --border: #e5e7eb;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-logout { margin: 0; }

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
}

footer {
    text-align: center;
    color: var(--muted);
    padding: 2rem 1rem;
}

h1 { font-size: 2rem; margin: 0 0 0.5rem; }
h2 { margin: 1.5rem 0 0.75rem; }

.lead { color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }

a { color: var(--primary); }

.flashes { max-width: 900px; margin: 1rem auto 0; padding: 0 1.5rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--error-bg); color: var(--error); }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.card .meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 0; }

section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.singles-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}
.singles-list li {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.team-list { list-style: none; padding: 0; margin: 0; }
.team {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}
.team-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.team-header .count { color: var(--muted); font-size: 0.9rem; }
.member-list {
    list-style: disc;
    margin: 0 0 0.5rem 1.25rem;
    padding: 0;
}
.member-list li { padding: 0.15rem 0; }

.join-form, .stacked, .score-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.stacked { flex-direction: column; max-width: 320px; }
.stacked label { display: flex; flex-direction: column; font-size: 0.9rem; color: var(--muted); }

input[type="text"], input[type="number"] {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.6rem;
    font-size: 1rem;
    font-family: inherit;
}

input[type="number"] { width: 4rem; }

button {
    border: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.85rem;
    font-size: 0.95rem;
    cursor: pointer;
    color: var(--text);
}

button:hover { background: var(--bg); }
button.primary { background: var(--primary); color: white; border-color: var(--primary); }
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.danger { background: var(--error); color: white; border-color: var(--error); }
button.link-btn { background: none; border: 0; color: var(--muted); padding: 0; text-decoration: underline; cursor: pointer; font-size: 0.85rem; }
button.link-btn:hover { color: var(--error); background: none; }

form.inline { display: inline; }

.badge {
    background: var(--success-bg);
    color: var(--success);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    white-space: nowrap;
}
.badge-muted {
    background: var(--border);
    color: var(--muted);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

table th, table td {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}
table th { font-weight: 600; color: var(--muted); }
table.matches td.vs { color: var(--muted); text-align: center; width: 1.5rem; }
table.ranking td:first-child { font-weight: 700; color: var(--muted); width: 2rem; }

.danger-zone summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.9rem;
}

.callout {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}
.callout-running { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.callout-champion { background: #fef3c7; border-color: #fbbf24; color: #92400e; font-size: 1.1rem; }

.admin-section { border-style: dashed; background: var(--bg); }

.match-list { list-style: none; padding: 0; margin: 0; }
.match {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.match:last-child { border-bottom: 0; }
.match-done { background: #f9fafb; }
.match-time { color: var(--muted); font-size: 0.9rem; }
.match-teams { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.match-teams .vs { color: var(--muted); font-size: 0.85rem; }
.team-name.winner, .winner { font-weight: 700; color: var(--success); }

table.schedule td { vertical-align: top; }
table.schedule .small { font-size: 0.8rem; }
table.schedule .vs { color: var(--muted); margin: 0 0.25rem; font-size: 0.85rem; }
table.schedule .winner { font-weight: 700; color: var(--success); }

/* --- "Jetzt läuft / als nächstes" --- */
.now-section { margin-top: 0.5rem; }
.now-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}
.now-venue {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
}
.now-venue-head {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.now-slot { padding: 0.5rem 0; border-top: 1px solid var(--border); }
.now-slot:first-of-type { border-top: 0; padding-top: 0; }
.now-time { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.now-live .now-time { color: #b91c1c; }
.now-overdue .now-time { color: #b45309; }
.now-teams { font-weight: 600; margin: 0.15rem 0; }
.now-teams .vs { color: var(--muted); font-weight: 400; font-size: 0.85rem; margin: 0 0.25rem; }
.now-meta { font-size: 0.85rem; }
.now-empty { color: var(--muted); font-size: 0.9rem; }
.live-dot { color: #dc2626; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

/* --- Bracket --- */
.bracket-section { padding-bottom: 1.5rem; }
.bracket {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    padding: 0.25rem 0.25rem 0.75rem;
}
.bracket-round {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    flex: 0 0 200px;
}
.bracket-round-header {
    text-align: center;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}
.bracket-matches {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1;
    gap: 0.5rem;
}
.bracket-match {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
}
.bracket-match.is-bye { opacity: 0.7; background: var(--bg); }
.bracket-match.is-waiting { background: var(--bg); border-style: dashed; }
.bracket-match.is-done { border-color: #d1d5db; }
.bracket-time {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.bracket-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
}
.bracket-team + .bracket-team { border-top: 1px dashed var(--border); }
.bracket-team .t-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bracket-team .t-score { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 1.5rem; text-align: right; }
.bracket-team.winner { font-weight: 700; color: var(--success); }
.bracket-team.winner .t-score { color: var(--success); }
.bracket-score-form {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border);
}
.bracket-score-form input[type="number"] {
    width: 2.75rem;
    padding: 0.25rem;
    font-size: 0.85rem;
}
.bracket-score-form button {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    margin-left: auto;
}

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-main {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 360px;
    width: 100%;
    text-align: center;
}
.login-main h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.login-main .lead { margin-bottom: 1.5rem; }
.login-form { display: flex; flex-direction: column; gap: 0.75rem; }
.login-form input { font-size: 1rem; }
