/* --- RESET / BAZA --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --primary: #27ae60;
    --primary-dark: #1e8449;
    --dark: #2c3e50;
    --border: #bdc3c7;
    --bg-light: #ecf0f1;
    --line-color: #95a5a6;
    --match-height: 70px;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #e5ebf3;
    color: #2c3e50;
}

/* --- HEADER / NAVBAR (Nowoczesny Styl) --- */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    height: 70px;
    background: rgba(255, 255, 255, 0.95); /* Prawie biały, lekko przeźroczysty */
    backdrop-filter: blur(10px); /* Efekt rozmycia tego co pod spodem */
    box-shadow: 0 4px 20px rgba(0,0,0,0.05); /* Miękki cień zamiast ramki */
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Lewa strona: Logo + Badge */
.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    font-weight: 900;
    font-size: 1.4rem;
    color: var(--dark);
    letter-spacing: -1px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--dark) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Badge (pastylka) aktywnego turnieju */
.tournament-badge {
    background: #e8f5e9;
    color: var(--primary-dark);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(39, 174, 96, 0.2);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tournament-badge.hidden {
    display: none;
}

/* Środek: Menu Nawigacyjne */
.main-nav {
    display: flex;
    gap: 10px;
    position: absolute; /* Centrowanie absolutne */
    left: 50%;
    transform: translateX(-50%);
}

.nav-link {
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #7f8c8d;
    cursor: pointer;
    padding: 8px 16px;
    position: relative;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--primary);
}

/* Styl dla zablokowanych przycisków */
.nav-link.disabled {
    color: #dcdcdc; /* Bardzo jasny szary */
    cursor: default;
    pointer-events: none; /* Blokuje kliknięcie systemowo */
}

/* Ukrywamy animowaną kreskę dla zablokowanych */
.nav-link.disabled::after {
    display: none;
}

/* Animowana kreska pod linkiem */
.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    background-color: var(--primary);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateX(-50%);
}

.nav-link.active {
    color: var(--primary);
}

.nav-link.active::after {
    width: 60%; /* Kreska pod aktywnym elementem */
}

/* Prawa strona: User + Przyciski Auth */
.auth-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

#currentUserLabel {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--dark);
    margin-right: 5px;
}

.btn-auth {
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: var(--dark);
    color: white;
}

.btn-auth:hover {
    background: #34495e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Wersja outline dla wyloguj */
.btn-auth.outline {
    background: transparent;
    color: #7f8c8d;
    border: 1px solid #dcdfe3;
}

.btn-auth.outline:hover {
    background: #f8f9fa;
    color: #e74c3c; /* Czerwony przy hoverze na wyloguj */
    border-color: #e74c3c;
    box-shadow: none;
}

/* --- GŁÓWNY LAYOUT --- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr);
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* --- KARTY / WIDOKI --- */
.view-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    margin-bottom: 20px;

    height: auto;        /* ważne */
    max-height: none;    /* ważne */
    overflow: visible;   /* żeby nic nie ucinał */
}
.view-card h2 {
    margin-top: 0;
}

.card-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.card {
    background: #f9fafb;
    border-radius: 10px;
    padding: 14px 16px;
    border: 1px solid #e5e7eb;

    height: auto;        /* kluczowe */
    max-height: none;    /* kluczowe */
    overflow: visible;   /* żeby nie pojawiał się wewnętrzny scrollbar */
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
}

/* --- FORMULARZE --- */
label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 4px;
}
label input,
label textarea {
    width: 100%;
    margin-top: 2px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.85rem;
}

button[type="submit"],
button,
input[type="button"] {
    font: inherit;
}

form button {
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
}
form button:hover {
    background: var(--primary-dark);
}

/* --- TABS AUTORYZACJI --- */
.tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 10px;
}
.tab-button {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
}
.tab-button.active {
    border-bottom: 3px solid var(--primary);
    font-weight: 600;
}
.auth-forms {
    display: grid;
}
.auth-form h2 {
    margin-top: 0;
}

.hidden {
    display: none !important;
}

/* --- TABELA --- */
/* ...existing code... */

