/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-container { position: relative; }
.search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px 12px 12px 40px;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.search-input:focus {
    background: rgba(0, 0, 0, 0.45);
    border-color: rgba(129, 140, 248, 0.5);
    box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.12);
}
.search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 1rem; pointer-events: none;
}

/* ============================================================
   TOOL BUTTONS
   ============================================================ */
.tools { display: flex; gap: 8px; margin-top: 12px; }
.tool-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 9px;
    border-radius: 10px;
    font-size: 0.78rem; font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.tool-btn:hover { background: rgba(255, 255, 255, 0.09); color: white; }
.tool-btn:active { transform: scale(0.97); }
.tool-btn.active {
    background: rgba(129, 140, 248, 0.14);
    color: var(--accent-2);
    border-color: rgba(129, 140, 248, 0.45);
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.15), 0 4px 12px rgba(129, 140, 248, 0.18);
}

/* ============================================================
   BOTTOM-BAR BUTTONS
   ============================================================ */
.bar-btn {
    position: relative;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 22px;
    border-radius: 999px;
    font-size: 0.85rem; font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    font-family: inherit;
}
.bar-btn:hover { background: rgba(255, 255, 255, 0.1); color: white; }
.bar-btn:active { transform: scale(0.96); }
.bar-btn.danger:hover { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

/* ============================================================
   INVENTORY ITEMS — LIQUID GLASS CARDS
   ============================================================ */
.inv-item {
    position: relative;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.04) 42%, rgba(129, 140, 248, 0.06) 100%),
        rgba(18, 18, 28, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--item-radius);
    padding: 10px 11px;
    min-width: 0;
    display: flex; align-items: center; gap: 8px;
    cursor: pointer;
    transition:
        transform 0.22s var(--ease-out),
        background 0.22s var(--ease-out),
        border-color 0.22s var(--ease-out),
        box-shadow 0.22s var(--ease-out);
    animation: invIn 0.4s var(--ease-out) backwards;
    backdrop-filter: blur(10px) saturate(160%);
    -webkit-backdrop-filter: blur(10px) saturate(160%);
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.38),
        inset 0 1px 0 rgba(255, 255, 255, 0.34),
        inset 0 -1px 0 rgba(0, 0, 0, 0.28),
        inset 1px 0 0 rgba(255, 255, 255, 0.08);
    overflow: hidden;
    isolation: isolate;
}

@keyframes invIn {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Top specular highlight — bright rim that gives the glass its sheen */
.inv-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        160deg,
        rgba(255, 255, 255, 0.28) 0%,
        rgba(255, 255, 255, 0.05) 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.03) 80%,
        rgba(255, 255, 255, 0.1) 100%
    );
    pointer-events: none;
    mix-blend-mode: overlay;
    opacity: 0.9;
    z-index: 0;
}

/* Bottom internal refraction — softens the lower half of the glass */
.inv-item::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        radial-gradient(ellipse 120% 50% at 50% 110%, rgba(129, 140, 248, 0.12), transparent 60%),
        radial-gradient(ellipse 100% 40% at 50% -20%, rgba(255, 255, 255, 0.18), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.inv-item .emoji,
.inv-item .name { position: relative; z-index: 1; }

.inv-item:hover {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05) 60%),
        rgba(22, 22, 34, 0.75);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px) scale(1.025);
    box-shadow:
        0 12px 30px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(129, 140, 248, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.inv-item:active { transform: translateY(-1px) scale(1.01); }

.inv-item .emoji {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.45));
    transition: transform 0.3s var(--ease-spring);
}
.inv-item:hover .emoji { transform: scale(1.1) rotate(-3deg); }

.inv-item .name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   DRAGGABLE CANVAS ELEMENTS — LIQUID GLASS PILL
   ============================================================ */
.element {
    position: absolute;
    background:
        linear-gradient(150deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.05) 40%, rgba(129, 140, 248, 0.08) 100%),
        rgba(20, 20, 30, 0.7);
    backdrop-filter: blur(9px) saturate(165%);
    -webkit-backdrop-filter: blur(9px) saturate(165%);
    color: #f8fafc;
    padding: 10px 18px;
    border-radius: 50px;
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 0.95rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.22);
    cursor: grab;
    z-index: 10;
    transition:
        box-shadow 0.2s var(--ease-out),
        border-color 0.2s var(--ease-out),
        opacity 0.18s;
    touch-action: none;
    backface-visibility: hidden;
    contain: layout style;
    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.46),
        0 2px 6px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.42),
        inset 0 -1px 0 rgba(0, 0, 0, 0.34),
        inset 1px 0 0 rgba(255, 255, 255, 0.1);
    isolation: isolate;
    overflow: hidden;
}

.element::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(165deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.08) 22%, transparent 48%),
        radial-gradient(ellipse 90% 55% at 50% 120%, rgba(165, 180, 252, 0.16), transparent 65%);
    pointer-events: none;
    z-index: 0;
}

.element::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 12%;
    right: 12%;
    height: 38%;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent);
    pointer-events: none;
    z-index: 0;
    opacity: 0.75;
}

.element > * { position: relative; z-index: 1; }

/* Dragging: keep glass look; perf handled in liquid-glass.css */
.element.dragging {
    cursor: grabbing;
    z-index: 1000;
    will-change: left, top, transform;
    border-color: rgba(255, 255, 255, 0.42);
    box-shadow:
        0 22px 44px rgba(0, 0, 0, 0.5),
        0 6px 14px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.55),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

body.is-dragging .element:not(.dragging) {
    transition: none;
}

