﻿/* ============================================
   CHEMISTRY LABORATORY — GAME DESIGN
   Full CSS3 + Framer-Motion-style animations
   ============================================ */

/* === SPRING EASING (Framer Motion style) === */
:root {
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-soft: cubic-bezier(0.22, 1.2, 0.36, 1);
    --spring-bounce: cubic-bezier(0.18, 1.8, 0.4, 1);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out-expo: cubic-bezier(0.87, 0, 0.13, 1);
    --lab-accent: #2563EB;
    --lab-accent-2: #60A5FA;
    --lab-danger: #ff4757;
    --lab-fire: #ff6348;
    --lab-glow: rgba(37, 99, 235, 0.15);
}

/* === LAYOUT === */
.chem-lab-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 80vh;
    position: relative;
    overflow: hidden;
}

/* === HEADER === */
.chem-header {
    padding: 20px 20px 12px;
}
.chem-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #1A1D26;
    margin: 0 0 6px;
}
.chem-header h2 i {
    color: var(--lab-accent-2);
    margin-right: 8px;
}
.chem-header p {
    font-size: 13px;
    color: #9CA3B4;
    margin: 0;
}

/* === TOP BAR: SEARCH === */
.chem-search-bar {
    position: relative;
    padding: 16px 20px;
    background: #FFFFFF;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.chem-search-bar input {
    width: 100%;
    padding: 14px 20px 14px 48px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    color: #1A1D26;
    font-size: 15px;
    outline: none;
    transition: all 0.3s var(--spring-soft);
}
.chem-search-bar input:focus {
    border-color: var(--lab-accent);
    box-shadow: 0 0 0 3px var(--lab-glow), 0 4px 20px rgba(0,0,0,0.3);
    transform: scale(1.01);
}
.chem-search-bar input::placeholder {
    color: #9CA3B4;
}
.chem-search-bar > i,
.chem-search-icon {
    position: absolute;
    left: 36px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3B4;
    font-size: 16px;
    pointer-events: none;
}

/* === CATEGORY FILTER CHIPS === */
.chem-category-filters {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.chem-category-filters::-webkit-scrollbar { display: none; }

.chem-cat-chip {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: 20px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.07);
    color: #9CA3B4;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.35s var(--spring-soft);
    white-space: nowrap;
    user-select: none;
}
.chem-cat-chip:hover {
    background: rgba(0, 0, 0, 0.02);
    color: #1A1D26;
    transform: translateY(-1px);
}
.chem-cat-chip.active {
    background: var(--lab-accent);
    color: #1A1D26;
    border-color: var(--lab-accent);
    box-shadow: 0 4px 15px var(--lab-glow);
    transform: scale(1.05);
}

/* === SUBSTANCE SHELF (search results grid) === */
.chem-shelf-section {
    padding: 0;
}
.shelf-header {
    padding: 14px 20px 0;
}
.shelf-header h3 {
    font-size: 14px;
    color: #5F6980;
    font-weight: 500;
    margin: 0;
}
.shelf-header h3 small {
    font-size: 11px;
    color: rgba(255,255,255,0.25);
    font-weight: 400;
}
.chem-shelf {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    padding: 16px 20px;
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(108,92,231,0.3) transparent;
}

.chem-bottle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 6px 10px;
    border-radius: 14px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.07);
    cursor: pointer;
    transition: all 0.4s var(--spring);
    position: relative;
    overflow: hidden;
    user-select: none;
    animation: bottleAppear 0.5s var(--spring) both;
}
.chem-bottle:nth-child(2) { animation-delay: 0.03s; }
.chem-bottle:nth-child(3) { animation-delay: 0.06s; }
.chem-bottle:nth-child(4) { animation-delay: 0.09s; }
.chem-bottle:nth-child(5) { animation-delay: 0.12s; }
.chem-bottle:nth-child(6) { animation-delay: 0.15s; }
.chem-bottle:nth-child(7) { animation-delay: 0.18s; }
.chem-bottle:nth-child(8) { animation-delay: 0.21s; }

@keyframes bottleAppear {
    0% { opacity: 0; transform: scale(0.7) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.chem-bottle:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(255,255,255,0.15);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}
.chem-bottle:active {
    transform: scale(0.95);
    transition-duration: 0.1s;
}

.bottle-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    position: relative;
    transition: all 0.3s ease;
}
.bottle-icon::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 14px;
    background: inherit;
    opacity: 0.15;
    filter: blur(8px);
}