/* =========================
   NOWOCZESNA TABELA + AKTYWNY TURNIEJ
   ========================= */

/* Bazowo: niech tabela wygląda jak "card table" */
.table {
    width: 100%;
    border-collapse: separate;   /* pozwala na radius */
    border-spacing: 0;
    font-size: 0.9rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;            /* obcina rogi */
}

/* Nagłówek */
.table thead th {
    position: sticky;            /* przy długich listach */
    top: 0;
    z-index: 1;
    text-align: left;
    padding: 12px 14px;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #475569;
    background: linear-gradient(180deg, #f8fafc 0%, #f3f4f6 100%);
    border-bottom: 1px solid #e5e7eb;
}

/* Komórki */
.table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #eef2f7;
    vertical-align: middle;
    color: #111827;
}

/* Ostatni wiersz bez kreski */
.table tbody tr:last-child td {
    border-bottom: none;
}

/* Hover na wierszu */
.table tbody tr {
    transition: background-color 0.15s ease, transform 0.12s ease;
}
.table tbody tr:hover {
    background: #f8fafc;
}

/* Link w tabeli jako nowoczesny "button-link" */
.table tbody td a {
    color: #0f172a;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 10px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.table tbody td a:hover {
    background: rgba(39, 174, 96, 0.10);
    color: var(--primary-dark);
}

/* Mini pill "Aktywny" */
.active-pill {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid rgba(39, 174, 96, 0.30);
    background: rgba(39, 174, 96, 0.12);
    color: var(--primary-dark);
}

/* Aktywny turniej: “selected row” */
.table tbody tr.is-active-tournament {
    background: linear-gradient(90deg, rgba(39, 174, 96, 0.10), rgba(39, 174, 96, 0.04));
}

/* Lewy akcent (border) dla aktywnego wiersza */
.table tbody tr.is-active-tournament td:first-child {
    position: relative;
}
.table tbody tr.is-active-tournament td:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 4px;
    border-radius: 999px;
    background: var(--primary);
}

/* Subtelne “wcięcie” przy aktywnym wierszu */
.table tbody tr.is-active-tournament td {
    border-bottom-color: rgba(39, 174, 96, 0.18);
}

/* Lepsze wyrównanie (kod/rola niech będą czytelniejsze) */
.table tbody td:nth-child(2),
.table tbody td:nth-child(3) {
    color: #475569;
    font-weight: 600;
}

/* Mobile: sticky head off (bo i tak robisz scroll) */
@media (max-width: 900px) {
    .table thead th {
        position: static;
    }
}

/* ...existing code... */

/* --- LOG BOX --- */
.log-box {
    background: #0f172a;
    color: #e5e7eb;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.75rem;
    padding: 8px;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
}

/* --- SIDEBAR / REKLAMY --- */
.sidebar {
    background: #ffffff;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    height: fit-content;
}
.ad-box {
    background: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 12px;
    text-align: center;
    font-size: 0.85rem;
}

/* --- GRUPY --- */
.groups-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin-top: 10px;
}
.group-card {
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s ease-in-out;
}
.group-card:hover {
    transform: translateY(-3px);
}
.group-title {
    font-weight: bold;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 8px;
    font-size: 0.9em;
    text-align: center;
}
.team-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
}
.team-row:nth-child(2),
.team-row:nth-child(3) {
    background-color: #d5f5e3;
    font-weight: bold;
}
.btn-move {
    background: none;
    border: 1px solid #ddd;
    cursor: pointer;
    padding: 0px 5px;
    border-radius: 3px;
    font-size: 0.8em;
}
.btn-move:hover {
    background: var(--dark);
    color: white;
}

/* --- 3. MIEJSCA (GRID KAFELKÓW) --- */
.third-place-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.third-place-header p.muted {
    margin: 0;
}

.third-place-counter {
    background: #e5e7eb;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #4b5563;
    transition: all 0.3s ease;
}

/* Kolor licznika zmienia się na zielony, gdy wybierzemy komplet */
.third-place-counter.full {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.4);
}

