﻿:root {
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --accent-color: #ff3e3e;
    --sandbag-color: #8d6e63;
    --ui-bg: #2d2d2d;
    --slot-bg: #1e1e1e;
    --slot-border: #444;

    /* Rarities */
    --rarity-normal: #c8c8c8;
    --rarity-magic: #8888ff;
    /* Blue */
    --rarity-rare: #ffff77;
    /* Yellow */
    --rarity-unique: #af6025;
    --rarity-epic: #a33eff;
    /* Purple */
    --rarity-legendary: #ffaa00;
    /* Orange */
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Remove tap highlight on mobile */
}

body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent double-tap zoom on mobile */
    touch-action: manipulation;
    font-family: 'Do Hyeon', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* Tooltip Customization */
.tooltip-container {
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #777;
    padding: 10px;
    z-index: 1000;
    pointer-events: none;
    min-width: 250px;
    box-shadow: 0 0 10px #000;
    font-family: 'Do Hyeon', sans-serif;
    text-align: center;
}

.tooltip-header {
    font-size: 1.2rem;
    padding-bottom: 5px;
    border-bottom: 1px solid #555;
    margin-bottom: 5px;
}

.tooltip-header.magic {
    color: var(--rarity-magic);
}

.tooltip-header.rare {
    color: var(--rarity-rare);
}

.tooltip-header.unique {
    color: var(--rarity-unique);
}

.tooltip-header.epic {
    color: var(--rarity-epic);
}

.tooltip-header.legendary {
    color: var(--rarity-legendary);
}

.tooltip-body {
    text-align: left;
    font-size: 0.9rem;
    color: #ddd;
}

.affix-line {
    padding: 2px 0;
}

.affix-tier {
    color: #777;
    font-size: 0.8rem;
    margin-right: 5px;
}

.affix-value {
    color: #88f;
}

/* Layout */
#main-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    max-width: 600px;
    /* Slightly wider tablet support/mobile defaults */
    margin: 0 auto;
    background: #222;
    overflow: hidden;
}

/* Header is just a block, height auto */

/* Important: Sandbag Container fills space */
#sandbag-container {
    flex: 1;
    /* Grow */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Align to top */
    padding-top: 50px;
    /* Add spacing from header */
    position: relative;
    min-height: 0;
    width: 100%;
    margin: 0 !important;
}

/* Bottom Section Wrapper */
#footer-section {
    flex: 0 0 auto;
    /* Fixed height based on content */
    width: 100%;
    background: #151515;
    z-index: 10;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
}

/* Legacy overrides */
#game-area {
    display: contents;
}

/* Remove wrapper effect if tag remains */
#side-panel {
    display: none;
}

/* Remove old desktop side panel */

header {
    padding: 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    z-index: 10;
}

h1 {
    font-family: 'Black Han Sans', sans-serif;
    color: var(--accent-color);
    font-size: 2rem;
    margin: 0 0 10px 0;
    text-shadow: 0 0 10px rgba(255, 62, 62, 0.5);
}

#score-board {
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: 1.2rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.7rem;
    color: #888;
}

#sandbag-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: crosshair;
    /* Make touch easier */
    touch-action: manipulation;
}

/* Sandbag Updates */
#sandbag {
    width: 140px;
    height: 220px;
    background-color: var(--sandbag-color);
    border-radius: 40px;
    border: 5px solid #3e2723;
    position: relative;
    box-shadow: inset -10px -10px 20px rgba(0, 0, 0, 0.3), inset 10px 10px 20px rgba(255, 255, 255, 0.1), 0 10px 20px rgba(0, 0, 0, 0.5);
    transform-origin: top center;
    transition: transform 0.05s ease;
    margin-top: 50px;
}

#sandbag::before {
    content: '';
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 100px;
    background: #5d4037;
    z-index: -1;
}

#sandbag::after {
    content: '';
    position: absolute;
    top: 40px;
    left: 0;
    width: 100%;
    height: 20px;
    background: rgba(0, 0, 0, 0.2);
}

.face {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 60px;
    opacity: 0.8;
}

.eye {
    position: absolute;
    top: 0;
    width: 18px;
    height: 18px;
    background: #3e2723;
    border-radius: 50%;
    animation: blink 4s infinite;
    display: flex;
    justify-content: center;
    align-items: center;
}

