:root {
    color-scheme: light;
    --bg: #f4f3ef;
    --surface: #ffffff;
    --surface-2: #f7f6f2;
    --border: #ddd9d0;
    --text: #201f1c;
    --text-secondary: #6b675f;
    --text-muted: #96918685;
    --club-red: #a3181c;
    --club-red-dark: #711013;
    --club-black: #17151a;
    --accent: var(--club-red);
    --danger: #a32d2d;
    --success: #3b6d11;
    --warning: #854f0b;
    --radius: 12px;
    --font-display: 'Anton', Impact, "Segoe UI", sans-serif;
    --font-body: 'Oswald', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 12px 12px 80px; }

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.topbar h1 { font-family: var(--font-display); font-size: 20px; font-weight: 400; letter-spacing: 0.02em; text-transform: uppercase; color: var(--club-red); margin: 0; }
.topbar .club { font-size: 12px; color: var(--text-muted); margin: 0; }
.topbar-title { display: flex; align-items: center; gap: 10px; }
.club-logo { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }
.portal-back { display: block; font-size: 11px; color: var(--text-muted); text-decoration: none; margin-bottom: 4px; }

.pill {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--surface-2);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.pill.admin { background: #faeeda; color: #633806; }

.admin-banner {
    background: #faeeda;
    color: #633806;
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.admin-banner .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}
.btn.primary { border: 2px solid var(--accent); font-weight: 600; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; color: var(--text-secondary); }

/* Startbildschirm: rote Logo-Box + schwarzer Titelbalken + Mannschaftsliste */
.start-screen { display: flex; flex-direction: column; align-items: center; padding: 8px 0; }
.hero-box {
    width: 100%;
    display: flex;
    justify-content: center;
    background: linear-gradient(160deg, var(--club-red) 0%, var(--club-red-dark) 100%);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 28px 20px 22px;
}
.hero-logo { width: 120px; height: 120px; object-fit: contain; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35)); }
.bg-preview {
    width: 100%;
    max-width: 380px;
    display: flex;
    justify-content: center;
    border-radius: var(--radius);
    padding: 28px 20px;
    background-size: cover;
    background-position: center;
}
.hero-title-bar {
    width: 100%;
    background: var(--club-black);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 12px 16px 16px;
    text-align: center;
    margin-bottom: 22px;
}
.hero-title-bar h2 {
    font-family: var(--font-display);
    font-weight: 400;
    color: #fff;
    font-size: 30px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0;
}
.team-list { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 380px; }
.team-row { display: flex; gap: 8px; align-items: stretch; }
.team-row-all { margin-top: 6px; }
.team-tile {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 5px solid var(--club-red);
    border-radius: var(--radius);
    padding: 14px;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text);
    text-decoration: none;
}
.team-tile:hover { border-color: var(--club-red); background: #fdf3f3; }
.team-tile-all { border-left-color: var(--club-black); color: var(--text-secondary); font-weight: 500; }
.team-side-btn {
    flex: 0 0 auto;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
}
.team-side-btn:hover { border-color: var(--club-red); color: var(--club-red); }
.team-side-btn.away:hover { border-color: var(--club-black); color: var(--club-black); }

/* Mannschaftsansicht: Filter + Spielliste */
.view-toggles { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 16px;
    line-height: 1;
    text-decoration: none;
    color: var(--text);
}
.view-toggle-btn.view-toggle-text { font-size: 13px; font-weight: 600; }
.view-toggle-btn.active { border-color: var(--accent); background: var(--surface-2); color: var(--accent); }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.game-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.game-card.home { border-color: var(--club-red); }
.game-card.away { border-color: var(--club-black); }
.game-card.past { opacity: 0.55; }
.game-line { margin: 0 0 5px; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.game-line:last-child { margin-bottom: 0; }
.game-icon { flex: 0 0 auto; color: var(--text-secondary); }
.game-datetime { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.02em; font-size: 16px; }
a.game-datetime { color: var(--text); text-decoration: none; }
a.game-datetime:hover { text-decoration: underline; }
.game-hall { color: var(--text-secondary); }
.game-team { color: var(--text-secondary); }
.game-matchup-box {
    display: block;
    background: var(--surface-2);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: auto;
    text-align: center;
    text-decoration: none;
    color: inherit;
}
a.game-matchup-box.editable {
    border: 1px dashed transparent;
    cursor: pointer;
}
a.game-matchup-box.editable:hover {
    border-color: var(--club-red);
    background: #fdf3f3;
}
.game-home, .game-away { margin: 0; font-size: 16px; font-weight: 600; }
.game-home { margin-bottom: 2px; }
.sva-team { color: var(--club-red); }

footer.appfooter { text-align: center; padding: 20px 0; }
footer.appfooter a { font-size: 11px; color: var(--text-muted); text-decoration: none; margin: 0 8px; }

.sheet-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    align-items: flex-end;
    justify-content: center;
}
.sheet {
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    padding: 16px;
    max-width: 480px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
}
@media (min-width: 640px) {
    .sheet-overlay { align-items: center; }
    .sheet { border-radius: 16px; }
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; gap: 8px; }
.sheet-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.sheet-head p { font-size: 13px; margin: 2px 0 0; color: var(--text-secondary); }
.sheet-close { font-size: 20px; text-decoration: none; color: var(--text-secondary); line-height: 1; padding: 4px 8px; }

.pin-form { display: flex; flex-direction: column; gap: 10px; }
.pin-form .row { display: flex; gap: 8px; }

input[type="text"], input[type="password"], input[type="file"], select, textarea {
    width: 100%;
    font-size: 14px;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}
label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 4px; }

.msg { border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 10px; }
.msg.error { background: #fcebeb; color: #791f1f; }
.msg.success { background: #eaf3de; color: #27500a; }

/* Admin: Mannschaftsverwaltung */
.team-admin-list { display: flex; flex-direction: column; gap: 8px; }
.team-admin-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}
.team-admin-row .move-form { display: flex; gap: 4px; }
.team-admin-row .rename-form { flex: 1; display: flex; gap: 8px; }
.team-admin-row form { margin: 0; }

/* Admin: CSV-Mannschaftszuordnung */
.mapping-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
}
.mapping-info { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.mapping-info span { font-size: 11px; color: var(--text-muted); }
.mapping-info .mapping-sample { font-style: italic; }
.mapping-row select { max-width: 200px; }
