body {
    margin: 0;
    font-family: 'MedievalSharp', cursive;
    background: url("imgs/BackgroundDungeon.png") no-repeat center center fixed;
    background-size: 100% 100%;
    color: #e0d3a3;
}

/* Fade in overlay */
#fadeOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    opacity: 1;
    z-index: 99999;
    pointer-events: none;
    transition: opacity 1s ease-in-out;
}

/* HEADINGS */
h2 {
    color: #d4af37;
    border-bottom: 2px solid #8b5a2b;
    padding-bottom: 5px;
}

.section-title {
    margin-top: 20px;
    color: #c9a96a;
}

/* LAYOUT */
#game-container {
    display: flex;
    height: 100vh;
}

/* SIDEBAR */
#sidebar {
    width: 220px;
    background: rgba(20, 15, 10, 0.9);
    border-right: 3px solid #5a3b1a;
    display: flex;
    flex-direction: column;
    padding: 15px;
    height: 106%;
}

#sidebar > * {
    flex-shrink: 0;
}

#sidebar button {
    margin: 8px 0;
    padding: 12px;

    background: linear-gradient(180deg, #5a3b1a, #3b2612);
    border: 2px solid #a67c52;

    color: #f5e6c8;
    font-weight: bold;
    letter-spacing: 1px;

    cursor: pointer;
    transition: 0.2s;
}

#sidebar button:hover {
    background: linear-gradient(180deg, #7a5228, #4a2f17);
    transform: scale(1.03);
}

#sidebar button:active {
    transform: scale(0.98);
}

/* MAIN */
#main {
    flex: 1;
    padding: 20px;
    background: rgba(10, 10, 10, 0.6);
    border-left: 2px solid #5a3b1a;
    height: 105%;
}

/* PANELS */
.panel {
    display: none;
    background: rgba(30, 20, 10, 0.85);
    border: 2px solid #8b5a2b;
    padding: 20px;
}

.panel.active {
    display: block;
}

/* ========================= */
/* INVENTORY TABLE STYLE */
/* ========================= */

#invcontainer {
width: 931px;
}

.inv-header {
    display: grid;
    grid-template-columns: 150px repeat(12, 60px);
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: bold;
    text-align: center;
    padding: 6px;
}

/* ROW */
.inv-row {
    width: 500px;
    display: grid;
    grid-template-columns: 150px repeat(12, 60px);
    align-items: center;

    padding: 6px;
    margin-bottom: 4px;

    background: rgba(40, 30, 15, 0.8);
    border: 1px solid #5a3b1a;

    transition: 0.2s;
}

#characterUI {
    display: flex;
    gap: 30px;
}

#charLeft {
    width: 200px;
}

#charImage {
    width: 100%;
    border: 0px solid #8b5a2b;
}

#statsPanel{
    margin: 8px 30px 0px 0px;
}

/* EQUIPMENT GRID */
#equipment {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

/* middle row */
.equip-row {
    display: flex;
    gap: 10px;
}

/* slots */
.equip-slot {
    width: 70px;
    height: 70px;

    border: 2px solid #a67c52;
    background: rgba(30, 20, 10, 0.85);

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    transition: 0.2s;
}

.equip-slot::after {
    font-size: 10px;
    opacity: 0.4;
}

/* hover */
.equip-slot:hover {
    border-color: #d4af37;
    transform: scale(1.05);
}

/* HOVER ROW */
.inv-row:hover {
    background: rgba(70, 50, 20, 0.9);
    transform: scale(1.01);
}

/* NAME COLUMN */
.inv-name {
    font-weight: bold;
    color: #f0d9a0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* CELLS */
.inv-cell {
    text-align: center;
    font-weight: bold;
    text-shadow: 0 0 3px black;
}

/* RARITY COLORS */
.white {
    color: #ddd;
}

.green {
    color: #4caf50;
}

.blue {
    color: #2196f3;
}

.purple {
    color: #c56cf0;
}

.orange {
    color: #ff9800;
}

.red {
    color: #ff3b3b;
}

/* OPTIONAL: subtle glow for high rarity */
.orange,
.red {
    text-shadow: 0 0 6px rgba(255, 140, 0, 0.6);
}

#inventoryGrid {
    display: grid;
    grid-template-columns: repeat(12, 70px);
    gap: 8px;
    margin-top: 10px;
}

