:root {
    --pb-bg: #0a0c14;
    --pb-surface: #141824;
    --pb-surface2: #1c2030;
    --pb-border: #2a3040;
    --pb-gold: #f0c040;
    --pb-gold-dim: #8a7030;
    --pb-blue: #4a90d9;
    --pb-green: #4ade80;
    --pb-red: #f87171;
    --pb-purple: #a78bfa;
    --pb-text: #e2e8f0;
    --pb-text-dim: #8892a6;
    --pb-player-bg: #1e293b;
    --pb-common: #c0c0c0;
    --pb-rare: #4169e1;
    --pb-epic: #9400d3;
    --pb-covert: #eb4b4b;
    --pb-legendary: #ffd700;
    --pb-skinvalue: #C0C0C0;
}

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

body {
    background: var(--pb-bg);
    color: var(--pb-text);
    font-family: "Montserrat", sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ═══════════════════════════════════════════
   UPGRADE GAME — Futuristic 3D UI
   ═══════════════════════════════════════════ */
/* Main container */
.upgradegame-container {
    max-width: 1100px; margin: 0 auto; padding: 20px;
}

/* Header */
.upgradegame-header {
    text-align: center; margin: 30px 0 24px;
    padding-top: 10px;
}
.upgradegame-header h1 {
    font-size: 2.2rem; font-weight: 800;
    font-family: "Orbitron", sans-serif;
    background: linear-gradient(135deg, #6200ff, #00ff6a);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.upgradegame-header p { color: gray; margin-top: 6px; font-size: 0.9rem; font-family: 'Montserrat', sans-serif; }
/* ── Loading Overlay ─────────────────────────── */
.upgrade-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(7, 11, 20, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 100;
    transition: opacity 0.3s ease;
    border-radius: 12px;
}
.upgrade-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.upgrade-loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(111, 0, 255, 0.2);
    border-top-color: rgb(111, 0, 255);
    border-radius: 50%;
    animation: upgrade-spin 0.8s linear infinite;
}

@keyframes upgrade-spin {
    to { transform: rotate(360deg); }
}

.upgrade-loading-text {
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

/* Make gameContent3 position relative so overlay is contained */
#gameContent3 {
    position: relative;
    min-height: 200px;
}

.upgradegame-container {
    margin: 0px auto;
    padding: 24px;
    background: linear-gradient(135deg, rgba(20, 10, 40, 0.85), rgba(10, 5, 25, 0.9));
    border: 1px solid rgba(111, 0, 255, 0.35);
    box-shadow: 0 0 40px rgba(111, 0, 255, 0.15), inset 0 0 60px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
}

.upgradegame-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* ── Button groups ── */
.upgradegame-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
}
.skin-upgrade-btn .primary-button {
    padding: 10px 20px;
    border: 1px solid rgba(111, 0, 255, 0.5);
    border-radius: 0;
    clip-path: polygon(8% 0, 100% 0, 92% 100%, 0% 100%);
    background: rgba(20, 10, 40, 0.8);
    color: #c0a8ff;
    cursor: pointer;
    min-width: 80px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    text-shadow: 0 0 6px rgba(160, 100, 255, 0.4);
}
.upgradegame-button-group .button {
    padding: 10px 20px;
    border: 1px solid rgba(111, 0, 255, 0.5);
    border-radius: 0;
    clip-path: polygon(8% 0, 100% 0, 92% 100%, 0% 100%);
    background: rgba(20, 10, 40, 0.8);
    color: #c0a8ff;
    cursor: pointer;
    min-width: 80px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    text-shadow: 0 0 6px rgba(160, 100, 255, 0.4);
}

.upgradegame-button-group .button:hover {
    background: rgba(111, 0, 255, 0.3);
    border-color: rgba(180, 100, 255, 0.8);
    color: #fff;
    box-shadow: 0 0 18px rgba(111, 0, 255, 0.5);
    transform: translateY(-1px);
}

.upgradegame-button-group .button.selected {
    background: linear-gradient(135deg, #6f00ff, #9333ea);
    color: #fff;
    border-color: #a855f7;
    box-shadow: 0 0 22px rgba(111, 0, 255, 0.7), inset 0 0 12px rgba(255, 255, 255, 0.1);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* ── Angle slider control ── */
.upgradegame-angle-control {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 16px;
    color: #b8a0e0;
    font-size: 0.85rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
}

.upgradegame-angle-control input[type="range"] {
    -webkit-appearance: none;
    width: 180px;
    height: 6px;
    border-radius: 3px;
    background: var(--pb-surface2);
    outline: none;
    cursor: pointer;
}

.upgradegame-angle-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff, #c0a0ff);
    border: 2px solid #6f00ff;
    box-shadow: 0 0 16px rgba(111, 0, 255, 0.7);
    cursor: pointer;
}

#upgradegame-angleDisplay {
    display: inline-block;
    min-width: 42px;
    text-align: center;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-shadow: 0 0 8px rgba(160, 100, 255, 0.6);
}

/* Offset display — fixed width to prevent jitter when value changes */
#skin-upgrade-offsetDisplay {
    display: inline-block;
    min-width: 42px;
    text-align: center;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-shadow: 0 0 8px rgba(160, 100, 255, 0.6);
}