/* Category colors */
.bottle-icon.cat-nonmetal   { background: linear-gradient(135deg, #00b894, #00cec9); color: #1A1D26; }
.bottle-icon.cat-alkali     { background: linear-gradient(135deg, #e17055, #d63031); color: #1A1D26; }
.bottle-icon.cat-alkaline   { background: linear-gradient(135deg, #fdcb6e, #e17055); color: #1A1D26; }
.bottle-icon.cat-halogen    { background: linear-gradient(135deg, #a29bfe, #6c5ce7); color: #1A1D26; }
.bottle-icon.cat-noble      { background: linear-gradient(135deg, #636e72, #b2bec3); color: #1A1D26; }
.bottle-icon.cat-transition { background: linear-gradient(135deg, #ffeaa7, #fdcb6e); color: #333; }
.bottle-icon.cat-metal      { background: linear-gradient(135deg, #74b9ff, #0984e3); color: #1A1D26; }
.bottle-icon.cat-compound   { background: linear-gradient(135deg, #fd79a8, #e84393); color: #1A1D26; }
.bottle-icon.cat-acid       { background: linear-gradient(135deg, #ff6b6b, #ee5a24); color: #1A1D26; }
.bottle-icon.cat-base       { background: linear-gradient(135deg, #4834d4, #686de0); color: #1A1D26; }
.bottle-icon.cat-salt       { background: linear-gradient(135deg, #7ed6df, #22a6b3); color: #1A1D26; }
.bottle-icon.cat-organic    { background: linear-gradient(135deg, #badc58, #6ab04c); color: #1A1D26; }
.bottle-icon.cat-oxide      { background: linear-gradient(135deg, #f8a5c2, #f78fb3); color: #1A1D26; }
.bottle-icon.cat-indicator  { background: linear-gradient(135deg, #cf6a87, #e66767); color: #1A1D26; }

.bottle-name {
    font-size: 10px;
    color: #9CA3B4;
    text-align: center;
    line-height: 1.2;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bottle-number {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 8px;
    color: rgba(255,255,255,0.2);
}

/* On table indicator */
.chem-bottle.on-table {
    border-color: var(--lab-accent);
    background: rgba(108,92,231,0.12);
    box-shadow: 0 0 15px var(--lab-glow);
}
.chem-bottle.on-table::after {
    content: '✓';
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 10px;
    color: var(--lab-accent-2);
}

/* === WORKBENCH / TABLE === */
.chem-workbench {
    position: relative;
    padding: 20px;
    background: linear-gradient(180deg, 
        #F0F2F5 0%,
        #E8EBF0 50%,
        #E2E5EB 100%);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    min-height: 280px;
}

.workbench-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.workbench-header h3 {
    font-size: 15px;
    color: #5F6980;
    font-weight: 600;
    margin: 0;
}
.chem-clear-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    background: #FFFFFF;
    color: #9CA3B4;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.chem-clear-btn:hover {
    border-color: #ff4757;
    color: #ff4757;
    background: rgba(255,71,87,0.08);
}

.workbench-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.table-zone {
    flex: 1;
    min-width: 0;
}
.table-label {
    font-size: 12px;
    color: #9CA3B4;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}
.table-label small {
    font-size: 10px;
    color: rgba(255,255,255,0.15);
    text-transform: none;
    letter-spacing: 0;
}

.table-substance.in-flask {
    border-color: var(--lab-accent);
    background: rgba(108,92,231,0.15);
    box-shadow: 0 0 12px var(--lab-glow);
}
.table-substance.in-flask::before {
    content: '🧪';
    font-size: 10px;
    position: absolute;
    top: -8px;
    left: -4px;
}

.flask-highlight {
    position: absolute;
    top: 0;
    left: 5%;
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0.06), transparent);
    border-radius: inherit;
    pointer-events: none;
}

/* Items on the table */
.table-items {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 70px;
    padding: 16px;
    border-radius: 16px;
    background: #FFFFFF;
    border: 2px dashed rgba(255,255,255,0.06);
    transition: all 0.3s ease;
    margin-bottom: 20px;
    align-items: center;
}
.table-items.highlight {
    border-color: var(--lab-accent);
    background: rgba(108,92,231,0.05);
}
.table-items:empty::after {
    content: 'Нажмите на вещества выше, чтобы добавить на стол ↑';
    color: rgba(255,255,255,0.15);
    font-size: 13px;
    width: 100%;
    text-align: center;
}

.table-substance {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    animation: substanceSlide 0.4s var(--spring) both;
    transition: all 0.3s var(--spring);
    position: relative;
}

@keyframes substanceSlide {
    0% { opacity: 0; transform: translateX(-20px) scale(0.8); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

.table-substance:hover {
    background: rgba(108,92,231,0.15);
    border-color: var(--lab-accent);
    transform: translateY(-2px);
}
.table-substance:active {
    transform: scale(0.93);
}

.table-substance .sub-symbol {
    font-weight: 700;
    font-size: 15px;
    color: #1A1D26;
}
.table-substance .sub-name {
    font-size: 11px;
    color: #9CA3B4;
}
.table-substance .sub-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ff4757;
    color: #1A1D26;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s var(--spring);
}
.table-substance:hover .sub-remove {
    opacity: 1;
    transform: scale(1);
}

/* === FLASK ZONE === */
.flask-zone {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 24px;
    padding: 10px 0;
}

.flask-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.flask-3d {
    width: 120px;
    height: 160px;
    position: relative;
    cursor: pointer;
    transition: transform 0.4s var(--spring);
    perspective: 600px;
}
.flask-3d:hover {
    transform: scale(1.05);
}

.flask-body {
    position: absolute;
    bottom: 0;
    left: 10px;
    right: 10px;
    height: 110px;
    background: #FFFFFF;
    border-radius: 0 0 50% 50% / 0 0 40% 40%;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-top: none;
    overflow: hidden;
    transition: border-color 0.3s ease;
}
.flask-body::after {
    content: '';
    position: absolute;
    top: 0;
    left: 5%;
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0.06), transparent);
    border-radius: inherit;
}

.flask-neck {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 60px;
    background: #FFFFFF;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}
.flask-neck::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: -20px;
    right: -20px;
    height: 2px;
    background: rgba(0, 0, 0, 0.04);
}

.flask-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    transition: height 0.6s var(--spring-soft), background 0.5s ease;
    border-radius: 0 0 50% 50% / 0 0 60% 60%;
}
.flask-liquid.has-content {
    height: 60%;
}

.flask-liquid.bubbling::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 10%;
    right: 10%;
    height: 10px;
    background: radial-gradient(circle at 20% 50%, rgba(255,255,255,0.3) 2px, transparent 3px),
                radial-gradient(circle at 60% 30%, rgba(255,255,255,0.2) 3px, transparent 4px),
                radial-gradient(circle at 80% 60%, rgba(255,255,255,0.25) 2px, transparent 3px);
    animation: bubbleFloat 1.5s ease-in-out infinite;
}

@keyframes bubbleFloat {
    0%, 100% { transform: translateY(0); opacity: 0.7; }
    50% { transform: translateY(-8px); opacity: 1; }
}

.flask-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    justify-content: center;
    z-index: 2;
}
.flask-tag {
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(0,0,0,0.65);
    color: #FFFFFF;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.flask-label {
    font-size: 12px;
    color: #9CA3B4;
    text-align: center;
    font-weight: 500;
}

/* === MIX BUTTON === */
.chem-mix-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 40px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--lab-accent), #a855f7);
    color: #1A1D26;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s var(--spring);
    position: relative;
    overflow: hidden;
    margin: 16px auto 0;
    letter-spacing: 0.5px;
}
.chem-mix-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}
.chem-mix-btn:hover::before {
    transform: translateX(100%);
}
.chem-mix-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 40px var(--lab-glow), 0 0 80px rgba(108,92,231,0.2);
}
.chem-mix-btn:active {
    transform: scale(0.96);
    transition-duration: 0.1s;
}
.chem-mix-btn.reacting {
    animation: mixBtnPulse 0.6s ease;
    pointer-events: none;
}
@keyframes mixBtnPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.1); box-shadow: 0 0 60px var(--lab-glow); }
    100% { transform: scale(1); }
}

/* Removed chem-clear-all (now using chem-clear-btn) */

/* === REACTION RESULT AREA === */
.chem-result-zone {
    padding: 0 20px 20px;
    transition: all 0.5s ease;
}

.chem-equation-box {
    padding: 18px 24px;
    border-radius: 14px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.07);
    text-align: center;
    font-family: 'Cambria', 'Georgia', serif;
    font-size: 18px;
    color: #1A1D26;
    letter-spacing: 1px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s var(--spring);
    margin-bottom: 16px;
    overflow-x: auto;
}
.chem-equation-box.visible {
    opacity: 1;
    transform: translateY(0);
}
.chem-equation-box .eq-arrow {
    color: var(--lab-accent);
    font-size: 22px;
    margin: 0 6px;
}
.chem-equation-box .eq-state {
    color: #ff6348;
    font-weight: 700;
}
.chem-equation-box .eq-coeff {
    color: var(--lab-accent-2);
    font-weight: 700;
}

/* Reaction info card */
.chem-info-card {
    border-radius: 16px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.07);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    transition: all 0.6s var(--spring);
}
.chem-info-card.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.info-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #FFFFFF;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}
.info-card-header h4 {
    font-size: 16px;
    color: #1A1D26;
    font-weight: 600;
    flex: 1;
}
.info-icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.info-icon-circle.exo { background: linear-gradient(135deg, #ff6348, #ff4757); }
.info-icon-circle.endo { background: linear-gradient(135deg, #4834d4, #686de0); }
.info-icon-circle.neutral { background: linear-gradient(135deg, #636e72, #b2bec3); }

.reaction-badge {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.reaction-badge.badge-exo { background: rgba(255,99,72,0.15); color: #ff6348; }
.reaction-badge.badge-endo { background: rgba(72,52,212,0.15); color: #a29bfe; }
.reaction-badge.badge-neutral { background: rgba(178,190,195,0.15); color: #b2bec3; }

.reaction-badge.badge-danger { 
    background: rgba(255,71,87,0.2); 
    color: #ff4757; 
    animation: dangerPulse 1.5s ease infinite;
}
@keyframes dangerPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,71,87,0.3); }
    50% { box-shadow: 0 0 15px 5px rgba(255,71,87,0.15); }
}

.info-card-body {
    padding: 16px 20px;
}

.info-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.info-detail {
    padding: 10px;
    border-radius: 10px;
    background: #FFFFFF;
}
.info-detail-label {
    font-size: 10px;
    color: #9CA3B4;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.info-detail-value {
    font-size: 14px;
    color: #1A1D26;
    font-weight: 500;
}

.info-description {
    font-size: 14px;
    line-height: 1.6;
    color: #5F6980;
    margin-bottom: 16px;
    padding: 12px;
    border-radius: 10px;
    background: #FFFFFF;
}

.info-medical {
    padding: 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(108,92,231,0.08), rgba(168,85,247,0.05));
    border: 1px solid rgba(37, 99, 235, 0.15);
}
.info-medical h5 {
    font-size: 13px;
    color: var(--lab-accent-2);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.info-medical p {
    font-size: 13px;
    line-height: 1.6;
    color: #9CA3B4;
}

.info-danger-warning {
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(255,71,87,0.08);
    border: 1px solid rgba(255,71,87,0.2);
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #ff6b6b;
    animation: dangerWarningAppear 0.5s var(--spring) both;
}
@keyframes dangerWarningAppear {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* === HISTORY PANEL === */
.chem-history-section {
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
}
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.history-header h3 {
    font-size: 14px;
    color: #5F6980;
    font-weight: 500;
    margin: 0;
}
.history-stats {
    display: flex;
    gap: 10px;
}
.stat-pill {
    padding: 4px 12px;
    border-radius: 8px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.07);
    font-size: 11px;
    color: #9CA3B4;
}
.stat-pill strong {
    color: var(--lab-accent-2);
    font-weight: 700;
}

.chem-hist-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(108,92,231,0.2) transparent;
}

.hist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.07);
    cursor: pointer;
    transition: all 0.3s ease;
    animation: histAppear 0.3s var(--spring) both;
}
.hist-item:hover {
    background: #FFFFFF;
    border-color: rgba(255,255,255,0.1);
}
.hist-item .hist-eq {
    flex: 1;
    font-size: 12px;
    color: #5F6980;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hist-item .hist-name {
    font-size: 11px;
    color: #9CA3B4;
}
.hist-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
}
@keyframes histAppear {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}

.history-empty-msg {
    text-align: center;
    padding: 24px;
    color: rgba(255,255,255,0.15);
    font-size: 13px;
}
.history-empty-msg i {
    font-size: 28px;
    margin-bottom: 8px;
    display: block;
}

/* === REACTION ANIMATIONS === */
.reaction-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    animation: particleExplode var(--dur, 0.8s) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes particleExplode {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

.smoke-puff {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 99;
    animation: smokeUp 2s ease-out forwards;
}
@keyframes smokeUp {
    0% { opacity: 0.8; transform: translateY(0) scale(0.5); }
    100% { opacity: 0; transform: translateY(-80px) scale(2.5); }
}

.fire-spark {
    position: absolute;
    width: 4px;
    height: 8px;
    border-radius: 2px;
    background: linear-gradient(180deg, #ff6348, #ffbe76);
    pointer-events: none;
    z-index: 100;
    animation: fireSpark 0.6s ease-out forwards;
}
@keyframes fireSpark {
    0% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2) rotate(var(--rot, 180deg)); }
}

.explosion-flash {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    z-index: 98;
    pointer-events: none;
    animation: flashBang 0.4s ease-out forwards;
}
@keyframes flashBang {
    0% { background: rgba(255,200,100,0.6); }
    50% { background: rgba(255,255,255,0.3); }
    100% { background: transparent; }
}

.shake-danger {
    animation: shakeIt 0.5s ease-in-out;
}
@keyframes shakeIt {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-4px); }
    30%, 70% { transform: translateX(4px); }
}

.ice-crystal {
    position: absolute;
    font-size: 14px;
    pointer-events: none;
    z-index: 100;
    animation: crystallize 1.5s ease-out forwards;
}
@keyframes crystallize {
    0% { opacity: 0; transform: translateY(0) scale(0) rotate(0deg); }
    50% { opacity: 1; transform: translateY(-30px) scale(1.2) rotate(180deg); }
    100% { opacity: 0; transform: translateY(-60px) scale(0.8) rotate(360deg); }
}

.precipitate-dot {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    animation: precipFall 1.2s ease-in forwards;
}
@keyframes precipFall {
    0% { opacity: 0.8; transform: translateY(0); }
    100% { opacity: 0.3; transform: translateY(var(--fall, 60px)); }
}

.flask-glow {
    animation: flaskGlowPulse 1.5s ease-in-out infinite;
}
@keyframes flaskGlowPulse {
    0%, 100% { filter: drop-shadow(0 0 5px var(--glow-color, rgba(108,92,231,0.3))); }
    50% { filter: drop-shadow(0 0 25px var(--glow-color, rgba(108,92,231,0.6))); }
}

/* === SAFETY BANNER === */
.chem-safety {
    margin: 12px 20px;
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(255,168,0,0.06);
    border: 1px solid rgba(255,168,0,0.15);
    font-size: 11px;
    color: rgba(255,168,0,0.7);
    text-align: center;
}

/* ============================================
   🎮 GAME BAR — XP, Level, Combo
   ============================================ */
.chem-game-bar {
    padding: 14px 20px;
    background: linear-gradient(135deg, rgba(108,92,231,0.08), rgba(168,85,247,0.04));
    border-bottom: 1px solid rgba(37, 99, 235, 0.15);
}
.game-level {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.game-level-badge {
    background: linear-gradient(135deg, var(--lab-accent), #a855f7);
    color: #1A1D26;
    padding: 4px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 3px 12px var(--lab-glow);
}
.game-xp-bar {
    flex: 1;
    height: 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.02);
    overflow: hidden;
    position: relative;
}
.game-xp-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--lab-accent), #a855f7);
    transition: width 0.5s var(--spring);
    position: relative;
}
.game-xp-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    background: rgba(255,255,255,0.4);
    border-radius: 0 6px 6px 0;
    filter: blur(2px);
}
.game-xp-text {
    font-size: 11px;
    color: #9CA3B4;
    white-space: nowrap;
    min-width: 60px;
    text-align: right;
}
.game-stats-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.game-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 12px;
    border-radius: 8px;
    background: #FFFFFF;
}
.game-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--lab-accent-2);
}
.game-stat-label {
    font-size: 9px;
    color: #9CA3B4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.combo-glow {
    background: rgba(255,200,0,0.15) !important;
    border: 1px solid rgba(255,200,0,0.3);
    animation: comboGlowPulse 0.8s ease infinite;
}
.combo-glow .game-stat-value { color: #ffc800; }
@keyframes comboGlowPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,200,0,0.2); }
    50% { box-shadow: 0 0 15px 3px rgba(255,200,0,0.15); }
}

/* ============================================
   SEARCH ROW + HINT BUTTON
   ============================================ */
.chem-search-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    padding: 0;
}
.chem-search-row .chem-search-bar {
    flex: 1;
    border-bottom: none;
}
.chem-hint-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    background: rgba(255,200,0,0.08);
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s var(--spring);
    margin: 16px 20px 16px 0;
}
.chem-hint-btn:hover {
    background: rgba(255,200,0,0.15);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255,200,0,0.2);
}
.chem-hint-msg {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s var(--spring);
    font-size: 13px;
    color: rgba(255,200,0,0.8);
}
.chem-hint-msg.visible {
    padding: 10px 20px;
    max-height: 60px;
    background: rgba(255,200,0,0.05);
    border-bottom: 1px solid rgba(255,200,0,0.1);
}

/* ============================================
   BOTTLE REAL COLOR LABEL
   ============================================ */
.bottle-real-color {
    font-size: 8px;
    color: rgba(255,255,255,0.2);
    text-align: center;
    line-height: 1.1;
    max-width: 80px;
}

/* bottle icon — use inline style from JS, not category colors */
.bottle-icon {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* sub-symbol on table */
.table-substance .sub-symbol {
    padding: 4px 8px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
}

/* ============================================
   XP POPUP
   ============================================ */
.xp-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    padding: 10px 24px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--lab-accent), #a855f7);
    color: #1A1D26;
    font-size: 18px;
    font-weight: 700;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.4s var(--spring);
    box-shadow: 0 8px 30px var(--lab-glow);
    white-space: nowrap;
}
.xp-popup.show {
    opacity: 1;
    transform: translate(-50%, -60%) scale(1);
}

/* ============================================
   LEVEL UP OVERLAY
   ============================================ */
.level-up-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.5s ease;
    backdrop-filter: blur(6px);
}
.level-up-overlay.show { opacity: 1; }
.level-up-card {
    text-align: center;
    padding: 40px 50px;
    border-radius: 24px;
    background: linear-gradient(180deg, #FFFFFF, #F8FAFB);
    border: 2px solid var(--lab-accent);
    box-shadow: 0 12px 40px rgba(37,99,235,0.15), 0 0 60px rgba(37,99,235,0.08);
    transform: scale(0.7);
    transition: transform 0.5s var(--spring-bounce);
}
.level-up-overlay.show .level-up-card { transform: scale(1); }
.level-up-icon {
    font-size: 56px;
    margin-bottom: 12px;
    animation: levelStar 1s ease infinite;
}
@keyframes levelStar {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(10deg); }
    75% { transform: scale(1.1) rotate(-5deg); }
}
.level-up-card h3 {
    font-size: 28px;
    color: #1A1D26;
    margin: 0 0 8px;
    background: linear-gradient(135deg, #2563EB, #8B5CF6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.level-up-card p {
    font-size: 14px;
    color: #5F6980;
    margin: 0;
}

/* ============================================
   ACHIEVEMENT POPUP
   ============================================ */
.achievement-popup {
    position: fixed;
    top: 80px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-radius: 16px;
    background: rgba(255,255,255,0.97);
    border: 1px solid rgba(255,200,0,0.4);
    color: #1A1D26;
    z-index: 10002;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1), 0 0 30px rgba(255,200,0,0.15);
    backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.5s var(--spring);
}
.achievement-popup.show {
    opacity: 1;
    transform: translateX(0);
}
.ach-icon {
    font-size: 32px;
}
.achievement-popup strong {
    color: #ffc800;
    font-size: 14px;
}

/* ============================================
   BUBBLE EFFECT
   ============================================ */
.reaction-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4), rgba(255,255,255,0.1));
    border: 1px solid rgba(255,255,255,0.2);
    pointer-events: none;
    z-index: 100;
    animation: bubbleRise 1.8s ease-out forwards;
}
@keyframes bubbleRise {
    0% { opacity: 0.8; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-100px) scale(0.3); }
}