.eye .pupil {
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    margin-top: -4px;
    margin-right: -4px;
}

.eye.left {
    left: 10px;
}

.eye.right {
    right: 10px;
}

@keyframes blink {

    0%,
    90%,
    100% {
        transform: scaleY(1);
    }

    95% {
        transform: scaleY(0.1);
    }
}

.mouth {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 15px;
    border-bottom: 3px solid #3e2723;
    border-radius: 50%;
}

.cheeks {
    position: absolute;
    top: 25px;
    width: 100%;
    height: 10px;
}

.cheeks::before,
.cheeks::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 8px;
    background: #ffaaaa;
    border-radius: 50%;
    opacity: 0.6;
}

.cheeks::before {
    left: 0;
}

.cheeks::after {
    right: 0;
}

@keyframes shake {
    0% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(5deg) scale(0.95);
    }

    50% {
        transform: rotate(0deg) scale(1);
    }

    75% {
        transform: rotate(-5deg) scale(0.95);
    }

    100% {
        transform: rotate(0deg) scale(1);
    }
}

.hit {
    animation: shake 0.2s ease-in-out;
}

/* Level & HP */
#char-info {
    margin-bottom: 10px;
    font-size: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#xp-bar-container {
    width: 200px;
    height: 10px;
    background: #444;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
}

/* Minion / Skeleton */
#minion-container {
    position: absolute;
    bottom: 20%;
    right: 20%;
    pointer-events: none;
}

.skeleton {
    width: 60px;
    height: 60px;
    image-rendering: pixelated;
    /* Crisp pixel art */
    animation: bounce 1s infinite alternate;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

.arrow {
    position: absolute;
    width: 30px;
    height: 30px;
    pointer-events: none;
    z-index: 5;
    background: none !important;
    border: none !important;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-5px);
    }
}

#xp-bar {
    width: 0%;
    height: 100%;
    background: #3eff3e;
    transition: width 0.2s;
}

#sandbag-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    margin-top: 20px;
}

#sandbag-controls button {
    background: #444;
    border: 1px solid #666;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 8px;
}

#sandbag-controls button:hover {
    background: #555;
}

#hp-bar-container {
    width: 200px;
    height: 15px;
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    position: relative;
    margin-bottom: 20px;
    overflow: hidden;
}

#hp-bar {
    width: 100%;
    height: 100%;
    background: #ff3e3e;
    transition: width 0.1s;
}

#hp-text {
    position: absolute;
    width: 100%;
    text-align: center;
    top: 0;
    line-height: 15px;
    font-size: 0.7rem;
    color: #fff;
    text-shadow: 1px 1px 1px #000;
}

/* Minions */
#minion-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 20;
}

.skeleton {
    width: 80px;
    height: 80px;
    position: absolute;
    bottom: 20%;
    left: 10%;
    /* Pixel Art Skeleton SVG */
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white" shape-rendering="crispEdges"><path d="M11 2h2v1h-2zM10 3h4v2h-4zM9 5h6v1H9zM11 6h2v2h-2zM8 8h8v1H8zM7 9h10v2H7zM9 11h6v3H9zM8 14h2v2h2v-2h4v2H8zM8 16h3v4H8zM13 16h3v4h-3zM6 10h1v4H6zM17 10h1v4h-1z"/></svg>') no-repeat center/contain;
    animation: bob 1s infinite;
    filter: drop-shadow(0 0 5px #000);
}

@keyframes bob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.arrow {
    position: absolute;
    width: 40px;
    height: 10px;
    /* Pixel Art Arrow SVG */
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 8" fill="%230ff" shape-rendering="crispEdges"><rect x="0" y="3" width="16" height="2"/><rect x="16" y="2" width="2" height="4"/><rect x="18" y="3" width="2" height="2"/><rect x="2" y="1" width="2" height="2"/><rect x="2" y="5" width="2" height="2"/></svg>') no-repeat center/contain;
    z-index: 9999;
    /* Ensure visible on top of everything */
    pointer-events: none;
    filter: drop-shadow(0 0 2px #0ff);
}

/* Sandbag Death */
#sandbag.dead {
    animation: shake 0.5s;
}

#sandbag.dead::before,
#sandbag.dead::after {
    height: 2px;
    top: 38px;
    background: #555;
    transition: all 0.1s;
}

