/* --------------------------------------------------------------------------
   GLOBAL STYLES AND TYPOGRAPHY
-------------------------------------------------------------------------- */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f7f9fb;
    margin: 0;
    padding: 1rem;
    color: #1f2937;
}

h1 {
    margin: 1.5rem 0 1rem;
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    color: #111827;
}

.round-title {
    margin: 0 0 1.25rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1d4ed8;
    text-align: center;
    letter-spacing: -0.025em;
}

/* --------------------------------------------------------------------------
   BRACKET CONTAINER & LAYOUT – FULL WIDTH
-------------------------------------------------------------------------- */
.bracket-outer {
    overflow-x: auto;
    padding: 2rem 0.5rem 3rem;     /* very small side padding for comfort */
    background: linear-gradient(to bottom, #f8fafc, #e5e7eb);
    border-radius: 12px;
    margin: 1.5rem auto;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.bracket {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 4.5rem;
    position: relative;
    min-height: 820px;
    padding: 1rem 0.75rem;         /* minimal horizontal padding */
    width: max-content;            /* allows content to be wide */
    min-width: 100%;               /* forces it to stretch across screen */
    margin: 0 auto;                /* centers if content is narrower than screen */
}

/* --------------------------------------------------------------------------
   ROUND – different vertical distribution per round
-------------------------------------------------------------------------- */
.round {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 260px;
    position: relative;
}

/* Vertical spacing per round (your current values kept, feel free to fine-tune) */
.round:nth-child(1) { /* Round of 16 */
    --match-spacing: 0.9rem;
    min-width: 240px;
}

.round:nth-child(2) { /* Quarterfinals */
    --match-spacing: 5.0rem;
    min-width: 270px;
}

.round:nth-child(3) { /* Semifinals */
    --match-spacing: 14rem;
    min-width: 290px;
}
.round:nth-child(4) {
    --match-spacing: 2rem;
    min-width: 320px;
    align-items: center;
    justify-content: flex-start;   /* Changed from center */
}

/* --------------------------------------------------------------------------
   ROUND – Finals round special handling
-------------------------------------------------------------------------- */
.round:last-child {                    /* This targets the final round regardless of how many rounds there are */
    --match-spacing: 2rem;
    min-width: 320px;
    align-items: center;
    justify-content: flex-start;       /* Important: don't use center */
}

/* Apply spacing to matches */
.match {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.07);
    width: 100%;
    margin: var(--match-spacing) 0;
    padding: 0.3rem;
    transition: all 0.18s ease;
    cursor: pointer;
    min-height: 60px;
}

/* Later rounds visual emphasis */
.round:nth-child(n+3) .match {
    border-left: 5px solid #60a5fa;
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
}

.round:last-child .match {
    border-left: 6px solid #3b82f6;
    font-size: 1.05rem;
}

/* --------------------------------------------------------------------------
   3RD PLACE MATCH – Dynamic spacing that actually works
-------------------------------------------------------------------------- */
.third-place-section {
    margin-top: 6.5rem;                /* Default for 16-player (4-round) bracket */
    text-align: center;
    width: 100%;
}

/* Closer spacing for smaller brackets */
.round:last-child .third-place-section {
    margin-top: 4rem;                  /* 8-player (3-round) and 4-player (2-round) brackets */
}

/* Even tighter if needed - you can adjust this */
.round:last-child:nth-child(2) .third-place-section,   /* 2-round bracket */
.round:last-child:nth-child(3) .third-place-section {  /* 3-round bracket */
    margin-top: 3rem;
}

/* Title closer to the match box */
.third-place-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1d4ed8;
    margin-bottom: 1rem;               /* Tight gap between title and box */
    letter-spacing: -0.02em;
}
/* --------------------------------------------------------------------------
   MODAL STYLES (unchanged)
-------------------------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.is-active {
    display: flex;
}

.modal-card {
    background: white;
    border-radius: 8px;
    width: 92%;
    max-width: 580px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    overflow: hidden;
}
/* --------------------------------------------------------------------------
   PLAYER ROW & SCORE (Clean single version)
-------------------------------------------------------------------------- */
.player-row {
    display: flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    min-height: 48px;
    border-radius: 6px;
    margin: 0.3rem 0;
    background: #fcfcfc;
    gap: 10px;
}