.third-place-grid {
    display: grid;
    /* Automatycznie układa kafelki, minimum 130px szerokości */
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

.third-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none; /* Zapobiega zaznaczaniu tekstu przy szybkim klikaniu */
}

.third-card:hover {
    border-color: #bdc3c7;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.06);
}

/* Stan zaznaczony */
.third-card.selected {
    border-color: var(--primary);
    background: #f0fdf4; /* Bardzo jasny zielony */
}

.tc-group {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.tc-team {
    font-weight: 700;
    color: var(--dark);
    font-size: 0.95rem;
}

/* Trik wizualny: dodanie "ptaszka" (checkmark) w rogu po zaznaczeniu */
.third-card.selected::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--primary);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    /* Animacja pojawiania się ptaszka */
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- DRABINKA --- */
.bracket-wrapper {
    display: flex;
    min-height: 900px;   /* możesz dać 1100px jak dalej jest ciasno */
    min-width: 1000px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 50px 20px 20px 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    overflow-x: auto;
    overflow-y: visible; /* ważne: nie tnij w pionie */
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.bracket-wrapper {
    /* Płynne animowanie rozjaśniania */
    transition: opacity 0.5s ease, filter 0.5s ease; 
}

.bracket-wrapper.locked {
    opacity: 0.35; /* Przygaszenie */
    filter: grayscale(80%); /* Wyssanie kolorów (wyszarzenie zielonego) */
    pointer-events: none; /* Totalna blokada kliknięć - nie da się typować na siłę */
}

/* --- ZMIENIONA DRABINKA - MATEMATYKA MARGINESÓW --- */

.round-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    margin: 0 20px;
    position: relative;
    border: none;
}

.round-column.champion-column {
    flex: 1;
    justify-content: center;
}

.round-column.final-column {
    padding-top: 0; 
    justify-content: center;
    position: relative;
}

.round-title {
    position: absolute;
    top: -40px;
    left: 0;
    width: 100%;
    text-align: center;
    font-weight: 700;
    color: var(--primary-dark);
    text-transform: uppercase;
    font-size: 0.95rem;
    letter-spacing: 1px;
}

/* KARTA MECZU (TYLKO NIEWIDZIALNY WRAPPER NA LINIE) */
.match-card {
    width: 100%;
    height: var(--match-height); /* 70px */
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 1;
}

/* NOWA KLASA: Tło, ramki i efekt HOVER powiększający sam mecz */
.match-content {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Przycina rogi dla slotów drużyn */
    position: relative;
    z-index: 2; /* Treść wyżej niż linie */
    transition: box-shadow 0.2s, transform 0.2s;
}

.match-content:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: scale(1.03); /* Powiększa TYLKO białe tło z drużynami */
}

/* MATEMATYKA ODSTĘPÓW */
.round-r32 .match-card { margin: 10px 0; }
.round-r16 .match-card { margin: 55px 0; }
.round-qf  .match-card { margin: 145px 0; }
.round-sf  .match-card { margin: 325px 0; }
.round-f   .match-card { margin: 685px 0; }

/* --- LINIE ŁĄCZĄCE (UKRYTE POD SPODEM NA ZAKŁADKĘ) --- */

/* LINIE POZIOME WYCHODZĄCE W PRAWO */
.match-card::after {
    content: '';
    position: absolute;
    right: -19px; /* Dociągnięte głębiej, likwiduje szparę */
    top: 50%;
    width: 19px;
    height: 2px;
    background: var(--line-color);
    transform: translateY(-50%);
    z-index: -1; /* Schowane pod .match-content */
}

/* LINIE PIONOWE I WEJŚCIOWE Z LEWEJ (Kształt |-) */
.match-card.has-connector::before {
    content: '';
    position: absolute;
    left: -22px; /* Dociągnięte głębiej, likwiduje szparę */
    top: 50%;
    width: 22px;
    transform: translateY(-50%);
    border-left: 2px solid var(--line-color);
    background-image: linear-gradient(var(--line-color), var(--line-color));
    background-size: 100% 2px;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1; /* Schowane pod .match-content */
}

/* Wypinamy pierwszą rundę */
.round-r32 .match-card.has-connector::before { display: none; }

