:root {
    --bg-main: #1d2021;
    --bg-surface: #282828;
    --bg-hover: #3c3836;
    --text-main: #ebdbb2;
    --text-muted: #928374;
    --border: #504945;
    --accent: #debc7a; /* Zgaszony, musztardowy żółty */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    padding: 40px 20px;
}

.container { max-width: 1200px; margin: 0 auto; }

/* Kafelki */
.tiles { display: flex; gap: 20px; margin-bottom: 40px; }
.tile { flex: 1; background-color: var(--bg-surface); border: 1px solid var(--border); padding: 24px; cursor: pointer; transition: background-color 0.2s; }
.tile:hover, .tile.active { background-color: var(--bg-hover); border-color: var(--text-muted); }
.tile-title { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 8px; }
.tile-numbers { font-size: 2.5rem; font-weight: 300; }
.tile-numbers span.emu { font-size: 1.2rem; color: var(--text-muted); }

/* Tabele */
.table-container { display: none; }
.table-container.active { display: block; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--text-muted); font-weight: 400; padding: 12px 8px; border-bottom: 1px solid var(--border); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; }
td { padding: 16px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background-color: rgba(255, 255, 255, 0.02); }
th.col-icon { width: 48px; } th.col-title { width: 25%; } th.col-note { width: 35%; }

/* Obrazki, ikony i statusy */
.game-icon { width: 32px; height: 32px; object-fit: cover; border-radius: 2px; display: block; background-color: var(--bg-surface); }
.status-badge { display: inline-block; padding: 2px 6px; border: 1px solid var(--border); font-size: 0.75rem; border-radius: 2px; color: var(--text-muted); }

/* Oceny (SVG) */
.rating-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: middle; }
a.rating-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; padding-bottom: 2px; border-bottom: 1px dotted transparent; transition: all 0.2s ease; }
a.rating-link:hover { border-bottom-color: var(--text-muted); color: var(--accent); }
a.rating-link svg { transition: transform 0.2s; }
a.rating-link:hover svg { transform: scale(1.1); }

/* Panel Admina i formularze */
.admin-form { background: var(--bg-surface); padding: 20px; border: 1px solid var(--border); margin-bottom: 30px; }
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-size: 0.85rem; color: var(--text-muted); }
input, select, textarea { width: 100%; background: var(--bg-main); border: 1px solid var(--border); color: var(--text-main); padding: 8px 12px; font-family: inherit; }
button { background: var(--text-main); color: var(--bg-main); border: none; padding: 10px 20px; cursor: pointer; font-weight: 600; }
button:hover { opacity: 0.9; }

/* Upload ikony (Dropzone) */
.dropzone { border: 1px dashed var(--border); background: var(--bg-main); padding: 30px 15px; text-align: center; color: var(--text-muted); cursor: pointer; transition: all 0.2s; margin-bottom: 5px; font-size: 0.9rem; }
.dropzone:hover { border-color: var(--text-main); color: var(--text-main); }
#icon-preview img { margin-top: 15px; border-radius: 2px; border: 1px solid var(--border); }

/* Paginacja i szukajka */
.search-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.search-bar button { padding: 8px 15px; }
.pagination { display: flex; gap: 5px; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); color: var(--text-muted); text-decoration: none; font-size: 0.8rem; }
.pagination a:hover { border-color: var(--text-main); color: var(--text-main); }
.pagination span.current { background: var(--text-main); color: var(--bg-main); border-color: var(--text-main); }

/* Dodatki tabeli admina */
.admin-table-container { margin-top: 40px; }
.admin-table-container h3 { margin-bottom: 15px; font-weight: 500; }
.action-links a { color: var(--text-muted); text-decoration: none; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; margin-right: 12px; transition: color 0.2s; }
.action-links a:hover { color: var(--text-main); }
.action-links a.delete-link:hover { color: #d64545; }

/* Sekcja W Trakcie */
.playing-section { margin-bottom: 40px; }
.playing-section h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 15px; }
.playing-grid { display: flex; gap: 15px; flex-wrap: wrap; }
.playing-card { display: flex; align-items: center; gap: 15px; background: var(--bg-surface); border: 1px solid var(--accent); padding: 15px 20px; flex: 1; min-width: 250px; max-width: 400px; }
.playing-info { flex: 1; display: flex; flex-direction: column; }
.playing-info strong { color: var(--text-main); font-size: 1rem; line-height: 1.2; margin-bottom: 4px; }
.playing-info span { color: var(--text-muted); font-size: 0.8rem; }
.playing-card .status-badge { color: var(--accent); border-color: var(--accent); font-weight: 500; }