.slot {
    width: 70px;
    height: 70px;

    background: linear-gradient(145deg, #3b2a1a, #1e140a);
    border: 2px solid #5a3b1a;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
}

/* RARITY GLOW */
.slot.white {
    box-shadow: 0 0 5px #ccc;
}

.slot.green {
    box-shadow: 0 0 8px #4caf50;
}

.slot.blue {
    box-shadow: 0 0 10px #2196f3;
}

.slot.purple {
    box-shadow: 0 0 12px #9c27b0;
}

.slot.orange {
    box-shadow: 0 0 14px #ff9800;
}

.slot.red {
    box-shadow: 0 0 16px #ff0000;
}

.mat-icon {
    width: 32px;
    height: 32px;

    object-fit: contain;

    margin-right: 6px;
    vertical-align: middle;
    border: 1px solid #5a3b1a;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px;
}

#tooltip {
    position: absolute;
    background: rgba(20, 15, 10, 0.95);
    border: 2px solid #a67c52;
    padding: 10px;
    color: #f5e6c8;
    font-size: 12px;

    pointer-events: none;
    display: none;
    z-index: 999;
    min-width: 120px;
}

.equip-slot.white {
    box-shadow: 0 0 5px #ccc;
}

.equip-slot.green {
    box-shadow: 0 0 8px #4caf50;
}

.equip-slot.blue {
    box-shadow: 0 0 10px #2196f3;
}

.equip-slot.purple {
    box-shadow: 0 0 12px #9c27b0;
}

.equip-slot.orange {
    box-shadow: 0 0 14px #ff9800;
}

.equip-slot.red {
    box-shadow: 0 0 16px #ff0000;
}

.equip-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #aaa;
}

#inventoryTabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    width: 100%;
}

#inventoryTabs button {
    flex: 1;
    padding: 6px;
    background: #2a1a0f;
    border: 1px solid #5a3b1a;
    color: #e0d3a3;
    cursor: pointer;
    opacity: 0.3;
}

#inventoryTabs button:hover {
    background: #3b2612;
}

#inventoryTabs button.active {
    opacity: 1;
    border: 1px solid #e0d3a3;
}

.click-effect {
    position: absolute;
    color: gold;
    font-weight: bold;
    pointer-events: none;
    animation: floatUp 0.6s ease-out;
}

@keyframes floatUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-40px);
        opacity: 0;
    }
}

#upgradePanel {
    margin-top: 20px;
}

.upgrade-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.upgrade-text {
    margin-bottom: 5px;
}

.upgrade-name {
    width: 80px;
    font-weight: bold;
}

.upgrade-row button {
    padding: 4px 10px;
    cursor: pointer;
}

#clickerArea {
    position: relative;
    flex: 2;
    min-height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#clickerBG {
    position: absolute;
    width: 90%;
    height: 90%;
    object-fit: contain;
    border-radius: 20px;
    border: 4px solid transparent;
}

#mainClicker {
    position: absolute;
    width: 30%;
    height: auto;
    cursor: pointer;
    z-index: 1;
    bottom: 18%;
}

#slimeHint {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    color: #f5e6c8;
    font-size: 14px;
    text-align: center;
    z-index: 2;
    opacity: 0.8;
    max-width: 80%;
}

.bounce {
    animation: bounceClick 0.25s ease;
}

@keyframes bounceClick {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(0.9, 1.1);
    }

    /* squish */
    60% {
        transform: scale(1.08, 0.92);
    }

    /* rebound */
    100% {
        transform: scale(1);
    }
}

.floating-text {
    position: fixed;
    font-weight: bold;
    pointer-events: none;
    z-index: 9999;
    animation: floatBounce 0.9s ease-out forwards;
}

.floating-text.green {
    color: #4caf50;
    text-shadow: 0 0 6px #4caf50;
}