/* Loot Filter */
#loot-filter {
    display: flex;
    gap: 8px;
    font-size: 0.7rem;
    color: #aaa;
}

#loot-filter label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 2px;
}

#loot-filter input {
    margin: 0;
    cursor: pointer;
}

.damage-text {
    position: absolute;
    color: #fff;
    font-weight: bold;
    font-size: 2rem;
    pointer-events: none;
    text-shadow: 2px 2px 0 #000;
    animation: floatUp 0.8s forwards;
    z-index: 100;
    left: 50%;
    top: 40%;
}

.damage-text.crit {
    color: #ff3e3e;
    font-size: 3rem;
    z-index: 101;
}

@keyframes floatUp {
    0% {
        transform: translate(-50%, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -100px) scale(1.5);
        opacity: 0;
    }
}

.panel-section {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 10px;
}

.panel-section h2 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    color: #aaa;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

#equipment-slots {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.slot {
    width: 60px;
    height: 60px;
    background: var(--slot-bg);
    border: 2px solid var(--slot-border);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.slot:hover {
    border-color: #888;
}

.slot-label {
    position: absolute;
    top: -18px;
    font-size: 0.7rem;
    color: #666;
    white-space: nowrap;
}

#inventory-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    height: 200px;
}

#trash-can {
    cursor: pointer;
    font-size: 1.2rem;
    padding: 2px 5px;
    border-radius: 4px;
    background: #333;
    border: 1px solid #555;
    transition: all 0.2s;
}

#trash-can:hover {
    background: #555;
}

#trash-can.active {
    background: #ff3e3e;
    border-color: #ff0000;
    box-shadow: 0 0 5px #ff0000;
}

.item {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.delete-mode .item {
    cursor: not-allowed;
    opacity: 0.8;
}

.delete-mode .item::after {
    content: '??;
 position: absolute;
    font-size: 1.2rem;
    color: red;
    text-shadow: 0 0 2px black;
}

.item.unique {
    border: 2px solid var(--rarity-unique);
    box-shadow: 0 0 10px var(--rarity-unique);
    animation: uniquePulse 2s infinite;
}

@keyframes uniquePulse {
    0% {
        box-shadow: 0 0 5px var(--rarity-unique);
    }

    50% {
        box-shadow: 0 0 15px var(--rarity-unique);
    }

    100% {
        box-shadow: 0 0 5px var(--rarity-unique);
    }
}

/* Shop / Gold */
#gold-display {
    text-shadow: 1px 1px 0 #000;
}

.game-btn {
    background: #444;
    color: #fff;
    border: 1px solid #666;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
}

.game-btn:hover {
    background: #555;
}

.game-btn:active {
    background: #333;
}

/* Floating Gold */
.gold-text {
    position: absolute;
    color: gold;
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    text-shadow: 1px 1px 0 #000;
    animation: floatUp 0.8s forwards;
    z-index: 100;
}

.item.rare {
    border: 2px solid var(--rarity-rare);
}

.item.magic {
    border: 2px solid var(--rarity-magic);
}

.item.normal {
    border: 1px solid var(--rarity-normal);
}

.item.food {
    border: 1px solid #55ff55;
}

.item.legendary {
    border: 2px solid var(--rarity-legendary);
    box-shadow: 0 0 5px var(--rarity-legendary);
}

.item.epic {
    border: 2px solid var(--rarity-epic);
}

/* Grid Drop Area */
#ground-items {
    height: 250px;
    /* Taller for 4 rows */
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    padding: 5px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 5px;
}

.ground-item {
    width: 100%;
    height: 100%;
    background: #444;
    border: 1px solid #666;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    border-radius: 4px;
    cursor: pointer;
    /* animation: bounce 0.5s; Removed per request */
    font-size: 1.5rem;
}

.ground-item.legendary {
    border-color: var(--rarity-legendary);
    color: var(--rarity-legendary);
}

.ground-item.epic {
    border-color: var(--rarity-epic);
    color: var(--rarity-epic);
}

.ground-item.rare {
    border-color: var(--rarity-rare);
    color: var(--rarity-rare);
}

.ground-item.magic {
    border-color: var(--rarity-magic);
    color: var(--rarity-magic);
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

#buff-bar {
    height: 20px;
    margin-top: 5px;
    display: flex;
    justify-content: center;
}

.buff {
    background: #d4a017;
    color: #000;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 1;
    }
}