/* Precipitate flake */
.precipitate-flake {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    animation: flakeFall 2.5s ease-in forwards;
}
@keyframes flakeFall {
    0% { opacity: 0.9; transform: translateY(0); }
    100% { opacity: 0.4; transform: translateY(70px); }
}

/* XP label in history */
.hist-xp {
    font-size: 11px;
    font-weight: 700;
    color: var(--lab-accent-2);
    white-space: nowrap;
}

/* Table-empty message */
.table-empty {
    width: 100%;
    text-align: center;
    padding: 20px;
    color: rgba(255,255,255,0.15);
    font-size: 14px;
}

/* ============================================
   3D РЕАЛИСТИЧНЫЕ ЭФФЕКТЫ — v4
   ============================================ */

/* --- 3D Колба: стекло, преломление, глубина --- */
.flask-3d {
    perspective: 800px;
    transform-style: preserve-3d;
}
.flask-3d:hover {
    transform: scale(1.05) rotateY(-5deg);
}
.flask-3d-active {
    animation: flask3dReact 1.5s ease-out !important;
}
@keyframes flask3dReact {
    0% { transform: scale(1) rotateX(0deg) rotateY(0deg); }
    15% { transform: scale(1.08) rotateX(-3deg) rotateY(5deg); }
    30% { transform: scale(1.03) rotateX(2deg) rotateY(-3deg); }
    50% { transform: scale(1.05) rotateX(-1deg) rotateY(2deg); }
    100% { transform: scale(1) rotateX(0deg) rotateY(0deg); }
}