/* Techniczny wskaźnik aktywnego wiersza tabeli */
tr {
    position: relative;
}

tr td:first-child::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--accent);
    transform: scaleY(0);
    transition: transform 0.15s ease-out;
}

tr:hover td:first-child::before {
    transform: scaleY(1);
}

/* Wypełniacz pustych komórek tabeli */
td:empty::before {
    content: "---";
    color: var(--border);
    font-family: monospace;
    letter-spacing: 2px;
}

/* Migający kursor dla aktywnego kafelka */
@keyframes blinkCursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.tile.active .tile-title::after {
    content: " _";
    color: var(--accent);
    animation: blinkCursor 1s step-end infinite;
}

/* Wymuszenie technicznego fontu dla Platformy i Daty */
/* Uwaga: Zakładamy, że Platforma to 4. kolumna, a Data to ostatnia. */
td:nth-child(4), 
td:last-child {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Ścięte rogi dla elementów interfejsu */
.tile, .playing-card, button, .dropzone {
    clip-path: polygon(
        10px 0, 
        100% 0, 
        100% calc(100% - 10px), 
        calc(100% - 10px) 100%, 
        0 100%, 
        0 10px
    );
    border: none; /* Przy clip-path często usuwa się standardowy border */
}

/* Co drugi wiersz w innym odcieniu */
tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Wzmocnienie efektu podświetlenia z Twoim żółtym akcentem na wierszu, na którym jesteś */
tbody tr:hover {
    background-color: rgba(215, 153, 33, 0.05); /* Ułamek Twojego --accent */
}

/* =========================================
   INTERFEJS MOBILNY - INSPEKTOR DANYCH (Properties Panel)
   ========================================= */
@media (max-width: 768px) {
    body { padding: 15px 10px; }
    .tiles { flex-direction: column; gap: 10px; margin-bottom: 25px; }
    
    table, thead, tbody, th, td, tr { display: block; width: 100%; border: none; }
    thead { display: none; } /* Ukrywamy standardowe nagłówki */

    /* Każda gra to osobny blok danych */
    tr {
        background: var(--bg-main);
        border: 1px solid var(--border);
        margin-bottom: 20px;
        position: relative;
    }

    tr::before { display: none !important; } /* Ukrywamy desktopowy lewy wskaźnik */

    /* Ikona - przyklejona do prawego górnego rogu */
    td:nth-child(1) {
        position: absolute;
        top: 15px;
        right: 15px;
        padding: 0;
        width: 32px;
        height: 32px;
    }

    /* Tytuł gry - główny nagłówek bloku */
    td:nth-child(2) {
        padding: 15px 60px 15px 15px; /* Prawy margines chroni przed najściem na ikonę */
        font-size: 1.1rem;
        font-weight: 600;
        color: var(--text-main);
        background: var(--bg-surface);
        border-bottom: 1px dashed var(--border);
    }

    /* Standardowy wiersz Klucz: Wartość */
    td:not(:nth-child(1)):not(:nth-child(2)) {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.02);
        font-size: 0.85rem;
    }

    /* Wstrzykiwanie Etykiet (Kluczy) przez CSS zależnie od tabeli */
    #table-completed td:nth-child(3)::before, #table-backlog td:nth-child(3)::before { content: "STATUS"; }
    #table-completed td:nth-child(4)::before, #table-backlog td:nth-child(4)::before { content: "PLATFORMA"; }
    #table-completed td:nth-child(5)::before { content: "OCENA"; }
    #table-completed td:nth-child(6)::before, #table-backlog td:nth-child(5)::before { content: "NOTATKA"; }
    #table-completed td:nth-child(7)::before { content: "DATA UKOŃCZENIA"; }
    #table-backlog td:nth-child(6)::before { content: "DATA ZAKUPU"; }

    /* Wygląd Etykiet (Kluczy) */
    td::before {
        font-family: ui-monospace, SFMono-Regular, monospace;
        color: var(--text-muted);
        margin-right: 15px;
        letter-spacing: 0.5px;
    }

    /* Notatka - jako jedyna łamie układ i układa się pod etykietą */
    #table-completed td:nth-child(6),
    #table-backlog td:nth-child(5) {
        flex-direction: column;
        align-items: flex-start;
        line-height: 1.5;
    }

    #table-completed td:nth-child(6)::before,
    #table-backlog td:nth-child(5)::before {
        margin-bottom: 8px;
        display: block;
        width: 100%;
        border-bottom: 1px dotted var(--border);
        padding-bottom: 4px;
    }

    /* Ukrywanie pustych danych (np. brak notatki lub oceny) */
    td:empty { display: none !important; }
}