/* Hide angle control during spin — preserve layout space to prevent jitter */
.upgradegame-angle-control.spin-locked {
    visibility: hidden;
}

/* ── Canvas ── */
.upgradegame-container canvas {
    border: none;
    border-radius: 50%;
    box-shadow: 0 0 30px rgba(111, 0, 255, 0.3), 0 0 80px rgba(111, 0, 255, 0.1);
    background: radial-gradient(circle, rgba(15, 8, 30, 0.95), rgba(5, 2, 15, 1));
}

#skin-upgrade-Canvas {
}

/* ── Skin Upgrade button (#skin-upgrade-btn) ── */
#skin-upgrade-btn {
    padding: 14px 48px;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #6f00ff, #a855f7);
    border: 1px solid rgba(180, 130, 255, 0.6);
    color: #fff;
    clip-path: polygon(6% 0, 100% 0, 94% 100%, 0% 100%);
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 24px rgba(111, 0, 255, 0.5);
    position: relative;
    overflow: hidden;
}

#skin-upgrade-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #8b20ff, #c060ff);
    box-shadow: 0 0 40px rgba(140, 30, 255, 0.7);
    transform: translateY(-2px);
}

#skin-upgrade-btn:active:not(:disabled) {
    transform: scale(0.96);
}

#skin-upgrade-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(30%);
}

/* ── Result text ── */
.upgradegame-result {
    font-size: 1.2rem;
    font-weight: 700;
    min-height: 2rem;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    transition: all 0.3s ease;
}

.upgradegame-result.success {
    color: #22ff66;
    text-shadow: 0 0 14px rgba(0, 255, 100, 0.7);
    animation: resultPulse 0.6s ease-out;
}

.upgradegame-result.failure {
    color: #ff3355;
    text-shadow: 0 0 10px rgba(255, 50, 80, 0.5);
}

.upgradegame-result.error {
    color: #ff6644;
    text-shadow: 0 0 8px rgba(255, 100, 60, 0.5);
    animation: shake 0.4s ease;
}

/* ── Potential reward ── */
.upgradegame-potential-reward {
    font-size: 1.05rem;
    color: #c8b0ff;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    text-shadow: 0 0 8px rgba(160, 120, 255, 0.4);
    min-height: 1.5rem;
}

/* ── Keyframes ── */
@keyframes resultPulse {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* ═══════════════════════════════════════════
   SKIN UPGRADE — Two-Pane Layout
   ═══════════════════════════════════════════ */
.skin-upgrade-layout {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    min-height: 320px;
}

.skin-upgrade-box {
    flex: 1;
    background: rgba(15, 8, 30, 0.75);
    border: 1px solid rgba(111, 0, 255, 0.3);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(4px);
    box-shadow: 0 0 20px rgba(111, 0, 255, 0.08);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.skin-upgrade-box:hover {
    border-color: rgba(140, 60, 255, 0.5);
    box-shadow: 0 0 28px rgba(111, 0, 255, 0.15);
}

/* Box Header */
.skin-upgrade-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(111, 0, 255, 0.12);
    border-bottom: 1px solid rgba(111, 0, 255, 0.2);
}

.skin-upgrade-box-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    color: #d4c0ff;
}

.skin-upgrade-box-count {
    font-size: 0.75rem;
    color: #8a7ab0;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
}

/* Box Search */
.skin-upgrade-box-search {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(111, 0, 255, 0.12);
}

.skin-upgrade-box-search input {
    width: 100%;
    padding: 7px 12px;
    background: rgba(10, 5, 22, 0.7);
    border: 1px solid rgba(111, 0, 255, 0.3);
    border-radius: 4px;
    color: #d0c0ff;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.skin-upgrade-box-search input:focus {
    border-color: rgba(160, 80, 255, 0.6);
    box-shadow: 0 0 10px rgba(111, 0, 255, 0.2);
}

.skin-upgrade-box-search input::placeholder {
    color: rgba(180, 150, 220, 0.4);
}

