/* --- 1. RESET I PODSTAWY --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #1b1b1b;
    color: white;
    text-align: center;
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

header {
    background: #111;
    padding: 30px 20px;
    border-bottom: 2px solid #333;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 { color: #f5c542; text-transform: uppercase; letter-spacing: 1px; }
.balance { margin-top: 10px; font-size: 20px; color: #f5c542; font-weight: bold; }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }

/* --- 2. PRZYCISK MOTYWU (Prawy Górny Róg) --- */
.theme-btn {
    position: absolute;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    background: #2a2a2a;
    border: 2px solid #f5c542;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.theme-btn:hover {
    transform: translateY(-50%) scale(1.1);
    background: #333;
    box-shadow: 0 0 15px rgba(245, 197, 66, 0.4);
}

/* --- 3. SEKPCJA SKRZYNEK (CASE) --- */
.case-container {
    margin: 40px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
}

.case {
    background: #2a2a2a;
    padding: 30px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 320px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid #444;
    transition: transform 0.3s ease;
}

.case:hover { transform: translateY(-5px); }

.case-img-wrapper {
    position: relative;
    display: inline-block;
}

.case-img {
    width: 200px;
    height: auto;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.8));
    transition: transform 0.3s ease;
    cursor: help;
}

/* --- 4. TOOLTIP (SZANSE PROCENTOWE) --- */
.case-info-tooltip {
    position: absolute;
    left: 115%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background: rgba(20, 20, 20, 0.98);
    border: 2px solid #f5c542;
    padding: 15px;
    border-radius: 12px;
    width: 190px;
    text-align: left;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px rgba(0,0,0,0.7);
}

.case-img-wrapper:hover .case-info-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

.case-info-tooltip h3 { font-size: 14px; color: #f5c542; margin-bottom: 10px; border-bottom: 1px solid #444; }
.case-info-tooltip ul { list-style: none; }
.case-info-tooltip li { font-size: 13px; margin: 6px 0; display: flex; align-items: center; }

.dot { width: 10px; height: 10px; border-radius: 50%; margin-right: 10px; }
.dot.common { background: #808080; }
.dot.uncommon { background: #4caf50; }
.dot.rare { background: #2196f3; }
.dot.epic { background: #9c27b0; }
.dot.legendary { background: #ffc107; }
.dot.mithic { background: #f44336; }

/* Strzałka tooltipa */
.case-info-tooltip::after {
    content: "";
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: transparent #f5c542 transparent transparent;
}

/* Formularze wewnątrz skrzynki */
.numCasesSelect, #numCases {
    width: 100%;
    padding: 12px;
    background: #1b1b1b;
    color: white;
    border: 2px solid #444;
    border-radius: 8px;
    outline: none;
}

.openBtn, #openCaseBtn {
    width: 100%;
    padding: 15px;
    font-weight: bold;
    text-transform: uppercase;
    background: #f5c542;
    color: #000;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.openBtn:hover, #openCaseBtn:hover { background: #ffdb70; transform: scale(1.02); }

/* --- 5. SEKPCJA DROPU (RESULT) --- */
.result-container { margin-top: 50px; }
.result-box {
    margin: 20px auto;
    padding: 25px;
    background: #111;
    border: 2px dashed #333;
    border-radius: 15px;
    min-height: 250px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.result-skin {
    width: 160px;
    background: #2a2a2a;
    padding: 12px;
    border-radius: 10px;
    border: 2px solid gray;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 1; transform: scale(1); }
}

/* --- 6. EKWIPUNEK (INVENTORY) --- */
.inventory { margin-top: 60px; background: #1e1e1e; padding: 30px; border-radius: 20px; }
.inventory-header { margin-bottom: 30px; }
.inventory-value { font-size: 26px; font-weight: bold; color: #ff4d4d; text-shadow: 0 0 10px rgba(255, 77, 77, 0.5); margin-bottom: 20px; }

.inventory-controls { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }
#searchInput, #sortSelect { padding: 12px; border-radius: 8px; border: 2px solid #444; background: #111; color: white; min-width: 200px; }
#sellAllBtn { padding: 12px 25px; background: #f54242; color: white; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; transition: 0.2s; }
#sellAllBtn:hover { background: #ff5c5c; }

#inventoryItems {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.item {
    background: #2a2a2a;
    padding: 15px;
    border-radius: 12px;
    border: 2px solid gray;
    transition: 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 300px;
}

/* Kolory rzadkości */
.common { border-color: #808080 !important; }
.uncommon { border-color: #4caf50 !important; }
.rare { border-color: #2196f3 !important; }
.epic { border-color: #9c27b0 !important; }
.legendary { border-color: #ffc107 !important; box-shadow: 0 0 15px rgba(255, 193, 7, 0.4); }
.mithic { border-color: #f44336 !important; box-shadow: 0 0 20px rgba(244, 67, 54, 0.6); animation: shake 0.5s infinite; }

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(1deg); }
    75% { transform: rotate(-1deg); }
}

/* Przycisk blokady/sprzedaży w EQ */
.item .buttons { display: flex; gap: 5px; margin-top: 10px; }
.item .sell { background: #4caf50; border: none; padding: 8px; border-radius: 5px; color: white; cursor: pointer; flex: 1; }
.item .lock { background: #ff9800; border: none; padding: 8px; border-radius: 5px; color: white; cursor: pointer; flex: 1; }

/* --- 7. STOPKA --- */
footer { margin-top: 60px; padding: 40px; background: #111; border-top: 2px solid #333; color: #888; }
footer strong { color: #f5c542; }

/* --- 8. TRYB JASNY (POPRAWKI) --- */
body.light-mode { background: #f4f4f4; color: #222; }
body.light-mode header, body.light-mode footer { background: #fff; border-color: #ddd; }
body.light-mode .case, body.light-mode .item, body.light-mode .result-skin, body.light-mode .inventory { 
    background: #fff; border-color: #ccc; color: #222; box-shadow: 0 5px 15px rgba(0,0,0,0.1); 
}
body.light-mode .result-box { background: #eee; border-color: #bbb; }
body.light-mode #searchInput, body.light-mode #sortSelect, body.light-mode .numCasesSelect { background: #fff; color: #222; border-color: #ccc; }

/* --- 9. RESPONSYWNOŚĆ (POPRAWKI MOBILNE) --- */
@media (max-width: 900px) {
    .case-info-tooltip {
        left: 50%;
        top: 110%;
        transform: translateX(-50%);
        width: 170px;
    }
    .case-img-wrapper:hover .case-info-tooltip {
        transform: translateX(-50%) translateY(10px);
    }
    .case-info-tooltip::after {
        left: 50%;
        top: -10px;
        transform: translateX(-50%) rotate(90deg);
    }
    .theme-btn { right: 10px; width: 40px; height: 40px; }
}

@media (max-width: 600px) {
    .case { width: 100%; }
    h1 { font-size: 20px; }
}