.floating-text.blue {
    color: #2196f3;
    text-shadow: 0 0 6px #2196f3;
}

.floating-text.purple {
    color: #c77dff;
    text-shadow: 0 0 10px #9c27b0;
}

/* 🎯 REAL BOUNCE */
@keyframes floatBounce {
    0% {
        opacity: 1;
        transform: translateY(0px) scale(0.8);
    }

    30% {
        transform: translateY(-25px) scale(1.2);
    }

    60% {
        transform: translateY(-15px) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.9);
    }
}

/* ICON ALIGN */
.floating-text img {
    vertical-align: center;
    margin-left: 4px;
}

#clickerLayout {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 40px;
}

/* LEFT SIDE - clickerArea already defined above, no need to duplicate */

/* RIGHT SIDE */
#upgradePanel {
    flex: 1;
    max-width: 30%;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    padding-left: 20px;
}

#upgradePanel button {
    margin: 8px 0;
    padding: 12px;

    background: linear-gradient(180deg, #5a3b1a, #3b2612);
    border: 2px solid #a67c52;

    color: #f5e6c8;
    font-weight: bold;
    letter-spacing: 1px;

    cursor: pointer;
    transition: 0.2s;
    width: 100%;
}

.forge-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.forge-row label {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 3px;
}

.forge-row select {
    padding: 5px;
    background: #1e1e1e;
    color: white;
    border: 1px solid #444;
}

.forge-preview {
    margin-top: 15px;
    padding: 10px;
    border: 1px solid #444;
    background: #111;
}

.forge-btn {
    margin-top: 10px;
    width: 100%;
    padding: 8px;
    background: #2e7d32;
    border: none;
    color: white;
    cursor: pointer;
}

.forge-btn:hover {
    background: #388e3c;
}

.forge-container {
    display: flex;
    gap: 20px;
}

/* LEFT PANEL */
.forge-left {
    width: 220px;
    background: rgba(0,0,0,0.4);
    padding: 10px;
    border: 1px solid #a67c52;
}

.forge-left select,
.forge-btn {
    width: 100%;
    margin-bottom: 10px;
}

.forge-btn {
    background: #3a2a1a;
    color: #f5d6a0;
    border: 1px solid #a67c52;
    cursor: pointer;
}

.forge-btn:hover {
    background: #5a3a1a;
}

/* RIGHT PANEL */
.forge-right {
    flex: 1;
}

/* PREVIEW */
#forgePreviewBox {
    display: flex;
    gap: 10px;
    padding: 10px;
    border: 1px solid #a67c52;
    background: rgba(0,0,0,0.3);
}

/* MATERIAL GRID */
#forgeMaterialsGrid {
    display: grid;
    grid-template-columns: repeat(4, 60px);
    gap: 10px;
    margin-top: 10px;
}

.material-slot {
    width: 60px;
    height: 60px;
    border: 1px solid #a67c52;
    background: rgba(0,0,0,0.4);
    position: relative;
    text-align: center;
    font-size: 12px;
}

.material-slot img {
    width: 32px;
    margin-top: 5px;
}

.material-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 11px;
}

.progress-bar {
    width: 100%;
    height: 18px;
    background: #2a1a0f;
    border: 1px solid #a67c52;
    margin-top: 5px;
    position: relative;
}

#forgeProgressFill {
    height: 100%;
    width: 10%;
    background: linear-gradient(90deg, #f5d6a0, #ffb347);
    transition: width 0.2s linear;
}

#forgeTimer {
    font-size: 12px;
    margin-top: 5px;
}


#forgeMaterialGrid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.material-box {
    border: 1px solid #444;
    padding: 6px;
    background: #1a1a1a;
    text-align: center;
    font-size: 12px;
}

.material-box input {
    width: 50px;
    margin-top: 4px;
}