/* Стеклянный корпус колбы */
.flask-body {
    background: linear-gradient(135deg,
        rgba(255,255,255,0.06) 0%,
        rgba(255,255,255,0.02) 50%,
        rgba(255,255,255,0.04) 100%) !important;
    backdrop-filter: blur(2px);
    box-shadow: inset 0 0 30px rgba(255,255,255,0.03),
                0 4px 20px rgba(0,0,0,0.3) !important;
}
.flask-body::before {
    content: '';
    position: absolute;
    top: 5%;
    left: 8%;
    width: 25%;
    height: 90%;
    background: linear-gradient(180deg,
        rgba(255,255,255,0.12) 0%,
        rgba(255,255,255,0.04) 50%,
        rgba(255,255,255,0.08) 100%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
}
.flask-body::after {
    content: '';
    position: absolute;
    top: 3%;
    right: 12%;
    width: 12%;
    height: 30%;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 100%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
}

/* Горлышко — стекло */
.flask-neck {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.06) 0%,
        rgba(255,255,255,0.02) 40%,
        rgba(255,255,255,0.05) 100%) !important;
    box-shadow: inset 0 0 10px rgba(255,255,255,0.02);
}

/* Жидкость с мениском и бликами */
.flask-liquid {
    z-index: 2;
}
.flask-liquid.has-content::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 5%;
    right: 5%;
    height: 6px;
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 100%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 5;
}

