.alchemy {
    position: relative;
    overflow: hidden;
    padding-bottom: 12px;
    background:
        linear-gradient(180deg, rgba(31, 38, 42, 0.86), rgba(19, 20, 21, 0) 170px),
        #1b1b1d;
}

.alchemy__scene {
    position: relative;
    display: grid;
    grid-template-columns: 148px minmax(0, 1fr);
    grid-template-rows: 150px auto;
    align-items: center;
    overflow: hidden;
    padding: 8px 10px 10px;
    background:
        radial-gradient(circle at 34% 74%, rgba(46, 251, 51, 0.14), transparent 28%),
        radial-gradient(circle at 20% 10%, rgba(91, 188, 255, 0.16), transparent 34%),
        radial-gradient(circle at 82% 20%, rgba(155, 33, 248, 0.14), transparent 30%),
        linear-gradient(180deg, #272225 0%, #17191b 76%, #111 100%);
    border-bottom: 2px solid #111;
    box-shadow: inset 0 -20px 34px rgba(0, 0, 0, 0.35);
}

.alchemy__scene:before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 54px;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.34));
    pointer-events: none;
}

.alchemy__shelf {
    position: absolute;
    top: 13px;
    display: flex;
    gap: 5px;
    align-items: flex-end;
    padding: 5px 7px 7px;
    background: rgba(19, 20, 21, 0.72);
    border: 1px solid #292931;
    border-bottom-color: #0a0a0b;
    border-radius: 6px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.28);
}

.alchemy__shelf--left {
    left: 10px;
}

.alchemy__shelf--right {
    right: 10px;
}

.alchemy__shelf span {
    display: block;
    width: 9px;
    height: 18px;
    background: linear-gradient(180deg, #5bbcff 0 34%, #192a2f 35% 100%);
    border: 1px solid #111;
    border-radius: 5px 5px 3px 3px;
}

.alchemy__shelf span:nth-child(2) {
    height: 23px;
    background: linear-gradient(180deg, #9b21f8 0 36%, #271730 37% 100%);
}

.alchemy__shelf span:nth-child(3) {
    height: 15px;
    background: linear-gradient(180deg, #f87721 0 35%, #332016 36% 100%);
}

.alchemy__workbench {
    position: relative;
    z-index: 1;
    grid-row: 1 / 2;
    width: 148px;
    height: 142px;
    align-self: end;
}

.alchemy__workbench:after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 2px;
    height: 18px;
    background: linear-gradient(180deg, #3b281c, #211711);
    border: 1px solid #0b0705;
    border-radius: 5px;
}

.alchemy__cauldron {
    position: absolute;
    left: 20px;
    bottom: 22px;
    width: 108px;
    height: 76px;
    background:
        radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.12), transparent 16%),
        linear-gradient(180deg, #3d4447 0%, #1b1f21 56%, #080909 100%);
    border: 2px solid #111;
    border-radius: 14px 14px 38px 38px;
    box-shadow:
        inset 0 -11px 0 rgba(0, 0, 0, 0.3),
        0 12px 16px rgba(0, 0, 0, 0.35),
        0 0 24px rgba(61, 168, 91, 0.12);
}

.alchemy__cauldron:before {
    content: "";
    position: absolute;
    left: -9px;
    right: -9px;
    top: -11px;
    height: 22px;
    background:
        linear-gradient(180deg, #596166, #30363a);
    border: 2px solid #111;
    border-radius: 50%;
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.08);
}

.alchemy__cauldron:after {
    content: "";
    position: absolute;
    left: -15px;
    right: -15px;
    bottom: -8px;
    height: 11px;
    background: rgba(0, 0, 0, 0.42);
    border-radius: 50%;
    filter: blur(2px);
}

.alchemy__liquid {
    position: absolute;
    z-index: 1;
    left: 9px;
    right: 9px;
    top: -6px;
    height: 12px;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 26% 28%, rgba(255, 255, 255, 0.58), transparent 13%),
        radial-gradient(ellipse at 70% 64%, rgba(155, 33, 248, 0.42), transparent 38%),
        linear-gradient(105deg, #34d96b 0%, #34c6cf 42%, #7653f2 78%, #9b21f8 100%);
    background-size: 100% 100%, 120% 120%, 180% 100%;
    border: 1px solid rgba(171, 242, 255, 0.26);
    border-radius: 50%;
    opacity: 0;
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, 0.24),
        inset 0 -5px 8px rgba(17, 8, 34, 0.34),
        0 0 18px rgba(91, 188, 255, 0.28);
    transition: opacity 0.22s ease;
    transform-origin: center center;
    animation: alchemyLiquid 3.2s ease-in-out infinite;
}

.alchemy__liquid:before,
.alchemy__liquid:after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.alchemy__liquid:before {
    left: -8px;
    right: -8px;
    top: -4px;
    height: 11px;
    background:
        radial-gradient(ellipse at 16% 55%, rgba(255, 255, 255, 0.62) 0 8%, transparent 9%),
        radial-gradient(ellipse at 42% 48%, rgba(255, 255, 255, 0.34) 0 6%, transparent 7%),
        radial-gradient(ellipse at 76% 52%, rgba(255, 255, 255, 0.44) 0 7%, transparent 8%),
        linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(226, 255, 248, 0.34), rgba(255, 255, 255, 0));
    border-radius: 50%;
    opacity: 0.78;
    animation: alchemyLiquidWave 2.4s ease-in-out infinite;
}