/* Dynamiczne wysokości linii */
.round-r16 .match-card.has-connector::before { height: 90px; }
.round-qf  .match-card.has-connector::before { height: 180px; }
.round-sf  .match-card.has-connector::before { height: 360px; }
.round-f   .match-card.has-connector::before { height: 720px; }


/* Przedłużona linia idąca z Finału prosto do Mistrza */
.round-f .match-card::after {
    width: 40px;
    right: -40px;
}

/* --- PRZYWRÓCONE STYLE DRUŻYN W MECZU --- */
.team-slot {
    flex: 1;
    padding: 0 10px;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s, color 0.2s;
    border-radius: 4px 4px 0 0;
}

.team-slot:first-child {
    border-bottom: 1px solid #eee; /* Linia oddzielająca drużyny w meczu */
}

.team-slot:last-child {
    border-radius: 0 0 4px 4px;
}

.team-slot:hover {
    background-color: #e9ecef; /* Podświetlenie po najechaniu myszką */
}

.team-slot.winner {
    background-color: var(--primary); /* Zielone tło po kliknięciu */
    color: white;
    font-weight: bold;
}

.team-slot.winner:hover {
    background-color: var(--primary-dark);
}

.slot-label {
    flex: 0 0 auto;
    font-weight: 700;          
    margin-right: 4px;         
    letter-spacing: 0.03em;
}

/* Mistrz */
.champion-box {
    background: gold;
    border: 2px solid orange;
    color: #d35400;
    padding: 20px;
    text-align: center;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(255, 215, 0, 0.4);
    opacity: 0.5;
    transform: scale(0.95);
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.champion-box.active {
    opacity: 1;
    transform: scale(1.1);
}

.third-place-box {
    position: absolute;
    bottom: 20px; /* Odrywamy box od flow, ląduje ładnie na dole pustej kolumny */
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 10px 12px;
    width: 100%;
    max-width: 180px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    text-align: center;
}

.third-place-box .third-title {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #7f8c8d;
}

/* select 3. miejsca – combobox spójny z drabinką */
.third-place-box .third-select {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    background: #f9fafb;
    color: #2c3e50;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.third-place-box .third-select:hover {
    background: #f3f4f6;
    border-color: var(--primary);
}

.third-place-box .third-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.25);
}

/* DROBNE */
.muted {
    font-size: 0.8rem;
    color: #6b7280;
}

/* --- ZAKŁADKA TYPY INNYCH --- */
.player-select-container {
    margin-bottom: 20px;
}

.full-width-select {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background-color: white;
    color: var(--dark);
    margin-top: 8px;
    cursor: pointer;
}

.full-width-select:focus {
    border-color: var(--primary);
    outline: none;
}

/* Drabinka tylko do odczytu (bez efektów hover i kursora rączki) */
.bracket-wrapper.locked-visual {
    pointer-events: none; /* Blokuje kliknięcia */
}

.bracket-wrapper.locked-visual .match-team {
    cursor: default;
}

/* Usuwamy efekt hover w trybie podglądu - żeby nie mylić użytkownika */
.bracket-wrapper.locked-visual .match-team:hover {
    background: #fff;
    border-color: #dcdfe3;
}

/* --- WELCOME HERO --- */
.welcome-hero {
    display: grid;
    gap: 10px;
    text-align: center;
    padding: 20px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}
.welcome-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
}
.welcome-actions button {
    padding: 8px 14px;
    border-radius: 999px;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
}
.welcome-actions button:hover {
    background: var(--primary-dark);
}

/* --- KOMUNIKAT BRAKU TURNIEJU --- */
.no-tournament-overlay {
    background: #fdfbf7;
    border: 2px dashed #f5b041;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    color: #b9770e;
    font-weight: 500;
    margin-top: 20px;
}
.no-tournament-overlay a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}
.no-tournament-overlay a:hover {
    text-decoration: underline;
}

/* --- PRZYCISK "ZAPISZ TYPY" --- */
#btnSaveTyping {
    display: block;
    width: 100%;
    max-width: 350px;
    margin: 50px auto;
    padding: 16px 24px;
    font-size: 1.15rem;
    font-weight: 800;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.35);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#btnSaveTyping:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.5);
}

