/* ============================================================
   Bezirkspokal – Frontend Styles v2
   Responsiver KO-Baum – Namen werden nie abgeschnitten
   ============================================================ */

:root {
    --bp-primary:   #1a3a5c;
    --bp-secondary: #c8a84b;
    --bp-green:     #2e7d32;
    --bp-border:    #ddd;
    --bp-text:      #333;
    --bp-radius:    8px;
    --bp-shadow:    0 2px 8px rgba(0,0,0,0.10);
    --bp-match-min: 190px;
    --bp-match-max: 260px;
    --bp-col-gap:   32px;
}

/* ---- Basis ---- */
.bp-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--bp-text);
    box-sizing: border-box;
}
.bp-wrap *, .bp-wrap *::before, .bp-wrap *::after { box-sizing: inherit; }

/* ---- Event-Header ---- */
.bp-event-header {
    background: linear-gradient(135deg, var(--bp-primary) 0%, #2a5080 100%);
    color: #fff; border-radius: var(--bp-radius); padding: 24px 20px 20px;
    text-align: center; margin-bottom: 20px; box-shadow: var(--bp-shadow);
}
.bp-logo-row { margin-bottom: 8px; }
.bp-org   { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.bp-sub   { display: block; font-size: 14px; font-weight: 600; }
.bp-title { font-size: clamp(20px, 4vw, 34px); margin: 10px 0 8px; color: var(--bp-secondary); }
.bp-meta  { font-size: 15px; opacity: .9; margin: 0; }
.bp-icon  { margin-right: 3px; }

/* ---- Event-Select ---- */
.bp-event-select-wrap { margin-bottom: 16px; }
.bp-event-select-wrap select { padding: 6px 10px; border-radius: 4px; border: 1px solid var(--bp-border); font-size: 14px; }

/* ---- Tabs ---- */
.bp-tabs {
    display: flex; flex-wrap: wrap; gap: 6px;
    border-bottom: 2px solid var(--bp-primary);
}
.bp-tab {
    background: #f5f5f5; border: 1px solid var(--bp-border); border-bottom: none;
    padding: 10px 18px; cursor: pointer; border-radius: 6px 6px 0 0;
    font-size: 14px; font-weight: 600; color: var(--bp-text);
    transition: background .2s, color .2s; white-space: nowrap;
}
.bp-tab:hover  { background: #e0e0e0; }
.bp-tab.active { background: var(--bp-primary); color: #fff; border-color: var(--bp-primary); }

/* ---- Panels ---- */
.bp-panel { display: none; background: #fff; border: 1px solid var(--bp-border); border-top: none; border-radius: 0 0 var(--bp-radius) var(--bp-radius); padding: 16px; }
.bp-panel.active { display: block; }
.bp-notice { color: #888; font-style: italic; padding: 20px 0; }

/* ============================================================
   KO-BAUM
   ============================================================ */

.bp-bracket-container { width: 100%; }

.bp-bracket-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--bp-primary) #f1f1f1;
}
.bp-bracket-scroll::-webkit-scrollbar       { height: 6px; }
.bp-bracket-scroll::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
.bp-bracket-scroll::-webkit-scrollbar-thumb { background: var(--bp-primary); border-radius: 3px; }

.bp-bracket {
    display: inline-flex;
    align-items: flex-start;
    gap: var(--bp-col-gap);
    padding: 16px 8px 8px;
    min-width: 100%;
}

/* ---- Runde ---- */
.bp-round {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 0 0 auto;
    width: var(--bp-match-max);
    min-width: var(--bp-match-min);
}

.bp-round-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: var(--bp-primary);
    background: #e8f0fe; border-radius: 4px;
    padding: 4px 10px; margin-bottom: 12px;
    text-align: center; white-space: nowrap;
}

.bp-matches {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

/* ---- Match ---- */
.bp-match { position: relative; }

/* Verbindungslinien */
.bp-match::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--bp-col-gap));
    top: 50%; width: var(--bp-col-gap); height: 1px;
    background: var(--bp-border);
    pointer-events: none;
}
.bp-round:first-child .bp-match::before { display: none; }

.bp-match::after {
    content: '';
    position: absolute;
    right: calc(-1 * var(--bp-col-gap));
    top: 50%; width: var(--bp-col-gap); height: 1px;
    background: var(--bp-border);
    pointer-events: none;
}
.bp-round-winner .bp-match::after { display: none; }

.bp-match-inner {
    background: #fff;
    border: 1.5px solid var(--bp-border);
    border-radius: var(--bp-radius);
    box-shadow: var(--bp-shadow);
    overflow: hidden;
}
.bp-match-bye  .bp-match-inner { opacity: .55; border-style: dashed; }
.bp-match-done .bp-match-inner { border-color: var(--bp-primary); }

/* ---- Competitor ---- */
.bp-competitor {
    display: flex;
    align-items: flex-start;
    padding: 8px 10px;
    gap: 6px;
    border-bottom: 1px solid #f0f0f0;
    min-height: 40px;
    transition: background .15s;
}
.bp-competitor:last-child  { border-bottom: none; }
.bp-competitor.bp-winner   { background: #e8f5e9; }
.bp-competitor.bp-loser    { background: #fafafa; opacity: .65; }

.bp-competitor-info {
    flex: 1;
    min-width: 0;  /* wichtig: erlaubt Textumbruch */
}

/* Namen UMBRECHEN statt abschneiden */
.bp-competitor-name {
    display: block;
    font-size: 13px; font-weight: 600; color: var(--bp-text);
    white-space: normal;       /* kein nowrap */
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.35;
}
.bp-competitor-bro {
    display: block;
    font-size: 11px; color: #888;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3; margin-top: 1px;
}

.bp-win-indicator { color: var(--bp-green); font-size: 13px; flex-shrink: 0; padding-top: 2px; }

/* ---- Schuss-Badges ---- */
.bp-shots-row {
    display: flex; align-items: center; gap: 3px;
    margin-top: 5px; flex-wrap: wrap;
}
.bp-shot {
    display: inline-block; font-size: 10px; font-weight: 700;
    padding: 2px 4px; border-radius: 3px;
    background: #eee; color: #555; min-width: 28px; text-align: center;
    line-height: 1.4;
}
.bp-shot-win  { background: #c8e6c9; color: #1b5e20; }
.bp-shot-lose { background: #ffcdd2; color: #b71c1c; }
.bp-shot-draw { background: #fff9c4; color: #6d4c00; }
.bp-pts {
    font-size: 10px; font-weight: 700; color: var(--bp-primary);
    background: #e8f0fe; padding: 2px 5px; border-radius: 3px; white-space: nowrap;
}

.bp-match-vs {
    text-align: center; font-size: 10px; color: #bbb;
    font-weight: 600; padding: 2px 0; background: #f9f9f9;
}

/* ---- Sieger ---- */
.bp-round-winner { justify-content: center; align-items: center; }
.bp-winner-box {
    background: linear-gradient(135deg, var(--bp-primary), #2a5080);
    color: #fff; border-radius: var(--bp-radius);
    padding: 20px 14px; text-align: center;
    box-shadow: var(--bp-shadow); width: 100%; margin-top: 28px;
}
.bp-winner-trophy { display: block; font-size: 34px; }
.bp-winner-name   { display: block; font-size: 14px; font-weight: 700; color: var(--bp-secondary); margin-top: 6px; word-break: break-word; }
.bp-winner-tbd    { display: block; font-size: 22px; color: rgba(255,255,255,.3); margin-top: 8px; }

/* ============================================================
   MANNSCHAFTSWERTUNG
   ============================================================ */
.bp-teams-wrap  { padding: 8px 0; }
.bp-teams-title { font-size: 20px; color: var(--bp-primary); margin-top: 0; }
.bp-table-wrap  { overflow-x: auto; }
.bp-teams-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.bp-teams-table th { background: var(--bp-primary); color: #fff; padding: 10px 12px; text-align: left; }
.bp-teams-table td { padding: 9px 12px; border-bottom: 1px solid #eee; }
.bp-teams-table tr:hover td { background: #f9f9f9; }
.bp-rank-1 td { background: #fffde7 !important; }
.bp-rank-2 td { background: #f5f5f5 !important; }
.bp-rank-3 td { background: #fbe9e7 !important; }
.bp-rank  { font-size: 20px; }
.bp-total { font-weight: 700; color: var(--bp-primary); }

/* Mannschafts-Detail */
.bp-team-detail { border: 1.5px solid var(--bp-border); border-radius: var(--bp-radius); margin-top: 16px; overflow: hidden; box-shadow: var(--bp-shadow); }
.bp-team-detail-header { background: var(--bp-primary); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bp-team-medal { font-size: 20px; }
.bp-team-name  { font-size: 15px; font-weight: 700; flex: 1; word-break: break-word; }
.bp-team-score { background: var(--bp-secondary); color: #1a1a1a; padding: 3px 10px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.bp-team-disc-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.bp-team-disc-col  { padding: 12px 14px; border-right: 1px solid var(--bp-border); }
.bp-team-disc-col:last-child { border-right: none; }
.bp-team-disc-label   { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--bp-primary); font-weight: 700; margin-bottom: 4px; }
.bp-team-disc-shooter { font-size: 12px; color: #555; margin-bottom: 8px; word-break: break-word; }
.bp-team-shots-display { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.bp-team-shot-badge { font-size: 12px; font-weight: 600; padding: 3px 6px; border-radius: 4px; min-width: 34px; text-align: center; }
.bp-shot-entered { background: #e8f0fe; color: var(--bp-primary); }
.bp-shot-empty   { background: #f5f5f5; color: #bbb; }
.bp-team-disc-total    { font-size: 14px; color: var(--bp-primary); }
.bp-team-disc-total em { color: #aaa; font-size: 12px; }

/* Scroll-Hinweis */
.bp-scroll-hint {
    font-size: 12px; color: #999; text-align: center;
    margin: 0 0 6px; display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
    :root { --bp-match-max: 230px; --bp-col-gap: 26px; }
}

@media (max-width: 768px) {
    :root { --bp-match-min: 160px; --bp-match-max: 200px; --bp-col-gap: 22px; }
    .bp-title { font-size: 20px; }
    .bp-tab   { padding: 8px 12px; font-size: 13px; }
    .bp-panel { padding: 12px 8px; }
    .bp-competitor-name { font-size: 12px; }
    .bp-competitor-bro  { font-size: 10px; }
}

@media (max-width: 500px) {
    :root { --bp-match-min: 140px; --bp-match-max: 175px; --bp-col-gap: 18px; }
    .bp-event-header { padding: 14px 12px; }
    .bp-title { font-size: 17px; }
    .bp-tab   { padding: 6px 9px; font-size: 11px; }
    .bp-panel { padding: 8px 4px; }
    .bp-competitor      { padding: 6px 7px; }
    .bp-competitor-name { font-size: 11px; }
    .bp-round-label     { font-size: 10px; padding: 3px 6px; }
    .bp-shot            { min-width: 24px; font-size: 9px; }
    .bp-teams-table th,
    .bp-teams-table td  { padding: 6px 7px; font-size: 12px; }
    .bp-team-disc-grid  { grid-template-columns: 1fr; }
    .bp-team-disc-col   { border-right: none; border-bottom: 1px solid var(--bp-border); }
    .bp-team-disc-col:last-child { border-bottom: none; }
}

/* ============================================================
   PRÄSENTATIONS-BUTTON
   ============================================================ */
.bp-tabs-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.bp-tabs-bar .bp-tabs {
    flex: 1;
}
.bp-presentation-btn {
    flex-shrink: 0;
    background: var(--bp-primary);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 6px 6px 0 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
    white-space: nowrap;
    align-self: flex-end;
    margin-bottom: 0;
}
.bp-presentation-btn:hover {
    background: #2a5080;
    transform: translateY(-1px);
}

/* ---- Live-Refresh-Badge ---- */
.bp-refresh-badge {
    font-size: 11px; font-weight: 600; color: #2e7d32;
    background: #e8f5e9; border: 1px solid #a5d6a7;
    padding: 3px 9px; border-radius: 10px;
    opacity: 0; transition: opacity .4s;
    align-self: center; white-space: nowrap;
}
.bp-refresh-badge.visible { opacity: 1; }