/* --- Свечение колбы (улучшенное) --- */
.flask-glow {
    animation: flaskGlowPulse3d 1.5s ease-in-out infinite !important;
}
@keyframes flaskGlowPulse3d {
    0%, 100% { filter: drop-shadow(0 0 8px var(--glow-color, rgba(108,92,231,0.3))); }
    50% { filter: drop-shadow(0 0 30px var(--glow-color, rgba(108,92,231,0.6)))
                  drop-shadow(0 0 60px var(--glow-color, rgba(108,92,231,0.2))); }
}

/* --- Частицы (с glow) --- */
.reaction-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    animation: particleExplode3d var(--dur, 0.8s) cubic-bezier(0.25,0.46,0.45,0.94) forwards;
}
@keyframes particleExplode3d {
    0% { opacity: 1; transform: translate(0,0) scale(1); filter: brightness(2); }
    60% { opacity: 0.7; filter: brightness(1.2); }
    100% { opacity: 0; transform: translate(var(--dx),var(--dy)) scale(0.1); filter: brightness(0.5); }
}

/* --- Дым (объёмный) --- */
.smoke-puff {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(180,180,180,0.3) 0%, rgba(100,100,100,0.15) 40%, transparent 70%) !important;
    pointer-events: none;
    z-index: 99;
    animation: smokeRise3d 2.5s ease-out forwards !important;
}
@keyframes smokeRise3d {
    0% { opacity: 0.6; transform: translateY(0) translateX(0) scale(0.4); }
    40% { opacity: 0.4; }
    100% { opacity: 0; transform: translateY(-100px) translateX(var(--drift, 0px)) scale(3); }
}