#btnSaveTyping:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(39, 174, 96, 0.3);
}

#btnSaveTyping:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    opacity: 0.8;
}



/* =========================================
   RESPONSYWNOŚĆ (MOBILE)
   Wklej to na samym dole pliku styles.css
   ========================================= */

   @media (max-width: 900px) {

    /* 1. ZMIANA GŁÓWNEGO UKŁADU */
    .layout {
        display: flex;
        flex-direction: column; /* Układamy elementy jeden pod drugim */
        padding: 10px;
        gap: 15px;
    }

    /* Reklamy zrzucamy na sam dół lub ukrywamy */
    .sidebar {
        order: 2; 
        width: 100%;
        margin-top: 20px;
    }

    /* 2. NAPRAWA NAVBARA (To był główny problem) */
    .main-header {
        height: auto; /* Pozwalamy nagłówkowi rosnąć */
        flex-direction: column;
        padding: 15px;
        position: relative; /* Zdejmujemy sticky na mobile, żeby nie zajmował ekranu */
    }

    /* Logo na środku */
    .header-left {
        width: 100%;
        justify-content: space-between; /* Logo z lewej, badge z prawej */
        margin-bottom: 15px;
    }

    /* Menu nawigacyjne - zdejmujemy pozycjonowanie absolutne */
    .main-nav {
        position: static;
        transform: none;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap; /* Przyciski mogą spaść do nowej linii */
        gap: 5px;
        margin-bottom: 15px;
        overflow-x: auto; /* W razie czego pozwól przewijać palcem */
        padding-bottom: 5px;
    }

    .nav-link {
        font-size: 0.85rem;
        padding: 6px 10px;
        white-space: nowrap;
    }

    /* Sekcja logowania na pełną szerokość */
    .auth-area {
        width: 100%;
        justify-content: space-between;
        border-top: 1px solid #eee;
        padding-top: 15px;
    }

    /* 3. KARTY I FORMULARZE */
    .view-card {
        padding: 15px; /* Mniejszy padding */
        border-radius: 8px;
    }

    .card-row {
        grid-template-columns: 1fr; /* Jedna kolumna kart */
    }

    .grid-2 {
        grid-template-columns: 1fr; /* Formularze jedna kolumna */
    }

    /* 4. DRABINKA (Najważniejsze!) */
    /* Drabinka jest za szeroka na telefon, więc musimy pozwolić jej scrollować WEWNĄTRZ karty,
       zamiast rozpychać całą stronę */
    .view-card, .card {
        overflow-x: hidden; /* Zapobiega scrollowaniu całej strony */
    }
    
    .bracket-wrapper {
        /* 1. Resetujemy style desktopowe, które mogą blokować szerokość */
        min-width: 0 !important; 
        min-height: 0 !important;
        
        /* 2. Ustawiamy kontener jako elastyczny pasek przewijania */
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap; /* Absolutny zakaz zawijania wierszy */
        
        width: 100%;
        overflow-x: auto; /* Włączamy scroll poziomy */
        overflow-y: visible; /* Pozwalamy elementom (jak cienie) wystawać w pionie */
        
        /* 3. Kluczowe: Padding z prawej strony (60px), 
           żeby dało się dopchnąć przewijanie do ostatniego elementu */
        padding: 20px 60px 50px 10px; 
        
        -webkit-overflow-scrolling: touch; /* Płynność na iOS */
        background: #f8f9fa; /* Tło, żeby było widać gdzie jest drabinka */
    
        transform-origin: 0 0; /* Skalujemy zawsze od lewego górnego rogu */
        transition: transform 0.1s ease-out; /* Lekkie wygładzenie ruchu */
    }

    /* Ustawienia dla wszystkich kolumn rund */
    .bracket-wrapper .round-column {
        flex: 0 0 auto;  /* Nie kurcz się, nie rozciągaj, zachowaj wymiar */
        width: 150px;    /* Bazowa szerokość kolumny */
        margin-right: 30px; /* Odstęp między kolumnami */
        
        /* Reset pozycjonowania, żeby nagłówki (Runda 1/16 itd.) były na miejscu */
        position: relative; 
        margin-top: 30px; /* Miejsce na nagłówek rundy */
    }

    /* Poprawka dla nagłówków rund, żeby nie uciekały */
    .round-title {
        width: 150px; /* Szerokość taka sama jak kolumny */
        left: 0;
        text-align: center;
    }

    /* Specjalne traktowanie Finału (jest szerszy przez 3. miejsce) */
    .bracket-wrapper .round-column.final-column {
        width: 200px;
        margin-right: 40px;
    }

    /* Specjalne traktowanie kolumny Mistrza (ostatnia) */
    .bracket-wrapper .round-column.champion-column {
        width: 160px;
        margin-right: 0; /* Ostatni margines załatwia padding kontenera */
    }

    /* Zmniejszamy trochę box mistrza na mobile */
    .champion-box {
        transform: scale(0.9);
        transform-origin: top center;
    }

    /* Zmniejszamy trochę marginesy w samej drabince na mobile */
    .round-column {
        margin: 0 10px;
    }
    
    /* 5. TABELE */
    /* Owijamy tabele scrollem, żeby nie ucięło kolumn */
    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* 6. TYPOWANIE 3. MIEJSC */
    .third-place-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); /* Mniejsze kafelki */
    }
    .third-card {
        padding: 8px 4px;
    }
    .tc-team {
        font-size: 0.8rem;
    }

    /* 7. DROBNE UI */
    #btnSaveTyping {
        width: 100%;
        max-width: none;
        margin: 20px 0;
    }
    
    /* Ukrywamy długie opisy na mobile, jeśli chcesz */
    .welcome-hero h2 {
        font-size: 1.5rem;
    }
}