.alchemy__liquid:after {
    inset: 2px 4px 3px;
    background:
        radial-gradient(circle at 30% 58%, rgba(246, 238, 113, 0.42), transparent 12%),
        radial-gradient(circle at 66% 42%, rgba(91, 188, 255, 0.58), transparent 16%);
    border-radius: 50%;
    mix-blend-mode: screen;
    opacity: 0.44;
    animation: alchemyLiquidGlow 2.8s ease-in-out infinite alternate;
}

.alchemy--cooking .alchemy__liquid {
    opacity: 0.92;
    animation-duration: 1.6s;
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, 0.24),
        inset 0 -5px 8px rgba(17, 8, 34, 0.34),
        0 0 18px rgba(91, 188, 255, 0.42),
        0 0 32px rgba(46, 251, 51, 0.22);
}

.alchemy__flame {
    position: absolute;
    z-index: 0;
    left: 51px;
    bottom: 11px;
    width: 46px;
    height: 54px;
    background:
        radial-gradient(circle at 52% 74%, #f6ee71 0 18%, transparent 19%),
        radial-gradient(circle at 50% 70%, #f1d600 0 26%, #f87721 44%, rgba(248, 119, 33, 0.22) 62%, transparent 70%);
    filter: blur(0.2px);
    transform-origin: center bottom;
    animation: alchemyFlame 0.9s ease-in-out infinite alternate;
}

.alchemy--cooking .alchemy__flame {
    animation-duration: 0.42s;
}

.alchemy__bubble,
.alchemy__steam {
    position: absolute;
    z-index: 2;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
}

.alchemy__bubble {
    width: 9px;
    height: 9px;
    border: 1px solid rgba(91, 188, 255, 0.9);
    animation: alchemyBubble 2.4s linear infinite;
}

.alchemy--cooking .alchemy__bubble {
    animation-duration: 1.15s;
}

.alchemy__bubble--one {
    left: 28px;
    top: -9px;
}

.alchemy__bubble--two {
    left: 54px;
    top: -2px;
    animation-delay: 0.7s;
}

.alchemy__bubble--three {
    left: 76px;
    top: -10px;
    animation-delay: 1.35s;
}

.alchemy__steam {
    width: 14px;
    height: 22px;
    border-left: 2px solid rgba(175, 180, 186, 0.28);
    transform: rotate(12deg);
    animation: alchemySteam 2.8s ease-in-out infinite;
}

.alchemy__steam--one {
    left: 29px;
    top: -34px;
}

.alchemy__steam--two {
    right: 30px;
    top: -31px;
    animation-delay: 0.8s;
    transform: rotate(-12deg);
}

.alchemy__spark {
    position: absolute;
    z-index: 3;
    width: 4px;
    height: 4px;
    background: #f6ee71;
    border-radius: 50%;
    box-shadow: 0 0 6px #f87721;
    opacity: 0;
    animation: alchemySpark 2.2s linear infinite;
}

.alchemy:not(.alchemy--cooking) .alchemy__bubble,
.alchemy:not(.alchemy--cooking) .alchemy__steam {
    display: none;
}

.alchemy__spark--one {
    left: 42px;
    top: 54px;
}

.alchemy__spark--two {
    left: 112px;
    top: 74px;
    animation-delay: 0.65s;
}

.alchemy__spark--three {
    left: 84px;
    top: 34px;
    animation-delay: 1.25s;
}

.alchemy__result {
    position: absolute;
    z-index: 5;
    left: 26px;
    top: -36px;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.24), rgba(91, 188, 255, 0.1) 54%, transparent 72%);
    border-radius: 50%;
    pointer-events: none;
}