/* --- Пузырьки (реалистичные с преломлением) --- */
.reaction-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.5), rgba(255,255,255,0.1) 60%, transparent) !important;
    border: 1px solid rgba(255,255,255,0.25) !important;
    pointer-events: none;
    z-index: 100;
    animation: bubbleRise3d 2s ease-out forwards !important;
}
.reaction-bubble.fizz-bubble {
    animation: fizzRise 1.2s ease-out forwards !important;
}
@keyframes bubbleRise3d {
    0% { opacity: 0.9; transform: translateY(0) translateX(0) scale(1); }
    50% { transform: translateY(-50px) translateX(var(--wobble, 5px)) scale(1.1); }
    90% { opacity: 0.6; transform: translateY(-95px) translateX(calc(var(--wobble, 5px) * -1)) scale(0.9); }
    100% { opacity: 0; transform: translateY(-110px) scale(0.5); }
}
@keyframes fizzRise {
    0% { opacity: 0.8; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-80px) translateX(var(--wobble, 3px)) scale(0.2); }
}

/* --- Осадок (хлопья) --- */
.precipitate-flake {
    position: absolute;
    border-radius: 40% !important;
    pointer-events: none;
    z-index: 100;
    animation: precipSettle3d 3s ease-in forwards !important;
}
@keyframes precipSettle3d {
    0% { opacity: 0; transform: translateY(0) translateX(0); }
    15% { opacity: 0.9; }
    50% { transform: translateY(calc(var(--fall, 60px) * 0.5)) translateX(var(--drift, 5px)); }
    100% { opacity: 0.5; transform: translateY(var(--fall, 60px)) translateX(calc(var(--drift, 5px) * -0.5)); }
}

/* --- Тряска ТЯЖЁЛАЯ (взрыв) --- */
.shake-heavy {
    animation: shakeHeavy 0.8s ease-in-out !important;
}
@keyframes shakeHeavy {
    0%, 100% { transform: translate(0,0) rotate(0deg); }
    10% { transform: translate(-8px,-4px) rotate(-1deg); }
    20% { transform: translate(6px,3px) rotate(1deg); }
    30% { transform: translate(-10px,2px) rotate(-2deg); }
    40% { transform: translate(8px,-3px) rotate(1.5deg); }
    50% { transform: translate(-6px,5px) rotate(-1deg); }
    60% { transform: translate(5px,-2px) rotate(0.5deg); }
    70% { transform: translate(-3px,3px) rotate(-0.5deg); }
    80% { transform: translate(4px,-1px) rotate(0.3deg); }
}

/* ============================================
   ВСПЫШКА НА ЭКРАНЕ (полноэкранная)
   ============================================ */
.screen-flash {
    position: fixed;
    inset: 0;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.08s ease-in;
}
.screen-flash.active {
    opacity: 1;
    animation: screenFlashFade 0.6s ease-out forwards;
}
@keyframes screenFlashFade {
    0% { opacity: 1; }
    30% { opacity: 0.7; }
    100% { opacity: 0; }
}

/* ============================================
   УДАРНАЯ ВОЛНА (расширяющееся кольцо)
   ============================================ */
.shockwave-ring {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.7);
    transform: translate(-50%,-50%) scale(0);
    pointer-events: none;
    z-index: 101;
    animation: shockwaveExpand 0.8s cubic-bezier(0.25,0.46,0.45,0.94) forwards;
    box-shadow: 0 0 20px rgba(255,200,100,0.4), inset 0 0 20px rgba(255,200,100,0.2);
}
@keyframes shockwaveExpand {
    0% { transform: translate(-50%,-50%) scale(0); opacity: 1; border-width: 4px; }
    70% { opacity: 0.5; border-width: 2px; }
    100% { transform: translate(-50%,-50%) scale(18); opacity: 0; border-width: 0.5px; }
}

/* ============================================
   ОГНЕННЫЙ ШАР (fireball)
   ============================================ */