.player-label {
    width: 42px;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 1.05rem;
    color: #1e40af;
    text-align: center;
    background: #e0f2fe;
    border-radius: 4px;
    padding: 2px 6px;
    line-height: 1.2;
}

.player-name {
    flex: 1 1 auto;
    font-size: 0.96rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    min-width: 0;
}

.player-score {
    min-width: 42px;
    text-align: right;
    font-weight: bold;
    font-size: 1.08rem;
    color: #1e40af;
    flex-shrink: 0;
}

/* Winner & Bye styling */
.player-row.winner {
    background: linear-gradient(to right, #ecfdf5, #d1fae5);
    font-weight: 600;
}

.player-row.winner .player-label {
    background: #a7f3d0;
    color: #065f46;
}

.player-row.bye {
    color: #94a3b8;
    background: #f1f5f9;
}

.player-row.bye .player-label {
    background: #e2e8f0;
    color: #64748b;
}
/* ====================== PRINT / PDF OPTIMIZATION ====================== */
@media print {
    @page {
        size: A4 landscape;
        margin: 12mm 8mm;           /* balanced margins */
    }

    body, .bracket-outer, .bracket {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Hide everything except the bracket */
    .no-print, .modal, .receptionist-area .level-left,
    .buttons, nav, .navbar, #matchModal {
        display: none !important;
    }

    /* Full width container */
    .bracket-outer {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10mm 5mm !important;
        margin: 0 !important;
        box-shadow: none !important;
    }

    .bracket {
        display: flex !important;
        flex-direction: row !important;
        gap: 18mm !important;           /* reduced horizontal spacing */
        width: 100% !important;
        overflow: visible !important;
        min-height: auto !important;
        justify-content: flex-start !important;
    }

    .round {
        min-width: 210px !important;
        flex-shrink: 0 !important;
        break-inside: avoid !important;
    }

    /* Tighter vertical spacing */
    .round:nth-child(1) { --match-spacing: 6mm !important; }
    .round:nth-child(2) { --match-spacing: 12mm !important; }
    .round:nth-child(3) { --match-spacing: 18mm !important; }
    .round:nth-child(4) { --match-spacing: 8mm !important; }

    .match {
        margin: var(--match-spacing) 0 !important;
        padding: 6mm 8mm !important;
        border: 2px solid #333 !important;
        box-shadow: none !important;
        width: 100% !important;
        min-height: 68px !important;
        page-break-inside: avoid !important;
    }

    /* Tighter text */
    .player-row {
        padding: 4mm 6mm !important;
        margin: 3mm 0 !important;
        font-size: 10.5pt !important;
        letter-spacing: -0.4px !important;
    }

    .player-label {
        width: 38px !important;
        font-size: 11pt !important;
        padding: 2px 4px !important;
    }

    .player-name {
        font-size: 10.5pt !important;
        letter-spacing: -0.3px !important;
    }

    .player-score {
        font-size: 11.5pt !important;
        min-width: 42px !important;
    }

    .round-title {
        font-size: 13pt !important;
        margin-bottom: 10mm !important;
        color: #000 !important;
        font-weight: 700 !important;
    }

    .third-place-section {
        margin-top: 25mm !important;
    }

    .third-place-title {
        font-size: 12pt !important;
        margin-bottom: 8mm !important;
    }

    /* Better header */
    .receptionist-area h1 {
        font-size: 18pt !important;
        margin-bottom: 4mm !important;
    }

    .bracket-outer, body {
            padding: 0 !important;
            margin: 0 !important;
        }
        body {
            margin: 0 !important;
        }
}