/* Styl dla wielokropka w paginacji */
.pagination span.dots {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 6px 4px;
    pointer-events: none;
}

/* =========================================
   ROZWIJANE DLC (ACCORDION)
   ========================================= */
.dlc-toggle {
    cursor: pointer;
    color: var(--accent);
    display: inline-block;
    margin-right: 10px;
    font-size: 0.85rem;
    transition: transform 0.2s ease;
    user-select: none;
    padding: 5px;
    margin-left: -5px; /* Kompensacja paddingu, by nie odsuwało tekstu */
}

.dlc-toggle:hover {
    color: var(--text-main);
}

.dlc-toggle.expanded {
    transform: rotate(90deg);
}

.dlc-row {
    display: none; /* Domyślnie schowane */
    background-color: rgba(0, 0, 0, 0.15); /* Delikatnie ciemniejsze tło */
}

.dlc-row.visible {
    display: table-row; /* Pokazane po kliknięciu strzałki */
}

.dlc-row td:first-child {
    padding-left: 20px; /* Wcięcie z lewej dla ikony DLC */
}

.dlc-row td:nth-child(2) strong::before {
    content: "└ DLC: ";
    color: var(--accent);
    font-weight: normal;
    font-size: 0.8rem;
    margin-right: 5px;
    font-family: ui-monospace, monospace;
}

        .sortable { cursor: pointer; user-select: none; transition: color 0.2s; }
        .sortable:hover { color: var(--text-main); }
        .sortable .ind { font-size: 0.75rem; margin-left: 5px; color: var(--accent); display: inline-block; width: 15px; text-align: center; }
        .loading-spinner { text-align: center; padding: 20px; color: var(--text-muted); font-family: monospace; display: none; margin-top: 20px; border-top: 1px dashed var(--border); }
        .loading-spinner.active { display: block; }
        .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; }
        .tile { width: auto; margin: 0; }
        
        /* =========================================
           USZTYWNIENIE TABELI (FIX NAGŁÓWKÓW)
           ========================================= */
        table {
            table-layout: fixed; /* Zapobiega losowemu rozszerzaniu się kolumn */
            width: 100%;
        }
        th, td {
            text-align: left;
            vertical-align: middle;
            overflow: hidden; 
            text-overflow: ellipsis; /* Jeśli notatka będzie za długa - zostanie ucięta z kropkami */
        }
        /* Stałe szerokości dla konkretnych kolumn */
        .col-icon { width: 60px; }
        th[data-col="title"] { width: 23%; }
        th[data-col="status"] { width: 10%; }
        th[data-col="platform"] { width: 22%; }
        th[data-col="rating"] { width: 9%; }
        .col-note { width: auto; } /* Notatka zajmuje pozostałą, elastyczną przestrzeń */
        th[data-col="completion_date"], 
        th[data-col="purchase_date"] { width: 14%; text-align: left; }
        td:last-child { text-align: left; } /* Wyrównanie samych dat do prawej */

        /* =========================================
           NOWY WYGLĄD PLATFORM (PIGUŁKI)
           ========================================= */
.plat-tag {
            display: inline-block;
            font-family: inherit;
            font-size: 0.8rem;
            color: var(--text-muted);
            margin-right: 15px;
            margin-bottom: 4px;
            position: relative;
            padding-left: 12px;
            white-space: nowrap;
        }
        .plat-tag::before {
            content: "";
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background-color: var(--border); /* Neutralna szara kropka */
        }