.element .emoji { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45)); }

/* ============================================================
   DISCOVERY MODAL — PREMIUM LIQUID GLASS
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(5, 5, 12, 0.72);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.discovery-card {
    position: relative;
    padding: 64px 72px;
    border-radius: 32px;
    text-align: center;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.06) 38%, rgba(129, 140, 248, 0.1) 100%),
        linear-gradient(180deg, rgba(28, 28, 40, 0.78), rgba(10, 10, 16, 0.86));
    border: 1px solid rgba(255, 255, 255, 0.24);
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    box-shadow:
        0 40px 90px -18px rgba(0, 0, 0, 0.78),
        0 0 50px rgba(129, 140, 248, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.48),
        inset 0 -1px 0 rgba(0, 0, 0, 0.35),
        inset 1px 0 0 rgba(255, 255, 255, 0.1);
    transform: translateY(28px) scale(0.94);
    opacity: 0;
    transition: transform 0.45s var(--ease-out), opacity 0.35s ease;
    overflow: hidden;
    isolation: isolate;
}
.modal-overlay.open .discovery-card { transform: translateY(0) scale(1); opacity: 1; }

/* Top specular sheen */
.discovery-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        165deg,
        rgba(255, 255, 255, 0.18) 0%,
        rgba(255, 255, 255, 0.02) 30%,
        transparent 55%,
        rgba(165, 180, 252, 0.04) 80%,
        rgba(255, 255, 255, 0.08) 100%
    );
    pointer-events: none;
    z-index: 0;
}

/* Animated shine sweep on open */
.discovery-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -100%;
    width: 60%;
    height: 200%;
    background: linear-gradient(
        100deg,
        transparent 0%,
        rgba(255, 255, 255, 0.08) 30%,
        rgba(255, 255, 255, 0.22) 50%,
        rgba(255, 255, 255, 0.08) 70%,
        transparent 100%
    );
    transform: rotate(8deg);
    pointer-events: none;
    transition: left 1.1s ease;
    z-index: 0;
}
.modal-overlay.open .discovery-card::after {
    left: 130%;
    transition-delay: 0.25s;
}

.d-badge {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1c1917;
    font-weight: 800;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 2.4px;
    padding: 7px 14px;
    border-radius: 999px;
    display: inline-block;
    margin-bottom: 26px;
    box-shadow:
        0 6px 16px rgba(245, 158, 11, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.d-icon {
    position: relative;
    z-index: 1;
    font-size: 6rem;
    margin-bottom: 20px;
    display: block;
    filter: drop-shadow(0 14px 40px rgba(0, 0, 0, 0.5));
    animation: float 4s ease-in-out infinite;
}
.d-name {
    position: relative;
    z-index: 1;
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-12px) rotate(2deg); }
}

/* ============================================================
   FX — PARTICLES, SHAKE, SHOCKWAVE, MERGE BLOB
   ============================================================ */
.particle {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    z-index: 2000;
    box-shadow: 0 0 8px currentColor;
}

.shake { animation: shake 0.32s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 1px, 0); }
    20%, 80% { transform: translate3d(2px, -1px, 0); }
    30%, 50%, 70% { transform: translate3d(-3px, 2px, 0); }
    40%, 60% { transform: translate3d(3px, -2px, 0); }
}

/* Expanding ring at the merge point */
.shockwave {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    pointer-events: none;
    z-index: 1500;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}
.shockwave.accent { border-color: rgba(165, 180, 252, 0.85); box-shadow: 0 0 40px rgba(129, 140, 248, 0.5); }

.element.merging {
    pointer-events: none;
    will-change: transform, opacity;
    z-index: 50;
}

/* ============================================================
   MULTI-SELECT & HINTS
   ============================================================ */
.selection-box {
    position: absolute;
    background: rgba(129, 140, 248, 0.12);
    border: 1px solid rgba(129, 140, 248, 0.55);
    border-radius: 6px;
    pointer-events: none;
    z-index: 9999;
    display: none;
    box-shadow:
        0 0 0 1px rgba(129, 140, 248, 0.15),
        inset 0 0 24px rgba(129, 140, 248, 0.1);
}

.element.selected {
    border-color: rgba(165, 180, 252, 0.85);
    box-shadow:
        0 0 0 2px var(--accent),
        0 0 22px rgba(129, 140, 248, 0.55),
        0 14px 32px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        inset 0 0 0 1px rgba(165, 180, 252, 0.25);
    z-index: 100;
}

.element.hint {
    z-index: 90;
    border-color: rgba(255, 255, 255, 0.72);
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.45),
        0 0 24px rgba(165, 180, 252, 0.4),
        0 12px 28px rgba(0, 0, 0, 0.46),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
    animation: hintPulse 1.1s ease-in-out infinite;
}
@keyframes hintPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35), 0 0 18px rgba(165, 180, 252, 0.28), 0 12px 28px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
    50% { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6), 0 0 28px rgba(165, 180, 252, 0.5), 0 14px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.55); }
}

/* ============================================================
   FUSION FLASH — the moment two pills collide and release energy
   ============================================================ */
.fusion-flash {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background:
        radial-gradient(circle,
            rgba(255, 255, 255, 0.9) 0%,
            rgba(199, 210, 254, 0.4) 40%,
            transparent 72%);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    z-index: 1400;
    mix-blend-mode: screen;
}

@media (prefers-reduced-motion: reduce) {
    .inv-item { animation: none; }
    .element.hint { animation: none; }
    .d-icon { animation: none; }
}