.rarity-white { color: #ccc; }
.rarity-green { color: #4caf50; }
.rarity-blue { color: #2196f3; }
.rarity-purple { color: #9c27b0; }
.rarity-orange { color: #ff9800; }
.rarity-red { color: #f44336; }

.required-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.material-required-slot {
    background: #111;
    border: 1px solid #555;
    padding: 5px;
    text-align: center;
    font-size: 12px;
}

.material-required-slot img {
    width: 32px;
    height: 32px;
}

/* JOIN DUNGEON BUTTON (sidebar) */
#joinDungeonBtn {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 12px;
    box-sizing: border-box;
    text-align: center;

    background: linear-gradient(180deg, #7a1a1a, #3b0a0a);
    border: 2px solid #c0392b;
    color: #f5e6c8;
    font-family: 'MedievalSharp', cursive;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    text-decoration: none;
    cursor: pointer;
    transition: 0.2s;
    text-shadow: 0 0 8px rgba(255, 60, 60, 0.7);
    box-shadow: 0 0 16px rgba(192, 57, 43, 0.5), inset 0 0 6px rgba(0,0,0,0.4);
}

#joinDungeonBtn:hover {
    background: linear-gradient(180deg, #a02020, #5a1010);
    border-color: #e74c3c;
    box-shadow: 0 0 28px rgba(231, 76, 60, 0.9);
    transform: scale(1.03);
}

#joinDungeonBtn:active {
    transform: scale(0.97);
}

#muteButton {
    display: block;
    width: 100%;
    margin-top: auto;
    margin-bottom: 8px;
    margin-left: 0;
    margin-right: 0;
    padding: 12px;
    box-sizing: border-box;
    text-align: center;

    background: linear-gradient(180deg, #4a4a4a, #2a2a2a);
    border: 2px solid #666666;
    color: #f5e6c8;
    font-family: 'MedievalSharp', cursive;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    transition: 0.2s;
    text-shadow: 0 0 8px rgba(200, 200, 200, 0.5);
    box-shadow: 0 0 10px rgba(100, 100, 100, 0.3), inset 0 0 6px rgba(0,0,0,0.4);
}

#muteButton:hover {
    background: linear-gradient(180deg, #5a5a5a, #3a3a3a);
    border-color: #888888;
    box-shadow: 0 0 18px rgba(150, 150, 150, 0.6);
    transform: scale(1.03);
}

#muteButton:active {
    transform: scale(0.97);
}

/* ========================= */
/* LEADERBOARD               */
/* ========================= */

#Leaderboard {
    padding: 30px;
}

#leaderboardBox {
    position: relative;
    max-width: 560px;
    margin: 64px auto 0;
    padding: 50px 40px 30px;
    background: rgba(12, 8, 3, 0.92);
    border: 3px solid #8b5a2b;
    box-shadow:
        0 0 0 1px #3b2010,
        0 0 30px rgba(0, 0, 0, 0.9),
        inset 0 0 20px rgba(0, 0, 0, 0.6);
}

#leaderboardSkull {
    position: absolute;
    top: -52px;
    left: 50%;
    transform: translateX(-50%);
    width: 84px;
    height: 84px;
    background: rgba(12, 8, 3, 0.98);
    border: 3px solid #8b5a2b;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 18px rgba(139, 90, 43, 0.5);
}

#leaderboardSkull img {
    width: 56px;
    height: 56px;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 6px rgba(200, 80, 80, 0.5));
}

#leaderboardHeader {
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-bottom: 2px solid #5a3b1a;
    color: #d4af37;
    font-weight: bold;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#leaderboardList {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    padding: 10px 12px;
    background: rgba(40, 25, 10, 0.6);
    border: 1px solid #3b2010;
    transition: 0.2s;
}

.leaderboard-row.lb-local {
    background: rgba(60, 35, 10, 0.8);
    border-color: #8b5a2b;
}

.leaderboard-row:hover {
    background: rgba(70, 45, 15, 0.8);
    border-color: #8b5a2b;
}

.lb-rank {
    font-weight: bold;
    font-size: 15px;
}

.lb-name {
    color: #f0d9a0;
    font-weight: bold;
}

.lb-you {
    color: #a67c52;
    font-size: 11px;
    font-weight: normal;
}

.lb-floor {
    color: #a67c52;
    text-align: right;
}