/* Box List — scrollable grid container */
.skin-upgrade-box-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    max-height: 260px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(111, 0, 255, 0.3) transparent;
}

.skin-upgrade-box-list::-webkit-scrollbar {
    width: 5px;
}

.skin-upgrade-box-list::-webkit-scrollbar-track {
    background: transparent;
}

.skin-upgrade-box-list::-webkit-scrollbar-thumb {
    background: rgba(111, 0, 255, 0.35);
    border-radius: 3px;
}

/* Items grid — 5 columns, scrollable */
.skin-upgrade-items-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    contain: layout style;
}

/* Individual Item Card (grid cell) */
.skin-upgrade-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    box-sizing: border-box;
    background: rgba(20, 12, 38, 0.6);
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    gap: 2px;
    min-width: 0;
    transition: all 0.15s;
    content-visibility: auto;
    contain-intrinsic-size: auto 150px;
    position: relative;
}

.skin-upgrade-item:hover {
    background: rgba(40, 20, 70, 0.6);
    border-color: rgba(111, 0, 255, 0.35);
}

.skin-upgrade-item.selected {
    background: rgba(80, 30, 140, 0.55);
    border-color: rgba(160, 80, 255, 0.6);
    box-shadow: 0 0 12px rgba(111, 0, 255, 0.25);
}

.skin-upgrade-item.selected-target {
    background: rgba(0, 180, 60, 0.3);
    border-color: rgba(0, 220, 100, 0.7);
    box-shadow: 0 0 16px rgba(0, 255, 100, 0.25);
}

.skin-upgrade-item-info {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

/* Item image + tier background wrapper */
.skin-upgrade-item-img-wrap {
    width: 56px; height: 56px;
    border-radius: 50%;
    margin: 2px auto 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.skin-upgrade-item-img-wrap img {
    width: 48px; height: 48px;
    object-fit: contain;
    border-radius: 4px;
    position: relative;
    z-index: 1;
}

/* Item type (before "|") — smaller, reduced weight */
.skin-upgrade-item-type {
    font-size: 0.58rem;
    font-weight: 450;
    color: #9a8abc;
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
    line-height: 1.1;
}

/* Item name (after "|") */
.skin-upgrade-item-name {
    font-size: 0.68rem;
    font-weight: 600;
    color: #e0d0ff;
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
    line-height: 1.2;
}

.skin-upgrade-item-meta {
    display: flex;
    gap: 8px;
    font-size: 0.62rem;
    color: #9a8abc;
    font-family: 'Montserrat', sans-serif;
    justify-content: center;
}

.skin-upgrade-item-wear {
    color: #b0a0d0;
}

.skin-upgrade-item-value {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--pb-skinvalue);
    font-family: 'Montserrat', sans-serif;
    text-shadow: 0 0 6px rgba(0, 220, 80, 0.4);
    white-space: nowrap;
    text-align: center;
    margin-top: 1px;
}

/* Partial badge — top-right corner tag for battle team split items */
.skin-upgrade-item-partial-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-family: "Montserrat", sans-serif;
    font-size: 0.5rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #4a90d9, #2856a3);
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    z-index: 3;
    pointer-events: none;
}

/* Empty State */
.skin-upgrade-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 100px;
    color: #5a4a7a;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.85rem;
    text-align: center;
    padding: 20px;
}

/* Box Footer */
.skin-upgrade-box-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: rgba(111, 0, 255, 0.08);
    border-top: 1px solid rgba(111, 0, 255, 0.18);
    font-size: 0.78rem;
    color: #b0a0d0;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
}

.skin-upgrade-box-footer strong {
    color: #d4c0ff;
}

/* ═══════════════════════════════════════════
   SKIN UPGRADE — Select All / Deselect All Buttons
   ═══════════════════════════════════════════ */
.skin-upgrade-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.skin-select-all-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    color: #b0a0d0;
    background: rgba(111, 0, 255, 0.12);
    border: 1px solid rgba(111, 0, 255, 0.25);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.skin-select-all-btn:hover {
    background: rgba(111, 0, 255, 0.25);
    border-color: rgba(160, 80, 255, 0.5);
    color: #d4c0ff;
    box-shadow: 0 0 8px rgba(111, 0, 255, 0.2);
}

/* Sort Button */
.skin-sort-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    color: #b0a0d0;
    background: rgba(111, 0, 255, 0.12);
    border: 1px solid rgba(111, 0, 255, 0.25);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.skin-sort-btn:hover {
    background: rgba(111, 0, 255, 0.25);
    border-color: rgba(160, 80, 255, 0.5);
    color: #d4c0ff;
    box-shadow: 0 0 8px rgba(111, 0, 255, 0.2);
}

