:root {
    --primary: #116035;
    --primary-dark: #0a4526;
    --secondary: #FFDD00;
    --accent: #E76F51;
    --ink: #111111;
    --white: #FDFDFD;
    --grey: #f1f5f9;
    --grey-mid: #e2e8f0;
    --grey-dark: #64748b;
    --text-muted: #64748b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --yellow-soft: #fefce8;
    --yellow-border: #fef08a;
    --red-soft: #fef2f2;
    --red-border: #fecaca;
    --red-text: #991b1b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--white);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* ─── HEADER ─────────────────────────────────── */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 8%;
    background: var(--white);
    border-bottom: 2px solid var(--grey);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    cursor: pointer;
    text-decoration: none;
    color: var(--ink);
}
.logo img { height: 46px; }
.logo span { color: var(--primary); }

.nav-actions { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }

/* ─── BUTTONS ─────────────────────────────────── */
.btn {
    padding: 0.65rem 1.3rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--grey-mid);
    background: white;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.18s ease;
    color: var(--ink);
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
    line-height: 1;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(17,96,53,0.3);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--ink);
    border-color: var(--secondary);
}
.btn-secondary:hover {
    background: #f0d000;
    border-color: #f0d000;
    transform: translateY(-1px);
}

.btn-danger {
    background: white;
    color: #dc2626;
    border-color: #fca5a5;
}
.btn-danger:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

.btn-full { width: 100%; justify-content: center; }

/* ─── ROUND NAV ───────────────────────────────── */
.round-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    background: var(--grey);
    padding: 0.4rem;
    margin: 0.9rem auto 0.5rem auto;
    max-width: 95%;
    width: max-content;
    border-radius: 18px;
    gap: 0.3rem;
    border: 1px solid var(--grey-mid);
}

.round-tab {
    padding: 0.7rem 1.4rem;
    border-radius: 14px;
    border: none;
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    background: transparent;
    transition: all 0.18s;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
}
.round-tab:hover { color: var(--ink); }
.round-tab.active {
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(17,96,53,0.25);
    color: white;
}

/* ─── ROUND DATE ──────────────────────────────── */
.round-date-info {
    text-align: center;
    font-weight: 700;
    color: var(--primary);
    margin: 1rem 0 2rem;
    font-size: 1rem;
}

/* ─── CONTENT ─────────────────────────────────── */
.content {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ─── MODULE HEADER CARD ─────────────────────── */
.module-head-wrap {
    margin-top: 2rem;
}

.module-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin-bottom: 2.2rem;
    padding: 1.2rem 1.3rem;
    border: 1px solid var(--grey-mid);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: var(--shadow-sm);
}

.module-title {
    font-size: 1.85rem;
    font-weight: 800;
    margin-bottom: 0.45rem;
    letter-spacing: -0.4px;
    line-height: 1.08;
}

.module-title span {
    color: var(--primary);
}

.module-subtitle {
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    color: var(--grey-dark);
    font-size: 0.9rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
}

.module-actions {
    gap: 0.55rem;
}

.module-action-btn {
    min-width: 122px;
    justify-content: center;
}

/* ─── MATCH GRID ──────────────────────────────── */
#roundView {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
    align-items: start;
}