#stats-summary {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #ccc;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px;
    border-radius: 5px;
}

/* Level Controls */
#sandbag-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
}

.lvl-btn {
    background: #444;
    border: 1px solid #666;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.8rem;
}

.lvl-btn:hover {
    background: #666;
}

.boss-btn {
    background: #500;
    border: 2px solid #a00;
    color: #ffaaaa;
    font-weight: bold;
    cursor: pointer;
    padding: 5px 15px;
    border-radius: 5px;
    animation: pulse 2s infinite;
}

.boss-btn:hover {
    background: #700;
}

/* Shop Modal */
#shop-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    background: #252525;
    border: 2px solid #555;
    z-index: 2000;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

#shop-modal.hidden {
    display: none;
}

/* Devil Mode */
#sandbag.devil {
    background: #500;
    /* Dark Red */
    border-color: #300;
    box-shadow: 0 0 20px #f00;
}

#sandbag.devil .eye {
    border-top: 5px solid black;
    /* Mean Eyes */
    background: #ffaa00;
}

#sandbag.devil .mouth {
    border-bottom: none;
    border-top: 3px solid #300;
    /* Frown */
    border-radius: 50% 50% 0 0;
}

/* Victory Overlay */
#victory-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

#victory-overlay.hidden {
    display: none;
}

.victory-content {
    background: #333;
    padding: 30px;
    border-radius: 10px;
    border: 2px solid gold;
    text-align: center;
    box-shadow: 0 0 30px gold;
}

.victory-content h1 {
    color: gold;
    font-size: 3rem;
}

.victory-content .stat-box {
    margin: 20px 0;
    font-size: 1.2rem;
    color: #eee;
}

/* ---- MEDIA QUERIES FOR MOBILE (Revised 3-Column) ---- */
/* Mobile Defaults Enforced */
/* @media screen and (max-width: 768px) { REMOVED */
body {
    overflow: hidden;
}

#main-wrapper {
    flex-direction: column;
    border-radius: 20px;
    /* Phone look */
    height: 100dvh;
    max-height: 900px;
    /* Limit height on big screens */
    width: 100%;
    max-width: 450px !important;
    /* Force constraint */
    margin: 0 auto;
    /* Center it */
    position: relative;
}

/* TOP HALF: SANDBAG */
#game-area {
    height: 55vh;
    /* Top 55% */
    flex: none;
    width: 100%;
    border-bottom: 2px solid #555;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    padding: 5px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

h1 {
    display: none;
}

/* Hide Title */

/* Player Info Top */
#char-info {
    font-size: 0.9rem;
    flex-direction: row;
    gap: 10px;
    margin: 0;
    position: static;
    transform: none;
    background: none;
    width: auto;
    /* Reset old styles */
}

#xp-bar-container {
    width: 100px;
    height: 6px;
    margin: 0;
}

#score-board {
    gap: 10px;
    margin-bottom: 5px;
}

.stat .label {
    font-size: 0.6rem;
}

#score,
#dps {
    font-size: 1rem;
}

#sandbag-controls {
    transform: scale(0.85);
    margin: 0;
}

#btn-boss {
    padding: 2px 8px;
    font-size: 0.8rem;
}

#sandbag-container {
    flex-grow: 1;
    width: 100%;
    /* Force alignment to TOP */
    align-items: flex-start;
    justify-content: center;
    padding-top: 0;
    /* Remove padding to let it go as high as possible */
    margin-top: -20px;
    /* Pull it up slightly under header if needed */
}

#sandbag {
    width: 30%;
    /* User requested Half Size (was 60%) */
    max-width: 250px;
    /* Reduced max width */
    height: auto;
    aspect-ratio: 0.8;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
    image-rendering: pixelated;
    transition: transform 0.05s;
    /* Removed margin-top to avoid overlap if container is small */
}

/* High Level Visual (Red/Dark) */
.sandbag-high-level {
    filter: sepia(1) hue-rotate(-50deg) saturate(4) contrast(1.2);
}

/* INTEGRATED HP BAR (HEADBAND) */
#hp-bar-container.headband {
    position: absolute;
    top: 25px;
    /* Forehead position */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    height: 12px;
    z-index: 5;
    border: 2px solid #222;
    border-radius: 5px;
    background: #333;
    margin: 0;
}

