/* ═══ SCENE 2: SPECIMENS — CHEMISTRY LAB ═══ */
.specimens-bg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background: #08120e;
}

.section-specimens .section-title {
    position: relative;
    z-index: 10;
    margin-top: 60px;
    text-shadow: 0 0 12px rgba(0, 0, 0, 0.8), 0 2px 4px rgba(0, 0, 0, 0.9);
}

/* ── Specimen Grid ── */
.specimen-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px 50px;
    max-width: 650px;
    margin: 60px auto 20px;
    padding: 0 40px;
    position: relative;
    z-index: 10;
}

.specimen-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
}
.specimen-container:hover { transform: translateY(-2px); }

/* ── SELECTED STATE ── */
.specimen-container.selected::after {
    content: '';
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 20px;
    border-radius: 50%;
    background: var(--flask-color, #a0ffd0);
    opacity: 0.2;
    filter: blur(10px);
    animation: glow-pulse 1s ease-in-out infinite;
}
.specimen-container.selected .flask-elixir {
    animation: elixir-boil 0.5s ease-in-out infinite;
}
.specimen-container.selected .flask-bubbles span {
    animation-duration: 0.4s;
}

/* ── RECEIVING STATE ── */
.specimen-container.receiving::after {
    content: '';
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 24px;
    border-radius: 50%;
    background: var(--flask-color, #a0ffd0);
    opacity: 0.3;
    filter: blur(12px);
    animation: glow-pulse 0.4s ease-in-out infinite;
}
.specimen-container.receiving .flask-elixir {
    transition: height 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── DRAINING STATE ── */
.specimen-container.draining .flask-elixir {
    transition: height 1s ease-in-out;
}

/* ── REACTION FLASH ── */
.specimen-container.reacting .flask-body {
    animation: reaction-flash 0.35s ease-out;
}
.specimen-container.reacting .flask-elixir {
    filter: brightness(2.5) saturate(2);
    transition: filter 0.1s ease-out;
}

/* ── MIXED RESULT STATE ── */
.specimen-container.mixed .flask-elixir {
    animation: mixed-glow 2.5s ease-in-out infinite;
    filter: saturate(1.2);
}
.specimen-container.mixed .specimen-label::after {
    content: ' [MIXED]';
    color: #a0ffd0;
    font-size: 8px;
}

/* ═══ PIXEL ART ERLENMEYER FLASK ═══ */
.specimen-flask {
    position: relative;
    width: 64px;
    height: 96px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Flask neck - narrow cylinder with 3-layer volumetric */
.flask-neck {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 28px;
    background: rgba(160, 255, 208, 0.08);
    border: 2px solid rgba(10, 60, 40, 0.9);
    border-top: none;
    border-bottom: none;
    border-radius: 0;
}
/* Rim/lip at top */
.flask-neck::after {
    content: '';
    position: absolute;
    top: -8px;
    left: -6px;
    right: -6px;
    height: 8px;
    background: linear-gradient(180deg, #c0c0c0 0%, #707070 60%, #2a2a2a 100%);
    border-radius: 3px 3px 0 0;
    border: 2px solid #0a0a0a;
    border-bottom: none;
}
/* Glass highlight streak on neck */
.flask-neck::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 1px;
    width: 2px;
    height: 65%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1px;
}

/* Flask body - conical with 3-layer volumetric */
.flask-body {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(160, 255, 208, 0.05);
    border: none;
    clip-path: polygon(
        30% 0%, 70% 0%,
        74% 12%, 80% 28%, 86% 48%, 92% 68%, 97% 88%, 100% 100%,
        0% 100%, 3% 88%, 8% 68%, 14% 48%, 20% 28%, 26% 12%
    );
    overflow: hidden;
}
/* Outline layer */
.flask-body::before {
    content: '';
    position: absolute;
    inset: -2px;
    clip-path: polygon(
        30% 0%, 70% 0%,
        74% 12%, 80% 28%, 86% 48%, 92% 68%, 97% 88%, 100% 100%,
        0% 100%, 3% 88%, 8% 68%, 14% 48%, 20% 28%, 26% 12%
    );
    border: 2px solid rgba(10, 60, 40, 0.9);
    pointer-events: none;
}
/* Glass highlight streak on body */
.flask-body::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 16%;
    width: 3px;
    height: 60%;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    transform: rotate(4deg);
}

/* Elixir liquid - STRATIFIED (2 layers: dense bottom + meniscus surface) */
.flask-elixir {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 75%;
    transition: height 1s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease, background 0.8s ease;
}
/* Meniscus surface - slow wave */
.flask-elixir::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 8%;
    right: 8%;
    height: 3px;
    background: var(--flask-color, #a0ffd0);
    opacity: 0.3;
    border-radius: 50%;
    filter: blur(1px);
    animation: meniscus-wave 3s ease-in-out infinite;
}
/* Inner glow at bottom - dense layer */
.flask-elixir::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 8%;
    right: 8%;
    height: 45%;
    background: radial-gradient(ellipse at center bottom, var(--flask-color, #a0ffd0) 0%, transparent 65%);
    opacity: 0.2;
}

/* ── Elixir colors - MUTED AQUA/TEAL DISCIPLINE ── */
.elixir-green { --flask-color: #a0ffd0; }
.elixir-green .flask-elixir {
    background: linear-gradient(180deg, rgba(160,255,208,0.25) 0%, rgba(136,204,170,0.4) 50%, rgba(100,180,140,0.6) 100%);
    box-shadow: inset 0 -8px 16px rgba(160,255,208,0.15);
}

.elixir-purple { --flask-color: #b0e0cc; }
.elixir-purple .flask-elixir {
    background: linear-gradient(180deg, rgba(176,224,204,0.25) 0%, rgba(144,200,180,0.4) 50%, rgba(120,176,156,0.6) 100%);
    box-shadow: inset 0 -8px 16px rgba(176,224,204,0.15);
}

.elixir-cyan { --flask-color: #88ccaa; }
.elixir-cyan .flask-elixir {
    background: linear-gradient(180deg, rgba(136,204,170,0.25) 0%, rgba(120,188,154,0.4) 50%, rgba(100,164,136,0.6) 100%);
    box-shadow: inset 0 -8px 16px rgba(136,204,170,0.15);
}

.elixir-red { --flask-color: #90d8b8; }
.elixir-red .flask-elixir {
    background: linear-gradient(180deg, rgba(144,216,184,0.25) 0%, rgba(128,200,168,0.4) 50%, rgba(104,176,144,0.6) 100%);
    box-shadow: inset 0 -8px 16px rgba(144,216,184,0.15);
}

.elixir-gold { --flask-color: #a8e0c8; }
.elixir-gold .flask-elixir {
    background: linear-gradient(180deg, rgba(168,224,200,0.25) 0%, rgba(144,204,180,0.4) 50%, rgba(120,184,160,0.6) 100%);
    box-shadow: inset 0 -8px 16px rgba(168,224,200,0.15);
}

.elixir-pink { --flask-color: #b8e8d0; }
.elixir-pink .flask-elixir {
    background: linear-gradient(180deg, rgba(184,232,208,0.25) 0%, rgba(160,212,188,0.4) 50%, rgba(136,192,168,0.6) 100%);
    box-shadow: inset 0 -8px 16px rgba(184,232,208,0.15);
}

/* ── Bubbles - smaller, subtler ── */
.flask-bubbles {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 50px;
    pointer-events: none;
    z-index: 5;
}
.flask-bubbles span {
    position: absolute;
    background: var(--flask-color, #a0ffd0);
    border-radius: 50%;
    opacity: 0.4;
    animation: bubble-up 2.8s ease-in-out infinite;
    box-shadow: inset -1px -1px 0 rgba(0,0,0,0.2), inset 1px 1px 0 rgba(255,255,255,0.3);
}
.flask-bubbles span:nth-child(1) { left: 12%; width: 4px; height: 4px; animation-delay: 0s; }
.flask-bubbles span:nth-child(2) { left: 48%; width: 5px; height: 5px; animation-delay: 0.7s; }
.flask-bubbles span:nth-child(3) { left: 72%; width: 3px; height: 3px; animation-delay: 1.4s; }
.flask-bubbles span:nth-child(4) { left: 30%; width: 4px; height: 4px; animation-delay: 2.1s; }

/* ── Floating bubbles above flask ── */
.specimen-flask::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--flask-color, #a0ffd0);
    border-radius: 50%;
    opacity: 0;
    animation: float-bubble-top 3.2s ease-in-out infinite;
    box-shadow:
        9px -10px 0 2px var(--flask-color, #a0ffd0),
        -7px -18px 0 2px var(--flask-color, #a0ffd0);
}

/* Label */
.specimen-label {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: rgba(160, 255, 208, 0.7);
    letter-spacing: 2px;
    text-align: center;
}

/* Instruction text */
.specimens-bg > p {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-dim);
    letter-spacing: 2px;
    position: relative;
    z-index: 10;
    margin-top: 10px;
}

/* ═══ SPECIMEN ENTITY CANVAS OVERLAY ═══ */
.specimen-entity {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 32px;
    pointer-events: none;
    z-index: 6;
}

/* ═══ AMBIENT ROOM EFFECTS ═══ */
.specimens-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(90deg, 
        transparent 0, transparent 80px,
        rgba(160,255,208,0.05) 80px, rgba(160,255,208,0.05) 82px);
    animation: cable-sway 8s ease-in-out infinite;
}

.specimens-bg::after {
    content: '';
    position: absolute;
    top: 12px;
    left: 20%;
    width: 1px;
    height: 40px;
    background: rgba(160,255,208,0.08);
    animation: cable-sway 6s ease-in-out infinite 0.5s;
}

/* ═══ LIQUID ARC OVERLAY ═══ */
.liquid-arc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

/* ═══ SMOKE / STEAM ═══ */
.smoke-cloud {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 70px;
    pointer-events: none;
    z-index: 25;
}
.smoke-cloud span {
    position: absolute;
    bottom: 0;
    border-radius: 50%;
    opacity: 0;
    background: rgba(160, 200, 180, 0.3);
}
.specimen-container.smoking .smoke-cloud span {
    animation: smoke-rise 2s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.smoke-cloud span:nth-child(1) { left: 25%; width: 6px; height: 6px; animation-delay: 0s; }
.smoke-cloud span:nth-child(2) { left: 55%; width: 8px; height: 8px; animation-delay: 0.1s; }
.smoke-cloud span:nth-child(3) { left: 10%; width: 5px; height: 5px; animation-delay: 0.2s; }
.smoke-cloud span:nth-child(4) { left: 70%; width: 7px; height: 7px; animation-delay: 0.3s; }
.smoke-cloud span:nth-child(5) { left: 40%; width: 9px; height: 9px; animation-delay: 0.4s; }
.smoke-cloud span:nth-child(6) { left: 5%; width: 5px; height: 5px; animation-delay: 0.5s; }
.smoke-cloud span:nth-child(7) { left: 60%; width: 6px; height: 6px; animation-delay: 0.6s; }
.smoke-cloud span:nth-child(8) { left: 35%; width: 7px; height: 7px; animation-delay: 0.7s; }

/* ═══ SCREEN SHAKE ═══ */
.specimens-bg.screen-shake {
    animation: screen-shake 0.25s ease-out;
}

/* ═══ KEYFRAMES ═══ */

@keyframes glow-pulse {
    0%, 100% { opacity: 0.2; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.4; transform: translateX(-50%) scale(1.1); }
}

@keyframes meniscus-wave {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1px); }
}

@keyframes elixir-boil {
    0%, 100% { height: 72%; }
    25% { height: 75%; }
    50% { height: 70%; }
    75% { height: 74%; }
}

@keyframes reaction-flash {
    0% { background: rgba(255,255,255,0); }
    25% { background: rgba(255,255,255,0.3); }
    100% { background: rgba(255,255,255,0); }
}

@keyframes mixed-glow {
    0%, 100% { filter: saturate(1.2) brightness(1); }
    50% { filter: saturate(1.4) brightness(1.15); }
}

@keyframes smoke-rise {
    0% { opacity: 0; transform: translateY(0) scale(0.3); }
    15% { opacity: 0.4; transform: translateY(-5px) scale(0.7); }
    45% { opacity: 0.25; transform: translateY(-25px) scale(1); }
    100% { opacity: 0; transform: translateY(-50px) scale(1.3); }
}

@keyframes bubble-up {
    0% { transform: translateY(0) scale(1); opacity: 0.3; }
    40% { opacity: 0.5; }
    100% { transform: translateY(-40px) scale(0.3); opacity: 0; }
}

@keyframes float-bubble-top {
    0%, 100% { opacity: 0; transform: translateX(-50%) translateY(0); }
    20% { opacity: 0.3; }
    50% { opacity: 0.25; transform: translateX(-50%) translateY(-12px); }
    80% { opacity: 0.1; }
}

@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-1px, 0.5px); }
    30% { transform: translate(1px, -0.5px); }
    50% { transform: translate(-0.5px, 0.5px); }
    70% { transform: translate(0.5px, -0.5px); }
}

@keyframes cable-sway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(2px); }
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
    .specimen-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px 15px;
        max-width: 320px;
        padding: 0 10px;
        margin-top: 30px;
    }
    .specimen-flask { width: 44px; height: 68px; }
    .flask-neck { width: 10px; height: 22px; }
    .flask-body { height: 42px; }
    .specimen-label { font-size: 7px; }
    .specimen-entity { width: 24px; height: 24px; top: 14px; }
}

/* Reaction tracker */
.reaction-tracker {
    margin-top: 16px;
    text-align: center;
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: #6affb3;
    letter-spacing: 1px;
    transition: color 0.3s;
}
.tracker-label { opacity: 0.7; margin-right: 6px; }
.tracker-count {
    color: #ffb84d;
    font-weight: 700;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}
.tracker-total { opacity: 0.5; margin-left: 4px; }
.reaction-tracker.hc-flash-tracker {
    color: #ffb84d;
    text-shadow: 0 0 8px rgba(255,184,77,0.8);
    animation: tracker-flash 0.6s;
}
@keyframes tracker-flash {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Selection / pour states */
.specimen-container.selected .specimen-flask {
    filter: drop-shadow(0 0 12px rgba(255,184,77,0.7));
    transform: translateY(-4px);
}
.specimen-container.pouring .specimen-flask {
    transform: rotate(-25deg) translateX(-6px);
}
.specimen-container.receiving .flask-body {
    animation: receive-bubble 0.6s ease-in-out 2;
}
@keyframes receive-bubble {
    0%,100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}
.specimen-container.splash-active .splash-ring {
    animation: splash-ring 0.8s ease-out;
}
@keyframes splash-ring {
    0% { opacity: 1; transform: scale(0.3); }
    100% { opacity: 0; transform: scale(2.2); }
}
.specimen-container .specimen-flask {
    transition: transform 0.4s, filter 0.3s;
}

/* ═══ REACTION PARTICLES ═══ */
.reaction-particle {
    position: fixed;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: particleBurst 0.65s ease-out forwards;
}
@keyframes particleBurst {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ═══ IMPROVED REACTION EFFECTS ═══ */

/* Selection pulse */
.specimen-container.pulse-select .specimen-flask {
    animation: pulseSelect 0.8s ease infinite;
}
@keyframes pulseSelect {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.6) drop-shadow(0 0 12px currentColor); }
}

/* Shake for invalid combos */
.specimen-container.shake {
    animation: shakeX 0.4s ease;
}
@keyframes shakeX {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Reaction flash overlay */
.reaction-flash {
    position: absolute;
    inset: 0;
    opacity: 0.3;
    z-index: 50;
    pointer-events: none;
    animation: flashFade 0.4s ease-out forwards;
}
@keyframes flashFade {
    0% { opacity: 0.3; }
    100% { opacity: 0; }
}

/* Reaction result banner */
.reaction-result-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    z-index: 100;
    text-align: center;
    padding: 16px 32px;
    background: rgba(8, 8, 12, 0.92);
    border: 1px solid var(--reaction-color, #33ff88);
    box-shadow: 0 0 30px color-mix(in srgb, var(--reaction-color) 40%, transparent),
                inset 0 0 20px color-mix(in srgb, var(--reaction-color) 15%, transparent);
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    font-family: 'VT323', monospace;
}
.reaction-result-banner.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.reaction-result-name {
    font-size: 22px;
    color: var(--reaction-color);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 6px;
    text-shadow: 0 0 8px var(--reaction-color);
}
.reaction-result-text {
    font-size: 13px;
    color: #aaa;
    letter-spacing: 1px;
}
.reaction-result-new {
    margin-top: 8px;
    font-size: 11px;
    color: #33ff88;
    letter-spacing: 2px;
    animation: blinkNew 0.5s step-end infinite;
}
@keyframes blinkNew {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Per-effect type animations on flask */
.specimen-container.fx-glow .specimen-flask {
    filter: brightness(2) drop-shadow(0 0 20px var(--fx-color));
    transition: filter 0.3s;
}
.specimen-container.fx-freeze .specimen-flask {
    filter: brightness(1.4) hue-rotate(180deg) drop-shadow(0 0 16px var(--fx-color));
    animation: freezeShake 0.15s linear 4;
}
@keyframes freezeShake {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(2px); }
}
.specimen-container.fx-electric .specimen-flask {
    animation: electricFlicker 0.1s linear 8;
    filter: drop-shadow(0 0 20px var(--fx-color));
}
@keyframes electricFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.specimen-container.fx-bubble .specimen-flask {
    animation: bubbleRise 0.3s ease 4;
    filter: drop-shadow(0 0 14px var(--fx-color));
}
@keyframes bubbleRise {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
.specimen-container.fx-void .specimen-flask {
    filter: brightness(0.3) saturate(0) drop-shadow(0 0 30px #000);
    transition: filter 0.5s;
}
.specimen-container.fx-flare .specimen-flask {
    filter: brightness(3) drop-shadow(0 0 40px var(--fx-color));
    animation: flarePulse 0.2s ease 5;
}
@keyframes flarePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.specimen-container.fx-toxic .specimen-flask {
    filter: brightness(1.5) hue-rotate(80deg) drop-shadow(0 0 18px var(--fx-color));
    animation: toxicDrip 0.4s ease 3;
}
@keyframes toxicDrip {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(2px) rotate(1deg); }
}

/* Electric particle variant */
.particle-electric {
    width: 2px;
    height: 8px;
    border-radius: 1px;
}
/* Void particle variant */
.particle-void {
    width: 8px;
    height: 8px;
    border-radius: 0;
    opacity: 0.7;
}