.group-header {
    grid-column: 1 / -1;
    background: var(--secondary);
    color: var(--ink);
    padding: 0.55rem 1.4rem;
    border-radius: 8px;
    margin: 2rem 0 0.5rem;
    font-size: 0.88rem;
    font-weight: 800;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.group-header:first-child { margin-top: 0; }
.group-header span {
    opacity: 0.65;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.match-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 1.3rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 7px solid var(--grey-mid);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s;
}
.match-card:hover { transform: scale(1.015); box-shadow: var(--shadow-md); }
.match-card.finished { border-left-color: var(--primary); }
.match-card.pending  { border-left-color: var(--secondary); }
.match-card.freilos  { border-left-color: var(--accent); opacity: 0.85; }

.match-card a.vs-badge {
    text-decoration: none;
    color: var(--ink);
    transition: all 0.2s;
    display: inline-block;
}
.match-card a.vs-badge:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.player-info { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.player-name { font-size: 1.1rem; font-weight: 700; }
.player-name.winner { color: var(--primary); }
.player-stats { font-size: 0.82rem; color: var(--grey-dark); font-weight: 600; }

.stat-tag-s { color: #16a34a; font-weight: 800; }
.stat-tag-n { color: #dc2626; font-weight: 800; }

.score-display {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--ink);
    padding: 0 1.2rem;
    min-width: 110px;
    text-align: center;
    line-height: 1.2;
}

.vs-badge {
    background: var(--grey);
    padding: 0.35rem 0.7rem;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

/* ─── EMPTY STATE ─────────────────────────────── */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state h3 { font-size: 1.4rem; color: var(--ink); margin-bottom: 0.75rem; }
.empty-state p { max-width: 400px; margin: 0 auto 1.5rem; line-height: 1.6; }

/* ─── HERO BANNER ─────────────────────────────── */
.hero-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    text-align: center;
    padding: 3.5rem 2rem;
    margin-bottom: 2.5rem;
}
.hero-banner h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; }
.hero-banner p { font-size: 1.1rem; opacity: 0.85; margin-bottom: 1.8rem; }

/* ─── ANMELDUNG / FORMS ───────────────────────── */
.page-container {
    max-width: 560px;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

.page-card {
    background: white;
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
}

.page-card h1 {
    font-size: 1.7rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
}
.page-card .subtitle {
    color: var(--grey-dark);
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.form-group { margin-bottom: 1.4rem; }
.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.45rem;
    font-size: 0.95rem;
}
.form-group .optional {
    font-weight: 400;
    color: var(--grey-dark);
    font-size: 0.85rem;
    margin-left: 0.3rem;
}
.form-group input {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 2px solid var(--grey-mid);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    color: var(--ink);
    background: var(--white);
    transition: border-color 0.18s, box-shadow 0.18s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(17,96,53,0.1);
}
.form-group input.error { border-color: #dc2626; }

.alert {
    padding: 1rem 1.2rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.5;
}
.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}
.alert-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #86efac;
}
.alert-info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

/* ─── MODAL (Spieler / Info) ──────────────────── */
.players-modal {
    margin: auto;
    border: none;
    border-radius: 24px;
    width: 92%;
    max-width: 580px;
    padding: 0;
    box-shadow: 0 10px 50px rgba(0,0,0,0.2);
}
.players-modal::backdrop {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
}

.modal-inner {
    padding: 2.5rem;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-inner h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.5rem; }

.close-btn {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    border: none;
    background: var(--grey);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--grey-dark);
    transition: background 0.18s;
}
.close-btn:hover { background: var(--grey-mid); color: var(--ink); }

.players-list { display: flex; flex-direction: column; gap: 0; }
.player-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--grey);
    gap: 1rem;
}
.player-list-item:last-child { border-bottom: none; }
.player-rank { font-weight: 800; color: var(--primary); width: 28px; }

.stat-badge {
    background: var(--grey);
    padding: 0.25rem 0.7rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.88rem;
    border: 1px solid var(--grey-mid);
    white-space: nowrap;
}

/* ─── INFO MODAL ──────────────────────────────── */
.info-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.info-modal.open { display: flex; }

.modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: 24px;
    width: 95%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.info-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    text-align: center;
}
.info-header h2 { font-size: 1.5rem; font-weight: 800; }

.info-body section { margin-bottom: 1.8rem; }
.info-body h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-weight: 800;
}
.info-body p { line-height: 1.6; color: #444; font-size: 0.95rem; margin-bottom: 0.5rem; }
.info-body ul { list-style: none; padding-left: 0.5rem; }
.info-body li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
    line-height: 1.5;
    color: #444;
    font-size: 0.95rem;
}
.info-body li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 800;
}

/* ─── STATUS BANNER ───────────────────────────── */
.status-banner {
    background: linear-gradient(135deg, var(--secondary) 0%, #f0d000 100%);
    color: var(--ink);
    padding: 0.9rem 1.5rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
}

/* ─── ADMIN EXTRAS (Interne Rangliste) ────────── */
.admin-main .admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 900px) {
    .admin-main .admin-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1400px) {
    .admin-main .admin-grid.triple {
        grid-template-columns: repeat(3, 1fr);
    }
}