.alchemy__result[hidden] {
    display: none;
}

.alchemy__result img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    filter: drop-shadow(0 0 7px rgba(91, 188, 255, 0.65));
}

.alchemy__result--show {
    animation: alchemyResult 1.45s ease-out both;
}

.alchemy__scene-text {
    position: relative;
    z-index: 1;
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    display: grid;
    gap: 5px;
    align-self: center;
    padding: 9px 8px;
    line-height: 1.35;
    text-align: center;
    background: rgba(19, 20, 21, 0.58);
    border: 1px solid rgba(41, 41, 49, 0.82);
    border-radius: 7px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.alchemy__scene-text .gems {
    font-family: Georgia, serif;
    font-size: 24px;
    line-height: 1.05;
    text-shadow: 0 0 9px rgba(91, 188, 255, 0.38);
}

.alchemy__scene-note {
    min-height: 17px;
    color: #afb4ba;
    font-size: 12px;
}

.alchemy__brew {
    position: relative;
    z-index: 2;
    grid-column: 1 / -1;
    grid-row: 2 / 3;
    align-self: end;
    margin-top: 4px;
    padding: 8px;
    font-size: 14px;
    background: rgba(19, 20, 21, 0.82);
    border: 1px solid #292931;
    border-radius: 7px;
}

.alchemy__brew-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: #ececec;
    font-size: 14px;
    line-height: 1.2;
}

.alchemy__brew-row span:first-child {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.alchemy__brew-track {
    height: 8px;
    margin-top: 6px;
    overflow: hidden;
    background: #080909;
    border: 1px solid #111;
    border-radius: 5px;
}

.alchemy__brew-track span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #4e4e4e, #abae52 54%, #33ff07);
    box-shadow: 0 0 10px rgba(91, 188, 255, 0.38);
    transition-property: width;
    transition-timing-function: linear;
}

.alchemy__status {
    margin: 8px;
    padding: 8px 10px;
    text-align: center;
    line-height: 1.35;
    background: #232429;
    border: 1px solid #111;
    border-left-color: #292931;
    border-radius: 7px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.alchemy__status--ok {
    color: #2efb33;
}

.alchemy__status--error {
    color: #fa2f4d;
}

.alchemy__section {
    position: relative;
}

.alchemy__section-title {
    padding: 8px 10px;
    text-align: center;
    background:
        linear-gradient(90deg, transparent, rgba(91, 188, 255, 0.08), transparent),
        #202022;
    border-top: 1px solid #292931;
    border-bottom: 1px solid #111;
}

.alchemy-recipes,
.alchemy-inventory {
    display: grid;
    gap: 0;
}

.alchemy-recipe {
    position: relative;
    display: flex;
    gap: 9px;
    padding: 10px 8px;
    background:
        linear-gradient(90deg, rgba(91, 188, 255, 0.035), transparent 42%),
        #1b1b1d;
    border-bottom: 1px solid #111;
}

.alchemy-recipe:nth-child(even),
.alchemy-inventory__item:nth-child(even) {
    background:
        linear-gradient(90deg, rgba(155, 33, 248, 0.035), transparent 44%),
        #232429;
}

.alchemy-recipe--locked {
    opacity: 0.68;
}

.alchemy-recipe--busy {
    filter: brightness(1.12);
}

.alchemy-recipe--busy:after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(91, 188, 255, 0.08), transparent);
    animation: alchemyRowBusy 1.1s linear infinite;
    pointer-events: none;
}