/* Zablokowana zakładka przed startem turnieju */
[data-typing-tab].disabled-tab {
    opacity: 0.5;
    cursor: help !important; 
    background-color: #e0e0e0 !important;
    color: #7f8c8d !important;
    pointer-events: auto !important; /* Wymusza działanie dymka "title" po najechaniu */
}

/* =========================================
   KOLOROWANIE TYPÓW (TRAFIONE / PUDŁA)
   ========================================= */

/* Zielone zaznaczenie (Trafiona drużyna) */
.team-slot.correct-pick, 
.third-select.correct-pick {
    background-color: rgba(39, 174, 96, 0.15) !important;
}
.team-slot.correct-pick .slot-name,
.third-select.correct-pick .slot-name {
    color: #1e8449 !important;
    font-weight: 700;
}

/* Zielone zaznaczenie, jeśli dodatkowo gracz wytypował to jako ZWYCIĘZCĘ w tym meczu */
.team-slot.winner.correct-pick {
    background-color: #27ae60 !important;
}
.team-slot.winner.correct-pick .slot-name {
    color: white !important;
}

/* Czerwone zaznaczenie (Nietrafiona drużyna) */
/* Czerwone zaznaczenie (Nietrafiona drużyna) - BEZ SKREŚLENIA */
.team-slot.wrong-pick,
.third-select.wrong-pick {
    background-color: rgba(231, 76, 60, 0.1) !important;
}
.team-slot.wrong-pick .slot-name,
.third-select.wrong-pick .slot-name {
    color: #c0392b !important;
}

/* Mistrz – trafiony */
.champion-box.correct-pick {
    background: rgba(39, 174, 96, 0.1) !important;   /* delikatna zieleń */
    box-shadow: 0 4px 10px rgba(39, 174, 96, 0.4) !important;
}
.champion-box.correct-pick .champion-name {
    color: #27ae60 !important;
}

/* Mistrz – pudło (to już masz, tylko dla porządku obok) */
.champion-box.wrong-pick {
    background: rgba(231, 76, 60, 0.1) !important;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.4) !important;
}
.champion-box.wrong-pick .champion-name {
    color: #c0392b !important;
}