/* Target Value Input (item DB header) */
.skin-target-value-input {
    width: 70px;
    padding: 4px 6px;
    font-size: 0.68rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    color: #d0c0ff;
    background: rgba(10, 5, 22, 0.7);
    border: 1px solid rgba(111, 0, 255, 0.3);
    border-radius: 3px;
    outline: none;
    text-align: right;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}
.skin-target-value-input:focus {
    border-color: rgba(160, 80, 255, 0.6);
    box-shadow: 0 0 8px rgba(111, 0, 255, 0.2);
}
.skin-target-value-input::placeholder {
    color: rgba(180, 150, 220, 0.4);
    font-weight: 500;
}
/* Hide number input spinners (Chrome/Safari/Edge) */
.skin-target-value-input::-webkit-outer-spin-button,
.skin-target-value-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
/* Hide number input spinners (Firefox) */
.skin-target-value-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Spin Lock — disable pointer events on boxes during spin */
.skin-upgrade-box.spin-locked {
    pointer-events: none;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

/* ═══════════════════════════════════════════
   SKIN UPGRADE — Canvas Row (imgs + canvas + preview)
   ═══════════════════════════════════════════ */
.skin-upgrade-canvas-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 16px;
}

/* ═══════════════════════════════════════════
   SKIN UPGRADE — Canvas
   ═══════════════════════════════════════════ */
.skin-upgrade-canvas-stack {
    position: relative;
    width: 300px;
    height: 300px;
    flex-shrink: 0;
    margin: 0 auto;
}

/* Result overlay — sits on top of the canvas */
.skin-upgrade-result-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    pointer-events: none;
    overflow: hidden;
    transition: opacity 0.35s ease;
}
.skin-upgrade-result-overlay.success {
    background: rgba(0, 180, 60, 0.25);
}
.skin-upgrade-result-overlay.fail {
    background: rgba(180, 20, 20, 0.25);
}
.skin-upgrade-result-overlay img {
    max-width: 65%;
    max-height: 50%;
    object-fit: contain;
    image-rendering: auto;
}
.skin-upgrade-result-overlay-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    margin-top: 4px;
    font-family: 'Montserrat', sans-serif;
}
.skin-upgrade-result-overlay-info span {
    text-align: center;
    text-shadow: 0 0 6px rgba(0,0,0,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}
#skin-upgrade-result-overlay-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
}
#skin-upgrade-result-overlay-wear {
    font-size: 0.6rem;
    color: #ccc;
}
#skin-upgrade-result-overlay-value {
    font-size: 0.7rem;
    font-weight: 700;
    color: #22ff66;
}

/* ═══════════════════════════════════════════
   SKIN UPGRADE — Preview Box (right side, no border by default)
   ═══════════════════════════════════════════ */
.upgradeskin-preview-box {
    width: 240px;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
    border-radius: 6px;
    background: rgba(15, 8, 30, 0.7);
    border: 1px solid rgba(111, 0, 255, 0.3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    margin-right: 5%;
}

/* Green success — solid glow (no animation) */
.upgradeskin-preview-box.success-glow {
    animation: none;
    border-color: rgba(0, 255, 80, 1) !important;
    box-shadow:
        0 0 24px rgba(0, 255, 80, 0.8),
        0 0 60px rgba(0, 255, 100, 0.4) !important;
}

/* Black fail state */
.upgradeskin-preview-box.fail-glow {
    animation: none;
    border-color: rgba(0, 0, 0, 0.9) !important;
    box-shadow:
        0 0 30px rgba(0, 0, 0, 0.6) !important;
}

/* Placeholder text */
.upgradeskin-preview-placeholder {
    color: rgba(180, 150, 220, 0.4);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    text-align: center;
    padding: 10px;
}

/* Preview image */
.upgradeskin-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    image-rendering: auto;
    
}

/* Preview info (name, wear, value) — overlaid at bottom center of image */
.upgradeskin-preview-info {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 4px 10px;
    background: rgba(7, 5, 18, 0.5);
    border-radius: 6px;
    pointer-events: none;
    max-width: 140px;
}

.upgradeskin-preview-name {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    color: #e0d0ff;
    text-align: center;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 130px;
}

.upgradeskin-preview-wear {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.6rem;
    color: #9a8abc;
    white-space: nowrap;
}

.upgradeskin-preview-value {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    color: #22dd66;
    text-shadow: 0 0 6px rgba(0, 220, 80, 0.4);
    white-space: nowrap;
}