#hp-text {
    font-size: 0.6rem;
    line-height: 12px;
}

/* BOTTOM HALF: 3 COLUMNS */
#bottom-panel {
    height: 40vh;
    /* User request: 40% */
    width: 100%;
    background: #222;
    display: flex;
    overflow: hidden;
}

.b-col {
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2px;
}

.inv-controls {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
    /* Force single line */
}

#btn-open-shop,
#trash-can {
    font-size: 0.9rem;
    padding: 2px 5px;
    /* Add horizontal padding */
    white-space: nowrap;
}

.gold-mode {
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

h3 {
    margin: 2px 0;
    font-size: 0.8rem;
    color: #aaa;
    text-align: center;
}

/* COL 1: EQUIP (Fixed Width) */
#col-equip {
    flex: 0 0 13%;
    /* Reduced further */
    background: #1a1a1a;
    min-width: 0;
}

#equipment-slots {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    overflow-y: auto;
    height: 100%;
    padding-top: 5px;
}

#equipment-slots .slot {
    width: 70%;
    /* User request: 70% size */
    aspect-ratio: 1/1;
    background: #252525;
    border: 1px solid #444;
    position: relative;
    border-radius: 4px;
}

/* Silhouette for Empty Slots (High Contrast) */
.weapon-slot .slot-content:empty::before {
    content: '🗡️';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(100%);
}

.ring-slot .slot-content:empty::before {
    content: '💍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(100%);
}

/* COL 2: INVENTORY (Fixed Width) */
#col-inv {
    flex: 0 0 42%;
    /* Reduced further */
    background: #252525;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 1px solid #444;
}

/* ... (headers unchanged) ... */

#inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: min-content;
    /* Don't stretch rows, use content size */
    /* Fixed 20 slots */
    width: 100%;
    flex-grow: 1;
    gap: 2px;
    padding: 2px;
    overflow-y: auto;
}

/* Shared Slot Styles for Inventory AND Drops */
#inventory-grid .slot,
#ground-items .slot {
    width: 100%;
    height: auto;
    /* Remove 100% height to prevent stretching */
    aspect-ratio: 1 / 1;
    /* Force Square strictly */
    background: #333;
    /* Grid Background */
    border: 1px solid #444;
    /* Grid Border */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* COL 3: DROPS (Fixed Width) */
#col-drops {
    flex: 0 0 42%;
    /* Reduced further */
    background: #1e1e1e;
    border-right: none;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ... (filters unchanged) ... */

#ground-items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: min-content;
    /* Don't stretch */
    gap: 2px;
    width: 100%;
    flex-grow: 1;
    overflow-y: auto;
    padding: 2px;
}

.ground-item {
    font-size: 1.5rem;
    background: #2a2a2a;
    width: 100%;
    height: 100%;
    /* Fill slot */
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #555;
    /* Default solid border */
    box-sizing: border-box;
}

/* Rarity Border Colors (Solid & Bold) */
.ground-item.magic {
    border-color: #3b82f6;
}

/* Blue */
.ground-item.rare {
    border-color: #eab308;
}

/* Yellow */
.ground-item.epic {
    border-color: #a855f7;
}

/* Purple */
.ground-item.legendary {
    border-color: #ef4444;
}

/* Red */
.ground-item.unique {
    border-color: #ec4899;
    box-shadow: 0 0 5px #ec4899;
}

/* Pink + Glow */

/* Also apply to inventory items for consistency if desired, or keep as is */
.item.magic {
    border: 1px solid #3b82f6;
}

.item.rare {
    border: 1px solid #eab308;
}

.item.epic {
    border: 1px solid #a855f7;
}

.item.legendary {
    border: 1px solid #ef4444;
}

.item.unique {
    border: 1px solid #ec4899;
}

/* Shop Modal Centered */
/* Shop & Info Modal Centered */
#shop-modal,
#info-modal,
#generic-modal,
#settings-modal {
    position: fixed;
    width: 80%;
    /* Slightly smaller for popup feel */
    max-width: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* True Center */
    background: #222;
    /* Ensure background */
    border: 2px solid #555;
    border-radius: 10px;
    padding: 10px;
    z-index: 2000;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}


/* CSS Utility: Force Hide */
.hidden {
    display: none !important;
}

/* CSS Utility: Force Hide */
.hidden {
    display: none !important;
}