.fireball {
    position: absolute;
    border-radius: 50%;
    transform: translate(-50%,-50%) scale(0);
    pointer-events: none;
    z-index: 102;
    background: radial-gradient(circle,
        rgba(255,255,200,1) 0%,
        rgba(255,200,50,0.9) 20%,
        rgba(255,100,0,0.7) 45%,
        rgba(200,30,0,0.4) 70%,
        transparent 100%);
    box-shadow: 0 0 40px rgba(255,100,0,0.8),
                0 0 80px rgba(255,50,0,0.4),
                0 0 120px rgba(255,0,0,0.2);
    animation: fireballExpand 1s ease-out forwards;
    mix-blend-mode: screen;
}
.fireball-core {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, rgba(255,255,200,0.8) 50%, transparent 100%);
    animation: coreFlicker 0.15s ease infinite alternate;
}
@keyframes fireballExpand {
    0% { transform: translate(-50%,-50%) scale(0); opacity: 1; }
    30% { transform: translate(-50%,-50%) scale(1.3); opacity: 1; }
    60% { transform: translate(-50%,-50%) scale(1); opacity: 0.7; }
    100% { transform: translate(-50%,-50%) scale(1.8); opacity: 0; }
}
@keyframes coreFlicker {
    0% { opacity: 0.8; transform: translate(-50%,-50%) scale(0.9); }
    100% { opacity: 1; transform: translate(-50%,-50%) scale(1.1); }
}

/* ============================================
   УГОЛЬКИ / ИСКРЫ (embers)
   ============================================ */
.ember-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 103;
    animation: emberFly var(--dur, 1s) ease-out forwards;
}
@keyframes emberFly {
    0% { opacity: 1; transform: translate(0,0) scale(1); filter: brightness(2); }
    40% { opacity: 0.9; filter: brightness(1.5); }
    70% { opacity: 0.4; }
    100% { opacity: 0; transform: translate(var(--dx),var(--dy)) scale(0.2); filter: brightness(0.3); }
}

/* ============================================
   СТОЛБ ПЛАМЕНИ (flame particles)
   ============================================ */
.flame-particle {
    position: absolute;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    pointer-events: none;
    z-index: 101;
    background: radial-gradient(ellipse at center bottom,
        rgba(255,255,200,0.9) 0%,
        rgba(255,180,50,0.8) 30%,
        rgba(255,80,0,0.5) 60%,
        rgba(200,20,0,0.2) 85%,
        transparent 100%);
    mix-blend-mode: screen;
    animation: flameRise 1.4s ease-out forwards;
    filter: blur(1px);
}
@keyframes flameRise {
    0% { opacity: 0; transform: translateY(0) translateX(0) scaleY(0.5) scaleX(1); }
    15% { opacity: 1; transform: translateY(-10px) scaleY(1.2) scaleX(1.1); }
    40% { opacity: 0.9; transform: translateY(calc(var(--rise, -80px) * 0.4)) translateX(var(--sway, 0px)) scaleY(1) scaleX(0.9); }
    70% { opacity: 0.5; transform: translateY(calc(var(--rise, -80px) * 0.75)) translateX(calc(var(--sway, 0px) * -0.5)) scaleY(0.7) scaleX(0.7); }
    100% { opacity: 0; transform: translateY(var(--rise, -80px)) scaleY(0.3) scaleX(0.4); }
}

/* ============================================
   ТЕПЛОВОЕ МЕРЦАНИЕ (heat shimmer)
   ============================================ */
.heat-shimmer {
    position: absolute;
    pointer-events: none;
    z-index: 98;
    background: repeating-linear-gradient(0deg,
        transparent, rgba(255,255,255,0.015) 2px, transparent 4px);
    animation: shimmerWave 3s ease-in-out infinite;
    filter: blur(1px);
    opacity: 0.7;
}
@keyframes shimmerWave {
    0%, 100% { transform: scaleX(1) skewX(0deg); }
    25% { transform: scaleX(1.02) skewX(1.5deg); }
    50% { transform: scaleX(0.98) skewX(-1deg); }
    75% { transform: scaleX(1.01) skewX(0.5deg); }
}

/* ============================================
   РАСПЛАВЛЕННЫЕ КАПЛИ (molten drips)
   ============================================ */
.molten-drip {
    position: absolute;
    border-radius: 40% 40% 50% 50%;
    pointer-events: none;
    z-index: 102;
    animation: moltDrip 1.8s ease-in forwards;
}
@keyframes moltDrip {
    0% { opacity: 1; transform: translateY(0) scaleY(0.5); filter: brightness(2); }
    20% { transform: translateY(5px) scaleY(1.3); filter: brightness(1.5); }
    100% { opacity: 0.2; transform: translateY(var(--fall, 60px)) scaleY(0.8); filter: brightness(0.5); }
}

/* ============================================
   ТОКСИЧНОЕ ОБЛАКО
   ============================================ */
.toxic-cloud {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,255,0,0.2) 0%, rgba(0,180,0,0.1) 40%, transparent 70%);
    pointer-events: none;
    z-index: 99;
    animation: toxicRise 3s ease-out forwards;
    mix-blend-mode: screen;
}
@keyframes toxicRise {
    0% { opacity: 0; transform: translateY(0) translateX(0) scale(0.3); }
    20% { opacity: 0.7; }
    60% { opacity: 0.4; transform: translateY(-60px) translateX(var(--drift, 0px)) scale(2); }
    100% { opacity: 0; transform: translateY(-120px) translateX(calc(var(--drift, 0px) * 2)) scale(3.5); }
}
.toxic-skull {
    position: absolute;
    transform: translate(-50%,-50%);
    font-size: 36px;
    pointer-events: none;
    z-index: 104;
    animation: skullAppear 2.5s ease-out forwards;
    filter: drop-shadow(0 0 10px rgba(0,255,0,0.5));
}
@keyframes skullAppear {
    0% { opacity: 0; transform: translate(-50%,-50%) scale(0) rotate(-30deg); }
    20% { opacity: 1; transform: translate(-50%,-80%) scale(1.2) rotate(0deg); }
    50% { opacity: 0.8; transform: translate(-50%,-120%) scale(1) rotate(5deg); }
    100% { opacity: 0; transform: translate(-50%,-170%) scale(0.6) rotate(-10deg); }
}

/* ============================================
   ПЕНА (foam)
   ============================================ */