.admin-main .admin-card h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-main .admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.admin-main .admin-table th {
    text-align: left;
    padding: 0.7rem 1rem;
    background: var(--grey);
    font-weight: 800;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.admin-main .admin-table th:first-child { border-radius: 8px 0 0 8px; }
.admin-main .admin-table th:last-child  { border-radius: 0 8px 8px 0; }
.admin-main .admin-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--grey);
    vertical-align: middle;
}
.admin-main .admin-table tr:last-child td { border-bottom: none; }
.admin-main .admin-table tr:hover td { background: #fafafa; }

.admin-main .badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}
.admin-main .badge-green { background: #dcfce7; color: #16a34a; }
.admin-main .badge-red   { background: #fee2e2; color: #dc2626; }
.admin-main .badge-grey  { background: var(--grey); color: var(--text-muted); }

.admin-main .admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-main .stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.admin-main .stat-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
}
.admin-main .stat-card .stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.3rem;
}
.admin-main .stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.admin-main .draggable-player {
    cursor: grab;
    padding: 0.5rem 0.8rem;
    background: var(--grey);
    border: 1px solid var(--grey-mid);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
    user-select: none;
    width: 100%;
    margin-bottom: 0.4rem;
}
.admin-main .draggable-player:hover {
    background: var(--grey-mid);
    border-color: var(--grey-dark);
}
.admin-main .draggable-player:active {
    cursor: grabbing;
    transform: scale(0.98);
}
.admin-main .draggable-player.dragging {
    opacity: 0.5;
    background: var(--primary);
    color: white;
}

.admin-main .drop-zone {
    border: 2px dashed transparent;
    border-radius: var(--radius-sm);
    transition: border-color 0.2s, background 0.2s;
}
.admin-main .drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(17, 96, 53, 0.05);
}

.admin-main .has-conflict {
    background: var(--red-soft) !important;
    border-color: var(--red-border) !important;
}
.admin-main .conflict-warning {
    display: none;
    color: var(--red-text);
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 0.4rem;
    align-items: center;
    gap: 4px;
}
.admin-main .has-conflict .conflict-warning {
    display: flex;
}

.admin-main .score-input {
    width: 65px;
    padding: 0.6rem 0.5rem;
    border: 2px solid var(--grey-mid);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 800;
    text-align: center;
    font-family: 'Outfit', sans-serif;
    transition: border-color 0.18s;
}
.admin-main .score-input:focus {
    outline: none;
    border-color: var(--primary);
}
.admin-main .score-colon {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.admin-main .round-status-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}
.admin-main .round-status-offen     { background: #eff6ff; color: #1d4ed8; border: 1px solid #93c5fd; }
.admin-main .round-status-aktiv     { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }
.admin-main .round-status-closed    { background: var(--grey); color: var(--text-muted); border: 1px solid var(--grey-mid); }

/* ─── RESPONSIVE ──────────────────────────────── */
@media (max-width: 850px) {
    .main-header { padding: 1.1rem 5%; }
}

@media (max-width: 650px) {
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 1.5rem;
    }
    .nav-actions { width: 100%; justify-content: flex-start; }
    
    #roundView { grid-template-columns: 1fr; }

    .match-card {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    .player-info[style*="text-align: right"] { text-align: center !important; }
    .score-display {
        border-top: 1px solid var(--grey-mid);
        border-bottom: 1px solid var(--grey-mid);
        padding: 0.5rem 0;
        width: 100%;
    }
    
    .page-card { padding: 1.8rem 1.5rem; }
    .hero-banner h1 { font-size: 1.5rem; }
    .hero-banner { padding: 2.5rem 1.5rem; }

    .module-head {
        padding: 1rem;
        border-radius: 10px;
    }

    .module-title {
        font-size: 1.45rem;
        margin-bottom: 0.4rem;
    }

    .module-subtitle {
        font-size: 0.83rem;
        padding: 0.25rem 0.55rem;
    }

    .module-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 0.5rem;
    }

    .module-action-btn {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 400px) {
    .round-nav { width: 95%; }
    .round-tab { padding: 0.6rem 0.9rem; font-size: 0.82rem; }
}