/* Pola wyboru 3. miejsca dla użytkownika */
select.correct-pick {
    background-color: rgba(39, 174, 96, 0.15) !important;
    border-color: #27ae60 !important;
    color: #1e8449 !important;
}
select.wrong-pick {
    background-color: rgba(231, 76, 60, 0.1) !important;
    border-color: #e74c3c !important;
    color: #c0392b !important;
}

.champion-box.wrong-pick {
    border-color: #e74c3c !important;
    background: rgba(231, 76, 60, 0.1) !important;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.4) !important;
}
.champion-box.wrong-pick .champion-name {
    color: #c0392b !important;
}

/* ...existing code... */

/* =========================
   RESULTS: TRYB SYMULACJI
   ========================= */

   .results-card-header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sim-badge{
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    border: 1px solid rgba(39, 174, 96, 0.35);
    background: rgba(39, 174, 96, 0.12);
    color: var(--primary-dark);
}

/* Pasek kontrolek */
.results-sim-controls{
    margin: 8px 0 12px 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Toggle */
.sim-toggle{
    display: inline-flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.sim-toggle-label{
    font-size: 0.85rem;
    font-weight: 700;
    color: #4b5563;
}

/* Switch (suwak) */
.switch{
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}
.switch input{
    opacity: 0;
    width: 0;
    height: 0;
}
.slider{
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #d1d5db;
    border-radius: 999px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}
.slider::before{
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 999px;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.switch input:checked + .slider{
    background: var(--primary);
    box-shadow: inset 0 0 0 1px rgba(39, 174, 96, 0.45), 0 0 0 4px rgba(39, 174, 96, 0.12);
}
.switch input:checked + .slider::before{
    transform: translateX(24px);
}
.switch input:focus-visible + .slider{
    outline: 2px solid rgba(39, 174, 96, 0.35);
    outline-offset: 2px;
}

/* Info box */
.sim-info{
    border: 1px solid rgba(39, 174, 96, 0.22);
    background: rgba(39, 174, 96, 0.07);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 0 12px 0;
}
.sim-info-title{
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--primary-dark);
    margin-bottom: 4px;
}
.sim-info-text{
    font-size: 0.85rem;
    color: #374151;
    line-height: 1.35;
}

/* Globalny "tryb symulacji" (klasa na body) */
body.results-sim-on #officialBracketContainer .bracket-wrapper{
    box-shadow: 0 8px 24px rgba(39, 174, 96, 0.14);
    outline: 2px solid rgba(39, 174, 96, 0.18);
    background: linear-gradient(180deg, rgba(39, 174, 96, 0.06), #f8f9fa 35%);
}

body.results-sim-on #scoringTable{
    outline: 2px solid rgba(39, 174, 96, 0.16);
    border-radius: 10px;
}

/* Badge widoczny tylko w symulacji */
body.results-sim-on #resultsSimBadgeBracket{
    display: inline-flex !important;
}
body.results-sim-on #resultsSimInfo{
    display: block !important;
}

.dash-tcard{
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(255,255,255,.03);
    border-radius: 14px;
    padding: 14px;
  }
  .dash-tcard.active{
    border-color: rgba(46, 204, 113, .5);
    background: linear-gradient(180deg, rgba(46,204,113,.10), rgba(255,255,255,.03));
  }
  .dash-tcard__top{
    display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap;
  }
  .dash-tcard__title{ display:flex; align-items:center; gap:10px; }
  .dash-tcard__name{ font-weight: 800; font-size: 16px; }
  .dash-tcard__chips{ display:flex; gap:8px; flex-wrap:wrap; }
  .dash-tcard__desc{ margin-top:8px; opacity:.85; line-height:1.35; }
  .dash-tcard__status{ margin-top:10px; display:flex; gap:8px; flex-wrap:wrap; }
  .status{
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.03);
  }
  .status.ok{ border-color: rgba(46,204,113,.5); background: rgba(46,204,113,.14); }
  .status.todo{ border-color: rgba(52,152,219,.5); background: rgba(52,152,219,.14); }
  .status.warn{ border-color: rgba(241,196,15,.5); background: rgba(241,196,15,.14); }
  
  .dash-tcard__actions{ margin-top: 12px; display:flex; gap:8px; flex-wrap:wrap; }