.alchemy-recipe__view {
    flex: 0 0 68px;
}

.alchemy-recipe__img {
    width: 66px;
    height: 66px;
    object-fit: contain;
    background:
        radial-gradient(circle at 50% 45%, rgba(91, 188, 255, 0.12), transparent 62%),
        #131415;
    border: 1px solid #292931;
    border-radius: 7px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 2px 0 rgba(0, 0, 0, 0.34);
}

.alchemy-recipe__body {
    min-width: 0;
    flex: 1;
}

.alchemy-recipe__head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    line-height: 1.3;
}

.alchemy-recipe__head > span:first-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

.alchemy-recipe__count {
    flex: 0 0 auto;
    color: #f6ee71;
    font-size: 12px;
}

.alchemy-recipe__timer {
    flex: 0 0 auto;
    align-self: flex-start;
    padding: 2px 5px;
    color: #2efb33;
    font-size: 14px;
    line-height: 1.2;
    background: rgba(19, 20, 21, 0.78);
    border: 1px solid rgba(46, 251, 51, 0.34);
    border-radius: 5px;
    box-shadow: 0 0 8px rgba(46, 251, 51, 0.12);
    white-space: nowrap;
}

.alchemy-recipe__meta {
    margin-top: 3px;
    color: #5bbcff;
    font-size: 14px;
    line-height: 1.25;
}

.alchemy-recipe__desc {
    margin-top: 4px;
    color: #afb4ba;
    font-size: 14px;
    line-height: 1.35;
}

.alchemy-recipe__ingredients {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.alchemy-ingredient-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    min-height: 22px;
    padding: 2px 6px;
    color: #ececec;
    font-size: 14px;
    line-height: 1.2;
    background: #131415;
    border: 1px solid #292931;
    border-radius: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.alchemy-ingredient-chip img {
    border-radius: 50%;
    background: #081018;
}

.alchemy-ingredient-chip--miss {
    color: #fa2f4d;
    border-color: rgba(250, 47, 77, 0.35);
}

.alchemy-recipe__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
}

.alchemy-recipe__amount {
    width: 50px;
    height: 34px;
    color: #ececec;
    text-align: center;
    background: #313436;
    border: 1px solid #111;
    border-top-color: #4a4f52;
    border-left-color: #4a4f52;
    border-radius: 5px;
    box-sizing: border-box;
}

.alchemy-recipe__actions .btn {
    min-width: 104px;
    height: 36px;
    font-size: 16px;
}

.alchemy-recipe__speedup-btn {
    min-width: 102px !important;
    padding-left: 8px;
    padding-right: 8px;
    color: #ececec;
    background: #956127 linear-gradient(#956127 50%, #885117 50%);
    border-color: #aa6d2a #aa6d2a #6a4015 #6a4015;
}

.alchemy-recipe__speedup-btn--ready {
    box-shadow: 0 0 10px rgba(248, 119, 33, 0.34);
}

.alchemy-recipe__speedup-btn.btn_disabled {
    opacity: 0.72;
    cursor: pointer;
}

.alchemy-recipe__instant-btn {
    min-width: 118px !important;
    gap: 2px;
    padding-left: 8px;
    padding-right: 8px;
    color: #ececec;
    background: #345881 linear-gradient(#345881 50%, #224971 50%);
}

.alchemy--busy .alchemy-recipe:not(.alchemy-recipe--busy) {
    opacity: 0.5;
}