/* Fix Touch Drag: Prevent browser scrolling when touching items */
.item,
.ground-item {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Mobile UI Universal End */

/* New Features CSS */

/* DPS Meter */
#dps-meter-container {
    width: 95%;
    background: #333;
    border: 1px solid #555;
    padding: 5px 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    margin-top: auto;
    /* Push to bottom of Game Area */
    min-height: 30px;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.3);
}

#dps-meter-value {
    color: #ff5555;
    font-weight: bold;
    font-size: 1.1rem;
    text-shadow: 1px 1px 0 #000;
}

/* Info Buttons */
.info-btn-small {
    background: #0077ff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 5px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
}

.info-btn-small:hover {
    background: #0099ff;
}

/* Close Btn */
.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
}

.close-btn:hover {
    color: #f00;
}

/* Modal Body Text */
#modal-body {
    white-space: pre-wrap;
    /* Preserve newlines */
    text-align: left;
}

/* Item Level Display */
.item-level {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.5rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    padding: 0 2px;
    border-radius: 2px;
    pointer-events: none;
    line-height: normal;
    font-weight: 300;
    z-index: 10;
}

/* Minion CSS */
.skeleton {
    position: absolute;
    width: 60px;
    height: 60px;
    bottom: 50px;
    left: 20px;
    z-index: 5;
    pointer-events: none;
}

#minion-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.arrow {
    position: absolute;
    width: 30px;
    height: 30px;
    z-index: 6;
    pointer-events: none;
}

#btn-settings {
    font-size: 1.2rem;
    padding: 5px;
    background: none;
    border: none;
    cursor: pointer;
}

/* Fix Rope Visibility */
#sandbag::before {
    content: '';
    position: absolute;
    top: -50vh;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 50vh;
    background: #5d4037;
    z-index: -1;
}

#sandbag {
    position: relative;
    z-index: 1;
}

/* Restoring Lost Styles */

.ground-item {
    font-size: 1.5rem;
    background: #2a2a2a;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #555;
    box-sizing: border-box;
}

/* Rarity Colors */
.ground-item.magic,
.item.magic {
    border-color: #3b82f6;
}

.ground-item.rare,
.item.rare {
    border-color: #eab308;
}

.ground-item.epic,
.item.epic {
    border-color: #a855f7;
}

.ground-item.legendary,
.item.legendary {
    border-color: #ef4444;
}

.ground-item.unique,
.item.unique {
    border-color: #ec4899;
    box-shadow: 0 0 5px #ec4899;
}

/* Modals */
#shop-modal,
#info-modal,
#generic-modal,
#settings-modal {
    position: fixed;
    width: 80%;
    max-width: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #222;
    border: 2px solid #555;
    border-radius: 10px;
    padding: 10px;
    z-index: 2000;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

/* Utilities */
.hidden {
    display: none !important;
}

.item,
.ground-item {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* DPS Meter and Info Buttons */
#dps-meter-container {
    width: 95%;
    background: #333;
    border: 1px solid #555;
    padding: 5px 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    margin-top: auto;
    min-height: 30px;
}

#dps-meter-value {
    color: #ff5555;
    font-weight: bold;
}

.info-btn-small {
    background: #0077ff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin-left: 5px;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

#modal-body {
    white-space: pre-wrap;
    text-align: left;
}

.hidden {
    display: none !important;
}

.hidden {
    display: none !important;
}

@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.5);
    }

    100% {
        transform: scale(1);
    }
}

.damage-text.pop {
    animation: pop 0.1s ease-out;
}

@keyframes float-fall {
    0% {
        transform: translate(-50%, -50%);
        opacity: 1;
    }

    30% {
        transform: translate(-50%, -150%);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, 50%);
        opacity: 0;
    }
}

.damage-text {
    animation: float-fall 0.8s ease-out forwards;
}

#btn-patch {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: #333;
    color: #fff;
    border: 1px solid #666;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
}

#btn-patch:hover {
    background: #555;
}

#patch-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 4000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#patch-modal.hidden {
    display: none;
}

.patch-content {
    background: #222;
    border: 2px solid #555;
    padding: 20px;
    border-radius: 10px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    width: 400px;
}
#patch-modal .patch-content, #patch-text { touch-action: pan-y !important; -webkit-overflow-scrolling: touch !important; pointer-events: auto !important; }