/* ═══════════════════════════════════════════
   SKIN UPGRADE — Selected Items Image Stack
   ═══════════════════════════════════════════ */
.userselectedskin-img-list {
    position: relative;
    width: 180px;
    height: 220px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10%;
}

.userselectedskin-img-list .stacked-img {
    position: absolute;
    width: 240px;
    height: 320px;
    object-fit: contain;
    border-radius: 6px;
    background: rgba(15, 8, 30, 0.7);
    border: 1px solid rgba(111, 0, 255, 0.3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

/* Staggered stacking — slightly offset each */
.userselectedskin-img-list .stacked-img:nth-child(1) {
    z-index: 1;
    transform: rotate(-6deg) translateX(-15px);
}
.userselectedskin-img-list .stacked-img:nth-child(2) {
    z-index: 2;
    transform: rotate(-2deg) translateY(-8px);
}
.userselectedskin-img-list .stacked-img:nth-child(3) {
    z-index: 3;
    transform: rotate(4deg) translateX(15px);
}

/* Empty state */
.userselectedskin-img-list:empty::after {
    content: 'Select items';
    color: rgba(180, 150, 220, 0.3);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    text-align: center;
}

/* Sum value overlay inside the selected-skin image stack */
.skin-selected-sum-value {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: 4px 12px;
    background: rgba(10, 5, 22, 0.85);
    border: 1px solid rgba(111, 0, 255, 0.35);
    border-radius: 4px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    color: #d0c0ff;
    white-space: nowrap;
    pointer-events: none;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — Mobile optimizations
   ═══════════════════════════════════════════ */
@media (max-width: 700px) {
    /* ── Full-width container on mobile ── */
    .upgradegame-container {
        max-width: 100%;
        margin: 10px 4px;
        padding: 12px 8px;
        clip-path: none;
        border-radius: 8px;
    }
    .upgradegame-header h1 {
        font-size: 1.6rem;
    }

    /* ── Canvas sizing — shrink to fit mobile screen ── */
    .upgradegame-area {
        gap: 10px;
    }
    #skin-upgrade-Canvas {
        width: 260px !important;
        height: 260px !important;
    }

    /* ── Two-pane layout stacks vertically ── */
    .skin-upgrade-layout {
        flex-direction: column;
        min-height: auto;
        gap: 10px;
    }
    .skin-upgrade-box-list {
        max-height: 170px;
    }
    .skin-upgrade-box {
        max-height: 260px;
    }

    /* ── Canvas row: stack vertically ── */
    .skin-upgrade-canvas-row {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    .skin-upgrade-canvas-stack {
        width: 260px;
        height: 260px;
    }
    .upgradeskin-preview-box {
        width: 110px;
        height: 110px;
    }
    .userselectedskin-img-list {
        width: 130px;
        height: 160px;
    }

    /* ── Button groups — larger touch targets ── */
    .upgradegame-button-group {
        gap: 6px;
    }
    .upgradegame-button-group .button {
        padding: 12px 14px;
        min-width: 56px;
        font-size: 0.78rem;
    }

    /* ── Slider controls ── */
    .upgradegame-angle-control {
        flex-wrap: wrap;
        gap: 6px;
        font-size: 0.75rem;
    }
    .upgradegame-angle-control input[type="range"] {
        width: 130px;
    }

    /* ── Upgrade buttons — full-width on mobile ── */
    #skin-upgrade-btn {
        width: 100%;
        max-width: 300px;
        padding: 14px 24px;
        font-size: 1rem;
    }

    /* ── Header actions / select-all buttons ── */
    .skin-upgrade-header-actions {
        gap: 4px;
    }
    .skin-select-all-btn {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* ── Search inputs ── */
    .skin-upgrade-box-search input {
        font-size: 0.9rem;  /* 16px+ prevents iOS zoom */
        padding: 8px 12px;
    }

    /* ── Result text ── */
    .upgradegame-result {
        font-size: 1rem;
    }
    .upgradegame-potential-reward {
        font-size: 0.9rem;
    }

    /* ── Disable heavy backdrop-filter on mobile ── */
    .upgradegame-container {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .skin-upgrade-box {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .upgrade-loading-overlay {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    /* ── User selected skin img stack ── */
    .userselectedskin-img-list .stacked-img {
        width: 80px;
        height: 115px;
    }
}

/* ═══════════════════════════════════════════
   Fix: prevent global-announcement-wrapper
   from shifting down and overlapping buttons
   on small screens
   ═══════════════════════════════════════════ */
.global-announcement-wrapper {
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .global-announcement-wrapper {
        top: auto !important;
        overflow-x: hidden;
    }
}