.alchemy-inventory {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.alchemy-inventory__item {
    min-width: 0;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    min-height: 42px;
    padding: 7px 8px;
    border-bottom: 1px solid #111;
}

.alchemy-inventory__img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    padding: 3px;
    box-sizing: border-box;
    background: #081018;
    border: 1px solid #292931;
    border-radius: 50%;
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.45));
}

.alchemy-inventory__name {
    overflow: hidden;
    color: #ececec;
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.alchemy-inventory__count {
    min-width: 24px;
    color: #5bbcff;
    font-size: 12px;
    text-align: right;
}

.alchemy-fly {
    position: fixed;
    z-index: 10000;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 0 6px rgba(91, 188, 255, 0.75));
    animation: alchemyFly 0.76s cubic-bezier(0.24, 0.86, 0.36, 1) forwards;
}



@keyframes alchemyLiquidWave {
    0%, 100% {
        transform: translateX(-5px) translateY(0) scaleX(1.02);
        opacity: 0.58;
    }
    50% {
        transform: translateX(5px) translateY(2px) scaleX(0.96);
        opacity: 0.9;
    }
}

@keyframes alchemyLiquidGlow {
    from {
        transform: translateX(-3px) scale(0.94);
        opacity: 0.32;
    }
    to {
        transform: translateX(4px) scale(1.04);
        opacity: 0.56;
    }
}

@keyframes alchemyFlame {
    from {
        transform: scaleY(0.9);
        opacity: 0.72;
    }
    to {
        transform: scaleY(1.08);
        opacity: 0.98;
    }
}

@keyframes alchemyBubble {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }
    20% {
        opacity: 0.85;
    }
    100% {
        transform: translateY(-54px) scale(1.25);
        opacity: 0;
    }
}

@keyframes alchemySteam {
    0% {
        transform: translateY(8px) rotate(10deg) scale(0.7);
        opacity: 0;
    }
    35% {
        opacity: 0.55;
    }
    100% {
        transform: translateY(-22px) rotate(-8deg) scale(1.08);
        opacity: 0;
    }
}

@keyframes alchemySpark {
    0% {
        transform: translateY(0) scale(0.6);
        opacity: 0;
    }
    16% {
        opacity: 0.95;
    }
    100% {
        transform: translateY(-34px) translateX(8px) scale(0.2);
        opacity: 0;
    }
}

@keyframes alchemyFly {
    0% {
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    72% {
        opacity: 1;
    }
    100% {
        transform: translate3d(var(--alchemy-fly-x), var(--alchemy-fly-y), 0) scale(0.42) rotate(26deg);
        opacity: 0;
    }
}

@keyframes alchemyResult {
    0% {
        transform: translateY(28px) scale(0.45);
        opacity: 0;
    }
    28% {
        transform: translateY(-8px) scale(1.12);
        opacity: 1;
    }
    68% {
        transform: translateY(-18px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-28px) scale(0.9);
        opacity: 0;
    }
}

@keyframes alchemyRowBusy {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@media (max-width: 360px) {
    .alchemy__scene {
        grid-template-columns: 132px minmax(0, 1fr);
        padding-left: 6px;
        padding-right: 6px;
    }

    .alchemy__workbench {
        transform: translateX(-5px) scale(0.92);
        transform-origin: left bottom;
    }

    .alchemy__scene-text {
        padding-left: 6px;
        padding-right: 6px;
    }

    .alchemy__scene-text .gems {
        font-size: 21px;
    }

    .alchemy-recipe {
        gap: 7px;
        padding-left: 6px;
        padding-right: 6px;
    }

    .alchemy-recipe__view {
        flex-basis: 60px;
    }

    .alchemy-recipe__img {
        width: 58px;
        height: 58px;
    }

    .alchemy-recipe__actions .btn {
        min-width: 92px;
        padding-left: 8px;
        padding-right: 8px;
        font-size: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .alchemy *,
    .alchemy-fly {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