.foam-layer {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 30%;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(255,255,255,0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 70%, rgba(255,255,255,0.35) 0%, transparent 45%),
        radial-gradient(ellipse at 80% 85%, rgba(255,255,255,0.3) 0%, transparent 50%),
        linear-gradient(180deg, rgba(255,255,255,0.25), transparent);
    border-radius: inherit;
    z-index: 5;
    animation: foamGrow 0.8s var(--spring) forwards, foamFade 4s 1s ease-out forwards;
    pointer-events: none;
}
@keyframes foamGrow {
    0% { height: 0; opacity: 0; }
    100% { height: 35%; opacity: 1; }
}
@keyframes foamFade {
    0% { opacity: 1; }
    100% { opacity: 0; height: 10%; }
}
.foam-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.6), rgba(255,255,255,0.15));
    border: 1px solid rgba(255,255,255,0.3);
    pointer-events: none;
    z-index: 100;
    animation: foamBubbleRise 2.5s ease-out forwards;
}
@keyframes foamBubbleRise {
    0% { opacity: 0.8; transform: translateY(0) translateX(0) scale(1); }
    30% { transform: translateY(-30px) translateX(var(--wobble, 5px)) scale(1.15); }
    70% { opacity: 0.5; transform: translateY(-70px) translateX(calc(var(--wobble, 5px) * -1.5)) scale(0.85); }
    100% { opacity: 0; transform: translateY(-100px) scale(0.3); }
}

/* ============================================
   ЗОЛОТОЙ ДОЖДЬ (golden crystals)
   ============================================ */
.golden-crystal {
    position: absolute;
    background: linear-gradient(135deg, #FFD700, #FFC107, #FFB300);
    border-radius: 2px;
    pointer-events: none;
    z-index: 101;
    animation: goldenFall 3s ease-in forwards;
    box-shadow: 0 0 6px rgba(255,215,0,0.6), 0 0 12px rgba(255,215,0,0.3);
}
@keyframes goldenFall {
    0% { opacity: 0; transform: translateY(0) translateX(0) rotate(0deg); }
    10% { opacity: 1; }
    50% { transform: translateY(calc(var(--fall, 100px) * 0.5)) translateX(var(--drift, 10px)) rotate(calc(var(--rot, 360deg) * 0.5)); }
    100% { opacity: 0.3; transform: translateY(var(--fall, 100px)) translateX(calc(var(--drift, 10px) * -0.5)) rotate(var(--rot, 360deg)); }
}

/* ============================================
   ВОЛНА ЦВЕТА (color wave in liquid)
   ============================================ */
.color-wave {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 0;
    border-radius: inherit;
    z-index: 3;
    pointer-events: none;
    animation: colorSpread 2s ease-out forwards;
    opacity: 0.7;
}
@keyframes colorSpread {
    0% { height: 0; opacity: 0; }
    30% { opacity: 0.8; }
    100% { height: 100%; opacity: 0; }
}

/* ============================================
   ЯРКИЕ ИСКРЫ (bright sparks)
   ============================================ */
.bright-spark {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 103;
    animation: sparkFly var(--dur, 0.6s) ease-out forwards;
}
@keyframes sparkFly {
    0% { opacity: 1; transform: translate(0,0) scale(1); filter: brightness(3); }
    50% { filter: brightness(2); }
    100% { opacity: 0; transform: translate(var(--dx),var(--dy)) scale(0.1); filter: brightness(0); }
}

/* ============================================
   ОБЛОМКИ (debris)
   ============================================ */
.debris-chunk {
    position: absolute;
    border-radius: 2px;
    pointer-events: none;
    z-index: 101;
    animation: debrisFly 1.2s cubic-bezier(0.25,0.46,0.45,0.94) forwards;
}
@keyframes debrisFly {
    0% { opacity: 1; transform: translate(0,0) rotate(0deg) scale(1); }
    60% { opacity: 0.7; }
    100% { opacity: 0; transform: translate(var(--dx),calc(var(--dy) + 30px)) rotate(var(--rot, 360deg)) scale(0.3); }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .chem-shelf {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 8px;
        padding: 12px 14px;
        max-height: 220px;
    }
    .chem-bottle {
        padding: 10px 4px 8px;
    }
    .bottle-icon {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
    .bottle-name {
        font-size: 9px;
    }
    .chem-workbench {
        padding: 14px;
    }
    .workbench-layout {
        flex-direction: column;
        gap: 16px;
    }
    .flask-3d {
        width: 100px;
        height: 140px;
    }
    .flask-body {
        height: 95px;
    }
    .flask-zone {
        gap: 16px;
        justify-content: center;
    }
    .chem-mix-btn {
        padding: 14px 32px;
        font-size: 15px;
    }
    .info-details-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .chem-equation-box {
        font-size: 14px;
        padding: 14px 16px;
    }
    .game-level-badge { font-size: 11px; padding: 3px 10px; }
    .game-stats-row { gap: 8px; }
    .game-stat { padding: 3px 8px; }
    .game-stat-value { font-size: 14px; }
    .chem-hint-btn { width: 44px; margin-right: 14px; }
    .level-up-card { padding: 30px 36px; }
    .level-up-card h3 { font-size: 24px; }
    .achievement-popup { right: 10px; top: 60px; padding: 12px 18px; }
}

@media (max-width: 480px) {
    .chem-shelf {
        grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
        max-height: 180px;
    }
    .bottle-icon {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }
    .flask-3d {
        width: 85px;
        height: 120px;
    }
    .flask-body {
        height: 80px;
    }
    .flask-neck {
        width: 24px;
        height: 48px;
    }
    .flask-zone {
        gap: 10px;
    }
    .info-details-grid {
        grid-template-columns: 1fr;
    }
    .bottle-real-color { display: none; }
    .chem-search-row { flex-direction: row; }
    .xp-popup { font-size: 15px; padding: 8px 18px; }
}

